/* ZKTeco Attendance App - hand-written design system (no build step).
   Color tokens follow a validated, colorblind-safe palette. */

:root {
  --surface: #fcfcfb;
  --plane: #f9f9f7;
  --ink-primary: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --line-hairline: #e1e0d9;
  --line-axis: #c3c2b7;

  --brand-50: #eaf2fc;
  --brand-500: #2a78d6;
  --brand-600: #256abf;
  --brand-700: #1c5cab;

  --status-good: #0ca30c;
  --status-good-bg: rgba(12, 163, 12, 0.1);
  --status-warning: #8a5c00;
  --status-warning-bg: rgba(250, 178, 25, 0.2);
  --status-critical: #d03b3b;
  --status-critical-bg: rgba(208, 59, 59, 0.1);
  --status-neutral-bg: rgba(137, 135, 129, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.25rem; }
h2.section-title { font-size: 0.9rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }

.tabular { font-variant-numeric: tabular-nums; }
.text-muted { color: var(--ink-secondary); }
.text-sm { font-size: 0.8rem; }

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line-hairline);
}
.topbar-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark {
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 0.4rem;
  background: var(--brand-500); color: #fff; font-weight: 700; font-size: 0.9rem;
}
.brand-name { font-weight: 600; font-size: 0.9rem; }

.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav-link {
  padding: 0.4rem 0.75rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-secondary);
}
.nav-link:hover { background: var(--plane); color: var(--ink-primary); }
.nav-link-active { background: var(--brand-50); color: var(--brand-700); }

.topbar-user { display: flex; align-items: center; gap: 0.75rem; }
.topbar-user-info { text-align: right; }
.topbar-user-name { font-size: 0.85rem; font-weight: 500; }
.topbar-user-role { font-size: 0.75rem; color: var(--ink-muted); text-transform: capitalize; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.45rem 0.9rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
}
.btn-primary { background: var(--brand-500); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-secondary { background: var(--surface); color: var(--ink-primary); border-color: var(--line-hairline); }
.btn-secondary:hover { background: var(--plane); }
.btn-ghost { background: transparent; color: var(--ink-secondary); border-color: var(--line-hairline); }
.btn-ghost:hover { background: var(--plane); }
.btn-disabled { opacity: 0.4; pointer-events: none; }

/* --- Layout --- */
.page { max-width: 80rem; margin: 0 auto; padding: 1.5rem; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}

/* --- Stat cards --- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem; margin-bottom: 1.25rem;
}
.stat-card { background: var(--surface); border: 1px solid var(--line-hairline); border-radius: 0.6rem; padding: 1rem; }
.stat-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-muted); }
.stat-value { font-size: 1.5rem; font-weight: 600; margin-top: 0.15rem; font-variant-numeric: tabular-nums; }

/* --- Cards / forms --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line-hairline);
  border-radius: 0.6rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.form-card { padding: 1.25rem; max-width: 32rem; }
.form-stack { display: flex; flex-direction: column; gap: 1rem; }
.form-field { display: flex; flex-direction: column; gap: 0.3rem; }
.form-field label { font-size: 0.75rem; font-weight: 600; color: var(--ink-secondary); }
.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-hairline);
  border-radius: 0.4rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink-primary);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--brand-500);
}

.alert { padding: 0.6rem 0.85rem; border-radius: 0.4rem; font-size: 0.85rem; }
.alert-error { background: var(--status-critical-bg); color: var(--status-critical); }
.alert-success { background: var(--status-good-bg); color: var(--status-good); }

/* --- Filter bar --- */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--line-hairline);
  border-radius: 0.6rem;
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.filter-presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.85rem; }
.chip {
  border: 1px solid var(--line-hairline);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-secondary);
}
.chip:hover { background: var(--plane); }
.chip-clear { color: var(--brand-600); border-color: transparent; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}
.filter-actions { display: flex; gap: 0.5rem; margin-top: 0.85rem; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 640px; }
.table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line-hairline);
}
.table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line-hairline);
  vertical-align: top;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--plane); }
.table-empty { text-align: center; color: var(--ink-muted); padding: 2.5rem 1rem; }
.cell-strong { font-weight: 500; }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-good { background: var(--status-good-bg); color: var(--status-good); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge-neutral { background: var(--status-neutral-bg); color: var(--ink-secondary); }

/* --- Pagination --- */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line-hairline);
  flex-wrap: wrap;
  gap: 0.5rem;
}
.pagination-controls { display: flex; align-items: center; gap: 0.6rem; }

/* --- Auth pages --- */
.auth-shell {
  min-height: calc(100vh - 2rem);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%; max-width: 22rem;
  background: var(--surface);
  border: 1px solid var(--line-hairline);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 2px rgba(11,11,11,0.04);
}

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .topbar-user-info { display: none; }
}
