/* ============================================================
   SizLix Payroll Dashboard — Premium Ledger Design System
   ============================================================
   Generated from Stitch design (asset e258ade1...). Vanilla
   CSS, no build step. Class names preserve backward-compat
   with existing page modules (owner.js, staff.js, etc.).
   ============================================================ */

/* Load fonts via CSS as well as <link> in HTML — defensive against
   stale cached HTML that pre-dates the font links being added. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,300..700,0..1,-50..200&display=swap');

:root {
  /* ---- Brand (Premium Ledger — emerald + cream) ---- */
  --primary:            #047857;  /* deep emerald  */
  --primary-dark:       #005d42;  /* darker emerald */
  --primary-light:      #7bd8b1;  /* mint */
  --primary-wash:       #d1fae5;  /* mint wash */
  --primary-fixed:      #97f5cc;
  --on-primary:         #ffffff;

  /* ---- Surface (warm cream paper feel) ---- */
  --surface:            #faf9f6;  /* base background */
  --surface-card:       #ffffff;  /* card / panel surface */
  --surface-low:        #f4f3f1;  /* subtle row tint */
  --surface-mid:        #efeeeb;  /* hint card bg */
  --surface-high:       #e9e8e5;  /* deeper layer */
  --surface-dim:        #dbdad7;

  /* ---- Text ---- */
  --text:               #1a1c1a;  /* on-surface */
  --text-muted:         #3e4943;  /* on-surface-variant */
  --text-faint:         #6e7a73;  /* outline */
  --text-disabled:      #a8b1ab;

  /* ---- Lines ---- */
  --border:             #e5e7eb;  /* hairline grey (key motif) */
  --border-strong:      #bdc9c1;  /* outline-variant */
  --divider:            #ececec;

  /* ---- Status ---- */
  --success:            #047857;
  --success-bg:         #d1fae5;
  --warning:            #b45309;
  --warning-bg:         #fef3c7;
  --error:              #b91c1c;
  --error-bg:           #fee2e2;
  --info:               #1d4ed8;
  --info-bg:            #dbeafe;

  /* ---- Radii ---- */
  --r-xs: 2px;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-pill: 9999px;

  /* ---- Spacing scale (Stitch ledger rhythm: 4/8/16/24/40) ---- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-gutter: 16px;

  /* ---- Elevation ---- */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-focus: 0 0 0 3px rgba(4, 120, 87, 0.18);

  /* ---- Layout ---- */
  --sidebar-w: 256px;
  --header-h: 64px;
  --content-max: 1440px;

  /* ---- Typography ---- */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

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

html { font-size: 14px; line-height: 1.5; }
html, body {
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button { font-family: inherit; cursor: pointer; }

img { max-width: 100%; display: block; }

/* Material Symbols default — Google's CSS URL only ships @font-face,
   we have to declare the class ourselves with font-family. */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  vertical-align: middle;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* Mono numbers — tabular figures, perfect column alignment */
.num, .mono, td.num, .nums {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' on, 'lnum' on;
  font-variant-numeric: tabular-nums;
}

/* Small uppercase labels (table headers, KPI labels) */
.label-caps {
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.bold  { font-weight: 600; }

/* ============================================================
   Shell layout (sidebar + main)
   ============================================================ */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  overflow-y: auto;
  padding: var(--space-lg) 0;
}

.sidebar-brand {
  padding: 0 var(--space-md);
  margin-bottom: var(--space-xl);
}
.sidebar-brand .firm-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.sidebar-brand .product-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.sidebar-brand .date-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--space-sm);
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-left: 3px solid transparent;
  margin-left: -3px;
  transition: background 80ms, color 80ms;
}
.sidebar nav a:hover {
  background: var(--surface-high);
  color: var(--text);
  text-decoration: none;
}
.sidebar nav a.active {
  background: rgba(4, 120, 87, 0.06);
  color: var(--primary-dark);
  font-weight: 600;
  border-left-color: var(--primary);
}
.sidebar nav a .material-symbols-outlined {
  color: inherit;
  font-size: 20px;
}

.sidebar nav .nav-section-end { flex: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  min-width: 18px;
  text-align: center;
}

.sidebar-user {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  margin: var(--space-md) var(--space-md) 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-user b {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.sidebar-user .role-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-mid);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  align-self: flex-start;
}
.sidebar-user #logout-btn {
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  align-self: flex-start;
  transition: all 80ms;
}
.sidebar-user #logout-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-spacer { flex: 1; }

/* Content area */
.main > *:not(.topbar) {
  padding: 32px 32px 64px;
  max-width: var(--content-max);
}

/* ============================================================
   Page header (used by main-header pattern in existing pages)
   ============================================================ */
.main-header,
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}
.main-header h1,
.page-header h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 36px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.main-header h2,
.page-header h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.page-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.page-header .eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}
.main-header .actions,
.page-header .actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: var(--on-primary);
  cursor: pointer;
  transition: background 80ms, transform 80ms, box-shadow 80ms;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--primary);
  transform: none;
}

.btn-secondary {
  background: var(--surface-card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-low);
  border-color: var(--border-strong);
}

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

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover { background: #991b1b; }

.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }

.btn .material-symbols-outlined { font-size: 18px; }

/* ============================================================
   Cards + KPI tiles
   ============================================================ */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}
.card-title .material-symbols-outlined {
  color: var(--text-muted);
  font-size: 20px;
}
.card-actions {
  display: flex;
  gap: var(--space-sm);
}

/* Stat / KPI tile (legacy .stat name + new .kpi-tile) */
.card-grid,
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-gutter);
  margin-bottom: var(--space-xl);
}
.stat,
.kpi-tile {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-lg);
  position: relative;
  transition: box-shadow 120ms;
}
.stat:hover,
.kpi-tile:hover {
  box-shadow: var(--shadow-md);
}
.stat::before,
.kpi-tile.accent::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 2px;
  background: var(--primary);
  border-radius: 1px;
}
.kpi-tile:not(.accent)::before { display: none; }

.stat-label,
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.stat-value,
.kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-value.text-primary,
.kpi-value.text-primary { color: var(--primary); }
.stat-value.text-error,
.kpi-value.text-error { color: var(--error); }
.stat-value.text-success,
.kpi-value.text-success { color: var(--success); }

.kpi-foot {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-foot.text-success { color: var(--success); }
.kpi-foot.text-error   { color: var(--error); }
.kpi-foot .material-symbols-outlined { font-size: 14px; }

/* ============================================================
   Tables (ledger style)
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead {
  background: var(--surface-low);
  border-bottom: 1px solid var(--border);
}
thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 16px;
  white-space: nowrap;
}
thead th.center { text-align: center; }
thead th.right  { text-align: right; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 80ms;
}
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover {
  background: rgba(4, 120, 87, 0.04);
}
tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}
tbody td.center { text-align: center; }
tbody td.right  { text-align: right; }
tbody td.num    {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 500;
}
tbody td b { font-weight: 600; }

/* Embedded table in a card — remove redundant border */
.card table { border-radius: 0; }
.card > table:first-child thead { border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg); }

/* Compact table variant */
table.dense thead th { padding: 8px 12px; }
table.dense tbody td { padding: 8px 12px; }

/* Table wrapper for horizontal scroll on narrow screens */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-card);
}
.table-wrap > table {
  border: 0;
}

/* ============================================================
   Status pills / badges
   ============================================================ */
.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  background: var(--surface-mid);
  color: var(--text-muted);
  line-height: 18px;
  white-space: nowrap;
}
.badge-success, .pill-success {
  background: var(--primary-wash);
  color: var(--primary-dark);
}
.badge-error, .pill-error {
  background: var(--error-bg);
  color: var(--error);
}
.badge-warning, .pill-warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.badge-info, .pill-info {
  background: var(--info-bg);
  color: var(--info);
}
.badge-neutral, .pill-neutral {
  background: var(--surface-mid);
  color: var(--text-muted);
}

/* Dot prefix variant */
.pill.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ============================================================
   Forms
   ============================================================ */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="time"],
input[type="date"],
input[type="search"],
textarea,
select {
  width: 100%;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  line-height: 1.4;
  transition: border-color 80ms, box-shadow 80ms;
}
textarea { min-height: 88px; resize: vertical; }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%236e7a73' stroke-width='1.5'><path d='M3 5l3 3 3-3'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
input::placeholder,
textarea::placeholder { color: var(--text-faint); }

input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-low);
  color: var(--text-faint);
  cursor: not-allowed;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.form-row > div:empty { display: none; }
.form-group {
  margin-bottom: var(--space-md);
}
.form-group .help,
.help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Checkbox / radio */
input[type="checkbox"],
input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  vertical-align: middle;
}

/* Search field with leading icon */
.search-field {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-field .material-symbols-outlined {
  position: absolute;
  left: 10px;
  color: var(--text-faint);
  pointer-events: none;
  font-size: 18px;
}
.search-field input { padding-left: 36px; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--text-muted);
  background: var(--surface-low);
  font-size: 13px;
  color: var(--text);
  margin-bottom: var(--space-md);
}
.alert-success {
  background: var(--primary-wash);
  border-left-color: var(--primary);
  color: var(--primary-dark);
}
.alert-error {
  background: var(--error-bg);
  border-left-color: var(--error);
  color: var(--error);
}
.alert-warning {
  background: var(--warning-bg);
  border-left-color: var(--warning);
  color: var(--warning);
}
.alert-info {
  background: var(--info-bg);
  border-left-color: var(--info);
  color: var(--info);
}

/* Audit hint / WhatsApp tip footer (Premium Ledger motif) */
.audit-hint {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}
.audit-hint-card {
  background: var(--surface-mid);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.audit-hint-card .material-symbols-outlined {
  color: var(--primary);
  font-size: 20px;
  margin-top: 1px;
}
.audit-hint-card code,
.audit-hint-card .cmd {
  display: inline-block;
  background: var(--surface-card);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.audit-hint-card b {
  color: var(--text);
  font-weight: 600;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-md);
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-card.wide { max-width: 720px; }
.modal-card h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ============================================================
   Loading + spinner
   ============================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn .spinner {
  width: 14px; height: 14px; border-width: 2px;
  border-top-color: currentColor;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Login (centered card)
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--surface);
}
.login-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}
.login-card .brand {
  text-align: center;
  margin-bottom: var(--space-lg);
}
.login-card .brand h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
}
.login-card .brand .sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}
.login-card h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-lg);
  text-align: center;
}
.login-card .field { margin-bottom: var(--space-md); }
.login-card .primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.login-card .primary:hover { background: var(--primary-dark); }
.login-card .footer-link {
  margin-top: var(--space-lg);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.login-card .error {
  background: var(--error-bg);
  color: var(--error);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: var(--space-md);
}

/* ============================================================
   Staff Directory cards (Premium Ledger pattern)
   ============================================================ */
.staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-gutter);
}
.staff-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  transition: box-shadow 120ms, border-color 120ms;
}
.staff-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.staff-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-wash);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  border: 2px solid var(--primary-fixed);
}
.staff-card-body { flex: 1; min-width: 0; }
.staff-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.staff-card-head h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.staff-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.staff-card-meta .label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 1px;
  display: block;
}
.staff-card-meta .value {
  font-family: var(--font-mono);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}
.staff-card-meta .value.salary {
  color: var(--primary-dark);
  font-weight: 600;
}

/* ============================================================
   Notifications bell + dropdown (preserved from existing)
   ============================================================ */
.notif-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.notif-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.notif-btn:hover {
  background: var(--surface-low);
  border-color: var(--border-strong);
  color: var(--text);
}
.notif-btn .notif-count {
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: var(--r-pill);
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}
.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 360px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  z-index: 60;
}
.notif-dropdown[hidden] { display: none; }
.notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notif-item:hover { background: var(--surface-low); }
.notif-item.unread { background: rgba(4, 120, 87, 0.04); }
.notif-item .time { font-size: 11px; color: var(--text-faint); }
.notif-item:last-child { border-bottom: 0; }
.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   Misc utilities
   ============================================================ */
.flex      { display: flex; }
.flex-col  { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.grow   { flex: 1; }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }
.text-right { text-align: right; }
.text-center { text-align: center; }

.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-primary { color: var(--primary); }
.text-muted   { color: var(--text-muted); }

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-lg) 0;
}

/* Two-column generic */
.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* ============================================================
   Empty states
   ============================================================ */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-low);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}
.empty .material-symbols-outlined {
  font-size: 40px;
  color: var(--text-faint);
  margin-bottom: 8px;
  display: block;
}
.empty h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

/* ============================================================
   Toolbar / filter bar
   ============================================================ */
.toolbar,
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}
.toolbar .grow { flex: 1; }
.toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .main > *:not(.topbar) { padding: 20px 16px 48px; }
  .form-row,
  .split-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  html { font-size: 13px; }
  .main-header,
  .page-header { flex-direction: column; align-items: flex-start; }
  .stat-value, .kpi-value { font-size: 24px; }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
  .sidebar, .topbar, .actions { display: none; }
  .main { margin-left: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ============================================================
   BACKWARD-COMPAT — classes used by un-translated client pages
   (advances, broadcasts-audit, holidays, login, owner-attendance,
   owner-dpdp, owner-face-reviews, owner-leaves, owner-payroll,
   owner-settings, staff, staff-extra, staff-crud, team-owners).
   Lets them render with the new design tokens until each page
   gets its proper redesign in a follow-up session.
   ============================================================ */

/* Generic alignment utilities used on <div>, <td>, <th> */
.right        { text-align: right; }
.center       { text-align: center; }
.left         { text-align: left; }
.nowrap       { white-space: nowrap; }
.right-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}
.sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface-card);
  z-index: 1;
}

/* Alternate empty state class name */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-low);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}

/* Modal close button (X) */
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.modal-close:hover {
  background: var(--surface-low);
  color: var(--text);
}
.modal-card { position: relative; }

/* Warning badge variant */
.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ── Login page (login.js uses .auth-* classes) ─────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--surface);
}
.auth-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow);
}
.auth-brand {
  text-align: center;
  margin-bottom: var(--space-lg);
}
.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--primary-wash);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 12px;
}
.auth-brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
}
.auth-brand-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}
.auth-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}
.auth-tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}
.auth-body { margin-bottom: var(--space-md); }
.auth-foot {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.auth-foot-sep {
  display: inline-block;
  margin: 0 6px;
  color: var(--text-disabled);
}
.auth-blurb {
  background: var(--surface-mid);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}
.step-back {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  display: block;
  width: 100%;
  text-align: center;
}
.step-back:hover { color: var(--primary); text-decoration: underline; }

/* ── Calendar widget (holidays.js) ──────────────────────────── */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.cal-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: var(--space-md);
}
.cal-dow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 0;
}
.cal-cell {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-height: 60px;
  padding: 6px 8px;
  font-size: 12px;
  position: relative;
  cursor: pointer;
  transition: border-color 80ms, background 80ms;
}
.cal-cell:hover {
  border-color: var(--primary);
  background: var(--surface-low);
}
.cal-blank {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.cal-blank:hover {
  background: transparent;
  border-color: transparent;
}
.cal-day-num {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}
.cal-day-name {
  font-size: 11px;
  display: block;
  margin-top: 2px;
}
.cal-cell.cal-today {
  background: var(--primary-wash);
  border-color: var(--primary);
}
.cal-cell.cal-today .cal-day-num { color: var(--primary-dark); }
.cal-cell.cal-sunday {
  background: var(--surface-mid);
}
.cal-cell.cal-holiday-mandatory {
  background: var(--error-bg);
  border-color: var(--error);
}
.cal-cell.cal-holiday-optional {
  background: var(--warning-bg);
  border-color: var(--warning);
}
.cal-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: var(--r-xs);
  vertical-align: middle;
  margin-right: 4px;
}
.cal-swatch.cal-holiday-mandatory { background: var(--error-bg); border: 1px solid var(--error); }
.cal-swatch.cal-holiday-optional  { background: var(--warning-bg); border: 1px solid var(--warning); }
.cal-swatch.cal-sunday            { background: var(--surface-mid); border: 1px solid var(--border); }
.cal-swatch.cal-today             { background: var(--primary-wash); border: 1px solid var(--primary); }

/* role-badge inside sidebar already styled; add legacy alias outside sidebar */
.role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-mid);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}

/* ============================================================
   Staff CRUD — master-detail layout (was unstyled, regression).
   /payroll/app/#/app/staff
   ============================================================
   Left rail: search + scrollable list of staff cards.
   Right pane: tabbed detail (Info / Attendance / Payments / etc).
   ============================================================ */

.staff-crud {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-md);
  min-height: calc(100vh - 200px);
}

/* ---- Left rail ---- */
.staff-list {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.staff-list-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-low);
}
.staff-list-header input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-card);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.staff-list-header input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-wash);
}
.staff-list-body {
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}
.staff-list-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name salary" "meta meta";
  gap: 4px;
  transition: background 80ms;
}
.staff-list-row:hover {
  background: var(--surface-low);
}
.staff-list-row.selected {
  background: var(--primary-wash);
  border-left: 3px solid var(--primary);
  padding-left: 11px;
}
.staff-list-row-name {
  grid-area: name;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.staff-list-row-meta {
  grid-area: meta;
  font-size: 12px;
  color: var(--text-muted);
}
.staff-list-row-salary {
  grid-area: salary;
  font-weight: 700;
  font-size: 13px;
  color: var(--primary-dark);
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
}

/* ---- Right pane ---- */
.staff-detail {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 24px;
  overflow: auto;
}
.staff-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}
.staff-detail-name {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.staff-detail-header .muted {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Tab bar ---- */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}
.tab-bar .tab-btn {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab-bar .tab-btn:hover {
  color: var(--text);
  background: var(--surface-low);
}
.tab-bar .tab-btn.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
  background: transparent;
}

/* ---- Mobile responsive (under 720px: stack list + detail) ---- */
@media (max-width: 720px) {
  .staff-crud {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .staff-list-body {
    max-height: 280px;
  }
}

/* ============================================================
   Locations (Leaflet map picker)
   ============================================================ */
.locations-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  height: calc(100vh - 220px);
  min-height: 500px;
}
.locations-list {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.locations-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-low);
}
.locations-list-header h3 {
  margin: 0;
  font-size: .95rem;
  font-weight: 600;
}
#loc-list-body {
  flex: 1;
  overflow-y: auto;
  padding: .5rem;
}
.loc-item {
  display: block;
  width: 100%;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .75rem;
  margin-bottom: .4rem;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.loc-item:hover { background: var(--surface-low); border-color: var(--primary-light); }
.loc-item.is-inactive { opacity: .55; }
.loc-item-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .15rem;
}
.loc-item-name {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
}
.loc-item-meta {
  font-size: .75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}
.pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.pill-primary { background: var(--primary-wash); color: var(--primary-dark); }
.pill-muted   { background: var(--surface-high); color: var(--text-muted); }
.pill-warn    { background: #fee2e2; color: #991b1b; }

/* ---- Payroll table expander + adjustment drawer ---- */
.payroll-table .expander {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 .35rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .85rem;
}
.payroll-table .expander:hover { color: var(--text); background: var(--surface-low); }
.payroll-drawer-row > td {
  background: var(--surface-low);
  padding: 0 !important;
  border-bottom: 1px solid var(--border);
}
.payroll-drawer { padding: 1rem 1.25rem; }
.drawer-inner { display: flex; flex-direction: column; gap: 1rem; }
.drawer-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: .5rem;
}
.drawer-section-head h4 { margin: 0; font-size: .95rem; font-weight: 600; }
.adj-table {
  width: 100%;
  margin: .25rem 0;
}
.adj-table th, .adj-table td {
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.adj-table th { font-weight: 500; color: var(--text-muted); text-align: left; }

.locations-main {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
  overflow: hidden;
}
.locations-map {
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
}
.locations-editor {
  position: absolute;
  right: 1rem;
  top: 1rem;
  width: 320px;
  max-width: calc(100% - 2rem);
  z-index: 500;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 1rem;
  max-height: calc(100% - 2rem);
  overflow-y: auto;
}
.locations-editor-inner .editor-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: .75rem;
  color: var(--text);
}
.editor-actions {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.locations-editor input[type="range"] {
  width: 100%;
  margin: .25rem 0;
}
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: .85rem;
}

/* Leaflet popups in dark/cream theme — keep popup readable. */
.leaflet-container { font-family: 'Inter', system-ui, sans-serif; }

@media (max-width: 900px) {
  .locations-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .locations-list { max-height: 220px; }
  .locations-main { min-height: 420px; }
  .locations-editor {
    position: fixed;
    inset: auto 1rem 1rem 1rem;
    top: auto;
    right: 1rem;
    width: auto;
    max-height: 60vh;
  }
}
