/* =============================================================================
 * Online Payroll Management System — base stylesheet
 * Design intent: clean government / financial dashboard.
 * Inspirations: Linear (sidebar density), Stripe Dashboard (number hierarchy),
 * Vercel (card rhythm, status badges).  Light theme only.
 * No purple gradients. No glassmorphism. No decorative blobs.
 * ============================================================================= */

/* --- Design tokens ------------------------------------------------------- */
:root {
  --bg:          #F7F8FA;
  --surface:     #FFFFFF;
  --surface-2:   #F1F3F6;
  --surface-3:   #E9ECF0;
  --border:      #E3E7EC;
  --border-2:    #D0D5DC;
  --text-1:      #0E1116;
  --text-2:      #3B424C;
  --text-3:      #6B7280;
  --text-4:      #9AA3AE;
  --brand:       #0F4C81;
  --brand-2:     #1463B0;
  --brand-soft:  #E3EEF8;
  --accent:      #B98900;
  --ok:          #047A55;
  --ok-soft:     #DAF1E7;
  --danger:      #B42318;
  --danger-soft: #FAE2E0;
  --info:        #0B6CB1;
  --info-soft:   #DCEAF6;
  --warn:        #92400E;
  --warn-soft:   #FCEFD3;

  --shadow-1: 0 1px 2px rgba(15,17,21,.05), 0 0 0 1px rgba(15,17,21,.04);
  --shadow-2: 0 4px 12px rgba(15,17,21,.08);
  --shadow-3: 0 12px 28px rgba(15,17,21,.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
               Consolas, "Liberation Mono", monospace;

  --motion-fast:   120ms;
  --motion-ui:     180ms;
  --motion-medium: 240ms;
  --motion-slow:   320ms;
  --ease-standard: cubic-bezier(.2,.8,.2,1);
  --ease-emphasis: cubic-bezier(.2,0,0,1);
  --ease-exit:     cubic-bezier(.4,0,1,1);

  --sidebar-w: 248px;
  --topbar-h:  60px;
  --content-max: 1280px;
}

/* --- Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); text-decoration: underline; }
::selection { background: var(--brand-soft); }

/* --- Typography ---------------------------------------------------------- */
h1,h2,h3,h4,h5,h6 { margin: 0 0 var(--space-3) 0; color: var(--text-1); line-height: 1.25; letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
p  { margin: 0 0 var(--space-3) 0; color: var(--text-2); }
small, .small { font-size: 12px; color: var(--text-3); }
.muted { color: var(--text-3); }
.text-tight { letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }
.numeric { font-variant-numeric: tabular-nums; text-align: right; }

/* --- Layout primitives --------------------------------------------------- */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--space-5); }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; gap: var(--space-4); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 980px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* --- Surfaces ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}
.card .card-body { padding: var(--space-5); }
.card .card-head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card .card-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.card.elev-2 { box-shadow: var(--shadow-2); }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-1);
  font-weight: 500; font-size: 14px;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-standard),
              border-color var(--motion-fast) var(--ease-standard),
              transform var(--motion-fast) var(--ease-standard),
              box-shadow var(--motion-fast) var(--ease-standard);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); color:#fff; }

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

.btn-danger { background: var(--danger); color:#fff; border-color: var(--danger); }
.btn-danger:hover { background: #9F1F15; border-color: #9F1F15; color:#fff; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }

/* --- Forms --------------------------------------------------------------- */
.form-group { margin-bottom: var(--space-4); }
.label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-2); font-size: 13px; }
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-1);
  font: inherit;
  transition: border-color var(--motion-fast) var(--ease-standard),
              box-shadow var(--motion-fast) var(--ease-standard);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,76,129,.15);
}
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--text-3); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 6px; }
.field-help  { color: var(--text-3); font-size: 12px; margin-top: 6px; }

/* --- Alerts (flash) ------------------------------------------------------ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 13px;
  margin-bottom: var(--space-4);
}
.alert-success { background: var(--ok-soft);     border-color: #B8E0CE; color: #14532D; }
.alert-info    { background: var(--info-soft);   border-color: #BCD7EB; color: #0B3C66; }
.alert-warning { background: var(--warn-soft);   border-color: #ECD9A6; color: #6B3F00; }
.alert-danger  { background: var(--danger-soft); border-color: #EDC1BD; color: #7B1A12; }

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  gap: 4px; height: 22px; padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.badge-ok      { background: var(--ok-soft);     color: #14532D; border-color: #B8E0CE; }
.badge-info    { background: var(--info-soft);   color: #0B3C66; border-color: #BCD7EB; }
.badge-warn    { background: var(--warn-soft);   color: #6B3F00; border-color: #ECD9A6; }
.badge-danger  { background: var(--danger-soft); color: #7B1A12; border-color: #EDC1BD; }
.badge-brand   { background: var(--brand-soft);  color: var(--brand);  border-color: #BCD7EB; }

/* --- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table thead th {
  background: var(--surface-2);
  font-weight: 600; color: var(--text-2);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.table tbody tr:hover td { background: rgba(15,76,129,.03); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Sidebar shell ------------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: #0B2D4D; color: #C9D6E2;
  display: flex; flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid #0A2542;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px 8px; color: #fff; }
.sidebar .brand .logo { width: 28px; height: 28px; background: var(--brand-2); border-radius: 7px; display:flex; align-items:center; justify-content:center; color:#fff; font-weight:700; }
.sidebar .brand strong { font-size: 14px; letter-spacing: -0.01em; }
.sidebar .nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1 1 auto; }
.sidebar .nav-group { margin-top: 14px; }
.sidebar .nav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6B7E94; padding: 6px 10px; }
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: #C9D6E2; font-size: 13px;
  transition: background var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);
}
.sidebar a.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar a.nav-item.active { background: rgba(255,255,255,0.10); color: #fff; }
.sidebar .footer-mini { padding: 12px 10px 0; font-size: 12px; color: #6B7E94; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  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(--space-5);
}
.topbar .crumbs { color: var(--text-3); font-size: 13px; }
.topbar .crumbs strong { color: var(--text-1); font-weight: 600; }
.topbar .user-menu { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.topbar .user-menu .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }

.content { padding: var(--space-5); max-width: var(--content-max); margin: 0 auto; width: 100%; }

/* --- Stat card ----------------------------------------------------------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-1);
}
.stat .label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 8px; }
.stat .value { font-size: 26px; font-weight: 600; color: var(--text-1); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .meta  { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* --- Auth layout --------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(180deg, #F7F8FA 0%, #EDF1F5 100%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .logo { width: 36px; height: 36px; background: var(--brand); border-radius: 8px; color: #fff; display:flex; align-items:center; justify-content:center; font-weight: 700; font-size: 16px; }
.auth-brand .name { font-weight: 600; color: var(--text-1); font-size: 16px; letter-spacing: -0.01em; }
.auth-brand .sub  { font-size: 12px; color: var(--text-3); }
.auth-card h1 { font-size: 20px; margin-bottom: 18px; }
.auth-card .form-actions { margin-top: 18px; }
.auth-card .meta { font-size: 12px; color: var(--text-3); margin-top: 18px; text-align: center; }

/* --- Empty / loading state ---------------------------------------------- */
.empty {
  text-align: center; padding: 36px 16px;
  border: 1px dashed var(--border-2); border-radius: var(--radius-md);
  color: var(--text-3); background: var(--surface);
}
.empty h4 { color: var(--text-2); margin-bottom: 4px; }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% {background-position: 200% 0} 100% {background-position: -200% 0} }

/* --- Motion (respect reduced motion) ------------------------------------ */
.fade-in { animation: fade-in var(--motion-medium) var(--ease-standard); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Utility ------------------------------------------------------------- */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0{margin-top:0!important} .mt-1{margin-top:var(--space-1)} .mt-2{margin-top:var(--space-2)} .mt-3{margin-top:var(--space-3)} .mt-4{margin-top:var(--space-4)} .mt-5{margin-top:var(--space-5)} .mt-6{margin-top:var(--space-6)}
.mb-0{margin-bottom:0!important} .mb-1{margin-bottom:var(--space-1)} .mb-2{margin-bottom:var(--space-2)} .mb-3{margin-bottom:var(--space-3)} .mb-4{margin-bottom:var(--space-4)} .mb-5{margin-bottom:var(--space-5)}
.pad-4{padding:var(--space-4)} .pad-5{padding:var(--space-5)}

/* --- Responsive sidebar ------------------------------------------------- */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* --- Clickable rows + keyboard focus ----------------------------------- */
table[data-keyboard-rows] tbody tr[data-href] { cursor: pointer; }
table[data-keyboard-rows] tbody tr.row-focus td {
  background: rgba(15, 76, 129, 0.08);
  box-shadow: inset 3px 0 0 var(--brand);
}
table[data-keyboard-rows] tbody tr[data-href]:hover td {
  background: rgba(15, 76, 129, 0.05);
}
#topbar-shortcut-slot .btn { line-height: 1; }
