:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #17212b;
  --muted: #5f6c7b;
  --border: #e1e6eb;
  --primary: #0f766e;
  --primary-soft: #e6f4f2;
  --on-primary: #ffffff;
  --success: #15803d;
  --success-soft: #e8f6ec;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fdf3e4;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1416;
    --surface: #161e21;
    --surface-2: #1b2528;
    --text: #e4ebee;
    --muted: #9aa8af;
    --border: #2a3639;
    --primary: #2dd4bf;
    --primary-soft: #133331;
    --on-primary: #06201d;
    --success: #4ade80;
    --success-soft: #12301d;
    --danger: #f87171;
    --danger-soft: #3a1616;
    --warn: #fbbf24;
    --warn-soft: #3a2a0c;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; padding: .25rem .5rem 1rem; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-size: .85rem;
}
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-radius: 8px;
  color: var(--text); margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav .ico { width: 1.2rem; text-align: center; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .9rem .65rem .3rem; }
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar .spacer { flex: 1; }
.content { padding: 1.5rem; max-width: 1200px; }
.demo-banner {
  background: var(--warn-soft); color: var(--warn); font-size: .8rem; padding: .35rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .85rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: .25rem .6rem; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.green { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.amber { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.teal { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tfoot td { font-weight: 700; }

label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: .5rem; align-items: center; color: var(--text); font-size: .9rem; }
.check input { width: auto; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .78rem; flex-shrink: 0;
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.person { display: flex; align-items: center; gap: .6rem; }
.person .name { font-weight: 600; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: .35rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs button {
  background: none; border: none; padding: .55rem .85rem; font: inherit; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.steps { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.step { padding: .3rem .7rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--border); color: var(--muted); }
.step.done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.step.current { background: var(--primary); color: var(--on-primary); border-color: transparent; font-weight: 600; }

.list-item { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }

.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }

.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar > div { height: 100%; background: var(--primary); }

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; overflow-x: auto; font-size: .8rem; margin: 0; }

.bell { position: relative; }
.bell .dot { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .65rem; display: grid; place-items: center; }

/* Payslip */
.payslip { max-width: 720px; }
.payslip-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 2px solid var(--text); padding-bottom: .75rem; margin-bottom: .75rem; }
.payslip .net { font-size: 1.3rem; font-weight: 700; display: flex; justify-content: space-between; border-top: 2px solid var(--text); padding-top: .6rem; margin-top: .6rem; }

/* Modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 1.25rem; border: 1px solid var(--border); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: .6rem 1rem; border-radius: 8px; z-index: 60; font-size: .9rem; max-width: calc(100% - 32px);
}
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* Responsive */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.3); }
  .shell.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: .6rem 16px; }
  .content { padding: 1rem 16px; }
  .demo-banner { padding: .35rem 16px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: .5rem; }
  .hide-sm { display: none; }
  #payslip-grid { grid-template-columns: 1fr !important; }
  .topbar .role-label { display: none; }
}
@media print {
  .sidebar, .topbar, .demo-banner, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
}
