/* ───────── Tokens ───────── */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --line: #dfe4ee;
  --line-strong: #c4ccdc;
  --text: #13213c;
  --muted: #5d6a82;
  --navy: #13213c;
  --navy-2: #1d3157;
  --teal: #2a7799;
  --teal-soft: #c9dfea;
  --blue: #2f55d4;
  --blue-press: #2546b5;
  --red: #c42b2b;
  --red-soft: #fde8e8;
  --green: #1e7a3f;
  --green-soft: #e3f4e8;
  --amber: #fde8a6;
  --amber-text: #7a5600;
  --chip: #eef1f7;
  --focus: #2f55d4;
  --shadow: 0 1px 2px rgba(19, 33, 60, .06), 0 4px 16px rgba(19, 33, 60, .06);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1424; --surface: #151f33; --surface-2: #1a2640; --line: #26344f; --line-strong: #34466a;
    --text: #e8edf7; --muted: #9aa8c2; --navy: #0a1120; --navy-2: #22365e; --teal: #22617f; --teal-soft: #1d3a4d;
    --blue: #5b7cf0; --blue-press: #4a6be0; --red: #ff7b7b; --red-soft: #3a1d24; --green: #6fd394; --green-soft: #183326;
    --amber: #4a3c12; --amber-text: #ffd76a; --chip: #1f2c47; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1424; --surface: #151f33; --surface-2: #1a2640; --line: #26344f; --line-strong: #34466a;
  --text: #e8edf7; --muted: #9aa8c2; --navy: #0a1120; --navy-2: #22365e; --teal: #22617f; --teal-soft: #1d3a4d;
  --blue: #5b7cf0; --blue-press: #4a6be0; --red: #ff7b7b; --red-soft: #3a1d24; --green: #6fd394; --green-soft: #183326;
  --amber: #4a3c12; --amber-text: #ffd76a; --chip: #1f2c47; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ───────── Base ───────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 32px; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 17px; font-weight: 800; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 6px 0 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.boot { display: grid; place-items: center; min-height: 80vh; color: var(--muted); }
.print-only { display: none; }

/* ───────── Controls ───────── */
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235d6a82' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
textarea { resize: vertical; min-height: 42px; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--blue); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.field.grow { flex: 1 1 220px; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline select { width: auto; min-width: 100px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 700; white-space: nowrap;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-press); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-ghost { color: var(--red); }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.xs { min-height: 28px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.three > .btn { flex: 1 1 0; }
.icon-btn { display: inline-grid; place-items: center; min-width: 40px; height: 40px; border: 0; background: transparent; border-radius: 10px; color: var(--muted); font-size: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { min-width: 30px; height: 30px; font-size: 16px; }
.icon-btn:disabled { opacity: .3; }
.link-btn { border: 0; background: none; color: var(--blue); font-weight: 600; padding: 6px 0; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; gap: 3px; }
.segmented button { border: 0; background: transparent; padding: 8px 16px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pill { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--chip); font-size: 12px; font-weight: 800; color: var(--muted); }
.pill.light { background: rgba(255,255,255,.22); color: #fff; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; }
.badge.paid { background: var(--green-soft); color: var(--green); }
.badge.unpaid { background: var(--red-soft); color: var(--red); }
.form-error { color: var(--red); font-size: 14px; min-height: 1em; margin: 4px 0; }
.warn-text { color: var(--red) !important; }

/* ───────── Header / tabs ───────── */
.app-header {
  position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line); padding-top: var(--safe-t);
}
.header-inner { max-width: 1320px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 20px; min-height: var(--header-h); }
.top-tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.top-tab { border: 0; background: transparent; padding: 10px 16px; border-radius: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; font-size: 15px; }
.top-tab:hover { background: var(--surface-2); color: var(--text); }
.top-tab[aria-current] { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .top-tab[aria-current] { background: var(--blue); }
.header-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.save-status { font-size: 13px; font-weight: 700; color: var(--green); white-space: nowrap; }
.save-status.pending, .save-status.saving { color: var(--muted); }
.save-status.error { color: var(--red); }
.mobile-title { display: none; font-weight: 800; font-size: 18px; }
.bottom-tabs { display: none; }

.view { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; display: flex; flex-direction: column; gap: 18px; }
.view > *, .groups > *, .ts-groups > *, .worker-list > *, .group-card, .table-scroll { min-width: 0; max-width: 100%; }
html, body { overflow-x: clip; }

/* ───────── Cards ───────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.hero-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); margin-bottom: 4px; }
.eyebrow.light { color: rgba(255,255,255,.85); }
.count-badge { background: var(--navy); color: #fff; border-radius: 14px; padding: 10px 18px; text-align: center; display: grid; min-width: 96px; }
:root[data-theme="dark"] .count-badge { background: var(--navy-2); }
.count-badge strong { font-size: 26px; line-height: 1.1; }
.count-badge span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.add-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 18px; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }
.card > .add-row:first-child { margin-top: 0; }
.add-row .field:not(.grow) { flex: 0 1 220px; }
.week-toggle { margin-top: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.empty-state { text-align: center; padding: 26px; }

/* ───────── Drag ───────── */
.drag-handle { cursor: grab; color: var(--muted); user-select: none; touch-action: none; font-size: 16px; padding: 6px 4px; line-height: 1; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: .95; box-shadow: 0 12px 30px rgba(0,0,0,.25); transform: rotate(1deg); }
.drag-ghost-table { border-collapse: collapse; background: var(--surface); box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.drag-placeholder { background: color-mix(in srgb, var(--blue) 10%, transparent) !important; border: 2px dashed color-mix(in srgb, var(--blue) 45%, transparent) !important; border-radius: 10px; }
.drag-placeholder > * { visibility: hidden; }
body.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }

/* ───────── Payday board ───────── */
.payday-board { display: grid; grid-template-columns: repeat(7, minmax(160px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.day-col { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--line-strong); border-radius: 14px; padding: 12px; min-height: 260px; display: flex; flex-direction: column; }
.day-col[data-day="Sunday"] { border-top-color: #9aa3b5; }
.day-col[data-day="Monday"] { border-top-color: #7b5cc8; }
.day-col[data-day="Tuesday"] { border-top-color: #2f55d4; }
.day-col[data-day="Wednesday"] { border-top-color: #22848c; }
.day-col[data-day="Thursday"] { border-top-color: #2f8a4e; }
.day-col[data-day="Friday"] { border-top-color: #d48a1f; }
.day-col[data-day="Saturday"] { border-top-color: #c4462b; }
.day-col-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; padding: 2px 2px 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.chip-list { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 60px; }
.chip { display: flex; align-items: center; gap: 4px; background: var(--chip); border: 1px solid var(--line); border-radius: 10px; padding: 4px 4px 4px 6px; min-height: 44px; }
.chip-name { flex: 1; min-width: 0; border: 0; background: none; text-align: left; font-weight: 800; padding: 6px 2px; overflow-wrap: anywhere; line-height: 1.2; }
.chip-x { border: 0; background: none; color: var(--muted); font-size: 20px; width: 32px; height: 32px; border-radius: 8px; }
.chip-x:hover { background: var(--red-soft); color: var(--red); }
.drop-hint { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 14px 8px; text-align: center; color: var(--muted); font-size: 12px; }
.chip-list .chip ~ .drop-hint { display: none; }

/* ───────── Schedule / summary tables ───────── */
.groups { display: flex; flex-direction: column; gap: 18px; }
.group-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.group-head { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--teal); color: #fff; padding: 12px 16px; }
.group-head h2 { font-size: 16px; letter-spacing: .06em; }
.group-head .pill { background: rgba(255,255,255,.22); color: #fff; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
table { border-collapse: collapse; width: 100%; }
.sched-table, .sum-table { min-width: 860px; font-size: 13px; }
.sched-table thead th, .sum-table thead th { background: var(--navy-2); color: #fff; font-weight: 700; padding: 9px 6px; font-size: 12px; text-align: center; }
.sched-table tbody th, .sum-table tbody th { color: var(--text); font-weight: 800; }
:root:not([data-theme="dark"]) .sched-table thead th, :root:not([data-theme="dark"]) .sum-table thead th { background: #1b3157; }
.sched-table td, .sched-table tbody th, .sum-table td, .sum-table tbody th { border: 1px solid var(--line); padding: 0; text-align: center; background: var(--surface); }
.sched-table tbody tr:nth-child(even) td, .sched-table tbody tr:nth-child(even) th { background: var(--surface-2); }
.sched-table .col-move, .sum-table .col-move { width: 44px; }
.sched-table .col-more { width: 40px; }
.sched-table .col-name { min-width: 150px; position: sticky; left: 0; z-index: 2; }
.sched-table tbody .col-name { box-shadow: 1px 0 0 var(--line); }
.sched-table input { border: 0; border-radius: 0; background: transparent; text-align: center; min-height: 40px; padding: 6px 4px; font-size: 13px; }
.sched-table input:focus { box-shadow: inset 0 0 0 2px var(--blue); }
.sched-table .name-input { font-weight: 800; }
.sched-table td.off input, .sched-table td.off .cell-btn { color: var(--red); font-weight: 800; }
.sched-table .short { display: none; }
.cell-btn { width: 100%; min-height: 44px; border: 0; background: transparent; font-size: 13px; padding: 4px; }
.empty-row td { color: var(--muted); padding: 16px !important; font-size: 13px; }

.sum-table .col-name { text-align: left; min-width: 220px; position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 var(--line); }
.sum-table thead .col-name { padding-left: 14px; }
.sum-table td.num { font-size: 15px; font-weight: 600; min-width: 84px; }
.sum-table .total { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 99px; background: var(--navy); color: #fff; font-weight: 800; padding: 0 8px; }
:root[data-theme="dark"] .sum-table .total { background: var(--blue); }
.emp-cell { padding: 8px 10px !important; text-align: left; }
.emp-line { display: flex; align-items: center; gap: 4px; }
.link-name { border: 0; background: none; font-weight: 800; font-size: 15px; padding: 4px; flex: 1; text-align: left; color: var(--text); }
.link-name:hover { color: var(--blue); text-decoration: underline; }
.note-input { min-height: 34px; font-size: 13px; padding: 6px 10px; margin-top: 4px; }

/* ───────── Time off lookup ───────── */
.lookup { padding: 0; overflow: hidden; }
.lookup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; background: var(--teal); color: #fff; padding: 18px 20px; }
.lookup-head h1 { font-size: 24px; }
.lookup-head .pill.light { height: 28px; padding: 0 12px; white-space: nowrap; }
.lookup-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.lookup-body > .btn.primary { align-self: flex-start; }
.entries { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.entry { display: grid; grid-template-columns: 140px 150px 1fr 34px; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry-date { display: flex; flex-direction: column; }
.entry-type { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; font-weight: 700; }
.entry-note { font-size: 14px; }
.entries .empty { padding: 16px; margin: 0; }

/* ───────── Timesheet ───────── */
.ts-controls { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.hint { margin: 0; }
.qe { padding: 0; overflow: hidden; }
.qe summary { list-style: none; cursor: pointer; padding: 14px 20px; background: var(--teal-soft); display: flex; flex-direction: column; gap: 2px; }
.qe summary::-webkit-details-marker { display: none; }
.qe summary .eyebrow { color: var(--muted); margin: 0; font-size: 11px; }
.qe summary::after { content: '▾'; position: absolute; right: 22px; margin-top: 8px; color: var(--muted); }
.qe { position: relative; }
.qe[open] summary::after { content: '▴'; }
.qe-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.qe-body > .btn { align-self: flex-start; min-width: 240px; }
.ts-groups { display: flex; flex-direction: column; gap: 16px; }
.ts-group { display: flex; flex-direction: column; gap: 14px; }
.ts-group-head { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--teal); color: #fff; border-radius: 14px; padding: 12px; }
.ts-group-head h2 { letter-spacing: .08em; }
.worker-list { display: flex; flex-direction: column; gap: 14px; }
.worker { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.worker-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; background: var(--teal-soft); }
.worker-name { border: 0; background: none; font-size: 20px; font-weight: 900; letter-spacing: .01em; padding: 4px 6px; border-radius: 8px; min-width: 120px; text-align: left; }
.worker-name:hover { background: rgba(255,255,255,.4); }
.worker-fields { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-left: auto; }
.worker-fields select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; font-weight: 600; width: 130px; }
.paycycle { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; padding-bottom: 7px; }

.ts-grid { display: flex; flex-direction: column; }
.ts-row { display: grid; grid-template-columns: 1.2fr repeat(6, 1fr); border-top: 1px solid var(--line); }
.ts-headrow { background: #1b3157; color: #fff; font-size: 13px; font-weight: 800; border-top: 0; }
:root[data-theme="dark"] .ts-headrow { background: var(--navy-2); }
.ts-h { padding: 9px 8px; text-align: center; }
.ts-h.c0 { text-align: left; }
.ts-day { border: 0; background: var(--surface-2); text-align: left; padding: 8px 10px; font-weight: 800; font-size: 14px; display: flex; flex-direction: column; justify-content: center; gap: 2px; border-right: 1px solid var(--line); min-height: 42px; }
.ts-day:hover { background: var(--chip); }
.tag { display: inline-block; font-size: 10px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tag.pay { color: var(--amber-text); }
.ts-c { border-right: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; }
.ts-c:last-child { border-right: 0; }
.ts-c.num { padding: 0 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ts-c input.time { border: 0; border-radius: 0; background: transparent; text-align: right; min-height: 42px; padding: 6px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.ts-c input.time::placeholder { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.ts-c input.time:focus { box-shadow: inset 0 0 0 2px var(--blue); }
.ts-c input.time.bad { box-shadow: inset 0 0 0 2px var(--red); }
.ts-row.payday, .ts-row.payday .ts-day { background: var(--amber); }
.ts-row.payday .ts-c input, .ts-row.payday .ts-c { color: var(--amber-text); font-weight: 800; }
.ts-row.extra .ts-day { background: color-mix(in srgb, var(--blue) 8%, var(--surface-2)); }
.ts-off { grid-column: 2 / -1; display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 8px, var(--surface) 8px, var(--surface) 16px); }
.off-tag { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--red); }
.ts-totals { border-top: 2px solid var(--line-strong); }
.tot { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line); font-weight: 700; }
.tot:first-child { border-top: 0; }
.tot span { color: var(--muted); }
.tot strong { font-variant-numeric: tabular-nums; font-size: 16px; min-width: 70px; text-align: right; }
.tot.final { background: var(--surface-2); }
.tot.final span { color: var(--text); font-weight: 900; }
.tot.final strong { font-size: 20px; }
.toggle-breaks { display: none; margin: 0 14px; }
.notes-field { padding: 10px 14px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* ───────── Modal / menu / toast ───────── */
.modal-wrap { position: fixed; inset: 0; z-index: 200; background: rgba(8, 14, 28, .45); display: grid; place-items: center; padding: 20px; opacity: 0; transition: opacity .18s; }
.modal-wrap.in { opacity: 1; }
.modal { width: min(460px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); transform: translateY(10px); transition: transform .18s; }
.modal.wide { width: min(640px, 100%); }
.modal-wrap.in .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 6px 20px; }
.modal-head h2 { font-size: 19px; }
.modal-body { padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.menu-list { display: flex; flex-direction: column; margin: 0 -8px; }
.menu-item { border: 0; background: none; text-align: left; padding: 13px 12px; border-radius: 10px; font-weight: 600; font-size: 15px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--red); }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(520px, calc(100% - 24px)); }
.toast { pointer-events: auto; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.3); opacity: 0; transform: translateY(10px); transition: .2s; font-size: 14px; font-weight: 600; }
:root[data-theme="dark"] .toast { background: #2a3b60; }
.toast.in { opacity: 1; transform: none; }
.toast.warn { background: #8a2323; }
.toast-btn { border: 0; background: rgba(255,255,255,.18); color: #fff; font-weight: 800; padding: 6px 12px; border-radius: 8px; }

/* Settings */
.settings { display: flex; flex-direction: column; gap: 18px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.warn-box { background: color-mix(in srgb, var(--amber) 45%, var(--surface)); border-color: color-mix(in srgb, var(--amber-text) 25%, transparent); }
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.tab-edit-list { display: flex; flex-direction: column; gap: 8px; }
.tab-edit-row { display: flex; align-items: center; gap: 6px; }

/* Login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; padding-top: calc(24px + var(--safe-t)); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 28px; }
.login-card p { margin: 0; }
.login-logo { display: flex; justify-content: center; margin-bottom: 4px; }
.login-logo img { width: min(260px, 78%); height: auto; display: block; }
.login-logo .logo-dark { display: none; }
:root[data-theme="dark"] .login-logo .logo-light { display: none; }
:root[data-theme="dark"] .login-logo .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-logo .logo-light { display: none; }
  :root:not([data-theme="light"]) .login-logo .logo-dark { display: block; }
}
.login-card h1 { text-align: center; }
.login-card > p.muted:first-of-type { text-align: center; }

/* ───────── Phone ───────── */
@media (max-width: 760px) {
  body { font-size: 15px; }
  h1 { font-size: 26px; }
  .header-inner { padding: 8px 12px 8px 16px; min-height: 52px; }
  .top-tabs { display: none; }
  .mobile-title { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .save-status { font-size: 12px; }
  .undo-btn { padding: 0 10px; }
  .bottom-tabs {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
  }
  .bottom-tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 700; }
  .bottom-tab[aria-current] { color: var(--blue); }
  .view { padding: 14px 12px calc(96px + var(--safe-b)); gap: 14px; }
  .card { padding: 16px; border-radius: 14px; }
  .count-badge { padding: 8px 14px; min-width: 80px; }
  .count-badge strong { font-size: 22px; }
  .add-row { padding: 12px; gap: 10px; }
  .add-row .field:not(.grow) { flex: 1 1 140px; }
  .add-row .btn { flex: 1 1 100%; }
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  input, select, textarea { font-size: 16px; } /* prevents iPhone auto-zoom */

  /* payday: stacked days */
  .payday-board { grid-template-columns: 1fr; overflow: visible; }
  .day-col { min-height: 0; }
  .chip-list { flex-direction: row; flex-wrap: wrap; min-height: 46px; }
  .chip { flex: 0 1 auto; max-width: 100%; }
  .chip-name { max-width: 180px; }
  .drop-hint { flex: 1 1 100%; padding: 10px; }

  .sched-table, .sum-table { min-width: 0; }
  .sched-table .long { display: none; }
  .sched-table .short { display: inline; }
  .sched-table .col-name { min-width: 112px; max-width: 120px; }
  .sched-table td.cell { min-width: 94px; }
  .sched-table .col-move { width: 34px; }
  .sched-table input, .sched-table .cell-btn { font-size: 13px; }
  .sched-table .name-input { font-size: 14px; }
  .sum-table .col-name { min-width: 168px; max-width: 180px; }
  .sum-table td.num { min-width: 64px; }
  .sum-table thead th { font-size: 11px; }

  .lookup-head { padding: 16px; }
  .lookup-head h1 { font-size: 21px; }
  .lookup-body { padding: 14px 16px; }
  .lookup-body > .btn.primary { align-self: stretch; }
  .entry { grid-template-columns: 1fr auto; grid-template-areas: "date edit" "type type" "note note"; gap: 6px; }
  .entry-date { grid-area: date; flex-direction: row; gap: 8px; align-items: baseline; }
  .entry-type { grid-area: type; flex-direction: row; align-items: center; gap: 8px; }
  .entry-note { grid-area: note; color: var(--muted); }
  .entry > .icon-btn { grid-area: edit; }

  .hero-top .btn-row { width: 100%; }
  .hero-top .btn-row .btn { flex: 1 1 auto; }
  .btn-row.three { display: grid; grid-template-columns: 1fr 1fr; }
  .btn-row.three > .btn:first-child { grid-column: span 2; }
  .qe summary { padding: 12px 16px; }
  .qe-body { padding: 14px 16px 16px; }
  .qe-body > .btn { align-self: stretch; }

  .worker-head { padding: 10px 12px; gap: 6px; }
  .worker-name { font-size: 18px; flex: 1; }
  .worker-fields { width: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 0; }
  .worker-fields select { width: 100%; font-size: 15px; padding-left: 8px; padding-right: 22px; background-position: right 7px center; }
  .paycycle { grid-column: 1 / -1; flex-direction: row; align-items: baseline; gap: 8px; padding: 0; }

  /* timesheet rows → two lines on phones; breaks only when shown */
  .ts-row { grid-template-columns: 68px minmax(0, 1fr) minmax(0, 1fr) 56px; grid-template-areas: "d i o h" "d bs be bt"; }
  .ts-c { min-width: 0; }
  .ts-c input.time { min-width: 0; width: 100%; }
  .ts-c input.time::-webkit-calendar-picker-indicator { display: none; }
  .ts-headrow { grid-template-areas: "d i o h"; font-size: 11px; }
  .ts-headrow .c4, .ts-headrow .c5, .ts-headrow .c6 { display: none; }
  .ts-h { padding: 7px 4px; }
  .ts-h.c0 { grid-area: d; } .ts-h.c1 { grid-area: i; } .ts-h.c2 { grid-area: o; } .ts-h.c3 { grid-area: h; }
  .ts-day { grid-area: d; font-size: 13px; padding: 6px 8px; }
  .ts-c.c1 { grid-area: i; } .ts-c.c2 { grid-area: o; } .ts-c.c3 { grid-area: h; border-right: 0; padding: 0 8px; }
  .ts-c.c4 { grid-area: bs; } .ts-c.c5 { grid-area: be; } .ts-c.c6 { grid-area: bt; border-right: 0; padding: 0 8px; }
  .worker:not(.show-breaks) .ts-c.c4, .worker:not(.show-breaks) .ts-c.c5, .worker:not(.show-breaks) .ts-c.c6 { display: none; }
  .worker.show-breaks .ts-c.c4, .worker.show-breaks .ts-c.c5, .worker.show-breaks .ts-c.c6 { border-top: 1px dashed var(--line); background: var(--surface-2); }
  .worker.show-breaks .ts-c.c4::before { content: 'Break'; font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--muted); padding-left: 8px; }
  .ts-c input.time { font-size: 16px; text-align: center; padding: 4px; min-height: 44px; }
  .ts-c.num { font-size: 14px; justify-content: center; }
  .ts-off { grid-area: i / i / h / h; }
  .worker.show-breaks .ts-row.dayoff { grid-template-areas: "d i o h"; }
  .toggle-breaks { display: inline-block; }
  .tot { padding: 8px 12px; font-size: 14px; }

  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0; padding-bottom: var(--safe-b); transform: translateY(40px); }
  .modal-actions .btn { flex: 1; }
  #toast-root { bottom: calc(84px + var(--safe-b)); }
}
@media (max-width: 380px) {
  .grid-2 { grid-template-columns: 1fr; }
  .worker-fields { grid-template-columns: 1fr 1fr; }
}

/* Touch devices: bigger targets */
@media (pointer: coarse) {
  .drag-handle { padding: 10px 8px; font-size: 18px; }
  .icon-btn.sm { min-width: 36px; height: 36px; }
}

/* ───────── Print ───────── */
@media print {
  @page { margin: 12mm; }
  :root { --bg: #fff; --surface: #fff; --surface-2: #f4f4f4; --shadow: none; color-scheme: light; }
  body { background: #fff; font-size: 11px; }
  .app-header, .bottom-tabs, .no-print, .qe, #toast-root, .drag-handle, .toggle-breaks, .count-badge, .add-row { display: none !important; }
  .print-only { display: block; font-weight: 800; font-size: 14px; margin-top: 6px; }
  .view { padding: 0; max-width: none; }
  .card, .worker, .group-card { box-shadow: none; }
  .worker { break-inside: avoid; margin-bottom: 8px; }
  .ts-row { grid-template-columns: 1.2fr repeat(6, 1fr) !important; grid-template-areas: none !important; }
  .ts-row > * { grid-area: auto !important; display: flex !important; }
  .ts-off { grid-column: 2 / -1 !important; }
  .ts-c input.time { font-size: 11px; min-height: 26px; }
  input, select, textarea { border-color: #ccc; }
}
