/* BoxApps Rota — calm, large, high-contrast. Colour never carries meaning alone. */
:root {
  --bg: #f5f4f0;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #4a4a4a;
  --line: #b9b6ad;
  --brand: #1d4f7a;
  --brand-dark: #133755;
  --focus: #ffbf47;
  --ok-bg: #e5f2e7; --ok-line: #2e7d3a;
  --warn-bg: #fff4d6; --warn-line: #a86b00;
  --err-bg: #fbe7e6; --err-line: #b3261e;
  --info-bg: #e6eef6; --info-line: #1d4f7a;
  --shift-bg: #ffffff;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; line-height: 1.45; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.75rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.35rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1.1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: .5rem 1rem; z-index: 10; }

/* Header */
.topbar { background: var(--brand-dark); color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: .6rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.topbar .site { font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none; margin-right: auto; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.topbar nav a, .topbar nav button { color: #fff; background: transparent; border: 2px solid rgba(255,255,255,.5); border-radius: 8px; padding: .45rem .85rem; font: inherit; font-size: .95rem; text-decoration: none; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; }
.topbar nav a:hover, .topbar nav button:hover { background: rgba(255,255,255,.12); }
.topbar nav a[aria-current="page"] { background: #fff; color: var(--brand-dark); }
.topbar form { margin: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 1rem 1rem 4rem; }
.narrow { max-width: 560px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .6rem 1.2rem; border-radius: 10px; border: 2px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: var(--info-bg); color: var(--brand-dark); }
.btn.danger { background: #fff; color: var(--err-line); border-color: var(--err-line); }
.btn.danger:hover { background: var(--err-bg); }
.btn.big { font-size: 1.1rem; min-height: 56px; padding: .75rem 1.5rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .75rem 0; }
.linkbtn { background: none; border: none; color: var(--brand); text-decoration: underline; font: inherit; cursor: pointer; padding: .3rem; min-height: 44px; }

/* Forms */
label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; display: block; }
input[type=text], input[type=email], input[type=password], input[type=time], input[type=date], input[type=tel], input[type=number], select, textarea {
  width: 100%; max-width: 30rem; font: inherit; padding: .6rem .7rem; min-height: 48px; border: 2px solid #6b6b6b; border-radius: 8px; background: #fff; color: var(--ink);
}
input[type=time], input.time24 { max-width: 10rem; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.checkbox { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.checkbox input { width: 26px; height: 26px; margin-top: .1rem; flex: none; }
.pw-wrap { display: flex; gap: .5rem; max-width: 30rem; }
.pw-wrap input { flex: 1; }

/* Messages */
.msg { border-left: 6px solid; padding: .75rem 1rem; border-radius: 6px; margin: .5rem 0 1rem; background: var(--info-bg); border-color: var(--info-line); }
.msg.success { background: var(--ok-bg); border-color: var(--ok-line); }
.msg.warning { background: var(--warn-bg); border-color: var(--warn-line); }
.msg.error { background: var(--err-bg); border-color: var(--err-line); }
.msg strong:first-child { margin-right: .3rem; }

/* Status badge: always text; border style differs so it survives greyscale */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; border: 2px solid; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.badge.not_started { border-style: dashed; border-color: #6b6b6b; color: #333; }
.badge.draft { border-color: var(--warn-line); background: var(--warn-bg); color: #5a3a00; }
.badge.issued { border-color: var(--ok-line); background: var(--ok-bg); color: #184d20; }
.badge.changes { border-color: var(--err-line); background: var(--err-bg); color: #7a1a14; border-style: double; border-width: 4px; }

/* Home */
.weeks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.week-card h2 { margin-top: 0; }
.week-card .dates { font-size: 1.15rem; font-weight: 600; }

/* Tables (settings, history) */
table.list { border-collapse: collapse; width: 100%; background: #fff; }
table.list th, table.list td { border: 1px solid var(--line); padding: .55rem .6rem; text-align: left; vertical-align: top; }
table.list th { background: #ecebe6; }
table.list form { display: inline; }

/* ---------- Weekly editor ---------- */
.week-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem 1rem; justify-content: space-between; }
.save-state { font-weight: 700; padding: .45rem .8rem; border-radius: 8px; border: 2px solid var(--ok-line); background: var(--ok-bg); display: inline-flex; gap: .5rem; align-items: center; min-height: 44px; }
.save-state.saving { border-color: var(--info-line); background: var(--info-bg); }
.save-state.failed { border-color: var(--err-line); background: var(--err-bg); }
.palette { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem .8rem; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); margin: .5rem 0 1rem; }
.chip { cursor: grab; user-select: none; border: 2px solid var(--brand); background: var(--info-bg); color: var(--brand-dark); border-radius: 999px; padding: .4rem .9rem; font-weight: 700; min-height: 44px; display: inline-flex; align-items: center; }
.chip:active { cursor: grabbing; }

.grid-wrap { overflow-x: auto; }
table.rota { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 980px; table-layout: fixed; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.rota th, table.rota td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .4rem; vertical-align: top; }
table.rota thead th { background: #ecebe6; text-align: left; font-size: .95rem; }
table.rota thead th .d { display: block; font-weight: 400; }
table.rota tbody th { width: 150px; text-align: left; font-size: 1rem; background: #faf9f6; }
table.rota col.name { width: 150px; }
.cell { min-height: 92px; display: flex; flex-direction: column; gap: .35rem; }
.shift { position: relative; border: 2px solid #333; border-radius: 8px; background: var(--shift-bg); padding: .35rem .45rem; text-align: left; font: inherit; cursor: pointer; width: 100%; color: var(--ink); }
.shift .t { font-weight: 800; font-size: 1.05rem; display: block; }
.shift .f { font-size: .82rem; display: block; color: var(--muted); }
.shift:hover { background: #f1f6fb; }
.shift.problem { border-color: var(--err-line); border-width: 3px; }
.shift.problem::after { content: "Check"; position: absolute; top: -.55rem; right: .3rem; background: var(--err-line); color: #fff; font-size: .7rem; padding: 0 .35rem; border-radius: 4px; }
.shift.inactive .t::after { content: " (not active)"; font-weight: 400; font-size: .8rem; }
.shift.drop-over, .shift.drop-over:hover { outline: 4px dashed var(--brand); background: var(--info-bg); }
.drop-hint { display: none; font-size: .8rem; font-weight: 700; color: var(--brand-dark); }
.dragging .shift .drop-hint { display: block; }
.cont { border: 2px dashed #777; border-radius: 8px; background: #f3f2ee; padding: .3rem .45rem; font-size: .85rem; font-style: italic; }
.addcell { border: 2px dashed #9a978f; background: transparent; border-radius: 8px; color: var(--brand); font: inherit; font-size: .9rem; min-height: 44px; cursor: pointer; opacity: .8; }
.addcell:hover, .addcell:focus-visible { opacity: 1; background: #f1f6fb; }
.legend { font-size: .9rem; color: var(--muted); }

/* Phone: day-by-day cards instead of a squeezed grid */
.daylist { display: none; }
@media (max-width: 820px) {
  html { font-size: 17px; }
  .grid-wrap, .palette { display: none; }
  .daylist { display: block; }
  .day { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin-bottom: .9rem; }
  .day h3 { margin: 0 0 .5rem; }
  .day .shift { margin-bottom: .5rem; }
  .day .shift .who { font-weight: 800; display: block; font-size: 1.05rem; }
  .topbar nav a, .topbar nav button { padding: .4rem .6rem; }
}

/* Dialog */
dialog { border: none; border-radius: 14px; padding: 0; width: min(560px, 96vw); max-height: 94vh; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .dlg { padding: 1.1rem 1.25rem 1.25rem; }
dialog h2 { margin-top: 0; }
.summary { background: var(--info-bg); border: 2px solid var(--info-line); border-radius: 8px; padding: .6rem .8rem; font-weight: 600; margin: .8rem 0; }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; }
.presets button { min-height: 44px; }
.row2 { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.row2 > div { flex: 1 1 200px; }
.sep { border-top: 1px solid var(--line); margin: 1rem 0 .5rem; padding-top: .75rem; }

/* Toast with Undo */
.toast { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); background: #222; color: #fff; padding: .6rem .6rem .6rem 1rem; border-radius: 10px; display: flex; gap: .75rem; align-items: center; z-index: 50; max-width: 94vw; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.toast[hidden] { display: none; }
.toast .btn { min-height: 44px; background: #fff; color: #222; border-color: #fff; }

/* Read-only rota view (review / version) */
.readonly .shift { cursor: default; }
.version-box { display: inline-block; border: 3px solid #222; padding: .2rem .7rem; font-weight: 800; font-size: 1.2rem; border-radius: 6px; }
.updated-box { display: inline-block; background: #222; color: #fff; padding: .2rem .6rem; font-weight: 700; border-radius: 6px; }
.problems li { margin-bottom: .4rem; }

@media print {
  .topbar, .btn-row, .palette, .no-print, .addcell, .toast { display: none !important; }
  body { background: #fff; }
}
.mt0 { margin-top: 0; }
.big-dates { font-size: 1.2rem; font-weight: 600; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 0; }
.inline-form input { max-width: 14rem; }
[hidden] { display: none !important; }
