/* PST Smart HR — design tokens & components (sáng/tối) */
:root {
  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f3f6fb; --surface: #ffffff; --surface-2: #f8fafc; --border: #e2e8f0; --border-strong: #cbd5e1;
  --text: #0f172a; --text-2: #475569; --text-3: #64748b;
  --primary: #1d4ed8; --primary-2: #2563eb; --primary-soft: #e8efff; --primary-ink: #ffffff;
  --ok: #047857; --ok-soft: #e7f7ef; --warn: #b45309; --warn-soft: #fff4e0; --bad: #b91c1c; --bad-soft: #fdecec;
  --info: #0369a1; --info-soft: #e5f4fc; --muted-soft: #eef2f6;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --hero: linear-gradient(135deg, #1e40af 0%, #2563eb 55%, #38bdf8 130%);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #121a2b; --surface-2: #0f1727; --border: #22304a; --border-strong: #31415f;
  --text: #e6ecf5; --text-2: #a9b6cb; --text-3: #8392aa;
  --primary: #4f8cff; --primary-2: #6aa0ff; --primary-soft: #16264a; --primary-ink: #ffffff;
  --ok: #34d399; --ok-soft: #0f2a22; --warn: #fbbf24; --warn-soft: #2d2410; --bad: #f87171; --bad-soft: #2f1517;
  --info: #38bdf8; --info-soft: #0d2536; --muted-soft: #1a2438;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --hero: linear-gradient(135deg, #172554 0%, #1e3a8a 60%, #0369a1 140%);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b1220; --surface: #121a2b; --surface-2: #0f1727; --border: #22304a; --border-strong: #31415f;
    --text: #e6ecf5; --text-2: #a9b6cb; --text-3: #8392aa;
    --primary: #4f8cff; --primary-2: #6aa0ff; --primary-soft: #16264a;
    --ok: #34d399; --ok-soft: #0f2a22; --warn: #fbbf24; --warn-soft: #2d2410; --bad: #f87171; --bad-soft: #2f1517;
    --info: #38bdf8; --info-soft: #0d2536; --muted-soft: #1a2438;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --hero: linear-gradient(135deg, #172554 0%, #1e3a8a 60%, #0369a1 140%);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.card-h h2, .card-h h3 { margin: 0; font-size: 15px; font-weight: 650; }
.card-b { padding: 14px 16px 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 600; transition: background .15s, transform .08s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); }
.input:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-soft); }
.hint { font-size: 12px; color: var(--text-3); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--muted-soft); color: var(--text-2); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--info); }
.flag { display: inline-block; margin: 2px 4px 0 0; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: var(--muted-soft); color: var(--text-2); }

.tbl-wrap { overflow: auto; border-top: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 650; color: var(--text-2);
  font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl td.r, .tbl th.r { text-align: right; }

.empty { padding: 28px 16px; text-align: center; color: var(--text-3); }
.sample-banner { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600; }

#toasts { position: fixed; z-index: 1000; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 12px 16px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow); font-weight: 600;
  animation: tin .2s ease-out; }
.toast.ok { background: #047857; } .toast.bad { background: #b91c1c; } .toast.warn { background: #b45309; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

.modal-back { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); display: grid; place-items: center; z-index: 900; padding: 16px; }
.modal { width: min(640px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; font-size: 17px; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Đăng nhập (dùng chung app + admin) */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--hero); }
.auth .card { width: min(420px, 100%); padding: 26px 22px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand .logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; letter-spacing: -.5px; }
.brand h1 { margin: 0; font-size: 19px; line-height: 1.2; } .brand p { margin: 0; color: var(--text-3); font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px; }
.tabs button { flex: 1; min-height: 36px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; color: var(--text-2); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.err { color: var(--bad); font-size: 13px; font-weight: 600; min-height: 20px; }
