/* TGSSH HRMS — "Clinical calm". Tokens and rules are described in DESIGN.md. No build step, no outside files. */
:root {
    --bg: #f3f6f6; --surface: #ffffff; --surface-2: #f7faf9; --line: #dfe7e6;
    --ink: #122020; --ink-soft: #55696a;
    --primary: #0f766e; --primary-hover: #0d645d; --primary-ink: #ffffff; --primary-soft: #e3f3f1;
    --side: #0b3b3c; --side-ink: #c9dedc; --side-muted: #7fa3a0; --side-hover: rgba(255,255,255,.07); --side-active: rgba(45,212,191,.16);
    --warn: #b45309; --warn-soft: #fdf1e3; --ok: #15803d; --ok-soft: #e5f5ea; --danger: #b91c1c; --danger-soft: #fdeaea;
    --neutral: #5b6b6b; --neutral-soft: #edf1f1;
    --shadow: 0 1px 2px rgba(16,40,40,.05), 0 4px 14px -6px rgba(16,40,40,.10);
    --radius: 10px; --radius-sm: 8px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1414; --surface: #141e1e; --surface-2: #1a2626; --line: #263535;
        --ink: #e4eeed; --ink-soft: #9db2b1;
        --primary: #2dd4bf; --primary-hover: #5eead4; --primary-ink: #04201d; --primary-soft: #123432;
        --side: #081d1e; --side-ink: #c9dedc;
        --warn: #fbbf24; --warn-soft: #3a2a0c; --ok: #4ade80; --ok-soft: #0f2e1a; --danger: #f87171; --danger-soft: #3a1414;
        --neutral: #a3b3b3; --neutral-soft: #1f2b2b;
        --shadow: 0 1px 2px rgba(0,0,0,.4);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0d1414; --surface: #141e1e; --surface-2: #1a2626; --line: #263535;
    --ink: #e4eeed; --ink-soft: #9db2b1;
    --primary: #2dd4bf; --primary-hover: #5eead4; --primary-ink: #04201d; --primary-soft: #123432;
    --side: #081d1e; --side-ink: #c9dedc;
    --warn: #fbbf24; --warn-soft: #3a2a0c; --ok: #4ade80; --ok-soft: #0f2e1a; --danger: #f87171; --danger-soft: #3a1414;
    --neutral: #a3b3b3; --neutral-soft: #1f2b2b;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); }
a { color: var(--primary); text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; color: #fff; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: #2dd4bf; color: #04201d; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12px; color: var(--side-muted); }
.brand .brand-mark { display: grid; color: #04201d; font-size: 15px; }
.nav { padding: 6px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 14px 10px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--side-ink); text-decoration: none; min-height: 40px; transition: background-color .14s ease, color .14s ease; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #2dd4bf; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav .count { margin-left: auto; background: #f59e0b; color: #241400; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.side-foot { margin-top: auto; padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .role { color: var(--side-muted); font-size: 12px; }
.side-foot .row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.side-foot button, .side-foot a.linkish { background: rgba(255,255,255,.07); color: var(--side-ink); border: 0; border-radius: 6px; padding: 6px 10px; font: inherit; font-size: 12px; cursor: pointer; text-decoration: none; }
.side-foot button:hover, .side-foot a.linkish:hover { background: rgba(255,255,255,.14); color: #fff; }

.topbar { display: none; }
.main { min-width: 0; }
.page { max-width: 1200px; margin: 0 auto; padding: 28px 24px 96px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); }
.crumb { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.crumb a { color: inherit; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .18s ease; }
    body.nav-open .side { transform: none; box-shadow: 12px 0 32px rgba(0,0,0,.3); }
    body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
    .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 30; }
    .topbar button { background: none; border: 0; color: #fff; padding: 8px; margin-left: -8px; cursor: pointer; min-height: 40px; min-width: 40px; display: grid; place-items: center; }
    .topbar svg { width: 24px; height: 24px; }
    .page { padding: 20px 16px 96px; }
}

/* ---------- Building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 16px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3-1, .grid-2 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

.stat { padding: 18px 20px; display: block; color: inherit; text-decoration: none; transition: border-color .14s ease; }
a.stat:hover { border-color: var(--primary); }
.stat .label { color: var(--ink-soft); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat.is-warn .value { color: var(--warn); }

/* Horizontal bars (department headcount) */
.bars { list-style: none; margin: 0; padding: 8px 20px 18px; }
.bars li { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) 2.5rem; gap: 10px; align-items: center; padding: 6px 0; }
.bars .bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bars .bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.bars .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background-color .14s ease, border-color .14s ease, color .14s ease; white-space: nowrap; }
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.btn-ok:hover { background: var(--ok-soft); border-color: var(--ok); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn-link { border: 0; background: none; color: var(--primary); padding: 0; min-height: 0; font-weight: 600; }
.btn svg { width: 16px; height: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .right { text-align: right; }
.person { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.person a { font-weight: 600; text-decoration: none; color: var(--ink); }
.person a:hover { color: var(--primary); text-decoration: underline; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* Pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--neutral-soft); color: var(--neutral); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-primary { background: var(--primary-soft); color: var(--primary); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field label, .field .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .opt { font-weight: 400; color: var(--ink-soft); }
.field .help { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; transition: border-color .14s ease, box-shadow .14s ease; }
textarea.input { min-height: 90px; resize: vertical; }
.input:hover { border-color: var(--ink-soft); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.field.has-error .input { border-color: var(--danger); }
/* Password box with an eye button inside it (partials/password-reveal) */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-reveal { position: absolute; top: 0; right: 0; width: 44px; height: 100%; min-height: 40px; display: grid; place-items: center; background: none; border: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-soft); cursor: pointer; transition: color .14s ease, background-color .14s ease; }
.pw-reveal:hover { color: var(--ink); background: var(--surface-2); }
.pw-reveal:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pw-reveal svg { width: 20px; height: 20px; }
/* Hide the browsers' own reveal icon so there's only one eye. */
input::-ms-reveal, input::-ms-clear { display: none; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 15px; font-weight: 600; padding: 0; margin-bottom: 12px; }
.form-section + .form-section { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 22px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .field { flex: 1 1 160px; }
.filters .field.grow { flex: 3 1 240px; }

/* Notices */
.notice { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; }
.notice-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ink); }
.notice-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.notice-info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.secret { font-family: Consolas, "Courier New", monospace; font-size: 16px; font-weight: 700; letter-spacing: .04em; background: var(--surface); padding: 4px 10px; border-radius: 6px; border: 1px dashed var(--line); user-select: all; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.table .decide { display: flex; gap: 6px; justify-content: flex-end; align-items: flex-start; flex-wrap: nowrap; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-soft); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { font-size: 12px; background: var(--surface-2); border-radius: 999px; padding: 0 7px; margin-left: 4px; }

/* Definition lists on profile pages */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
.facts div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { font-size: 12px; color: var(--ink-soft); }
.facts dd { margin: 2px 0 0; font-weight: 500; }
@media (max-width: 700px) { .facts { grid-template-columns: 1fr; } }
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head h1 { font-size: 22px; }

/* Pagination */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-soft); flex-wrap: wrap; }
.pager .actions a, .pager .actions span { min-height: 32px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 32px 28px; }
.auth-card .brand { padding: 0 0 22px; color: var(--ink); }
.auth-card .brand span { color: var(--ink-soft); }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card .stack > * + * { margin-top: 14px; }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--ink-soft); text-align: center; }

dialog.confirm { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 420px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.confirm::backdrop { background: rgba(10, 20, 20, .45); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; } }
@media print { .side, .topbar, .no-print, .actions, .filters, .pager { display: none !important; } .shell { display: block; } body { background: #fff; } .card { box-shadow: none; } }
