/* ================================================
   STAFFPRO TIMEKEEPING v2 — DESIGN SYSTEM
   ================================================
   Tokens → Base → Components → Layout → Screens → Motion
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* =============== TOKENS =============== */
:root {
  /* Brand */
  --brand-50:  #EEF2FF;
  --brand-100: #DCE5FF;
  --brand-200: #B6C5FF;
  --brand-300: #889EFF;
  --brand-400: #5573F0;
  --brand-500: #2540C8;  /* StaffPro signature */
  --brand-600: #1E36B0;
  --brand-700: #182A8C;
  --brand-800: #142270;
  --brand-900: #0F1B57;
  --brand-950: #0A1340;

  /* Neutrals — slightly warm slate */
  --ink-0:   #FFFFFF;
  --ink-50:  #FAFBFC;
  --ink-100: #F3F4F8;
  --ink-150: #EAECF2;
  --ink-200: #DDE0EA;
  --ink-300: #BFC4D4;
  --ink-400: #8E94A8;
  --ink-500: #686E82;
  --ink-600: #4C5167;
  --ink-700: #353A4C;
  --ink-800: #232737;
  --ink-900: #161927;
  --ink-950: #0D101C;

  /* Semantic */
  --green-50:  #ECFDF5;  --green-100: #D1FAE5;  --green-500: #10B981;  --green-700: #047857;
  --amber-50:  #FFFBEB;  --amber-100: #FEF3C7;  --amber-500: #F59E0B;  --amber-700: #B45309;
  --red-50:    #FEF2F2;  --red-100:   #FEE2E2;  --red-500:   #EF4444;  --red-700:   #B91C1C;
  --sky-50:    #F0F9FF;  --sky-100:   #E0F2FE;  --sky-500:   #0EA5E9;  --sky-700:   #0369A1;
  --violet-50: #F5F3FF;  --violet-500:#7C3AED;

  /* Accents */
  --accent: var(--brand-500);
  --accent-fg: #FFFFFF;

  /* Surfaces */
  --bg:        var(--ink-50);
  --surface:   var(--ink-0);
  --surface-2: var(--ink-100);
  --border:    var(--ink-200);
  --border-strong: var(--ink-300);
  --text:      var(--ink-900);
  --text-muted:var(--ink-500);
  --text-subtle: var(--ink-400);

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --fs-xs:   0.75rem;
  --fs-sm:   0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md:   1rem;
  --fs-lg:   1.125rem;
  --fs-xl:   1.375rem;
  --fs-2xl:  1.75rem;
  --fs-3xl:  2.25rem;
  --fs-4xl:  3rem;
  --fs-5xl:  4rem;

  /* Spacing (4px grid) */
  --sp-0: 0;
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.25rem;  --sp-6: 1.5rem;   --sp-8: 2rem;     --sp-10: 2.5rem;
  --sp-12: 3rem;    --sp-16: 4rem;    --sp-20: 5rem;    --sp-24: 6rem;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-2xl: 32px;
  --r-full: 9999px;

  /* Shadows — layered for depth */
  --sh-xs:  0 1px 2px rgba(13, 16, 28, 0.04);
  --sh-sm:  0 1px 3px rgba(13, 16, 28, 0.06), 0 1px 2px rgba(13, 16, 28, 0.04);
  --sh:     0 4px 12px rgba(13, 16, 28, 0.06), 0 2px 4px rgba(13, 16, 28, 0.04);
  --sh-md:  0 8px 24px rgba(13, 16, 28, 0.08), 0 3px 8px rgba(13, 16, 28, 0.05);
  --sh-lg:  0 16px 48px rgba(13, 16, 28, 0.12), 0 4px 12px rgba(13, 16, 28, 0.06);
  --sh-xl:  0 24px 64px rgba(13, 16, 28, 0.18);
  --sh-brand: 0 8px 24px rgba(37, 64, 200, 0.28);

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-mobile: 0;
  --topbar-h: 64px;
  --container: 1280px;

  /* Motion */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --d-fast: 120ms;
  --d:      200ms;
  --d-slow: 360ms;
}

/* =============== BASE =============== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  font-feature-settings: 'cv11', 'ss01';
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

a { color: var(--brand-500); text-decoration: none; }
a:hover { color: var(--brand-700); }

::selection { background: var(--brand-200); color: var(--brand-900); }

/* Scrollbar — subtle */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: var(--r-full); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); background-clip: padding-box; border: 2px solid transparent; }

/* =============== TYPOGRAPHY =============== */
h1 { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.018em; line-height: 1.2; }
h3 { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.012em; line-height: 1.3; }
h4 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.008em; }
h5 { font-size: var(--fs-md); font-weight: 600; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.eyebrow {
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted);
}
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-md { font-size: var(--fs-md); }
.text-lg { font-size: var(--fs-lg); }
.semibold { font-weight: 600; }
.bold { font-weight: 700; }

/* =============== LAYOUT HELPERS =============== */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }
.between { justify-content: space-between; }
.center { justify-content: center; align-items: center; }
.start { align-items: flex-start; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.right { text-align: right; }
.center-text { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.full { width: 100%; }
.relative { position: relative; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* =============== ICONS =============== */
.icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon svg { width: 100%; height: 100%; stroke-width: 1.75; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

/* =============== BUTTONS =============== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: 0.55rem 0.95rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent-fg);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease), background var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease), color var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-700); color: white; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--ink-100); color: var(--text); }

.btn-soft {
  background: var(--brand-50); color: var(--brand-700); border-color: transparent;
}
.btn-soft:hover { background: var(--brand-100); color: var(--brand-800); }

.btn-outline {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--ink-100); color: var(--text); border-color: var(--ink-400); }

.btn-danger { background: var(--red-500); color: white; }
.btn-danger:hover { background: var(--red-700); color: white; }

.btn-success { background: var(--green-500); color: white; }
.btn-success:hover { background: var(--green-700); color: white; }

.btn-sm { padding: 0.35rem 0.65rem; font-size: var(--fs-xs); border-radius: var(--r-sm); gap: var(--sp-1); }
.btn-lg { padding: 0.85rem 1.4rem; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn-xl {
  padding: 1.25rem 2rem; font-size: var(--fs-lg);
  border-radius: var(--r-lg); box-shadow: var(--sh-brand);
  letter-spacing: -0.005em;
}
.btn-block { width: 100%; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: var(--r);
}

/* =============== FORMS =============== */
.field { margin-bottom: var(--sp-4); }
.field-row { display: flex; gap: var(--sp-3); }
.field-row > .field { flex: 1; margin-bottom: 0; }
.field > label {
  display: block;
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.input, .select, .textarea {
  width: 100%;
  padding: 0.625rem 0.8rem;
  font-size: var(--fs-sm);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease), background var(--d-fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(37, 64, 200, 0.12);
}

.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23686E82' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2.25rem;
}

.checkbox {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  cursor: pointer; user-select: none; font-size: var(--fs-sm);
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand-500); }

/* Toggle switch */
.switch {
  position: relative; display: inline-block;
  width: 38px; height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--ink-300); border-radius: var(--r-full);
  transition: background var(--d) var(--ease);
}
.switch-track::before {
  content: '';
  position: absolute; left: 3px; bottom: 3px;
  width: 16px; height: 16px;
  background: white; border-radius: 50%;
  transition: transform var(--d) var(--ease);
  box-shadow: var(--sh-sm);
}
.switch input:checked + .switch-track { background: var(--brand-500); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }

/* =============== CARDS =============== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: box-shadow var(--d) var(--ease), border-color var(--d) var(--ease);
}
.card-padded { padding: var(--sp-6); }
.card-flush  { padding: 0; }
.card-elev   { box-shadow: var(--sh-sm); border: 1px solid transparent; }
.card-hover:hover { border-color: var(--border-strong); box-shadow: var(--sh); }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.card-title { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.008em; }
.card-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

/* =============== STAT CARDS =============== */
.stat {
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--d) var(--ease), border-color var(--d) var(--ease), transform var(--d) var(--ease);
}
.stat:hover { border-color: var(--border-strong); }
.stat-label {
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center; gap: var(--sp-2);
}
.stat-value {
  font-size: var(--fs-3xl); font-weight: 700;
  letter-spacing: -0.025em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-sub { font-size: var(--fs-xs); color: var(--text-muted); display: flex; align-items: center; gap: var(--sp-1); }
.stat-trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: var(--fs-xs); }
.stat-trend.up   { color: var(--green-700); }
.stat-trend.down { color: var(--red-700); }
.stat-accent {
  background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-700) 100%);
  color: white;
  border-color: transparent;
}
.stat-accent .stat-label,
.stat-accent .stat-value,
.stat-accent .stat-sub { color: white; }
.stat-accent .stat-label { opacity: 0.85; }
.stat-accent .stat-sub { opacity: 0.78; }

/* =============== BADGES =============== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: var(--r-full);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.badge-brand { background: var(--brand-50); color: var(--brand-700); }
.badge-gray  { background: var(--ink-100); color: var(--ink-700); }
.badge-green { background: var(--green-50); color: var(--green-700); }
.badge-amber { background: var(--amber-50); color: var(--amber-700); }
.badge-red   { background: var(--red-50);   color: var(--red-700); }
.badge-sky   { background: var(--sky-50);   color: var(--sky-700); }
.badge-violet{ background: var(--violet-50);color: var(--violet-500); }

/* Live pulse */
.pulse {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--green-500);
  position: relative;
}
.pulse::after {
  content: ''; position: absolute; inset: 0;
  border-radius: 50%; background: var(--green-500);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* =============== TABLES =============== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
table.tbl {
  width: 100%; border-collapse: collapse;
  font-size: var(--fs-sm);
}
table.tbl th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--ink-50);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
table.tbl td {
  padding: 0.75rem var(--sp-4);
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
table.tbl tbody tr { transition: background var(--d-fast) var(--ease); }
table.tbl tbody tr:hover { background: var(--ink-50); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tfoot td {
  padding: var(--sp-3) var(--sp-4);
  background: var(--brand-50);
  font-weight: 600;
  color: var(--brand-900);
  border-top: 1px solid var(--brand-100);
}

/* =============== TABS =============== */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
  overflow-x: auto;
}
.tab {
  padding: 0.7rem 1rem;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand-500); }
.tab-panel { display: none; animation: fadeUp var(--d-slow) var(--ease-out); }
.tab-panel.active { display: block; }

/* Pill tabs */
.pills { display: inline-flex; padding: 3px; background: var(--ink-100); border-radius: var(--r-full); gap: 2px; }
.pill {
  padding: 0.4rem 0.85rem; font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--r-full);
  transition: all var(--d-fast) var(--ease);
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); }

/* =============== APP SHELL =============== */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: 'side top' 'side main';
}
.topbar {
  grid-area: top;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: var(--sp-3); }
.topbar-right { display: flex; align-items: center; gap: var(--sp-2); }
.topbar h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.015em; }

.sidebar {
  grid-area: side;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh;
  position: sticky; top: 0;
  overflow-y: auto;
}
.sidebar-brand {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3);
}
.brand-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 14px;
  box-shadow: var(--sh-brand);
}
.brand-name {
  font-weight: 800; font-size: var(--fs-md);
  letter-spacing: -0.015em;
}
.brand-name .light { color: var(--text-muted); font-weight: 700; }

/* Full StaffPro wordmark — replaces .brand-mark + .brand-name when used */
.brand-logo {
  height: 32px;
  width: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.brand-logo-lg { height: 44px; }
.brand-logo-sm { height: 26px; }
.brand-block {
  display: flex; align-items: center; gap: var(--sp-3);
  text-decoration: none; color: inherit;
}
.brand-block:hover { text-decoration: none; }

.role-pill {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0 var(--sp-5) var(--sp-4);
  padding: 4px 8px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--brand-50); color: var(--brand-700);
  border-radius: var(--r-sm);
  align-self: flex-start;
}
.role-pill.staff { background: var(--violet-50); color: var(--violet-500); }
.role-pill.client { background: var(--sky-50); color: var(--sky-700); }
.role-pill.emp { background: var(--green-50); color: var(--green-700); }

.sidebar-section {
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-subtle);
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0.6rem 0.8rem;
  margin: 2px var(--sp-3);
  border-radius: var(--r);
  color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: 500;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
  position: relative;
}
.nav-item:hover { background: var(--ink-100); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.nav-item.active .icon svg { stroke: var(--brand-700); }
.nav-item .icon svg { stroke: var(--text-muted); transition: stroke var(--d-fast) var(--ease); }
.nav-item:hover .icon svg { stroke: var(--text); }
.nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  background: var(--red-500); color: white;
  border-radius: var(--r-full);
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.nav-badge.gray { background: var(--ink-200); color: var(--text-muted); }

.sidebar-footer {
  margin-top: auto;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease);
}
.user-chip:hover { background: var(--ink-100); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; }
.user-chip-info { display: flex; flex-direction: column; min-width: 0; }
.user-chip-name { font-size: var(--fs-sm); font-weight: 600; }
.user-chip-role { font-size: 11px; color: var(--text-muted); }

.main {
  grid-area: main;
  padding: var(--sp-6);
  max-width: 100%;
  min-width: 0;
}
.main-narrow { max-width: 980px; margin: 0 auto; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.page-head h1 { font-size: var(--fs-2xl); letter-spacing: -0.022em; }
.page-head .sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }

/* Mobile sidebar */
.sidebar-toggle { display: none; }
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: 'top' 'main'; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 280px; z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--d) var(--ease);
    box-shadow: var(--sh-xl);
  }
  .shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .main { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .sidebar-scrim {
    display: none; position: fixed; inset: 0; background: rgba(13, 16, 28, 0.4);
    z-index: 90; animation: fadeIn var(--d) var(--ease);
  }
  .shell.sidebar-open .sidebar-scrim { display: block; }
}

/* =============== MOBILE EMPLOYEE SHELL =============== */
.mobile-shell {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex; flex-direction: column;
  position: relative;
}
.mobile-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.mobile-body { flex: 1; padding: var(--sp-5); padding-bottom: 5rem; }
.mobile-tabbar {
  position: sticky; bottom: 0;
  display: flex; justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--sp-2);
  padding-bottom: max(var(--sp-2), env(safe-area-inset-bottom));
  z-index: 20;
}
.mobile-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--sp-2);
  border-radius: var(--r);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  transition: color var(--d-fast) var(--ease), background var(--d-fast) var(--ease);
}
.mobile-tab:hover { background: var(--ink-100); }
.mobile-tab.active { color: var(--brand-700); }
.mobile-tab.active .icon svg { stroke: var(--brand-700); }
.mobile-tab .icon svg { stroke: var(--text-muted); }

/* =============== LANDING =============== */
.landing {
  min-height: 100vh;
  display: flex; flex-direction: column;
  position: relative;
  background:
    radial-gradient(circle at 20% 0%, rgba(37, 64, 200, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(124, 58, 237, 0.05) 0%, transparent 50%),
    var(--bg);
}
.landing-nav {
  padding: var(--sp-5) var(--sp-8);
  display: flex; justify-content: space-between; align-items: center;
}
.landing-hero {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-12) var(--sp-6);
}
.landing-inner {
  width: 100%; max-width: 1080px;
  text-align: center;
}
.landing h1 {
  font-size: clamp(2.25rem, 5.5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin-bottom: var(--sp-4);
  background: linear-gradient(180deg, var(--ink-900) 0%, var(--ink-700) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 6px 12px;
  background: var(--brand-50); color: var(--brand-700);
  border: 1px solid var(--brand-100);
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600;
  margin-bottom: var(--sp-5);
}
.landing p.lead {
  font-size: var(--fs-lg); color: var(--text-muted);
  max-width: 640px; margin: 0 auto var(--sp-10);
}
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
@media (max-width: 800px) { .role-grid { grid-template-columns: 1fr; } }

.role-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-6);
  text-align: left;
  transition: all var(--d) var(--ease);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.role-card:hover {
  border-color: var(--brand-300);
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
  text-decoration: none;
}
.role-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 50%, var(--brand-50) 100%);
  opacity: 0; transition: opacity var(--d) var(--ease);
  pointer-events: none;
}
.role-card:hover::before { opacity: 1; }
.role-card .role-icon {
  width: 48px; height: 48px;
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: var(--sh-brand);
  margin-bottom: var(--sp-2);
}
.role-card.staff .role-icon { background: linear-gradient(135deg, var(--violet-500), #5B21B6); box-shadow: 0 8px 24px rgba(124, 58, 237, 0.28); }
.role-card.client .role-icon { background: linear-gradient(135deg, var(--sky-500), #0369A1); box-shadow: 0 8px 24px rgba(14, 165, 233, 0.28); }
.role-card.emp .role-icon { background: linear-gradient(135deg, var(--green-500), var(--green-700)); box-shadow: 0 8px 24px rgba(16, 185, 129, 0.28); }
.role-card h3 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.015em; margin-bottom: 2px; color: var(--text); }
.role-card p { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.55; }
.role-card .role-cta {
  margin-top: auto;
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--brand-700);
}
.landing-foot {
  padding: var(--sp-6) var(--sp-6);
  text-align: center;
  font-size: var(--fs-xs); color: var(--text-subtle);
}

/* =============== PUNCH HERO (mobile employee) =============== */
.punch-hero {
  position: relative;
  border-radius: var(--r-2xl);
  background: linear-gradient(160deg, var(--brand-700) 0%, var(--brand-900) 100%);
  color: white;
  padding: var(--sp-6);
  overflow: hidden;
}
.punch-hero::before {
  content: '';
  position: absolute; top: -40%; right: -20%;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
  border-radius: 50%;
  pointer-events: none;
}
.punch-clock {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 3.25rem; font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 4px;
}
.punch-date { font-size: var(--fs-sm); opacity: 0.85; margin-bottom: var(--sp-5); }

.punch-state {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  font-size: var(--fs-sm);
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.punch-state.in {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.35);
}

.punch-button {
  width: 100%;
  padding: 1.25rem;
  background: white;
  color: var(--brand-700);
  border: none;
  border-radius: var(--r-lg);
  font-size: var(--fs-lg); font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.punch-button:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32); }
.punch-button:active { transform: translateY(0); }
.punch-button.out { background: var(--red-500); color: white; }
.punch-button.out:hover { background: var(--red-700); }

.geo-chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 5px 10px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
  background: rgba(16, 185, 129, 0.18);
  color: white;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.geo-chip.fail {
  background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.4);
}

/* =============== PIN PAD =============== */
.pin-display {
  display: flex; gap: var(--sp-2); justify-content: center;
  margin: var(--sp-5) 0;
}
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink-200);
  transition: background var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
}
.pin-dot.filled { background: var(--brand-500); transform: scale(1.1); }
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  max-width: 320px; margin: 0 auto;
}
.pin-key {
  font-size: var(--fs-xl); font-weight: 600;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: all var(--d-fast) var(--ease);
  user-select: none;
}
.pin-key:hover { background: var(--ink-50); border-color: var(--border-strong); }
.pin-key:active { transform: scale(0.96); background: var(--brand-50); border-color: var(--brand-300); }
.pin-key.alt { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; }

/* =============== EXCEPTION LIST / FEED =============== */
.feed { display: flex; flex-direction: column; gap: var(--sp-2); }
.feed-item {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color var(--d-fast) var(--ease);
  align-items: flex-start;
}
.feed-item:hover { border-color: var(--border-strong); }
.feed-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--ink-100);
  display: inline-flex; align-items: center; justify-content: center;
}
.feed-icon.red    { background: var(--red-50); color: var(--red-700); }
.feed-icon.amber  { background: var(--amber-50); color: var(--amber-700); }
.feed-icon.green  { background: var(--green-50); color: var(--green-700); }
.feed-icon.sky    { background: var(--sky-50); color: var(--sky-700); }
.feed-icon.brand  { background: var(--brand-50); color: var(--brand-700); }
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: var(--fs-sm); font-weight: 600; }
.feed-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.feed-time { font-size: var(--fs-xs); color: var(--text-subtle); }

/* =============== LIVE SHIFT BOARD =============== */
.shift-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto auto;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--ink-100);
  transition: background var(--d-fast) var(--ease);
}
.shift-row:hover { background: var(--ink-50); }
.shift-row:last-child { border-bottom: none; }
.shift-name { font-size: var(--fs-sm); font-weight: 600; }
.shift-meta { font-size: 11px; color: var(--text-muted); }

/* =============== TIMESHEET DAY ROW =============== */
.ts-row {
  display: grid;
  grid-template-columns: 110px 80px 80px 80px 70px 70px 70px 110px auto;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  align-items: center;
  border-bottom: 1px solid var(--ink-100);
  font-size: var(--fs-sm);
}
.ts-row.head {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--ink-50);
}
.ts-row:hover:not(.head) { background: var(--ink-50); }
.ts-row.flag { background: var(--amber-50); }
.ts-row.flag:hover { background: #FFF7DA; }

/* =============== CHART (mini) =============== */
.chart {
  width: 100%; height: 180px;
  display: block;
}
.chart-bars { display: grid; grid-auto-flow: column; gap: 6px; align-items: end; height: 140px; }
.chart-bar {
  background: linear-gradient(180deg, var(--brand-400) 0%, var(--brand-600) 100%);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  position: relative;
  transition: opacity var(--d) var(--ease);
}
.chart-bar:hover { opacity: 0.85; }
.chart-bar.dim { background: var(--ink-200); }
.chart-x { display: grid; grid-auto-flow: column; gap: 6px; margin-top: var(--sp-2); }
.chart-x span { text-align: center; font-size: 10px; color: var(--text-muted); }

/* =============== MODAL =============== */
.scrim {
  position: fixed; inset: 0;
  background: rgba(13, 16, 28, 0.55);
  display: none; align-items: center; justify-content: center;
  padding: var(--sp-4);
  z-index: 200;
  animation: fadeIn var(--d) var(--ease);
}
.scrim.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 100%; max-width: 560px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: var(--sh-xl);
  animation: scaleIn var(--d) var(--ease-out);
  overflow: hidden;
}
.modal-wide { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.modal-head h3 { font-size: var(--fs-lg); font-weight: 600; }
.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-tabs {
  display: flex;
  gap: 2px;
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  background: var(--surface);
}
.modal-tabs .tab { padding: 0.7rem 0.9rem; }
.modal-foot {
  padding: var(--sp-4) var(--sp-6);
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  border-top: 1px solid var(--border);
  background: var(--ink-50);
  border-bottom-left-radius: var(--r-xl);
  border-bottom-right-radius: var(--r-xl);
  flex: 0 0 auto;
}
.x-close {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.x-close:hover { background: var(--ink-100); color: var(--text); }

/* =============== TOAST =============== */
.toast {
  position: fixed; bottom: var(--sp-5); right: var(--sp-5);
  background: var(--ink-900); color: white;
  padding: 0.85rem 1.1rem;
  border-radius: var(--r);
  font-size: var(--fs-sm); font-weight: 500;
  display: flex; align-items: center; gap: var(--sp-2);
  box-shadow: var(--sh-lg);
  z-index: 300;
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--d) var(--ease), transform var(--d) var(--ease);
  pointer-events: none;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green-700); }
.toast.error   { background: var(--red-700); }
.toast.warn    { background: var(--amber-700); }
@media (max-width: 600px) { .toast { left: var(--sp-3); right: var(--sp-3); max-width: none; } }

/* =============== EMPTY STATES =============== */
.empty {
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
}
.empty .empty-icon {
  width: 56px; height: 56px;
  border-radius: var(--r-xl);
  background: var(--ink-100);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: var(--sp-2);
  color: var(--text-muted);
}
.empty h4 { color: var(--text); font-weight: 600; }
.empty p { max-width: 360px; font-size: var(--fs-sm); }

/* =============== MOTION =============== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.anim-up { animation: fadeUp var(--d-slow) var(--ease-out); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============== UTILITIES =============== */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); } .mb-6 { margin-bottom: var(--sp-6); } .mb-8 { margin-bottom: var(--sp-8); }
.p-0 { padding: 0; }

/* Avatar palette */
.av-blue   { background: linear-gradient(135deg, #4F7BE8, #2540C8); }
.av-violet { background: linear-gradient(135deg, #A78BFA, #7C3AED); }
.av-green  { background: linear-gradient(135deg, #34D399, #059669); }
.av-amber  { background: linear-gradient(135deg, #FBBF24, #D97706); }
.av-red    { background: linear-gradient(135deg, #F87171, #DC2626); }
.av-sky    { background: linear-gradient(135deg, #38BDF8, #0284C7); }
.av-pink   { background: linear-gradient(135deg, #F472B6, #DB2777); }
.av-teal   { background: linear-gradient(135deg, #2DD4BF, #0F766E); }
.av-orange { background: linear-gradient(135deg, #FB923C, #EA580C); }
.av-indigo { background: linear-gradient(135deg, #818CF8, #4338CA); }

/* Map placeholder */
.map-mock {
  position: relative;
  height: 160px;
  border-radius: var(--r-md);
  background:
    linear-gradient(135deg, #DCE5FF 0%, #B6C5FF 60%, #88A1F8 100%);
  overflow: hidden;
  border: 1px solid var(--border);
}
.map-mock::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.4) 0, transparent 30%),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.3) 0, transparent 35%),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,0.08) 12px 13px),
    repeating-linear-gradient(-45deg, transparent 0 12px, rgba(255,255,255,0.08) 12px 13px);
}
.map-pin {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -100%);
  width: 28px; height: 36px;
  background: var(--red-500);
  border-radius: 14px 14px 14px 0;
  transform: translate(-50%, -100%) rotate(-45deg);
  box-shadow: var(--sh-md);
}
.map-pin::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 10px; height: 10px;
  background: white; border-radius: 50%;
  transform: translate(-50%, -50%);
}
.map-radius {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 140px; height: 140px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  background: rgba(37, 64, 200, 0.15);
}

/* Code/note inline */
.kbd {
  font-family: var(--mono); font-size: 11px;
  padding: 2px 6px;
  background: var(--ink-100);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
}
