:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #667085;
  --line: #e4e7ec;
  --line-2: #eef1f5;
  --brand: #0f6e5c;
  --brand-2: #12876f;
  --brand-soft: #e7f4f0;
  --nav: #0d1b2a;
  --nav-2: #13293d;
  --ok: #067647;
  --ok-soft: #e6f4ec;
  --warn: #b54708;
  --warn-soft: #fdf3e7;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #175cd3;
  --info-soft: #eaf1fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: linear-gradient(180deg, var(--nav) 0%, var(--nav-2) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--brand-2), #1fa88a);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; color: #fff; }
.brand-text small { font-size: 10.5px; color: #8fa3bb; }

.nav { padding: 10px 8px 20px; flex: 1; }
.nav-group { margin-bottom: 14px; }
.nav-group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; padding: 6px 10px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  color: #c3ced9; font-size: 13px; font-weight: 500;
  text-decoration: none; margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(18,135,111,.22); color: #fff; box-shadow: inset 2px 0 0 #1fa88a; }
.nav-item svg { opacity: .85; flex: 0 0 auto; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  background: #1f3a52; color: #dbe7f1; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.user-meta strong { font-size: 12px; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 10px; color: #8296ab; }
.icon-btn {
  background: transparent; border: 0; color: #93a4b8; cursor: pointer;
  padding: 5px; border-radius: 6px; display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.inline { display: inline; margin: 0; }

.main { flex: 1; min-width: 0; padding: 22px 28px 60px; max-width: 1500px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.subtitle { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- surfaces ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 18px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2);
  flex-wrap: wrap;
}
.card-head h2 { font-size: 14px; font-weight: 650; margin: 0; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--line-2); background: #fbfcfe; }

.grid { display: grid; gap: 14px; }
.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: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .nav-group { margin: 0; }
  .nav-group-label { display: none; }
  .main { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- stats ---------- */
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.stat-label { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.stat.accent { border-left: 3px solid var(--brand); }
.stat.warn { border-left: 3px solid #dc6803; }
.stat.info { border-left: 3px solid var(--info); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); font-weight: 650; padding: 10px 12px;
  background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:hover { background: #fbfcfe; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td { padding: 10px 12px; font-weight: 700; background: #f8fafc; border-top: 2px solid var(--line); font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.strong-row { background: #f8fafc; }

.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 11.5px; color: var(--ink-3); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 99px;
  white-space: nowrap; border: 1px solid transparent;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: #c7e7d5; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #f6ddbf; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #cadcfb; }
.badge-muted { background: #f2f4f7; color: var(--ink-2); border-color: var(--line); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #f7cdc9; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #f2f4f7; }
.btn-danger { background: #fff; border-color: #f3c2be; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 760px) {
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 11.5px; color: var(--ink-3); }
.input {
  width: 100%; padding: 8px 11px; font-size: 13px; font-family: inherit;
  border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,110,92,.12); }
.input:disabled, .input[readonly] { background: #f9fafb; color: var(--ink-3); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
textarea.input { min-height: 76px; resize: vertical; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ink-2); }
.check input { margin-top: 2px; accent-color: var(--brand); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--line-2); margin-top: 8px; padding-top: 14px; }

/* ---------- alerts ---------- */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.alert-ok { background: var(--ok-soft); border-color: #b7e1c8; color: #04603a; }
.alert-error { background: var(--danger-soft); border-color: #f5c6c2; color: #912018; }
.alert-info { background: var(--info-soft); border-color: #c3d8fa; color: #1249a3; }
.alert-warn { background: var(--warn-soft); border-color: #f5d9b8; color: #8f3a05; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty-icon { width: 52px; height: 52px; border-radius: 14px; background: #f2f4f7; display: grid; place-items: center; margin: 0 auto 12px; color: #98a2b3; }
.empty h3 { margin: 0 0 5px; font-size: 14px; color: var(--ink); }
.empty p { margin: 0 0 14px; font-size: 13px; max-width: 380px; margin-inline: auto; }

/* ---------- misc ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .input { width: auto; min-width: 150px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hr { height: 1px; background: var(--line-2); margin: 16px 0; border: 0; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--ink-3);
  border-bottom: 2px solid transparent; text-decoration: none; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 550; }

.hint { font-size: 12px; color: var(--ink-3); margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; } .mt-2 { margin-top: 8px; }
.w-100 { width: 100%; }
.text-sm { font-size: 12px; }

.bar { height: 6px; background: #eef1f5; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #dff0eb 0%, var(--bg) 55%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-brand .brand-mark { width: 38px; height: 38px; }
.auth-card h1 { font-size: 18px; margin: 0 0 4px; }
.auth-card p.lead { color: var(--ink-3); font-size: 13px; margin: 0 0 18px; }
.auth-card .field { margin-bottom: 12px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 16px; }

/* payslip */
.payslip { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 26px; max-width: 820px; margin: 0 auto; }
.payslip-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--nav); padding-bottom: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.payslip-head h2 { margin: 0 0 2px; font-size: 17px; }
.payslip-head .company-meta { font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
.payslip-title { text-align: right; }
.payslip-title .period { font-size: 14px; font-weight: 700; }
.payslip-title .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.payslip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 720px) { .payslip-cols { grid-template-columns: 1fr; } }
.payslip table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.payslip table td { padding: 5px 0; border-bottom: 1px solid #f2f4f7; }
.payslip table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.payslip tfoot td { font-weight: 700; border-top: 1.5px solid var(--line); border-bottom: 0; padding-top: 8px; }
.net-box { margin-top: 18px; background: var(--brand-soft); border: 1px solid #c9e5dd; border-radius: 9px; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.net-box .lbl { font-size: 12px; font-weight: 650; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; }
.net-box .val { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.payslip-foot { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line-2); font-size: 10.5px; color: var(--ink-3); }

@media print {
  .sidebar, .page-head .head-actions, .no-print { display: none !important; }
  .main { padding: 0; }
  .payslip, .card { border: 0; box-shadow: none; }
  body { background: #fff; }
}

/* matrix */
.matrix { font-size: 12.5px; }
.matrix th, .matrix td { padding: 7px 10px; }
.matrix td.center input { accent-color: var(--brand); }
.perm-group-row td { background: #fafbfc; font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
