/* Timecard Portal - shared styles. Tokens first; everything below reads from them. */
:root {
  --ink: #0d1624;          /* sidebar */
  --ink-2: #16233a;
  --ink-text: #c6d0e0;
  --canvas: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --line: #d9dfe9;
  --text: #121a2a;
  --muted: #5d6b82;
  --accent: #2a5bff;
  --accent-ink: #ffffff;
  --lit: #5b82ff;
  --hero: linear-gradient(135deg, #0d1624, #0d1624);
  --accent-soft: #e6edff;
  --ok: #0f8a5f;   --ok-soft: #dff5ec;
  --warn: #7a5600; --warn-soft: #ffeb99;
  --bad: #c2342c;  --bad-soft: #fde6e4;
  --radius: 8px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --side: 248px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0a111d; --surface: #111c2e; --surface-2: #0e1829; --line: #22324c;
    --text: #e6ebf5; --muted: #8fa0ba; --accent: #5b82ff; --accent-soft: #172448;
    --ok: #3cc88f; --ok-soft: #0f2f26; --warn: #f5d04c; --warn-soft: #3a3008;
    --bad: #ff7d73; --bad-soft: #3a1815; --ink: #070d17; --ink-2: #101c31;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font: 15px/1.55 var(--sans);
  padding: 36px 44px 72px calc(var(--side) + 44px);
}
body > *:not(.side) { max-width: 1120px; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; font-weight: 600; }
h1, h2 { font-size: 26px; margin-bottom: 6px; }       /* h2 kept so old markup still looks right */
h3 { font-size: 16px; margin: 32px 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.sub { color: var(--muted); margin-bottom: 24px; max-width: 70ch; }
.num, td.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Sidebar ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--ink);
  color: var(--ink-text); display: flex; flex-direction: column; padding: 20px 14px; overflow-y: auto; z-index: 20;
}
.side .brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; color: #fff; text-decoration: none; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.side .brand .bt small { display: block; font-weight: 400; font-size: 12px; color: #9fb0cc; letter-spacing: 0; margin-top: 2px; }
.side .mark.logo { background: #fff; width: 40px; height: 40px; border-radius: 10px; padding: 4px; }
.side .mark.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.side .mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; flex: none; }
.side .mark svg { width: 17px; height: 17px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side .grp { margin: 18px 8px 6px; font-size: 12px; color: #7d8ca6; letter-spacing: 0.02em; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px;
  color: var(--ink-text); text-decoration: none; font-size: 14px; border-left: 2px solid transparent;
}
.side li a svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.side li a:hover { background: var(--ink-2); color: #fff; }
.side li a.active { background: var(--ink-2); color: #fff; border-left-color: var(--lit); }
.side li a.active svg { color: var(--lit); }
.side li a.active svg { opacity: 1; }
.side .user { margin-top: auto; padding: 14px 8px 2px; border-top: 1px solid #1d2c47; font-size: 13px; }
.side .user strong { display: block; color: #fff; font-weight: 500; overflow-wrap: anywhere; }
.side .user a { color: #9fb0cc; text-decoration: none; }
.side .user a:hover { color: #fff; }
.side #navToggle, .side .burger { display: none; }

/* ---------- Panels, stats ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 20px; }
.panel > h3:first-child { margin-top: 0; }
details.panel > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; font-family: var(--mono); font-size: 18px; color: var(--muted); }
details.panel[open] > summary::after { content: "\2212"; }
details.panel[open] > summary { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font: 600 26px/1.2 var(--mono); font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -0.02em; }
.stat .v small { font-size: 14px; color: var(--muted); font-weight: 400; }

/* Clock panel: the one loud element */
.clock {
  background: var(--hero); color: #fff; border-radius: 12px; padding: 24px; margin-bottom: 20px;
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
}
.clock .state { display: flex; align-items: center; gap: 10px; color: var(--ink-text); font-size: 14px; }
.clock .dot { width: 10px; height: 10px; border-radius: 50%; background: #5d6b82; }
.clock.on .dot { background: #3cc88f; box-shadow: 0 0 0 4px rgba(60,200,143,.2); }
.clock { border: 1px solid rgba(255,255,255,.08); }
.clock .t { font: 500 clamp(40px, 7vw, 64px)/1.05 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; margin: 8px 0 2px; }
.clock .since { color: #8fa0ba; font-size: 13px; }
.clock form { display: flex; gap: 10px; }
.clock .btn { min-width: 150px; padding: 14px 18px; font-size: 16px; }
@media (max-width: 760px) { .clock { grid-template-columns: 1fr; } .clock form { flex-direction: column; } }

/* ---------- Forms & buttons ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 14px 0 5px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=month], input[type=datetime-local], input[type=email], select, textarea {
  width: 100%; max-width: 100%; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: -3px; margin-right: 8px; }
label:has(> input[type=checkbox]) { display: flex; align-items: center; color: var(--text); font-size: 14px; margin: 6px 0; font-weight: 400; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > div { min-width: 170px; flex: 0 1 220px; }
.row label { margin-top: 0; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font: 500 14px/1 var(--sans); padding: 11px 16px; min-height: 40px; border-radius: 6px; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); margin-top: 14px;
}
button:hover, .btn:hover { border-color: var(--muted); }
.btn-primary, button[type=submit]:not(.btn-danger):not(.btn-ghost):not(.btn-ok) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover, button[type=submit]:not(.btn-danger):not(.btn-ghost):not(.btn-ok):hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; }
button:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.row button, .clock .btn, td button { margin-top: 0; }
.clock .btn-ok { background: #1fa774; border-color: #1fa774; }
.clock .btn-danger { background: #d8453c; border-color: #d8453c; }
.wide { width: 100%; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; margin: 12px 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-wrap table { margin: 0; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; }
td.num, th.num { text-align: right; }
tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
table td form { display: inline-block; margin: 0; }
table td input[type=text], table td input[type=datetime-local] { min-width: 150px; margin: 2px 0; }
table td label { margin: 4px 0 2px; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
/* tables written directly in a page (no wrapper) still get a frame */
body > table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; margin: 12px 0 20px; }
body > table th:first-child { border-top-left-radius: var(--radius); }
details table { margin-top: 8px; }

/* ---------- Badges & messages ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.msg { padding: 11px 14px; border-radius: 6px; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); margin: 0 0 18px; }
.msg.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.msg.ok { border-left-color: var(--ok); }
.hint { color: var(--muted); font-size: 13px; }
details > summary { cursor: pointer; }
details:not(.panel) { margin: 10px 0; }

/* ---------- Phones / small screens: sidebar becomes a top bar ---------- */
@media (max-width: 900px) {
  body { padding: 96px 16px 56px; }
  .side { inset: 0 0 auto 0; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; overflow: visible; }
  .side .brand { padding: 0; flex: 1; }
  .side .burger { display: inline-flex; color: #fff; border: 1px solid #2a3b5a; border-radius: 6px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
  .side nav { display: none; width: 100%; padding-top: 10px; max-height: calc(100vh - 70px); overflow-y: auto; }
  .side #navToggle:checked ~ nav { display: block; }
  .side .user { display: none; width: 100%; margin-top: 10px; }
  .side #navToggle:checked ~ .user { display: block; }
  h1, h2 { font-size: 22px; }
}

/* ---------- Login ---------- */
body.login { padding: 0; min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(320px, 440px); background: var(--canvas); }
body.login > * { max-width: none; }
.login .brandpane { background: var(--hero), var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .brandpane::before {   /* faint ruled grid, like a timesheet */
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(135deg, transparent 20%, #000 90%);
}
.login .brandpane > * { position: relative; }
.login .brandpane h1 { font-size: clamp(28px, 3.4vw, 42px); max-width: 17ch; margin: 0 0 14px; }
.login .brandpane p { color: #9fb0cc; max-width: 38ch; }
.login .brandpane .mark { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.login .brandpane .mark svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login .formpane { padding: 56px 44px; display: flex; flex-direction: column; justify-content: center; }
.login .formpane h2 { font-size: 24px; margin-bottom: 4px; }
.login .formpane button { width: 100%; margin-top: 22px; padding: 13px; }
@media (max-width: 820px) { body.login { grid-template-columns: 1fr; } .login .brandpane { padding: 28px 24px; min-height: 0; } .login .brandpane h1 { font-size: 26px; } .login .formpane { padding: 32px 24px; } }

@media (prefers-reduced-motion: no-preference) { .clock.on .dot { animation: pulse 2s ease-out infinite; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(60,200,143,.5); } 100% { box-shadow: 0 0 0 10px rgba(60,200,143,0); } }
th.num, th.r { font-family: var(--sans); }

.badge { white-space: nowrap; }
td.mono { white-space: nowrap; }

/* Login: school crest card + site switcher */
.login .crest { display: block; align-self: flex-start; width: auto; height: auto; max-width: 260px; max-height: 160px; object-fit: contain; margin: 0 0 22px; }
.login .brandpane .site { color: var(--lit); font-weight: 500; margin-bottom: 8px; }
.login .switch { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 26px; font-size: 13px; }
.login .switch a { color: var(--muted); text-decoration: none; }
.login .switch a:hover, .login .switch a.on { color: var(--accent); }
.login .switch a.on { font-weight: 600; }
@media (max-width: 820px) { .login .crest { max-height: 110px; } }
