/* Visual design (Spec §53): white, clean, neutral, calm, uncluttered. */
:root {
  /* Warm neutral tones (A41, replacing the original "white" in Spec §53) */
  --bg: #f6f4ef;         /* page: warm oat, not stark white */
  --field: #fbfaf7;      /* inputs, sticky column, light buttons */
  --surface: #ece9e2;    /* headings, panels */
  --border: #ddd8ce;
  --text: #2e2c28;
  --muted: #6b665d;
  --draft: #e6e2d9;      /* subtle grey-beige */
  --published: #dce8d8;  /* soft sage green */
  --warning: #f3e6c9;    /* muted amber */
  --danger: #9a3b34;     /* restrained red */
  --focus: #6b7f5e;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: inherit; }
h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 1rem; }
p.muted, .muted { color: var(--muted); }

/* Forms and buttons: neutral */
label { display: block; font-weight: 500; margin: 1rem 0 .35rem; }
input[type=email], input[type=password], input[type=text] {
  width: 100%; padding: .7rem .8rem; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--field);
}
input:focus, button:focus, a:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
button, .button {
  display: inline-block; margin-top: 1.25rem; padding: .7rem 1.2rem; font-size: 1rem; font-weight: 500;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
}
button.primary, .button.primary { background: var(--text); border-color: var(--text); color: var(--field); }
.errors { background: var(--warning); border-radius: 8px; padding: .6rem .8rem; margin: 1rem 0 0; }
.errors ul { margin: 0; padding-left: 1.1rem; }
.helptext, .form-help { color: var(--muted); font-size: .9rem; }

/* Single-column pages: login, password, worker */
.narrow { max-width: 420px; margin: 0 auto; padding: 3rem 16px; }
.brand { font-size: .95rem; color: var(--muted); margin-bottom: 2rem; }
.link-row { margin-top: 1.25rem; font-size: .95rem; }

/* Admin layout: left navigation (Spec §13); a top bar on narrow screens */
.admin { display: flex; min-height: 100vh; }
.admin nav { width: 220px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 1.5rem 1rem; display: flex; flex-direction: column; }
.admin nav .brand { margin-bottom: 1.5rem; }
.admin nav a.nav { display: block; padding: .55rem .75rem; border-radius: 8px; text-decoration: none; margin-bottom: .2rem; }
.admin nav a.nav.active { background: var(--surface); font-weight: 600; }
.admin nav form { margin-top: auto; }
.admin main { flex: 1; padding: 2rem; min-width: 0; }
@media (max-width: 900px) {
  .admin { flex-direction: column; }
  .admin nav { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .25rem; border-right: 0; border-bottom: 1px solid var(--border); padding: .75rem 16px; }
  .admin nav .brand { width: 100%; margin-bottom: .25rem; }
  .admin nav form { margin: 0 0 0 auto; }
  .admin nav form button { margin-top: 0; }
  .admin main { padding: 1.25rem 16px; }
}

/* Admin pages: headings, tables, actions */
h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
section { margin-top: 2.25rem; }
.page-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }
.page-head .button, .section-head .button { margin-top: 0; }
.crumb { font-size: .9rem; color: var(--muted); margin: 0 0 .75rem; }
.crumb a { color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0 0; }
.actions button { margin-top: 0; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th, table.list td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list th { font-weight: 500; color: var(--muted); background: var(--surface); }
table.list td a { text-decoration: none; }
table.list td a:hover { text-decoration: underline; }
table.narrow-table { max-width: 480px; }
.row-actions { text-align: right; }
.row-actions a { margin-left: .75rem; text-decoration: underline !important; }
button.danger { border-color: var(--danger); color: var(--danger); background: var(--field); }
.form { max-width: 480px; }
.form .button { margin-left: .5rem; }
.message { padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; background: var(--published); }
.message.info { background: var(--surface); }
input[type=date], input[type=number] {
  width: 100%; padding: .7rem .8rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--field);
}

/* Tablets (A30.3): narrower menu and tighter tables so rate tables fit an upright iPad */
@media (max-width: 1100px) and (min-width: 901px) {
  .admin nav { width: 170px; padding: 1.25rem .75rem; }
  .admin main { padding: 1.5rem 1.25rem; }
}
@media (max-width: 1100px) {
  table.list th, table.list td { padding: .55rem .5rem; }
  table.list th { white-space: normal; }
  .row-actions a { margin-left: .5rem; }
}

/* Rota (Stage 3): draft = subtle grey, published = pale green (Spec §22, §53) */
.rota-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.rota-controls .button, .rota-controls button { margin-top: 0; }
.rota-controls .button.selected { background: var(--text); color: var(--field); border-color: var(--text); }
.range-form { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.range-form label { margin: 0; font-weight: 400; color: var(--muted); }
.range-form input[type=date] { width: auto; padding: .5rem .6rem; }
.prev-next { display: inline-flex; gap: .5rem; margin-left: auto; }
.legend { margin: .25rem 0 .75rem; font-size: .85rem; }
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 6px; border: 1px solid var(--border); }
.rota-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table.rota { border-collapse: collapse; border-style: hidden; width: 100%; font-size: .9rem; }
table.rota th, table.rota td { border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); vertical-align: top; padding: .3rem; min-width: 80px; }
table.rota thead th { background: var(--surface); font-weight: 500; text-align: left; }
table.rota th.bh { background: var(--warning); }
.day-name { white-space: nowrap; }
.bh-form label { display: inline-flex; align-items: center; gap: .25rem; margin: .2rem 0 0; font-weight: 400; font-size: .8rem; color: var(--muted); }
.bh-mark { font-size: .75rem; font-weight: 600; margin-top: .15rem; }
.worker-col { position: sticky; left: 0; background: var(--field); z-index: 1; min-width: 88px; border-left: 0 !important; }
thead .worker-col { background: var(--surface); }
.worker-name { font-weight: 600; }
.worker-hours { color: var(--muted); font-size: .85rem; font-weight: 400; }
a.shift { display: block; padding: .3rem .3rem; font-size: .85rem; margin-bottom: .3rem; border-radius: 6px; border: 1px solid var(--border); text-decoration: none; white-space: nowrap; }
.draft, a.shift.draft { background: var(--draft); }
.published, a.shift.published { background: var(--published); border-color: #c5d6c0; }
.pending-delete, a.shift.pending-delete { background: var(--field); color: var(--muted); text-decoration: line-through; border-style: dashed; }
.night { display: block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
a.add-shift { display: block; text-align: center; color: var(--muted); text-decoration: none; border: 1px dashed var(--border); border-radius: 6px; padding: .15rem 0; }
a.add-shift:hover { color: var(--text); border-color: var(--muted); }
.delete-form { margin-top: 2rem; }
input[type=time] { width: 100%; padding: .7rem .8rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--field); }
select { width: 100%; padding: .7rem .8rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--field); }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; }

/* Month and longer ranges: stacked Mon–Sun week blocks with worker rows (A42) */
table.rota.blocks tbody.week-block tr.block-head th { background: var(--surface); border-top: 2px solid var(--border); }
table.rota.blocks tbody.week-block:first-child tr.block-head th { border-top: 0; }
table.rota.blocks th.outside, table.rota.blocks td.outside { background: var(--surface); color: var(--muted); }
table.rota.blocks th.bh { background: var(--warning); }
table.rota .worker-hours { white-space: nowrap; font-size: .75rem; line-height: 1.35; }
table.rota.blocks .day-name { font-size: .8rem; }
table.rota.blocks th, table.rota.blocks td { min-width: 76px; }
table.rota.blocks .worker-col { min-width: 84px; }
table.rota.blocks .day-name { white-space: normal; }

/* NS (No Shift) days: whole day greyed as a reminder (A43.2); week notes (A43.1) */
.day-flags { display: flex; gap: .5rem; flex-wrap: wrap; }
table.rota th.ns, table.rota td.ns { background: repeating-linear-gradient(135deg, #e3dfd6, #e3dfd6 6px, #ddd8ce 6px, #ddd8ce 12px); }
.ns-mark { font-size: .75rem; font-weight: 600; margin-top: .15rem; color: var(--muted); }
tr.note-row td, tr.note-row th { background: var(--field); font-size: .85rem; }
.note-label { color: var(--muted); font-weight: 500; }
.week-note { margin-right: .75rem; }
.note-link { font-size: .85rem; color: var(--muted); }
textarea { width: 100%; padding: .7rem .8rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; background: var(--field); }

/* Drag and drop (checkpoint 3b) */
.cell-shifts { min-height: 1.75rem; }
a.shift { cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.drag-ghost { opacity: .4; }
.drag-chosen { box-shadow: 0 2px 8px rgba(46, 44, 40, .25); }
body.saving { cursor: progress; }
body.saving .rota-wrap { opacity: .6; pointer-events: none; }
.drag-help { margin-top: .75rem; }

/* Publish and Dashboard (checkpoint 3c) */
.publish-button { margin-right: .5rem; }
.dash-section { margin-top: 1rem; }
table.dash-week { max-width: 640px; }
table.dash-week th { width: 7rem; background: var(--surface); }
table.dash-week td { white-space: normal; }
.dash-shift { margin: .1rem 0; }
.night.inline { display: inline; }
.or-heading { margin-top: 1.5rem; }
input[type=text] { width: 100%; padding: .7rem .8rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--field); }

/* Worker app (Stage 4): phone first, calm, very simple (Spec §25) */
.worker { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; padding: 0 16px; }
.worker-top { padding: 1rem 0 .5rem; }
.worker-top .brand { margin-bottom: .75rem; }
.worker-tabs { display: flex; gap: .5rem; }
.worker-tabs a { flex: 1; text-align: center; padding: .6rem; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; background: var(--field); }
.worker-tabs a.active { background: var(--text); color: var(--field); border-color: var(--text); }
.worker-main { flex: 1; padding: 1.5rem 0; }
.worker-foot { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0 1.5rem; border-top: 1px solid var(--border); }
.worker-foot button { margin-top: 0; }
.today-label { font-size: 1.1rem; font-weight: 700; letter-spacing: .04em; margin: 0 0 .25rem; }
.today-time { font-size: 2rem; font-weight: 600; margin: 0 0 .25rem; }
.big-button { display: block; width: 100%; margin-top: 1.5rem; padding: 1.1rem; font-size: 1.25rem; font-weight: 700; letter-spacing: .04em; background: var(--text); color: var(--field); border-color: var(--text); border-radius: 12px; }
.small-button { display: block; width: 100%; margin-top: 1rem; font-size: .95rem; }
.early-note { margin-top: 1.5rem; padding: .8rem; background: var(--warning); border-radius: 8px; }
.shift-list { list-style: none; padding: 0; margin: 0; }
.shift-list li { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: .5rem; padding: .8rem 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.sl-date { font-weight: 600; }
.sl-time { font-variant-numeric: tabular-nums; }
.ts-list, .ts-history { list-style: none; padding: 0; margin: 0; }
.ts-list li { padding: .9rem 0; border-bottom: 1px solid var(--border); }
.ts-head { display: flex; justify-content: space-between; align-items: baseline; }
.ts-date { font-weight: 600; }
.ts-status { white-space: nowrap; font-size: .8rem; padding: .1rem .5rem; border-radius: 6px; background: var(--draft); }
.ts-status.status-approved { background: var(--published); }
.ts-status.status-not-clocked-in { background: var(--warning); }
.ts-line { margin-top: .2rem; }
.ts-action { margin-top: .5rem; font-size: .9rem; padding: .45rem .9rem; }
.ts-history li { padding: .35rem 0; font-size: .9rem; color: var(--muted); }
.worker-tabs a { font-size: .9rem; padding: .6rem .3rem; }
.wmark { display: block; font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
span.shift.unscheduled { display: block; padding: .3rem .3rem; margin-bottom: .3rem; border-radius: 6px; border: 1px dashed #b9c9b3; font-size: .85rem; cursor: default; }

/* Timesheets (Stage 5) */
.sheet-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: 1rem; }
.sheet-filter label { margin: 0; font-weight: 400; color: var(--muted); }
.sheet-filter select, .sheet-filter input[type=date] { width: auto; padding: .5rem .6rem; }
.sheet-filter button { margin-top: 0; }
.bulk-actions { display: flex; gap: .5rem; margin-bottom: .5rem; }
.bulk-actions button { margin-top: 0; }
table.sheet td { vertical-align: top; }
table.sheet td.wrap { white-space: normal; max-width: 14rem; }
table.sheet tr.is-approved td { background: var(--published); }
.small { font-size: .78rem; }
td.row-actions.stacked { white-space: normal; text-align: left; font-size: .85rem; line-height: 1.6; }
td.row-actions.stacked a { display: block; margin-left: 0; white-space: nowrap; }
table.sheet th, table.sheet td { padding: .5rem .45rem; }
table.sheet th, table.sheet td { white-space: normal; }
table.sheet tbody td:nth-child(3), table.sheet tbody td:nth-child(4), table.sheet tbody td:nth-child(6), table.sheet tbody td:nth-child(7), table.sheet tbody td:nth-child(8), table.sheet tbody td:nth-child(9) { white-space: nowrap; }
table.sheet tfoot td { white-space: nowrap; border-top: 2px solid var(--border); }
table.sheet tfoot td:first-child { white-space: normal; }
.sheet-summary { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0 0 1rem; padding: .75rem 1rem; background: var(--field); border: 1px solid var(--border); border-radius: 8px; }
.sheet-summary span.muted:first-child { display: block; font-size: .8rem; }
.friday-report { padding: 1rem; background: var(--warning); border-radius: 8px; margin-bottom: 1.5rem; }
.friday-report .section-head button { margin-top: 0; }
.friday-report table.list th { background: rgba(255,255,255,.5); }

/* Holiday (Stage 6) */
.unavailable { font-size: .75rem; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); padding: .15rem .35rem; margin-bottom: .25rem; border-radius: 4px;
  background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 4px, var(--draft) 4px, var(--draft) 8px); }
.ts-status.status-pending { background: var(--warning); }
.ts-status.status-declined, .ts-status.status-cancelled { background: var(--surface); color: var(--muted); }
.hol-alert { padding: 1rem; background: var(--warning); border-radius: 8px; margin-bottom: 1.5rem; }
.hol-alert h2 { margin-top: 0; }
.hol-alert ul { margin: 0; padding-left: 1.2rem; }
.hol-alert li { margin: .3rem 0; }
.hol-balance { background: var(--surface); border-radius: 8px; padding: .6rem 1rem; margin-bottom: .75rem; }
.hol-balance h2 { margin: 0 0 .3rem; font-size: 1rem; }
.hol-balance dl { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; margin: 0; }
.hol-balance dt { font-size: .8rem; color: var(--muted); }
.hol-balance dd { margin: 0; }
.hol-hours { display: flex; align-items: center; gap: .4rem; }
.hol-hours input { width: 5rem; }
.hol-shifts ul { padding-left: 1.2rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: normal; }
label.check input { width: auto; }
.hol-part { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.hol-part h2 { margin-top: 0; }
.head-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.hol-unavailable, .hol-conflicts { background: var(--warning); }
.hol-unavailable p { margin: 0 0 .3rem; font-weight: 600; }
.hol-unavailable ul, .hol-conflicts ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* Pay (Stage 7) */
.sheet-links { margin: .5rem 0 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.pay-warning { background: var(--warning); }
.pay-table td:nth-child(n+2), .pay-table th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.pay-table tfoot th { border-top: 2px solid var(--text); }
.pay-table tbody.pay-total th { border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); }
.pay-table td:first-child, .pay-table th:first-child { text-align: left; }
.report-shifts td:nth-child(-n+4), .report-shifts th:nth-child(-n+4) { text-align: left; }
.report-shifts tr.part td { border-top: none; }
.report-form { display: grid; gap: .75rem; margin-bottom: 1rem; }
.report-form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .9rem .7rem; margin: 0; }
.report-form legend { font-weight: 600; padding: 0 .3rem; }
.report-workers { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; padding-left: 1.6rem; }
.report-dates { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.report-dates input { width: auto; }
.report-form > button { justify-self: start; }
.report-head { margin-top: 1.5rem; }
.report-worker { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.report-worker h3 { font-size: 1rem; margin: 1rem 0 .4rem; }

/* Calendar (Stage 9) */
.cal-add { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.cal-add h2 { margin-top: 0; }
.cal-copy { display: flex; gap: .5rem; }
.cal-copy input { flex: 1; min-width: 0; font-size: .8rem; }
.cal-copy button { margin-top: 0; white-space: nowrap; }
.cal-help { padding-left: 1.2rem; font-size: .9rem; }
.cal-help li { margin: .4rem 0; }
.shift-list li.muted { display: block; }

/* Reasons on the Today screen (A57) */
.clock-form { display: grid; gap: .4rem; margin-top: 1rem; }
.clock-form textarea { width: 100%; font-size: 1rem; }
.reason-label { font-weight: 600; }
.reason-note { margin: 0; color: var(--muted); }
