/* ============================================================
   JTA Clean & Safe — JTA Residential Care green, mobile-first
   ============================================================ */
:root {
  --brand: #176554;
  --brand-dark: #0f4a3d;
  --brand-soft: #e5f2ee;
  --ink: #1f2937;
  --muted: #6b7280;
  --paper: #f3f1eb;
  --card: #ffffff;
  --line: #e5e7eb;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b4463d;
  --bad-soft: #fee2e2;
  --info-soft: #e0f2fe;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 55, 45, 0.10), 0 4px 14px rgba(15, 55, 45, 0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
label { display: block; font-size: 0.92rem; font-weight: 600; margin: 10px 0 4px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }

/* ---------- Buttons ---------- */
.primary-button {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 600;
}
.primary-button:disabled { background: #9db5ae; cursor: not-allowed; }
.ghost-button {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 600;
}
.warn-button {
  background: var(--warn-soft);
  color: var(--warn);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
}
.text-button {
  background: none;
  border: none;
  color: var(--brand-dark);
  padding: 6px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Auth ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 500px at 15% -10%, #d9ece6 0%, transparent 60%),
    radial-gradient(800px 420px at 110% 110%, #e8e3d3 0%, transparent 55%),
    var(--paper);
}
body:not(.auth-pending):not(.auth-signed-out) .auth-screen { display: none; }
.auth-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  max-width: 440px;
  width: 100%;
  padding: 28px;
}
.auth-brand, .brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.05em;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1.05rem;
}
.auth-brand strong, .brand strong { display: block; font-size: 1.02rem; }
.auth-brand small, .brand small { color: var(--muted); }
.auth-ethos {
  color: var(--brand-dark);
  font-style: italic;
  font-size: 0.9rem;
  margin: 10px 0 4px;
}
.section-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brand);
  margin: 14px 0 2px;
}
.auth-copy h1 { font-size: 1.35rem; }
.auth-copy p { color: var(--muted); margin: 6px 0 0; }
.auth-form { margin-top: 12px; }
.auth-submit { width: 100%; margin-top: 14px; }
.auth-message { min-height: 1.2em; color: var(--bad); font-size: 0.9rem; }
.auth-safeguarding {
  margin-top: 14px;
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.85rem;
}
.auth-safeguarding p { margin: 4px 0 0; color: var(--brand-dark); }

/* ---------- Shell ---------- */
.app-shell { display: none; }
body.auth-signed-in .app-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
body.auth-signed-in .auth-screen { display: none; }

.sidebar {
  background: var(--brand-dark);
  color: #eaf4f0;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar .brand small { color: #a9c9bf; }
.sidebar .brand-mark { background: #fff; color: var(--brand-dark); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-button {
  background: none;
  border: none;
  color: #d7e8e2;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-button:hover { background: rgba(255, 255, 255, 0.08); }
.nav-button.is-active { background: var(--brand); color: #fff; }
.nav-badge {
  margin-left: auto;
  background: var(--bad);
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 1px 8px;
}
.sidebar-footer { margin-top: auto; font-size: 0.88rem; }
.sidebar-footer .text-button { color: #cfe5de; display: block; }
.signed-in { margin: 0 0 4px; font-weight: 700; cursor: pointer; }
.sidebar-ethos { color: #a9c9bf; font-style: italic; font-size: 0.78rem; margin-top: 12px; }

.main { padding: 16px 18px 90px; max-width: 1080px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.menu-button {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 1.1rem;
}
.home-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.home-chip {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  color: var(--muted);
}
.home-chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
/* Howards House is orange — its selected state must match its identity */
.home-chip.is-active[data-home="Howards House"] { background: #ea580c; border-color: #ea580c; }
.sync-state { margin-left: auto; font-size: 0.8rem; color: var(--muted); }

/* ---------- Views & cards ---------- */
.view { display: none; }
.view.is-active { display: block; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view-note { color: var(--muted); font-size: 0.88rem; margin: 0 0 12px; }
.view-note p { margin: 0 0 8px; }

/* ---------- Shift header ---------- */
.shift-header { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.shift-header .shift-title h2 { font-size: 1.25rem; margin: 0; }
.shift-header .shift-title p { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.shift-progress { text-align: right; }
.shift-progress strong { font-size: 1.3rem; color: var(--brand-dark); }
.deadline-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.deadline-chip.is-late { background: var(--bad-soft); color: var(--bad); }
.deadline-chip.t-amber { background: var(--warn-soft); color: var(--warn); }
.deadline-chip.t-orange { background: #ffedd5; color: #c2410c; font-size: 0.95rem; }
.deadline-chip.t-red { background: var(--bad-soft); color: var(--bad); font-size: 0.95rem; }

.shift-progress { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.progress-chip {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
}
.progress-chip.is-warn { background: var(--warn-soft); color: var(--warn); }
.progress-chip.is-done { background: var(--ok-soft); color: var(--ok); }
.unassigned-warning {
  flex-basis: 100%;
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 4px 0 0;
}
.board-section-title { margin: 18px 0 4px; color: var(--brand-dark); }
.board-section-title:first-child { margin-top: 4px; }
.tile-group-title {
  margin: 12px 2px 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.tile.is-nodata strong { color: var(--muted); font-size: 0.95rem; line-height: 2; }

/* ---------- Big actions ---------- */
.big-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.big-action {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 12px;
  font-weight: 700;
  font-size: 0.98rem;
  box-shadow: var(--shadow);
}
.big-action:hover { border-color: var(--brand); }
.big-action.is-warn { border-color: var(--warn); color: var(--warn); }

/* ---------- Round board ---------- */
.round-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.round-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--line);
}
.round-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.round-table tr:last-child td { border-bottom: none; }
.zone-name { font-weight: 700; }
.zone-name small { display: block; color: var(--muted); font-weight: 400; }
.task-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.task-actions button { padding: 7px 10px; font-size: 0.85rem; }

.status-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-chip[data-status="Not started"] { background: #f1f5f9; color: var(--muted); }
.status-chip[data-status="In progress"] { background: var(--info-soft); color: #0369a1; }
.status-chip[data-status="Awaiting verification"] { background: var(--warn-soft); color: var(--warn); }
.status-chip[data-status="Accepted"] { background: var(--ok-soft); color: var(--ok); }
.status-chip[data-status="Partially accepted"] { background: var(--warn-soft); color: var(--warn); }
.status-chip[data-status="Reclean required"] { background: var(--bad-soft); color: var(--bad); }
.status-chip[data-status="Manager review"] { background: #ede9fe; color: #6d28d9; }
.status-chip[data-status="Exception"] { background: var(--warn-soft); color: var(--warn); }

.flag-chip {
  display: inline-block;
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  margin: 2px 3px 0 0;
}

/* ---------- Lists (verify / maintenance / exceptions / dashboard) ---------- */
.item-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: none; }
.item-main { flex: 1 1 240px; min-width: 0; }
.item-main strong { display: block; }
.item-main small { color: var(--muted); display: block; margin-top: 2px; }
.empty-note { color: var(--muted); font-size: 0.9rem; padding: 14px 4px; text-align: center; }

/* ---------- Dashboard ---------- */
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-row label { flex: 1 1 140px; margin: 0; font-size: 0.82rem; }
.home-dash { margin-bottom: 14px; }
.home-dash > h2 { margin: 4px 2px 10px; }
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.tile {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.tile strong { display: block; font-size: 1.35rem; color: var(--brand-dark); }
.tile.is-bad strong { color: var(--bad); }
.tile.is-warn strong { color: var(--warn); }
.tile span { font-size: 0.78rem; color: var(--muted); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.mini-table th { text-align: left; color: var(--muted); font-size: 0.74rem; text-transform: uppercase; padding: 6px; border-bottom: 1px solid var(--line); }
.mini-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.mini-table tr:last-child td { border-bottom: none; }

/* ---------- Forms ---------- */
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.inline-form input, .inline-form select { flex: 1 1 160px; width: auto; }
.inline-form button { flex: 0 0 auto; }

/* ---------- Dialogs ---------- */
.app-dialog {
  border: none;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(15, 55, 45, 0.25);
  padding: 20px;
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
}
.app-dialog::backdrop { background: rgba(15, 45, 38, 0.45); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.close-button {
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--muted);
}
.dialog-note { color: var(--muted); font-size: 0.86rem; margin: 6px 0 10px; }
.dialog-sub { color: var(--muted); margin: 2px 0 12px; font-size: 0.9rem; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.identity-dialog::backdrop { background: rgba(15, 45, 38, 0.75); }

/* ---------- Task workflow ---------- */
.task-stage { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.task-stage:first-of-type { border-top: none; margin-top: 4px; }
.stage-status { font-size: 0.85rem; font-weight: 600; color: var(--brand-dark); min-height: 1.1em; margin: 8px 0 0; }
.stage-status.is-bad { color: var(--bad); }
#qr-reader { margin: 10px 0; border-radius: 12px; overflow: hidden; }
.task-steps { list-style: none; padding: 0; margin: 0; }
.task-steps li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.task-steps li.is-locked { opacity: 0.35; }
.task-steps label { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-weight: 500; }
.task-steps input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.photo-label {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  margin-top: 8px;
}
.photo-label input { display: none; }
#photo-preview { max-width: 100%; border-radius: 10px; margin-top: 8px; }
.verdict-set { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 10px; }
.verdict-set legend { font-weight: 700; font-size: 0.9rem; padding: 0 6px; }
.verdict-set label { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 8px 0; }
.verdict-set input { width: auto; }

.verify-photo { max-width: 100%; border-radius: 10px; margin-top: 8px; }
.kv { font-size: 0.9rem; margin: 3px 0; }
.kv b { color: var(--brand-dark); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: calc(100vw - 32px);
}

/* ---------- Handover ---------- */
.handover-declaration {
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 14px;
  margin: 10px 0;
  font-size: 0.95rem;
}
.reject-zone-list label { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 6px 0; }
.reject-zone-list input[type="checkbox"] { width: 18px; height: 18px; }

/* ---------- Mobile ---------- */
@media (max-width: 840px) {
  body.auth-signed-in .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 84px 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    max-width: 300px;
  }
  .sidebar.is-open { transform: translateX(0); }
  .menu-button { display: block; }
  .main { padding: 12px 12px 90px; }
  .round-table thead { display: none; }
  .round-table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .round-table td { display: block; border: none; padding: 3px 4px; }
  .task-actions { justify-content: flex-start; }
  .shift-progress { align-items: flex-start; }
}

@media print {
  .sidebar, .topbar, .big-actions, .dialog-actions, .toast { display: none !important; }
}
