:root {
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --ink: #1B2433;
  --ink-2: #5B6678;
  --line: #DCE1E8;
  --accent: #1B2433;

  --ready: #1E8A5E;
  --occupied: #4A5A70;
  --needs: #D08700;
  --refreshing: #2B63D9;
  --maint: #C23B3B;

  --radius: 14px;
  --tap: 52px;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-size: 17px; line-height: 1.45;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; margin: 6px 0 12px; }
h2 { font-size: 18px; font-weight: 700; margin: 26px 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.center { text-align: center; margin-top: 24px; }
code { font: 13px/1.3 ui-monospace, Menlo, monospace; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--ink); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.brand { font-weight: 700; font-size: 17px; }
.who { font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.page { max-width: 720px; margin: 0 auto; padding: 16px 16px 24px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.head h1 { margin-bottom: 8px; }
.back { display: inline-block; color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }

/* Status board: the one bold element. Colour is the status. */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 18px; }
.tile {
  position: relative; min-height: 118px; border-radius: var(--radius);
  padding: 14px 14px 12px; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  transition: background-color .5s ease;
}
.tile-name { font-weight: 700; font-size: 18px; line-height: 1.2; }
.tile-status { font-size: 15px; opacity: .95; margin-top: 4px; }
.tile-since { font-size: 12px; opacity: .75; }
.st-ready { background: var(--ready); }
.st-occupied { background: var(--occupied); }
.st-needs_refresh { background: var(--needs); }
.st-refreshing { background: var(--refreshing); }
.st-maintenance { background: var(--maint); }
.st-needs_refresh::before, .st-maintenance::before {
  content: ""; position: absolute; top: 12px; right: 12px; width: 10px; height: 10px; border-radius: 50%;
  background: #fff; animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .st-needs_refresh::before, .st-maintenance::before { animation: none; } .tile { transition: none; } }
.tile-menu { position: absolute; top: 4px; right: 34px; }
.tile-menu summary { list-style: none; cursor: pointer; font-weight: 700; padding: 4px 8px; font-size: 18px; opacity: .8; }
.tile-menu summary::-webkit-details-marker { display: none; }
.tile-menu form { position: absolute; right: 0; top: 34px; background: var(--surface); color: var(--ink); border-radius: 10px; box-shadow: 0 8px 24px rgba(27,36,51,.18); padding: 6px; z-index: 5; min-width: 160px; }
.tile-menu form button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; font: inherit; border-radius: 8px; cursor: pointer; }
.tile-menu form button:hover { background: var(--bg); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.list li { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); min-height: var(--tap); }
.list li:last-child { border-bottom: 0; }
.list li.urgent { box-shadow: inset 4px 0 0 var(--maint); }
.list li.unread { background: #F7FAFF; }
.list li.faded { opacity: .55; }
.grow { flex: 1; min-width: 0; }
.chev { color: var(--ink-2); font-size: 22px; }
.col { display: flex; flex-direction: column; gap: 6px; }
.linklist { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.linklist a { display: flex; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.linklist a:last-child { border-bottom: 0; }
.linklist span { color: var(--ink-2); }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; color: #fff; }
.pill.red { background: var(--maint); } .pill.blue { background: var(--refreshing); } .pill.green { background: var(--ready); }
.pill.grey { background: var(--line); color: var(--ink-2); }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin-top: 0; }
.note { white-space: pre-line; }
.empty { text-align: center; color: var(--ink-2); padding: 28px 12px; }
.empty h1 { color: var(--ink); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
label { display: block; font-size: 15px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=datetime-local], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; min-height: var(--tap);
}
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(43,99,217,.45); outline-offset: 2px; }
fieldset { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px 6px; margin: 0; }
legend { font-weight: 600; color: var(--ink-2); padding: 0 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters select, .filters input { flex: 1 1 140px; margin: 0; min-height: 44px; padding: 8px 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 20px; border-radius: 12px; font: inherit; font-weight: 600;
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); cursor: pointer; text-align: center;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.big { width: 100%; font-size: 18px; min-height: 58px; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--maint); }
.btn:active { transform: translateY(1px); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row.actions { margin: 4px 0 8px; }
.row.actions .btn { flex: 1; }

/* Checklist: big tap targets */
.checklist { list-style: none; padding: 0; margin: 0 0 18px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.check { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 60px; font-size: 17px; font-weight: 500; color: var(--ink); cursor: pointer; }
.check input { width: 26px; height: 26px; flex: none; accent-color: var(--ready); margin: 0; }
.check.done span { color: var(--ink-2); text-decoration: line-through; }
.check.toggle { background: var(--surface); border-radius: 12px; border: 1.5px solid var(--line); min-height: var(--tap); padding: 10px 14px; font-weight: 500; }
.check.toggle input { accent-color: var(--accent); }

/* Messages */
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: #E3F4EB; color: #145C3F; }
.flash-error { background: #FBE7E7; color: #7E1F1F; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; max-width: 92vw; z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* Table (audit) */
.tablewrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--ink-2); font-weight: 600; white-space: nowrap; }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { font-size: 30px; }

/* Bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); position: relative; min-height: 56px; }
.tabs a.active { color: var(--ink); }
.tabs .ico { font-size: 20px; line-height: 1; }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--maint); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 6px; }
#offline-bar { display: none; background: var(--needs); color: #fff; text-align: center; padding: 6px; font-size: 14px; }
.offline #offline-bar { display: block; }

@media (min-width: 720px) {
  .tabs a { font-size: 13px; flex: 0 0 120px; }
  .tabs { justify-content: center; }
}
