/* The app's one stylesheet: a light dashboard theme. Every text/background pair is at least 4.5:1.
   Two colours differ from the approved mockup for that reason: --muted (was #6b7280) and --late (was #a16207). */
:root {
  --bg: #f4f6fa; --surface: #fff; --text: #1f2937; --muted: #5b6472;
  --border: #e5e7eb; --border-strong: #cbd5e1; --field: #7b8494; --head: #f9fafb; --hover: #fafafa;
  --side: #111827; --side-text: #cbd5e1; --side-group: #94a3b8; --side-hover: #1f2937; --side-line: #334155;
  --accent: #2563eb; --accent-dark: #1d4ed8; --accent-soft: #eff6ff;
  --ok: #15803d; --ok-bg: #dcfce7; --late: #8a5a00; --late-bg: #fef3c7; --late-line: #fde68a;
  --bad: #b91c1c; --bad-bg: #fee2e2; --bad-line: #fecaca; --leave: #6d28d9; --leave-bg: #ede9fe;
  --neutral: #374151; --neutral-bg: #f3f4f6;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
h1, h2, h3, p, dl, dd, fieldset { margin: 0; }
h1 { font-size: 20px; line-height: 1.3; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Shell: dark sidebar, white top bar, grey content */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; background: var(--side); color: var(--side-text); }
.side :focus-visible { outline-color: #93c5fd; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-size: 16px; font-weight: 700; color: #fff; }
.logo { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; }
.side-menu { display: flex; flex-direction: column; flex: 1; gap: 4px; }
.menu { display: none; }
.group { margin: 14px 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-group); }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none; }
.side nav a:hover { background: var(--side-hover); color: #fff; }
.side nav a.on { background: var(--accent); color: #fff; }
.side svg { flex: none; width: 18px; height: 18px; }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--side-hover); }
.me span { overflow-wrap: anywhere; }
.side button { padding: 4px 10px; border: 1px solid var(--side-line); border-radius: 6px; background: transparent; color: var(--side-text); font: inherit; cursor: pointer; }
.side button:hover { background: var(--side-hover); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; min-height: 75px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.sub { font-size: 13px; color: var(--muted); }
.sub:empty { display: none; }
.tools { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tools form { display: flex; align-items: center; gap: 8px; }
.tools label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; }
.pager { display: flex; gap: 6px; }
.content { display: flex; flex-direction: column; gap: 20px; padding: 24px 28px; }

.seg { display: inline-flex; max-width: 100%; border: 1px solid var(--border-strong); border-radius: 8px; overflow: auto hidden; background: var(--surface); }
.seg a { flex: none; padding: 6px 12px; color: var(--muted); font-weight: 500; text-decoration: none; white-space: nowrap; }
.seg a:focus-visible { outline-offset: -2px; }
.seg a + a { border-left: 1px solid var(--border); }
.seg a:hover { background: var(--neutral-bg); }
.seg a.on { background: var(--accent-soft); color: var(--accent-dark); }

/* Buttons: bare <button> and .btn are the quiet style; .primary submits a form; .sm and .danger are for table rows */
button, .btn { display: inline-block; padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; line-height: 1.4; text-decoration: none; cursor: pointer; }
button:hover, .btn:hover { background: var(--neutral-bg); color: var(--text); }
.primary { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); color: #fff; }
.sm { padding: 2px 10px; font-size: 12px; }
.danger { color: var(--bad); }
.danger:hover { background: var(--bad-bg); color: var(--bad); }

/* Alerts: .alert is the amber device warning; .warn is a form error (in a roster cell it shrinks to red text) */
.alert, .warn { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border: 1px solid var(--late-line); border-radius: var(--radius); background: var(--late-bg); color: var(--late); }
.alert svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.warn { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad); }

/* Cards */
.card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-body { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); }
.hint, .note { font-size: 12px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.kpi dt { font-size: 13px; color: var(--muted); }
.kpi .value { margin-top: 4px; font-size: 28px; font-weight: 700; line-height: 1.2; }
.kpi.ok .value { color: var(--ok); }
.kpi.late .value { color: var(--late); }
.kpi.bad .value { color: var(--bad); }

/* Tables: wrap them in .scroll; the first column (.name) stays put while the rest scrolls */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
thead th { background: var(--head); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
tbody tr:hover > * { background: var(--hover); }
tbody tr:last-child > * { border-bottom: 0; }
.name { position: sticky; left: 0; z-index: 1; background: var(--surface); font-weight: 600; }
thead .name { background: var(--head); }
.name a { color: var(--text); text-decoration: none; }
.name a:hover { text-decoration: underline; }
.name small { display: block; font-weight: 400; color: var(--muted); }
.week { min-width: 760px; }
.week .total { font-weight: 600; }
.data td form { display: inline-flex; }

/* Status pills (data-status is the Status; flags are data-flag). */
.pill { display: inline-block; margin-top: 3px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--neutral-bg); color: var(--neutral); }
.pill::first-letter { text-transform: uppercase; }
.pill[data-status="on time"] { background: var(--ok-bg); color: var(--ok); }
.pill[data-status="late"] { background: var(--late-bg); color: var(--late); }
.pill[data-status="absent"] { background: var(--bad-bg); color: var(--bad); }
.pill[data-status="leave"] { background: var(--leave-bg); color: var(--leave); }
.pill[data-status="holiday"] { background: var(--accent-soft); color: var(--accent-dark); }
.pill[data-tone="ok"] { background: var(--ok-bg); color: var(--ok); }
.pill[data-tone="warn"] { background: var(--late-bg); color: var(--late); }
.pill[data-tone="bad"] { background: var(--bad-bg); color: var(--bad); }
.pill[data-status="off"] { padding-left: 0; background: none; color: var(--muted); font-weight: 500; }
.shift, .hrs, .times, .flag, .num { display: block; }
.shift { font-size: 11px; color: var(--muted); }
.hrs { margin-top: 2px; font-size: 12px; color: var(--muted); }
.hrs b { color: var(--text); }
.flag { width: fit-content; margin-top: 3px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--neutral-bg); color: var(--neutral); }
.flag[data-flag^="no check"] { background: var(--late-bg); color: var(--late); }

/* Month grids (calendar and person) */
.month { min-width: 700px; table-layout: fixed; }
.month th, .month td { white-space: normal; }
.month td { height: 96px; padding: 8px; border-right: 1px solid var(--border); }
.month td:last-child { border-right: 0; }
.month td.blank { background: var(--head); }
.num { font-weight: 600; }
.month .quiet .num { font-weight: 400; color: var(--muted); }
.wd { display: none; }
.chip { display: block; margin-top: 4px; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--neutral-bg); color: var(--neutral); overflow-wrap: anywhere; }
.chip[data-status="late"] { background: var(--late-bg); color: var(--late); }
.chip[data-status="absent"] { background: var(--bad-bg); color: var(--bad); }
.chip a { color: inherit; font-weight: 600; text-decoration: none; }
.chip a:hover { text-decoration: underline; }
.times { font-size: 12px; }

/* Forms */
form { margin: 0; }
input, select { padding: 6px 10px; border: 1px solid var(--field); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; line-height: 1.4; }
input:disabled { border-color: var(--border-strong); background: var(--neutral-bg); color: var(--neutral); }
input[type="checkbox"] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
select { max-width: 100%; }
.fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.fields.row { flex-wrap: nowrap; align-items: center; }
.fields label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--neutral); }
fieldset { min-width: 0; padding: 0; border: 0; }
legend { padding: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--neutral); }
.days { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.fields .days label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; color: var(--text); }
.shifts { display: flex; flex-direction: column; gap: 10px; }

/* Roster cells: the select, then a refusal under it */
.roster td { padding-inline: 6px; }
.cell select { padding: 3px 4px; font-size: 12px; }
.cell .warn { display: block; padding: 2px 0; border: 0; background: none; white-space: normal; }

/* Sign-in */
.login { display: grid; align-content: center; justify-items: center; gap: 20px; min-height: 100vh; padding: 24px 16px; }
.login .brand { padding: 0; color: var(--text); }
.login .card { width: min(380px, 100%); }
.login .fields { flex-direction: column; align-items: stretch; }
.login input { width: 100%; }

@media (max-width: 1100px) {
  .kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Phone: the sidebar becomes a top bar whose Menu button shows the nav and the user */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0; padding: 10px 14px; }
  .brand { flex: 1; padding: 0; }
  .menu { display: inline-block; }
  .side-menu { display: none; width: 100%; flex: none; padding-top: 10px; }
  .side.open .side-menu { display: flex; }
  .top { padding: 12px 16px; }
  .tools { width: 100%; margin-left: 0; }
  .tools form { width: 100%; }
  .tools label, .tools select { flex: 1; min-width: 0; }
  .content { gap: 14px; padding: 16px; }
  .kpis, .kpis.six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 22px; }
  /* month grids: just the days that have entries, as a list */
  .month { min-width: 0; }
  .month, .month tbody, .month tr, .month td { display: block; height: auto; }
  .month thead, .month .blank, .month .quiet { display: none; }
  .month td { border-right: 0; }
  .wd { display: inline; }
}
