/* ═══ PBSG Admin Tracker — design system ═══ */
:root {
  --bg: #f3f4fa;
  --surface: #ffffff;
  --ink: #17192e;
  --ink-2: #4b4f6b;
  --ink-3: #878ca8;
  --line: #e6e8f2;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --green: #059669;
  --green-soft: #e7f7f0;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --sidebar-w: 236px;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 25, 46, 0.05), 0 4px 16px rgba(23, 25, 46, 0.06);
  --shadow-lift: 0 4px 10px rgba(23, 25, 46, 0.08), 0 12px 32px rgba(23, 25, 46, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

.boot-splash { display: grid; place-items: center; height: 100vh; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ── */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(79, 70, 229, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(124, 58, 237, 0.16), transparent 60%),
    var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lift);
  padding: 38px 36px; width: 100%; max-width: 380px;
}
.login-logo {
  width: 68px; height: 68px; margin-bottom: 16px;
  display: grid; place-items: center;
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--ink-3); margin: 0 0 22px; }
.login-error {
  background: var(--red-soft); color: var(--red); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 14px; font-weight: 500; display: none;
}
.login-error.show { display: block; }

/* ── Shell ── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; inset: 0 auto 0 0;
  background: linear-gradient(180deg, #1d1a4d 0%, #241d63 55%, #2b2075 100%);
  color: #cdd0f2; display: flex; flex-direction: column; padding: 22px 14px 18px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 22px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: #fff; padding: 4px;
  display: grid; place-items: center;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #8f93c9; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 10px; color: #b6b9e6; font-weight: 500; transition: all 0.15s;
}
.nav a svg { width: 18px; height: 18px; opacity: 0.85; }
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, 0.13); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,0.1); }
.mel-clock { font-size: 12px; color: #9fa3d4; margin-bottom: 10px; }
.mel-clock strong { display: block; color: #fff; font-size: 15px; font-weight: 600; }
.btn-logout {
  width: 100%; background: rgba(255,255,255,0.08); color: #cdd0f2; border: none;
  padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 500; font-size: 13px;
}
.btn-logout:hover { background: rgba(255,255,255,0.16); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); padding: 26px 32px 60px; min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title h1 { font-size: 22px; letter-spacing: -0.02em; }
.page-title p { margin: 3px 0 0; color: var(--ink-3); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: none; cursor: pointer;
  border-radius: 10px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  transition: all 0.15s; white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(23,25,46,0.04); }
.btn-ghost:hover:not(:disabled) { border-color: #c9cde4; color: var(--ink); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #fbdcdc; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover:not(:disabled) { background: #e2e5ff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 7px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards & grid ── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card + .card { margin-top: 18px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title h3 { font-size: 15px; }
.card-title .hint { color: var(--ink-3); font-size: 12px; font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .card { margin: 0; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 2px;
}
.stat .k { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; }
.stat .l { color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.stat.alert .k { color: var(--red); }
.stat.ok .k { color: var(--green); }

/* ── Badges & chips ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  padding: 3px 10px; font-size: 11.5px; font-weight: 600;
}
.badge-employee { background: var(--accent-soft); color: var(--accent); }
.badge-contractor { background: #fdf0e3; color: #c2620a; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #eef0f6; color: var(--ink-2); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--red-soft);
  color: var(--red); border-radius: 7px; padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.chip.gray { background: #eef0f6; color: var(--ink-2); }

/* ── Staff list ── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 9px 13px;
}
.search input { border: none; outline: none; flex: 1; font: inherit; background: transparent; color: var(--ink); }
.search svg { width: 16px; height: 16px; color: var(--ink-3); flex-shrink: 0; }
.seg { display: inline-flex; background: #e9ebf5; border-radius: 10px; padding: 3px; }
.seg button {
  border: none; background: transparent; padding: 6px 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(23,25,46,0.12); }

.staff-card {
  display: flex; align-items: center; gap: 16px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px 20px;
  margin-bottom: 10px; cursor: pointer; transition: all 0.15s; border: 1px solid transparent;
}
.staff-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); border-color: #dfe2f3; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
}
.avatar.lg { width: 64px; height: 64px; font-size: 22px; border-radius: 18px; }
.staff-id { min-width: 190px; flex: 1.3; }
.staff-id .nm { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.staff-id .ps { color: var(--ink-3); font-size: 12.5px; margin-top: 1px; }
.staff-meta { flex: 2.6; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.meta-block { min-width: 86px; }
.meta-block .mk { font-size: 11px; color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.meta-block .mv { font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.meta-block .mv.soft { font-weight: 500; color: var(--ink-2); }
.setup-icons { display: flex; gap: 6px; }
.tickdot {
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  font-size: 11px; font-weight: 800;
}
.tickdot.on { background: var(--green-soft); color: var(--green); }
.tickdot.off { background: var(--red-soft); color: var(--red); }
.staff-right { display: flex; align-items: center; gap: 14px; }
.ring { position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.ring .pct { font-size: 10.5px; font-weight: 700; }
.ring::after { content: ""; position: absolute; inset: 4px; background: var(--surface); border-radius: 50%; }
.ring span { position: relative; z-index: 1; }
.chev { color: var(--ink-3); font-size: 18px; }

.staff-card.archived { opacity: 0.72; background: #f7f8fc; }
.staff-card.archived .nm { text-decoration: line-through; color: var(--ink-3); }
.section-label {
  margin: 26px 0 12px; color: var(--ink-3); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; display: flex; align-items: center; gap: 10px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ── Mini bars ── */
.mini-bar { width: 92px; height: 6px; background: #edeef6; border-radius: 4px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; border-radius: 4px; }
.bar-label { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px;
  font: inherit; font-size: 13.5px; color: var(--ink); background: #fbfbfe; outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.13); background: #fff;
}
.field textarea { resize: vertical; min-height: 74px; }
.field .note { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.day-picker { display: flex; gap: 5px; flex-wrap: wrap; }
.day-picker button {
  border: 1px solid var(--line); background: #fbfbfe; border-radius: 8px; cursor: pointer;
  padding: 6px 0; width: 44px; font-size: 12px; font-weight: 600; color: var(--ink-3); transition: all 0.12s;
}
.day-picker button.on { background: var(--accent-soft); border-color: #c3c8ff; color: var(--accent); }

/* ── Switch ── */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .sl { font-weight: 600; font-size: 13.5px; }
.switch-row .sd { color: var(--ink-3); font-size: 12px; margin-top: 1px; }
.switch {
  position: relative; width: 42px; height: 24px; border-radius: 999px; border: none;
  background: #d9dcec; cursor: pointer; transition: background 0.18s; flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: left 0.18s;
}
.switch.on { background: var(--green); }
.switch.on::after { left: 21px; }

/* ── Tables ── */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 10px; border-bottom: 1px solid #f0f1f8; font-size: 13px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; }

/* ── Documents ── */
.doc-row {
  display: flex; align-items: center; gap: 13px; padding: 12px 0;
  border-bottom: 1px solid #f0f1f8;
}
.doc-row:last-child { border-bottom: none; }
.doc-ic {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-size: 16px; flex-shrink: 0;
}
.doc-ic.ok { background: var(--green-soft); }
.doc-ic.missing { background: var(--red-soft); }
.doc-main { flex: 1; min-width: 0; }
.doc-main .dn { font-weight: 600; font-size: 13.5px; }
.doc-main .dm { color: var(--ink-3); font-size: 12px; margin-top: 1px; }
.doc-files { margin: 6px 0 0; padding: 0; list-style: none; }
.doc-files li {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0;
  color: var(--ink-2); flex-wrap: wrap;
}
.doc-files li a { font-weight: 600; }

/* ── Training matrix ── */
.matrix-wrap { overflow-x: auto; }
.matrix { border-collapse: collapse; min-width: 100%; }
.matrix th, .matrix td { border-bottom: 1px solid #f0f1f8; padding: 9px 12px; font-size: 12.5px; white-space: nowrap; }
.matrix thead th { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.matrix th.mod-name { text-align: left; position: sticky; left: 0; background: var(--surface); min-width: 200px; z-index: 2; }
.matrix td.mod-name { text-align: left; position: sticky; left: 0; background: var(--surface); font-weight: 600; z-index: 1; }
.matrix td.cell { text-align: center; }
.tickbox {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid #d6d9ea; background: #fff;
  cursor: pointer; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800;
  color: transparent; transition: all 0.13s; padding: 0;
}
.tickbox.on { background: var(--green); border-color: var(--green); color: #fff; }
.tickbox:hover { border-color: var(--accent); }
.tickbox.on:hover { border-color: var(--green); filter: brightness(1.08); }

/* ── Detail page ── */
.detail-head {
  display: flex; align-items: center; gap: 18px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; flex-wrap: wrap;
}
.detail-head .dh-main { flex: 1; min-width: 220px; }
.detail-head h1 { font-size: 21px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.detail-head .dh-sub { color: var(--ink-3); margin-top: 3px; }
.detail-head .dh-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.completeness { margin-top: 12px; }
.completeness .cbar { height: 8px; border-radius: 5px; background: #edeef6; overflow: hidden; max-width: 420px; }
.completeness .cbar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.completeness .miss { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.clock-line { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 4px; }
.clock-box .ck { font-size: 11px; color: var(--ink-3); text-transform: uppercase; font-weight: 700; letter-spacing: 0.05em; }
.clock-box .cv { font-size: 19px; font-weight: 700; margin-top: 2px; }
.clock-box .cd { font-size: 12px; color: var(--ink-3); }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-weight: 600; font-size: 13px; margin-bottom: 14px; }
.back-link:hover { color: var(--accent); }

/* ── Coming up list ── */
.up-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0f1f8; }
.up-item:last-child { border-bottom: none; }
.up-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; background: var(--accent-soft); }
.up-main { flex: 1; min-width: 0; }
.up-main .ut { font-weight: 600; font-size: 13px; }
.up-main .us { color: var(--ink-3); font-size: 12px; }
.up-when { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.up-when.soon { color: var(--amber); }
.up-when.now { color: var(--red); }

/* attention list */
.att-row { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid #f0f1f8; align-items: flex-start; cursor: pointer; }
.att-row:last-child { border-bottom: none; }
.att-row:hover .ut { color: var(--accent); }
.att-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(18, 16, 44, 0.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 90; padding: 20px;
  animation: fadein 0.15s;
}
@keyframes fadein { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lift);
  width: 100%; max-width: 460px; padding: 24px; animation: pop 0.18s;
}
.modal.wide { max-width: 620px; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.modal h3 { font-size: 16px; margin-bottom: 6px; }
.modal .modal-body { color: var(--ink-2); margin-bottom: 18px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 9px; }

/* ── Toasts ── */
#toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 9px; z-index: 120; }
.toast {
  background: #23253d; color: #fff; border-radius: 11px; padding: 11px 16px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lift);
  animation: slidein 0.2s; max-width: 340px;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* ── Empty state ── */
.empty { text-align: center; padding: 38px 20px; color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.empty p { margin: 0; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; flex-direction: row; align-items: center; padding: 10px 14px; }
  .shell { flex-direction: column; }
  .main { margin-left: 0; padding: 18px 14px 50px; }
  .nav { flex-direction: row; margin-left: 12px; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; display: flex; align-items: center; gap: 10px; }
  .mel-clock { margin: 0; }
  .brand-sub, .staff-meta { display: none; }
}
