/* Brand colour #548888. Contrast palette: warm coral (alerts/late), gold (idle/pending), green (success), blue (info). */
:root, :root[data-theme="dark"] {
  --bg: #0C1517; --panel: #131F22; --raised: #1B2B2F; --line: #2A3F44;
  --accent: #548888; --accent-ink: #031314; --link: #86BDBD;
  --green: #5BC48A; --red: #F08A6A; --amber: #E8B04A; --blue: #7FAEE8;
  --text: #E6F0F0; --muted: #98B0B2; --faint: #6A8487;
  --scrim: #02080ACC; --shadow: 0 10px 30px #00000066;
  --radius: 10px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F2F6F6; --panel: #FFFFFF; --raised: #E8F0F0; --line: #D0DEDE;
  --accent: #548888; --accent-ink: #031314; --link: #3B6969;
  --green: #1C7F4D; --red: #C2512C; --amber: #9A6A06; --blue: #2E64B0;
  --text: #102022; --muted: #4B6466; --faint: #7C9294;
  --scrim: #0A1A1C99; --shadow: 0 10px 30px #0A1A1C33;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; }
.hidden { display: none !important; } .nowrap { white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 24px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; padding: 0 10px; }
.brand span { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 9px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--raised); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.me-box { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 0; display: flex; flex-direction: column; gap: 6px; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-align: left; font-size: 13px; }
.linklike:hover { color: var(--text); }
.main { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 32px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 20; }
.topbar .clock { color: var(--muted); font-size: 13px; }
.topbar .clock strong { color: var(--text); font-size: 15px; margin: 0 4px; font-variant-numeric: tabular-nums; }
.content { padding: 28px 32px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { color: var(--muted); margin: 6px 0 0; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--raised); padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--red) 45%, transparent); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.big { padding: 15px 30px; font-size: 16px; border-radius: var(--radius); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=datetime-local], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; width: 100%; min-width: 0; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 7px 13px; color: var(--muted); cursor: pointer; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--raised); color: var(--text); }

/* surfaces */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel + .panel, .stats + .panel, .table-wrap + .panel { margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 22px; }
.stat { padding: 18px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.alert .v { color: var(--red); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--raised); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--raised); color: var(--muted); white-space: nowrap; }
.pill.green { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.pill.red { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.pill.amber { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.pill.blue { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }
.rows .row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rows .row:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .panel { margin-top: 0 !important; }

/* staff home */
.hero { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 34px 38px; margin-bottom: 22px; }
.big-clock { font-size: clamp(48px, 7vw, 80px); font-weight: 300; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; margin: 6px 0 14px; }
.big-clock .sec { color: var(--faint); font-size: .42em; margin-left: 6px; }
.state { font-size: 15px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.row-actions { margin-top: 22px; }

/* monitor */
.meter { display: inline-block; width: 90px; height: 7px; background: var(--raised); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.meter span { display: block; height: 100%; background: var(--green); }
.strip { display: grid; grid-template-columns: repeat(96, 1fr); gap: 1px; margin-top: 8px; }
.strip i { height: 28px; background: var(--raised); border-radius: 1px; }
.theme-btn { padding: 6px 12px; }
.strip i.a { background: var(--green); } .strip i.i { background: var(--amber); } .strip i.h { background: var(--red); }
.strip-labels { display: grid; grid-template-columns: repeat(24, 1fr); font-size: 10.5px; color: var(--faint); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend b { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* modal / toast / login */
.modal-back { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: min(540px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal.wide { width: min(820px, 100%); }
.modal h2 { margin-bottom: 14px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--raised); border: 1px solid var(--line); border-left: 3px solid var(--green); padding: 11px 16px; border-radius: 6px; max-width: 360px; box-shadow: var(--shadow); }
.toast.err { border-left-color: var(--red); }
.secret { font-size: 20px; font-weight: 700; letter-spacing: .06em; background: var(--bg); border: 1px dashed var(--accent); padding: 12px 16px; border-radius: 6px; text-align: center; margin: 10px 0; user-select: all; }
.err-box { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-card .brand { padding: 0; font-size: 22px; }
.blocked { max-width: 460px; text-align: center; margin: 14vh auto; padding: 24px; }
.notice { font-size: 12px; color: var(--faint); line-height: 1.4; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
  .nav a { white-space: nowrap; }
  .me-box { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; gap: 12px; }
  .me-box .hide-m { display: none; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px 60px; }
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
  .hero { padding: 24px; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
