:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #667085;
  --border: #e3e6eb;
  --brand: #2f5bea;
  --brand-ink: #ffffff;
  --brand-soft: #eaf0ff;
  --ok: #157f3d;
  --ok-soft: #e6f6ec;
  --warn: #a15c00;
  --warn-soft: #fff4e0;
  --bad: #c0262d;
  --bad-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1e26;
    --text: #e6e8ec;
    --muted: #98a2b3;
    --border: #2b313c;
    --brand: #6d8cff;
    --brand-ink: #0d1020;
    --brand-soft: #1f2840;
    --ok: #4cc27a;
    --ok-soft: #15291e;
    --warn: #f0b04a;
    --warn-soft: #2d2412;
    --bad: #ff6b6b;
    --bad-soft: #321a1c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 16px; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; }
.brand img { width: 28px; height: 28px; }
.nav a {
  display: block; padding: 8px 12px; border-radius: 8px; color: var(--text); font-weight: 500;
}
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.sidebar .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar .me .role { color: var(--muted); text-transform: capitalize; }
.main { padding: 28px 32px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar { display: none; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card + .card, .stats > .card + .card { margin-top: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); text-transform: capitalize; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--brand-soft); color: var(--brand); }

/* Forms */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar label { min-width: 160px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.error { color: var(--bad); font-size: 13px; margin-top: 10px; }
.muted { color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { padding: 0 0 18px; font-size: 20px; }
.login form { display: grid; gap: 14px; }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(10, 14, 22, .5); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 12px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 30; }
.toast[hidden] { display: none; }

/* Payslip */
.slip { max-width: 760px; }
.slip-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 14px; }
.slip dl { display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.slip dt { color: var(--muted); }
.slip dd { margin: 0; }
.slip .net { font-size: 18px; font-weight: 700; display: flex; justify-content: space-between; border-top: 2px solid var(--text); padding-top: 10px; margin-top: 10px; }

/* Bars */
.bar-row { display: grid; grid-template-columns: 120px 1fr 32px; gap: 8px; align-items: center; margin: 6px 0; }
.bar { height: 8px; background: var(--brand); border-radius: 4px; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; inset: 0 30% 0 0; z-index: 10; height: auto; }
  .sidebar.open { display: flex; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .main { padding: 16px; }
  .grid2, .form-grid { grid-template-columns: 1fr; }
  .slip dl { grid-template-columns: max-content 1fr; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { border: 0; box-shadow: none; }
}
