/* Staff Time Clock — shared styles. Light and dark, one design across all three pages. */

:root {
  color-scheme: light;
  --bg: #f1f4f9;
  --bg-2: #e6ebf3;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #76859b;

  --brand: #3b5bdb;
  --brand-hover: #3450c8;
  --brand-soft: #e8edfd;
  --brand-text: #2f49b8;

  --in: #1a8a4a;
  --in-soft: #dff5e7;
  --lunch: #b4700a;
  --lunch-soft: #fdf0d8;
  --out: #94a3b8;
  --out-soft: #eef1f5;
  --danger: #c23b32;
  --danger-soft: #fbe6e4;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 4px 14px rgba(15, 23, 42, .07);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .22);
  --ring: 0 0 0 3px rgba(59, 91, 219, .25);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1420;
    --bg-2: #0a0f18;
    --surface: #161e2e;
    --surface-2: #1b2435;
    --surface-3: #212c3f;
    --line: #2a3650;
    --line-strong: #3a4761;

    --text: #eef2f8;
    --text-2: #aab6c9;
    --text-3: #8392a8;

    --brand: #6f8bf5;
    --brand-hover: #839bf7;
    --brand-soft: #1f2b4d;
    --brand-text: #a9bcfb;

    --in: #4ec97f;
    --in-soft: #16331f;
    --lunch: #e0a53c;
    --lunch-soft: #35270f;
    --out: #6b7a90;
    --out-soft: #222c3d;
    --danger: #f3796c;
    --danger-soft: #3a1c1b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 6px 18px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
    --ring: 0 0 0 3px rgba(111, 139, 245, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
@media (max-width: 640px) { body { padding: 0; } }

[hidden] { display: none !important; }
a { color: var(--brand-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h2 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 650; margin: 22px 0 10px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ── App shell ─────────────────────────────────────────────── */

.window {
  width: 100%; max-width: 1200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 40px);
}
@media (max-width: 640px) { .window { border-radius: 0; border: 0; min-height: 100vh; } }

.titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 16px; font-weight: 650; letter-spacing: -.01em;
}
@media (max-width: 520px) {
  .titlebar { padding: 12px 14px; font-size: 15px; gap: 9px; }
  .titlebar .time { font-size: 13px; }
}
.titlebar svg { flex: none; color: var(--brand); }
.titlebar .grow { flex: 1; }
.titlebar .time {
  font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.titlebar button {
  font: inherit; font-size: 14px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; white-space: nowrap;
}
.titlebar button:hover { background: var(--surface-3); color: var(--text); }

/* Nav — pill tabs */
.toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.tool {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid transparent; background: none;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text-2);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.tool svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: var(--surface-3); color: var(--text); }
.tool.active, .tool.primary {
  background: var(--brand-soft); color: var(--brand-text); font-weight: 600;
}
.tool .badge {
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 2px;
}
.spacer { flex: 1; }

.content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pad { padding: 22px; }
@media (max-width: 640px) { .pad { padding: 16px; } }

.bottombar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2); font-size: 13px;
}
.bottombar .box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 12px; color: var(--text-2); font-weight: 500;
}

/* ── Clock screen ──────────────────────────────────────────── */

.clock-main {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  flex: 1; min-height: 0; gap: 0;
}
.clock-main > .people { padding: 22px; overflow: auto; }
.side {
  background: var(--surface-2); border-left: 1px solid var(--line);
  padding: 20px; overflow: auto;
}
.side h3:first-child { margin-top: 0; }
@media (max-width: 860px) {
  .clock-main { grid-template-columns: 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
}

.people-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.person {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 20px; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  font: inherit; color: inherit; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.person:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.person:active { transform: translateY(0); }
.avatar {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 650; font-size: 17px; letter-spacing: .02em;
  background: var(--out-soft); color: var(--text-2);
}
.person.is-in .avatar { background: var(--in-soft); color: var(--in); }
.person.is-lunch .avatar { background: var(--lunch-soft); color: var(--lunch); }
.person .info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.person .pname { display: block; font-weight: 600; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .pmeta { display: block; color: var(--text-2); font-size: 13px; }

.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--out-soft); color: var(--text-2);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.in { background: var(--in-soft); color: var(--in); }
.chip.lunch { background: var(--lunch-soft); color: var(--lunch); }

.off-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.off-item .avatar { width: 34px; height: 34px; font-size: 13px; }
.off-item span { min-width: 0; }
.off-item b { display: block; font-size: 14px; }
.off-item .when { color: var(--text-2); font-size: 12.5px; }
.empty-note { color: var(--text-3); font-size: 13px; padding: 2px; }

/* Legacy status marks still used in admin tables */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--out); vertical-align: middle; }
.dot.in { background: var(--in); }
.lunch-icon { width: 20px; height: 18px; vertical-align: middle; stroke: var(--lunch); fill: none; stroke-width: 1.6; }

/* ── Tables ────────────────────────────────────────────────── */

.gridwrap {
  overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; white-space: nowrap;
  padding: 11px 14px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
table.grid th.num { text-align: right; }
table.grid td {
  padding: 12px 14px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid.clickable tbody tr { cursor: pointer; }
table.grid.clickable tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr.selected { background: var(--brand-soft); }
table.grid tfoot td {
  font-weight: 650; background: var(--surface-2);
  border-top: 1px solid var(--line); border-bottom: 0; padding: 12px 14px;
}
table.grid td.icon { width: 46px; text-align: center; }
table.grid td.wrap { white-space: normal; min-width: 160px; }

/* ── Month calendar ────────────────────────────────────────── */

.cal-wrap { overflow-x: auto; padding-bottom: 4px; }
.cal {
  display: grid; grid-template-columns: repeat(7, minmax(104px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; min-width: 740px;
}
.cal-head {
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  padding: 9px 10px; text-align: center;
}
.cal-day {
  background: var(--surface); min-height: 96px; padding: 7px 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.cal-day.weekend { background: var(--surface-2); }
.cal-day.empty { background: var(--surface-2); opacity: .45; min-height: 0; }
.cal-day.bank { background: var(--brand-soft); }
.cal-num { font-size: 13px; font-weight: 600; color: var(--text-2); }
.cal-day.today .cal-num {
  background: var(--brand); color: #fff; border-radius: 999px;
  width: 24px; height: 24px; display: grid; place-items: center; margin: -2px 0 0 -2px;
}
.cal-bank { font-size: 11px; font-weight: 600; color: var(--brand-text); line-height: 1.25; }
.cal-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--c) 13%, transparent);
  color: var(--c); border-radius: 7px; padding: 2px 7px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cal-chip i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.bottombar .cal-chip { font-size: 12px; }
@media (prefers-color-scheme: dark) {
  .cal-chip { background: color-mix(in srgb, var(--c) 26%, transparent); color: #fff; }
}

/* ── Dialogs ───────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } }
.dialog {
  width: 100%; max-width: 400px;
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 36px); display: flex; flex-direction: column;
  overflow: hidden; animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog.wide { max-width: 580px; }
.dialog .dtitle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-weight: 650; background: var(--surface-2);
}
.dialog .dtitle button {
  background: none; border: 0; color: var(--text-2);
  font-size: 22px; line-height: 1; padding: 0 4px; cursor: pointer; border-radius: 6px;
}
.dialog .dtitle button:hover { color: var(--text); }
.dialog .dbody { padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.dialog h2 { margin: 0; font-size: 21px; }
.sub { color: var(--text-2); margin-top: -8px; }

.pin-dots { display: flex; gap: 12px; justify-content: center; padding: 6px 0 2px; }
.pin-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-strong); background: none;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.pin-dots i.on { background: var(--brand); border-color: var(--brand); transform: scale(1.08); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  padding: 16px 0; font: inherit; font-size: 21px; font-weight: 500;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .1s ease, transform .1s ease;
}
.keypad button:hover { background: var(--surface-3); }
.keypad button:active { transform: scale(.96); }

.big {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 17px; border: 0; border-radius: var(--radius-sm);
  font: inherit; font-size: 17px; font-weight: 650; color: #fff;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: filter .12s ease, transform .1s ease;
}
.big:hover { filter: brightness(1.07); }
.big:active { transform: scale(.99); }
.big:disabled { opacity: .55; cursor: default; }
.big svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.b-in { background: var(--in); }
.b-out { background: var(--danger); }
.b-lunch { background: var(--lunch); }

.confirm {
  background: var(--in-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--in) 30%, transparent);
  border-radius: var(--radius-sm); padding: 16px; font-size: 16px;
}
.warn {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--lunch-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--lunch) 30%, transparent);
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px;
}
.error { color: var(--danger); font-size: 14px; min-height: 18px; }

table.day { width: 100%; border-collapse: collapse; font-size: 14px; }
table.day td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.day tr:last-child td { border-bottom: 0; }
table.day tr.total td { font-weight: 700; font-size: 15px; }

/* ── Forms and buttons ─────────────────────────────────────── */

form.stack, .stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 150px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 9px; font-weight: 400; color: var(--text); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
input[type=date], input[type=time] { min-height: 42px; }
textarea { min-height: 72px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px 14px; }
legend { color: var(--text-2); font-size: 13px; padding: 0 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  text-decoration: none; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, filter .12s ease;
}
.btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.good { background: var(--in); border-color: var(--in); color: #fff; }
.btn.good:hover { filter: brightness(1.07); background: var(--in); }
.btn.bad { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.btn.bad:hover { background: var(--danger-soft); }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; color: var(--brand-text); cursor: pointer; font: inherit; padding: 4px 0; align-self: flex-start; }
.link:hover { text-decoration: underline; }

/* ── Cards, pills, misc ────────────────────────────────────── */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px; }
.card {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.card .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.card .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.card.highlight { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 28%, transparent); }
.card.highlight .value, .card.highlight .label { color: var(--brand-text); }

.pill {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 650; text-transform: capitalize;
  background: var(--out-soft); color: var(--text-2);
}
.pill.pending { background: var(--lunch-soft); color: var(--lunch); }
.pill.approved { background: var(--in-soft); color: var(--in); }
.pill.rejected { background: var(--danger-soft); color: var(--danger); }
.flag { color: var(--danger); font-size: 13px; }

.login-box { max-width: 390px; margin: min(9vh, 70px) auto; width: 100%; }
.login-box h2 { font-size: 23px; }
.section { margin-bottom: 30px; }
.toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-row b { font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--surface);
  padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: rise .18s ease;
  max-width: calc(100vw - 32px); text-align: center;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
