:root {
  --bg: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --card: #ffffff;
  --accent: #22a33b;        /* green primary (brand) */
  --accent-dark: #1c7a2e;
  --green-bright: #32cd32;
  --orange: #ff8c00;        /* orange highlight */
  --navy: #0f172a;
  --navy-2: #1e293b;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #0ea5e9;
  --indigo: #6366f1;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 8px 24px rgba(15,23,42,.06);
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent-dark); }
.boot { min-height: 100vh; display: grid; place-items: center; }
.spin { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, #1e293b, #0f172a); }
.login-card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  width: 100%; max-width: 380px; padding: 30px 26px; }
.login-card .brand { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.login-card .brand span { color: var(--accent); }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }
.fld { display: block; margin-bottom: 14px; }
.fld span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.fld input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; background: #f8fafc; }
.fld input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn { border: none; border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 14px; background: var(--accent); color: #fff; transition: filter .15s, transform .1s; }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #cbd5e1; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 4px; }
.sidebar .logo span { color: var(--accent); }
.sidebar .tag { font-size: 11px; color: #64748b; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 26px; }
.navitem { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 11px; color: #cbd5e1; font-weight: 600; font-size: 14px; border: none; background: none; width: 100%; text-align: left; transition: background .15s, color .15s; }
.navitem .ic { font-size: 17px; }
.navitem:hover { background: var(--navy-2); color: #fff; }
.navitem.active { background: var(--accent); color: #fff; }
.sidebar .who { position: absolute; bottom: 18px; left: 16px; right: 16px; font-size: 13px; color: #94a3b8; }
.sidebar .who b { color: #fff; display: block; }

.main { padding: 22px 26px 50px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -.4px; }
.topbar .spacer { flex: 1; }
.rangesel { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.rangesel button { border: none; background: none; padding: 7px 11px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); }
.rangesel button.active { background: var(--navy); color: #fff; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { margin: 0 0 14px; font-size: 14px; font-weight: 700; color: var(--ink); }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px; }
  .sidebar .tag, .sidebar .who { display: none; }
  .sidebar .logo { margin: 0 12px 0 0; }
  .navitem { width: auto; padding: 8px 12px; }
  .grid > [class^="col-"] { grid-column: span 12 !important; }
}

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .val { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .ic { font-size: 20px; opacity: .9; }
.kpi.accent { background: linear-gradient(135deg, var(--green-bright), var(--accent-dark)); color: #fff; border: none; }
.kpi.accent .lbl { color: rgba(255,255,255,.85); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }

/* ---------- charts ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-center { font-size: 26px; font-weight: 800; }
.donut-center small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
svg { display: block; max-width: 100%; }

/* ===== Duty roster (day/week/month) ===== */
.duty-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.duty-nav { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.duty-nav #dtitle { min-width: 180px; text-align: center; }
.navbtn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; font-weight: 700; color: var(--ink); }
.navbtn:hover { background: #f1f5f9; }
.navbtn.today { color: var(--accent-dark); }
.staff-chip { display: inline-block; background: #eaf7ec; color: var(--accent-dark); border: 1px solid #cdebd3; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; margin: 2px 3px 2px 0; }
.duty-shift { padding: 12px 14px; }
.duty-shift.gap { border-color: #fecaca; background: #fef5f5; }
.ds-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.ds-count { font-weight: 800; color: var(--accent-dark); }
.ds-count.low { color: var(--red); }
.ds-staff { display: flex; flex-wrap: wrap; gap: 2px; }

/* week grid */
.week-grid { width: 100%; border-collapse: collapse; }
.week-grid th { font-size: 12px; padding: 8px 6px; border-bottom: 2px solid var(--line); text-align: center; }
.week-grid th.is-today { color: var(--accent-dark); }
.week-grid td { border-bottom: 1px solid #f1f5f9; padding: 6px; vertical-align: top; }
.dw-name { font-weight: 700; white-space: nowrap; font-size: 13px; }
.dw-cell { min-width: 96px; }
.dw-shift { display: block; background: #eaf7ec; color: var(--accent-dark); border-radius: 7px; padding: 2px 7px; font-size: 11px; font-weight: 600; margin: 2px 0; white-space: nowrap; }
.dw-pill { display: inline-block; border-radius: 7px; padding: 2px 7px; font-size: 11px; font-weight: 700; }
.dw-pill.ANNUAL { background: #fff3df; color: #b45309; }
.dw-pill.SICK { background: #fae8ff; color: #a21caf; }
.dw-pill.WEEKLY { background: #eef2f7; color: #475569; }

/* month grid */
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.mcell { aspect-ratio: 1 / 0.92; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; cursor: default; text-align: left; }
.mcell.empty { border: none; background: transparent; }
.mcell.has { background: #f6fbf6; }
.mcell.today { outline: 2px solid var(--accent); }
.mnum { font-size: 13px; font-weight: 700; }
.mcount { font-size: 11px; color: var(--accent-dark); font-weight: 700; }
.mdots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: auto; }
.mdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.moff { font-size: 10px; color: var(--muted); }

/* device actions */
.dev-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dev-actions .dev-staff { width: auto; min-width: 130px; padding: 6px 8px; font-size: 12px; }

/* hbars */
.hbar { margin: 9px 0; }
.hbar-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.hbar-track { height: 9px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; }

/* coverage gauges */
.cov-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gauge { text-align: center; }
.gauge .num { font-size: 24px; font-weight: 800; }
.gauge .nm { font-size: 12px; color: var(--muted); font-weight: 600; }
.gauge.gap .num { color: var(--red); }
.cov-warn { margin-top: 14px; background: #fef2f2; color: #b91c1c; border-radius: 11px; padding: 9px 12px; font-size: 13px; font-weight: 600; }
.cov-ok { margin-top: 14px; color: var(--green); font-size: 13px; font-weight: 600; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid #f1f5f9; }
.role-pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef2f7; color: #475569; }
.minibar { height: 7px; border-radius: 999px; background: #eef2f7; overflow: hidden; width: 110px; display: inline-block; vertical-align: middle; }
.minibar > i { display: block; height: 100%; }
.tag-ok { color: var(--green); font-weight: 700; } .tag-no { color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); }
.toast.err { background: var(--red); }
.muted { color: var(--muted); }
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 40; display: grid; place-items: center; padding: 18px; }
.sheet { position: relative; background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.sheet h2 { margin: 0 0 14px; font-size: 18px; padding-right: 30px; }
.sheet-x { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--line); color: var(--ink); font-size: 13px; }
.sheet-x:hover { background: #cbd5e1; }

/* ---------- attendance chips · extra duty · report ---------- */
.staff-chip.att-present { background: #e6f7ea; color: #15803d; border-color: #b6e2c2; }
.staff-chip.att-absent { background: #fde8e8; color: #b91c1c; border-color: #f5c2c2; }
.month-input {
  font: inherit; font-size: 13px; padding: 3px 8px; border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px; margin-left: 8px; vertical-align: middle; background: #fff;
}
.report-table th { font-size: 12px; white-space: nowrap; }
.report-table td { text-align: center; }
.report-table td:first-child { text-align: left; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: #f1f6ef; }
/* ===== Confirmation dialog (styled replacement for native confirm()) ===== */
.cd-scrim{position:fixed;inset:0;z-index:10000;display:flex;align-items:center;
  justify-content:center;padding:20px;background:rgba(18,28,18,.46);
  -webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);animation:cd-fade .14s ease}
.cd-card{width:100%;max-width:400px;background:#fff;border-radius:16px;
  padding:24px 22px 18px;box-shadow:0 20px 55px rgba(0,0,0,.3);
  animation:cd-pop .17s cubic-bezier(.2,.8,.3,1)}
.cd-icon{width:48px;height:48px;margin:0 auto 14px;border-radius:50%;display:flex;
  align-items:center;justify-content:center;font-size:25px;background:#eaf6ea}
.cd-card.danger .cd-icon{background:#fdeceb}
.cd-title{margin:0 0 7px;font-size:18px;font-weight:700;text-align:center;color:#1b2a1b}
.cd-msg{margin:0 0 21px;font-size:14.5px;line-height:1.5;text-align:center;color:#5c685c}
.cd-actions{display:flex;gap:10px}
.cd-btn{flex:1;padding:12px 14px;border-radius:11px;font-size:15px;font-weight:600;
  border:1px solid transparent;cursor:pointer;transition:filter .12s,background .12s}
.cd-cancel{background:#f0f3ef;color:#39463a;border-color:#e2e8e0}
.cd-cancel:hover{background:#e6ece5}
.cd-ok{background:#22a33b;color:#fff}
.cd-ok:hover{filter:brightness(1.07)}
.cd-card.danger .cd-ok{background:#dc3545}
.cd-btn:focus-visible{outline:2px solid #1b2a1b;outline-offset:2px}
@keyframes cd-fade{from{opacity:0}to{opacity:1}}
@keyframes cd-pop{from{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}
@media (max-width:420px){.cd-card{max-width:none}}

/* Static (non-clickable) chip used by the Today roster strip. */
.chip-static{display:inline-block;padding:3px 9px;margin:2px 3px 2px 0;border-radius:99px;
  background:#f1f5f9;border:1px solid #e2e8f0;font-size:12.5px;color:#334155;white-space:nowrap}
