:root {
  --bg: #ffffff;
  --fg: #1f2933;
  --muted: #616e7c;
  --accent: #1d4ed8;
  --border: #e4e7eb;
  --error-bg: #fdecec;
  --error-fg: #9b1c1c;
  --notice-bg: #e8f3ff;
  --notice-fg: #1e3a8a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.nav a { color: var(--fg); }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}
.card.narrow { max-width: 420px; }
.card.highlight { border-color: var(--accent); }

label { display: block; margin: 12px 0; }
label.check { display: flex; gap: 8px; align-items: center; }
input, select { display: block; width: 100%; padding: 8px; margin-top: 4px; font: inherit; }
label.check input, td input[type="checkbox"] { width: auto; display: inline; margin: 0; }
input.copy { font-family: ui-monospace, monospace; }

button, .button {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
}
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.alert { padding: 8px 12px; border-radius: 6px; }
.alert.error { background: var(--error-bg); color: var(--error-fg); }
.alert.notice { background: var(--notice-bg); color: var(--notice-fg); }
.alert.warn { background: #fff6e0; color: #7a5200; }

.muted { color: var(--muted); }

table { width: 100%; border-collapse: collapse; margin: 16px 0; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }  /* a long e-mail breaks instead of widening the page */

.qr svg { width: 220px; height: auto; }
.secret code { font-size: 1.1em; letter-spacing: 0.05em; }

textarea { display: block; width: 100%; padding: 8px; margin-top: 4px; font: inherit; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
.two, .three { display: grid; gap: 0 16px; }
@media (min-width: 640px) {
  .two { grid-template-columns: 1fr 1fr; }
  .three { grid-template-columns: 1fr 1fr 1fr; }
}
.scroll { overflow-x: auto; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form select { width: auto; margin: 0; }
tr.row-error td { background: var(--error-bg); }
tr.row-existing td, tr.row-duplicate td { color: var(--muted); }
tr.row-update td { background: var(--notice-bg); }

/* --- document cards (household and staff pages) --- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; background: #eef1f5; font-size: 0.85rem; }
.badge.ok { background: #e6f4ea; color: #1e7b34; }
.badge.error { background: var(--error-bg); color: var(--error-fg); }
.badge.warn { background: #fff6e0; color: #7a5200; }
.badge.info { background: var(--notice-bg); color: var(--notice-fg); }
.doc-card { border-left: 4px solid var(--border); }
.doc-card.status-approved { border-left-color: #1e7b34; }
.doc-card.status-rejected { border-left-color: var(--error-fg); }
.doc-card.status-uploaded { border-left-color: var(--accent); }
.doc-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.doc-head h2 { margin: 0; }
.doc-badges { display: flex; gap: 4px; flex-wrap: wrap; align-items: flex-start; }
.pages { list-style: none; padding: 0; margin: 12px 0; }
.page {
  display: grid;
  grid-template-columns: auto 72px 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 6px 0;
  background: var(--bg);
}
.page .page-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.page-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.handle { cursor: grab; font-size: 1.4rem; color: var(--muted); padding: 0 4px; touch-action: none; user-select: none; }
.thumb { width: 72px; height: 96px; object-fit: contain; background: #f1f3f5; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.sortable-ghost { opacity: 0.4; }
.held-page, .rejected-page { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 8px; margin: 8px 0; }
.held-page { background: #fff6e0; }
.rejected-page { background: var(--error-bg); flex-direction: column; }
.held-page .button, .held-page button { margin: 4px 6px 0 0; }
.upload { margin-top: 10px; }
.upload-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.upload-buttons .button, .upload .button { cursor: pointer; }
.progress progress { width: 100%; max-width: 320px; }
.staff-box { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 8px; }
.review { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; margin: 8px 0; }
.review .reject { flex: 1; min-width: 240px; }
.review textarea { width: 100%; }
.history ul { list-style: none; padding: 0; }
.history li { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.complete-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.locked { background: #f8f9fb; }
@media (max-width: 480px) {
  .page { grid-template-columns: auto 56px 1fr; }
  .thumb { width: 56px; height: 75px; }
}
.panel { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 12px 0; background: var(--bg); }
/* The file pickers live inside their labelled buttons; the general input styles must not
   bring them back. */
.upload input[type="file"][hidden] { display: none; }
.upload-buttons .button, .upload .button { flex: 1 1 auto; text-align: center; }
[hidden] { display: none !important; }

/* --- step 7: tracking panel, person screen --- */
.container.wide { max-width: 1400px; }
.status { white-space: nowrap; }
.status-code { color: var(--muted); font-size: 0.75rem; }
.summary { font-size: 1.15rem; margin: 4px 0 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--border); border-radius: 16px; color: var(--fg); text-decoration: none; font-size: 0.9rem; }
.chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.chip.active .count { color: #dbe4ff; }
.chip.empty { opacity: 0.55; }
.search { margin: 8px 0; }
.search input[type="search"] { width: 260px; max-width: 100%; display: inline-block; }
.small { font-size: 0.85rem; }
table.tracking tr.flagged td { background: #fffbeb; }
table.booking tr.row-warn td { background: #fff6e0; }
table.booking tr.row-closed td { color: var(--muted); }
table.booking tr.row-error .row-note { color: var(--error-fg); display: block; }
table.booking tr.row-warn .row-note { color: #7a5200; display: block; }
table.booking td input[type="date"], table.booking td input[type="time"] { width: auto; margin: 0; }
.booking-top { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .booking-top { grid-template-columns: 2fr 1fr 1fr 1fr; } }
table.tracking tr.flagged td:first-child { box-shadow: inset 4px 0 0 #d97706; }
@media (max-width: 700px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; padding: 6px 10px; }
  table.stack td { border: none; padding: 3px 0; display: flex; gap: 12px; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 0.85rem; }
  table.tracking tr.flagged { border-left: 4px solid #d97706; }
  table.tracking tr.flagged td, table.tracking tr.flagged td:first-child { background: none; box-shadow: none; }
  .search input[type="search"] { width: 100%; }
}
.person-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.person-head h1 { margin: 0 0 4px; }
.person-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.person-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 12px; }
@media (min-width: 1100px) {
  .person-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .viewer { position: sticky; top: 8px; align-self: start; }
}
.form-data { max-height: 78vh; overflow-y: auto; padding-right: 8px; }
.form-data h3 { margin: 16px 0 4px; font-size: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 2px; }
dl.fields { margin: 0; }
.field-row { display: grid; grid-template-columns: minmax(140px, 2fr) 3fr; gap: 2px 12px; padding: 4px 0; border-bottom: 1px dashed #eef1f5; }
.field-row dt { color: var(--muted); font-size: 0.9rem; }
.field-row dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.field-row .value { margin-right: 4px; overflow-wrap: anywhere; }
.list-row { width: 100%; margin: 4px 0; padding: 4px 8px; background: #f8f9fb; border-radius: 6px; }
dl.fields.sub .field-row { grid-template-columns: minmax(100px, 1fr) 2fr; }
.govuk-name { display: block; font-size: 0.75rem; color: var(--accent); }
.warn-text { color: #7a5200; }
/* Step 11a: what the portal fills in on gov.uk, the flags and the per-person changes. */
.govuk-flags { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 4px; }
.govuk-flags .issue.info { background: #eef4fb; color: #1d3f66; }
.field-row.derived { background: #f6f8fb; }
.govuk-overrides { margin-top: 16px; }
.govuk-overrides label { display: block; margin: 8px 0; }
.govuk-overrides textarea, .govuk-overrides input:not([type="radio"]) { width: 100%; }
.copy-btn { padding: 1px 8px; font-size: 0.8rem; background: #fff; color: var(--accent); border: 1px solid var(--accent); border-radius: 12px; }
.copy-btn .copy-val { font-family: ui-monospace, monospace; color: var(--fg); }
.copy-btn.copied { background: #1e7b34; border-color: #1e7b34; color: #fff; }
.copy-btn.copied .copy-val { color: #fff; }
.viewer iframe.pdf { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 8px; background: #f1f3f5; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 24px; border-bottom: 2px solid var(--border); }
.tab { padding: 8px 14px; color: var(--fg); text-decoration: none; border-radius: 6px 6px 0 0; }
.tab.active { background: var(--accent); color: #fff; }
.tab-body { padding-top: 8px; }
@media (max-width: 700px) {
  .field-row { grid-template-columns: 1fr; }
  .person-status { align-items: flex-start; }
}
.small-heading { font-size: 1rem; margin: 0 0 8px; }
.transitions { padding: 12px 16px; }
.transition-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.transition { flex: 1 1 320px; min-width: 0; }
.transition p { margin: 0 0 6px; }
.transition label { margin: 6px 0; }
details.transition.back { flex: 0 1 360px; border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px; }
details summary { cursor: pointer; color: var(--accent); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1000px) { .two-col { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
tr.cancelled td { color: var(--muted); text-decoration-line: none; background: #fafafa; }
.inline-details { display: inline-block; margin-left: 6px; }
ul.findings { list-style: none; padding: 0; margin: 0; }
.finding { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.finding.sev-critical { border-left-color: var(--error-fg); }
.finding.sev-needs_fix { border-left-color: #d97706; }
.finding.sev-info { border-left-color: var(--accent); }
.finding.resolved { opacity: 0.65; }
.finding p { margin: 4px 0; }
.finding-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.transition input[name="note"] { max-width: 560px; }

/* --- step 7b: collapsible filters, summary cards, rooms, lists --- */
details.filter-box { border: 1px solid var(--border); border-radius: 8px; margin: 8px 0 12px; background: #fafbfc; }
details.filter-box > summary { list-style: none; padding: 10px 12px; color: var(--fg); display: flex; justify-content: space-between; gap: 8px; min-height: 44px; align-items: center; }
details.filter-box > summary::-webkit-details-marker { display: none; }
details.filter-box > summary::after { content: "▸"; color: var(--accent); }
details.filter-box[open] > summary::after { content: "▾"; }
details.filter-box .filter-body { padding: 0 12px 8px; border-top: 1px solid var(--border); }
.group-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.group-title { margin: 8px 0 4px; font-size: 1.4rem; }
ul.buckets { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 768px) { ul.buckets { grid-template-columns: repeat(4, 1fr); } }
.bucket { display: flex; flex-direction: column; padding: 8px 12px; border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; color: var(--fg); text-decoration: none; min-height: 44px; }
.bucket.ok { border-left-color: #1e7b34; }
.bucket.error { border-left-color: var(--error-fg); }
.bucket.info { border-left-color: var(--accent); }
.bucket.active { background: var(--notice-bg); border-color: var(--accent); }
.bucket-count { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.bucket-label { font-size: 0.85rem; color: var(--muted); }
ul.person-cards { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
@media (min-width: 1000px) { ul.person-cards { grid-template-columns: 1fr 1fr; } }
.person-card { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.pc-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.pc-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 4px; }
.pc-appt { font-size: 0.9rem; font-weight: 500; }
.pc-appt.past { color: var(--muted); font-weight: 400; }
.pc-missing, .pc-phone, .pc-address { margin-top: 2px; }
ul.totals { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; }
ul.totals li { border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-variant-numeric: tabular-nums; }
.allot-list { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.allot-list li { border: 1px solid var(--border); border-radius: 16px; padding: 2px 12px; font-variant-numeric: tabular-nums; }
.allot-list li.full { background: #e6f4ea; border-color: #b7dfc2; }
.allot-list li.over { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-fg); }
.allot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0 12px; }
.allot-grid label { margin: 6px 0; }
.checks { margin: 8px 0 12px; }
.checks-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 6px; }
ul.issues { list-style: none; padding: 0; margin: 0; }
.issue { padding: 6px 10px; border-radius: 6px; margin: 4px 0; font-size: 0.9rem; }
.issue.error { background: var(--error-bg); color: var(--error-fg); }
.issue.warn { background: #fff6e0; color: #7a5200; }
ul.rooms { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
@media (min-width: 1000px) { ul.rooms { grid-template-columns: 1fr 1fr 1fr; } }
.room.card { margin: 0; padding: 10px 12px; }
.room.has-error { border-color: var(--error-fg); }
.room-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.room-head h3 { margin: 0; font-size: 1rem; }
.room-head label { margin: 0; display: flex; gap: 6px; align-items: center; }
.room-head select { width: auto; margin: 0; }
ul.room-people { list-style: none; padding: 0; margin: 6px 0; }
ul.room-people li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed #eef1f5; }
.rp-name { font-weight: 500; }
.rp-meta { flex: 1 1 auto; }
form.move { margin-left: auto; gap: 4px; }
form.move select, ul.room-people select { width: auto; max-width: 190px; margin: 0; padding: 6px; }
.small-btn { padding: 6px 10px; font-size: 0.9rem; }
.room-edit { margin-top: 6px; }
.room-edit form { margin: 6px 0; }
/* A red text link, not a red button: no background behind the red text (11a review). */
button.link.danger { color: var(--error-fg); background: none; border: none; }
.add-room select { min-width: 170px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--border); align-items: center; }
.lock-box { padding: 10px 14px; }
.lock-box p { margin: 4px 0; }
.lock-box.locked { border-color: #b7dfc2; background: #f4fbf6; }
.changes-box p { margin: 0 0 6px; }
ul.changes { margin: 4px 0 8px; padding-left: 18px; }
ul.changes li { margin: 2px 0; }
.list-options { padding: 10px 14px; }
.column-choice { border: none; padding: 0; margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.column-choice legend { margin-bottom: 4px; }
.column-choice label.check { margin: 2px 0; }
table.list-preview td { white-space: nowrap; }
table.list-preview tr.flagged td { background: #fffbeb; }
.title-edit form { margin: 4px 0; }
.title-input { width: 160px; display: inline-block; margin: 0; }
table.list-preview tr.band td { background: #ddebf7; }
table.list-preview td.room-cell { vertical-align: middle; font-weight: 600; background: #f5f8fc; }
.type-box { padding: 8px 14px; margin: 8px 0; }
.type-box p { margin: 4px 0; }
.type-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.type-form { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 0 12px; align-items: end; }
.type-form p, .type-form button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 700px) { .type-form { grid-template-columns: 1fr; } }
fieldset.eta-choice { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 6px 0; }
fieldset.eta-choice .eta-fee, fieldset.eta-choice .eta-valid { margin: 0 0 8px 24px; }
.badge.kind { font-size: 0.75rem; padding: 1px 8px; }
/* Step 9: reminders */
.reminder-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.reminder-card { margin: 0; }
.reminder-card.due { border-left: 4px solid #e0a100; }
.reminder-card header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.reminder-card .actions { gap: 8px; }
.reminder-card .actions form { margin: 0; }
.chain-card.unreachable { border-left: 4px solid var(--error-fg, #b42318); }
.chain-card .call-link { margin-left: auto; }
.call-result input[name="not"] { width: 100%; box-sizing: border-box; margin-bottom: 6px; }
.people-counts { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
.people-counts .unreachable { color: var(--error-fg); font-weight: 600; }
.teacher-view fieldset { border: 0; border-top: 1px solid #e3e6ea; padding: 12px 0 4px; margin: 0; }
.teacher-view legend { font-weight: 600; padding: 0; }
.teacher-view .choices { display: grid; gap: 8px; }
.teacher-view .choice { align-items: flex-start; }
.teacher-view .choice .explain { display: block; }
.warn-text { color: var(--warn-fg, #7a4b00); }
.message-preview { white-space: pre-wrap; font-family: inherit; font-size: 0.9rem; background: #f6f7f9; padding: 8px; border-radius: 6px; margin: 4px 0; }
.reminder-settings input.num { width: 5em; }
button.secondary, .button.secondary { background: #fff; color: var(--accent); }
/* eVisa steps on the household card: the admin's texts carry their own numbers (step 9). */
ol.evisa-steps { list-style: none; padding: 0; margin: 8px 0; }
ol.evisa-steps > li { margin-bottom: 8px; }
/* The household's own share code, in full, with a copy button (plan section 18). */
.share-code { font-family: ui-monospace, monospace; letter-spacing: 0.05em; }
details.evisa-change { margin-top: 8px; }
details.evisa-change > summary { cursor: pointer; color: var(--accent); }
/* Step 10: htmx's request indicator (htmx runs with includeIndicatorStyles=false, so it injects
   no <style> of its own; the strict CSP would block it). Same rules as htmx's defaults. */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }
.help-image-preview { max-width: 320px; }
/* Step 10: retention */
.danger-zone { border-color: #e8b4b4; }
button.danger { background: #b42318; border-color: #b42318; color: #fff; }
.retention-list td, .retention-list th { vertical-align: top; }
.retention-list form { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.retention-list input.num { width: 5em; }

/* Plan 12: the extension's pairing code on "Hesabım", read off and typed into the extension. */
.pair-code { font-family: ui-monospace, Consolas, monospace; font-size: 1.6rem; letter-spacing: 0.15em; margin: 0.5rem 0; }
