/* ============================================================================
   StaffOra — design tokens ported 1:1 from the prototype (light + dark).
   ========================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --background: #ffffff; --foreground: #09090b;
  --card: #ffffff; --card-2: #fafafa; --muted: #f4f4f5; --muted-foreground: #71717a;
  --border: #e7e7ea; --input: #e4e4e7; --ring: #a1a1aa;
  --primary: #18181b; --primary-foreground: #fafafa; --accent: #f4f4f5; --accent-foreground: #18181b;
  --sidebar: #fafafa; --sidebar-foreground: #52525b; --sidebar-border: #e7e7ea;
  --sidebar-accent: #ececee; --sidebar-accent-foreground: #18181b;
  --present: #16a34a; --break: #d97706; --leave: #2563eb; --off: #a1a1aa; --danger: #dc2626;
  --shadow: 0 1px 2px 0 rgba(9, 9, 11, .05);
  --pad: 26px; --gap: 18px; --cardpad: 20px;
}
[data-app-theme="dark"] {
  color-scheme: dark;
  --background: #09090b; --foreground: #fafafa;
  --card: #101013; --card-2: #161619; --muted: #1c1c20; --muted-foreground: #a1a1aa;
  --border: #26262b; --input: #26262b; --ring: #52525b;
  --primary: #fafafa; --primary-foreground: #18181b; --accent: #1c1c20; --accent-foreground: #fafafa;
  --sidebar: #0b0b0d; --sidebar-foreground: #a1a1aa; --sidebar-border: #1e1e22;
  --sidebar-accent: #1c1c20; --sidebar-accent-foreground: #fafafa;
  --present: #22c55e; --break: #f59e0b; --leave: #3b82f6; --off: #71717a; --danger: #ef4444;
  --shadow: 0 1px 2px 0 rgba(0, 0, 0, .3);
}

body {
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--background); color: var(--foreground);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--foreground); text-decoration: none; }
a:hover { color: var(--muted-foreground); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }
input, select, textarea, button { font-family: inherit; }
@keyframes hrpulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.tabnum { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- shell */
.app { display: flex; min-height: 100vh; width: 100%; background: var(--background); color: var(--foreground); }

.sidebar {
  width: 250px; flex: 0 0 250px; background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--primary-foreground);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; letter-spacing: -.02em;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--muted-foreground); }
.sidebar-rule { height: 1px; background: var(--sidebar-border); margin: 0 0 8px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-foreground); padding: 10px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border: none;
  border-radius: 9px; cursor: pointer; font-size: 14px; text-align: left; text-decoration: none;
  transition: background .12s; background: transparent; color: var(--sidebar-foreground); font-weight: 500;
}
.nav-item:hover { background: var(--sidebar-accent); color: var(--sidebar-foreground); }
.nav-item.is-active { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: 600; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary);
  color: var(--primary-foreground); font-size: 11px; font-weight: 600; display: flex;
  align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.sidebar-foot { padding: 12px; border-top: 1px solid var(--sidebar-border); }
.me-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
}
.avatar {
  border-radius: 99px; background: var(--muted); display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex: 0 0 auto;
}
.a30 { width: 30px; height: 30px; font-size: 12px; }
.a32 { width: 32px; height: 32px; font-size: 11.5px; }
.a34 { width: 34px; height: 34px; font-size: 12px; }
.a38 { width: 38px; height: 38px; font-size: 13px; }
.a40 { width: 40px; height: 40px; font-size: 13px; }
.dot { border-radius: 99px; flex: 0 0 auto; display: inline-block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 0 var(--pad); height: 64px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 82%, transparent); backdrop-filter: blur(10px);
}
.header h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.header-sub { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.searchbox {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--input);
  border-radius: 9px; background: var(--card); min-width: 120px; max-width: 230px; flex: 0 1 175px;
}
.searchbox input { border: none; outline: none; background: transparent; color: var(--foreground); font-size: 13px; width: 100%; }
.icon-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--input); border-radius: 9px; background: var(--card); cursor: pointer; color: var(--foreground);
  position: relative;
}
.icon-btn:hover { background: var(--accent); }
.icon-btn svg, .nav-item svg { stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.notif-dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 99px; background: var(--danger); border: 1.5px solid var(--card); }

.content { flex: 1; overflow-y: auto; padding: var(--pad); }
.screen { display: flex; flex-direction: column; gap: var(--gap); max-width: 1280px; }

/* ---------------------------------------------------------------- controls */
.segment { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--muted); }
.segment button {
  padding: 6px 11px; border: none; border-radius: 7px; cursor: pointer; font-size: 12.5px; font-weight: 500;
  background: transparent; color: var(--muted-foreground); box-shadow: none;
}
.segment button.is-active { background: var(--card); color: var(--foreground); box-shadow: var(--shadow); }
.segment.sm button { padding: 5px 10px; border-radius: 6px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px;
  border: 1px solid var(--input); border-radius: 10px; background: var(--card); color: var(--foreground);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background .12s, opacity .12s;
}
.btn:hover { background: var(--accent); }
.btn svg { stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.btn-primary { border: none; background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary); opacity: .9; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn-danger { color: var(--danger); }

.chip {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; cursor: pointer;
  font-size: 12.5px; font-weight: 500; background: var(--card); color: var(--foreground);
}
.chip.is-active { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

.badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap;
  display: inline-block;
}

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  padding: var(--cardpad); min-width: 0;
}
.card-lg { padding: 24px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.muted { color: var(--muted-foreground); }
.link-btn { font-size: 12.5px; color: var(--muted-foreground); background: none; border: none; cursor: pointer; text-decoration: none; }
.link-btn:hover { color: var(--foreground); }

.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: var(--gap); }
.cols { display: grid; gap: var(--gap); }
.cols-2-1 { grid-template-columns: 1.9fr 1fr; }
.cols-1-2 { grid-template-columns: 1fr 1.9fr; }
.cols-1-15 { grid-template-columns: 1fr 1.5fr; }
.cols-1-14 { grid-template-columns: 1fr 1.4fr; }
.cols-11-1 { grid-template-columns: 1.1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 12px; }
.kpi-label { font-size: 12.5px; color: var(--muted-foreground); font-weight: 500; }
.kpi-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.kpi-value { font-size: 25px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi-delta { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--muted-foreground); }
.spark { width: 60px; height: 24px; flex: 0 0 auto; overflow: visible; }
.spark polyline { fill: none; stroke: var(--muted-foreground); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* chart */
.chart-svg { width: 100%; height: 210px; display: block; overflow: visible; }
.chart-ticks { display: flex; justify-content: space-between; margin-top: 10px; }
.chart-ticks span { font-size: 11px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

/* gauge */
.gauge-wrap { display: flex; justify-content: center; padding: 14px 0 6px; }
.gauge { position: relative; width: 150px; height: 150px; }
.gauge svg { width: 150px; height: 150px; transform: rotate(-90deg); }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-rate { font-size: 30px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; border-radius: 99px; background: var(--muted); overflow: hidden; }
.bar-track.tall { height: 7px; }
.bar-fill { height: 100%; border-radius: 99px; }

/* lists */
.duty-row { display: flex; align-items: center; gap: 11px; padding: 8px 6px; border-radius: 9px; }
.duty-row:hover { background: var(--accent); }
.avatar-wrap { position: relative; flex: 0 0 auto; }
.avatar-wrap .dot { position: absolute; bottom: -1px; right: -1px; width: 11px; height: 11px; border: 2px solid var(--card); }
.activity-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.list-scroll { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* tables */
.table-scroll { overflow-x: auto; }
.trow, .thead {
  display: grid; gap: 10px; align-items: center; border-bottom: 1px solid var(--border);
}
.thead {
  padding: 0 6px 10px; font-size: 11.5px; font-weight: 600; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .04em;
}
.trow { padding: 11px 6px; }
.trow:hover { background: var(--accent); }
/* Whole-row link (team directory → a worker's report). */
a.row-link { color: inherit; text-decoration: none; cursor: pointer; }
a.row-link:hover { background: var(--accent); }
.grid-attend { grid-template-columns: 2fr 1.2fr 1fr 1fr 1fr; min-width: 640px; }
.grid-team { grid-template-columns: 2fr 1.2fr 1fr 1fr 0.8fr; min-width: 680px; }
.grid-pay { grid-template-columns: 1.5fr 1fr 1fr 0.8fr; min-width: 520px; }
.right { text-align: right; }

/* punch card */
.clock-panel { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border); }
.clock-big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.empty { padding: 26px; text-align: center; font-size: 13px; color: var(--muted-foreground); }

/* schedule */
.rota { min-width: 820px; }
.rota-head, .rota-row { display: grid; grid-template-columns: 180px repeat(7, 1fr); gap: 8px; }
.rota-head { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.rota-row { padding: 9px 0; border-bottom: 1px solid var(--border); align-items: center; }
.rota-daycell { text-align: center; line-height: 1.2; padding: 4px; border-radius: 8px; }
.rota-daycell.today { background: var(--muted); }
.rota-cell {
  text-align: center; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums;
  padding: 8px 4px; border-radius: 8px; background: var(--muted); color: var(--foreground);
}
.rota-cell.today { background: var(--accent); }
.rota-cell.off { background: transparent; color: var(--muted-foreground); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted-foreground); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--input); border-radius: 9px; background: var(--card);
  color: var(--foreground); font-size: 14px;
}
.field textarea { resize: vertical; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }

/* hero */
.hero { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding: 22px 24px; }
.hero-status { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.hero-dot { width: 10px; height: 10px; border-radius: 99px; }

/* toast */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.14);
  padding: 12px 16px; font-size: 13px; font-weight: 500; color: var(--foreground); max-width: 320px;
  display: flex; align-items: center; gap: 10px; animation: toastin .2s ease;
}
.toast.err { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.toast .toast-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--present); flex: 0 0 auto; }
.toast.err .toast-dot { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* mobile */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 65; }
.menu-btn { display: none; }
.bottomnav { display: none; }
.mobile-only { display: none; }

@media (max-width: 980px) {
  .cols-2-1, .cols-1-2, .cols-1-15, .cols-1-14, .cols-11-1, .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .desktop-only { display: none !important; }
  .menu-btn { display: flex; }
  .content { padding: 16px 16px 86px; }
  .header { padding: 0 14px; gap: 10px; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: 286px; z-index: 70;
    transform: translateX(-100%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 8px 0 44px rgba(0, 0, 0, .32);
  }
  .sidebar.is-open { transform: translateX(0); }
  .scrim.is-open { display: block; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 55; height: 62px;
    padding-bottom: env(safe-area-inset-bottom); background: var(--sidebar);
    border-top: 1px solid var(--sidebar-border); align-items: stretch; justify-content: space-around;
  }
  .bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: none; background: none; cursor: pointer; color: var(--sidebar-foreground); font-size: 10.5px; font-weight: 600;
  }
  .bottomnav a.is-active { color: var(--sidebar-accent-foreground); }
  .bottomnav svg { stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
}

/* ---------------------------------------------------------------- auth pages */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; background: var(--background);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .08); padding: 30px 28px;
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-title { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.auth-sub { margin: 4px 0 20px; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-foreground); cursor: pointer; }
.auth-remember input { width: 15px; height: 15px; }
.auth-error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px;
}
.auth-note {
  background: var(--muted); border-radius: 10px; padding: 14px 16px; font-size: 13px;
  color: var(--muted-foreground); line-height: 1.5; margin-bottom: 18px;
}
.auth-link { display: block; text-align: center; margin-top: 16px; font-size: 13px; }
.auth-foot { font-size: 12px; }

/* ---------------------------------------------------------------- user menu */
.usermenu { position: relative; }
.usermenu-trigger {
  display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 8px 0 10px;
  border: 1px solid var(--input); border-radius: 9px; background: var(--card); cursor: pointer; color: var(--foreground);
}
.usermenu-trigger:hover { background: var(--accent); }
.usermenu-trigger .avatar { width: 24px; height: 24px; font-size: 10.5px; }
.usermenu-name { font-size: 13px; font-weight: 500; max-width: 120px; }
.role-badge {
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 99px;
  background: var(--muted); color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .03em;
}
.usermenu-pop {
  position: absolute; top: 44px; right: 0; z-index: 40; width: 224px; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .16);
  padding: 8px; display: none;
}
.usermenu-pop.is-open { display: block; }
.usermenu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.usermenu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: none; border-radius: 8px;
  background: none; cursor: pointer; font-size: 13px; color: var(--foreground); text-align: left; text-decoration: none;
}
.usermenu-item:hover { background: var(--accent); }
.usermenu-item.danger { color: var(--danger); }

/* users + logs tables reuse .trow/.thead grids */
.grid-users { grid-template-columns: 2fr 1.4fr 1fr 1.2fr 0.8fr; min-width: 720px; }
.grid-logs { grid-template-columns: 1.4fr 1.3fr 1.6fr 1fr; min-width: 720px; }
.pill-ok { background: rgba(22, 163, 74, .14); color: var(--present); }
.pill-off { background: var(--muted); color: var(--muted-foreground); }
.temp-pass {
  background: color-mix(in srgb, var(--present) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--present) 35%, var(--border));
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: var(--gap);
}
.temp-pass code { font-family: 'Geist Mono', ui-monospace, monospace; font-weight: 600; font-size: 14px; }
.flash {
  background: var(--muted); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; margin-bottom: var(--gap);
}
.qr-instruct {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px;
  background: var(--card-2); border: 1px dashed var(--input); color: var(--muted-foreground);
  font-size: 13px; line-height: 1.4;
}
.qr-instruct b { color: var(--foreground); }
