:root {
  --bg: #f6f3ec; --surface: #fff; --ink: #1f2a24; --muted: #6b746e; --line: #e4dfd4;
  --brand: #24392d; --brand-2: #3d5c49; --accent: #c8963e;
  --ok: #2f7d4f; --ok-bg: #e5f3ea; --warn: #9a6400; --warn-bg: #fdf1dc; --bad: #b03a2e; --bad-bg: #fbe7e4;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#141a16; --surface:#1d2520; --ink:#e8ece9; --muted:#9aa59e; --line:#2e3832;
    --brand:#8fbf9f; --brand-2:#6f9f80; --ok-bg:#1d3326; --warn-bg:#3a2e14; --bad-bg:#3d1f1b; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-2); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #fff; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { font-weight: 700; font-size: 18px; padding: 4px 10px 18px; letter-spacing: .2px; }
.side .brand small { display: block; font-weight: 400; opacity: .7; font-size: 12px; }
.nav a { display: flex; gap: 10px; align-items: center; color: #e9efe9; text-decoration: none; padding: 10px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.on { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav .ico { width: 20px; text-align: center; }
.side .who { margin-top: 18px; padding: 10px; border-top: 1px solid rgba(255,255,255,.15); font-size: 13px; opacity: .9; }
.side .who button { margin-top: 8px; }
main { padding: 24px; max-width: 1200px; width: 100%; }
.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 820px) {
  .shell { display: block; }
  .side { display: none; }
  main { padding: 14px 14px 90px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--brand); color: #fff; padding: 12px 14px; position: sticky; top: 0; z-index: 5; }
  .topbar b { font-size: 16px; }
  .topbar button { background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
  .tabbar a { flex: 1; text-align: center; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; }
  .tabbar a .ico { display: block; font-size: 20px; line-height: 1.2; }
  .tabbar a.on { color: var(--brand-2); font-weight: 600; }
}

/* Components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.stat { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--line); color: var(--ink); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.empty { color: var(--muted); padding: 10px 0; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 14px; border-radius: 9px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
button:hover, .btn:hover { border-color: var(--brand-2); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #10160f; } }
button.danger { color: var(--bad); border-color: var(--bad); }
button.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); min-height: 42px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand-2); }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.fields .full { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 15px; margin: 0; }
.money { position: relative; } .money input { padding-left: 24px; } .money::before { content: '£'; position: absolute; left: 10px; top: 10px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Rota grid */
.rota { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 8px; min-width: 940px; }
.rota .day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 160px; }
.rota .day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.rota .day h4 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; }
.shift { border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: 13px; background: var(--ok-bg); border-left: 4px solid var(--ok); cursor: default; }
.shift.draft { background: var(--warn-bg); border-left-color: var(--warn); }
.shift.open { background: var(--bad-bg); border-left-color: var(--bad); }
.shift.mine { box-shadow: 0 0 0 2px var(--brand-2) inset; }
.shift.edit { cursor: pointer; }
.shift b { display: block; }
.shift .t { color: var(--muted); font-size: 12px; }
.off { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; background: var(--c); }

/* Checklist runner */
.item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .q { font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.yn { display: flex; gap: 8px; }
.yn button { flex: 1; justify-content: center; }
.yn button.on-yes { background: var(--ok); border-color: var(--ok); color: #fff; }
.yn button.on-no { background: var(--bad); border-color: var(--bad); color: #fff; }
.item .extra { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photo-btn { position: relative; overflow: hidden; }
.photo-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); transition: width .2s; }

/* Toast & modal */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); color: #fff; }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, 94vw); background: var(--surface); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
#modal-body { padding: 18px; }
#modal-body .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Login */
.login { max-width: 380px; margin: 12vh auto; text-align: center; padding: 0 16px; }
.login .logo { font-size: 40px; }
.login .card { padding: 28px 22px; }
#gbtn { display: flex; justify-content: center; margin: 18px 0 6px; min-height: 44px; }

.tabs { display: flex; gap: 6px; margin: 4px 0 14px; flex-wrap: wrap; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
@media print { .side, .tabbar, .topbar, button { display: none !important; } main { padding: 0; } }
