:root {
  --paper: #F6F3EC;
  --paper-2: #EFEAE0;
  --ink: #20241F;
  --ink-soft: #5B5B54;
  --line: #D9D3C4;
  --rust: #A8451F;
  --ok: #3E6B3A;
  --ok-bg: #EAF3DE;
  --ok-text: #27500A;
  --amber-bg: #FAEEDA;
  --amber-text: #633806;
  --red-bg: #FAECE7;
  --red-text: #712B13;
  --radius: 14px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; position: relative; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 700; }
p { margin: 0; }
button { font-family: var(--font-body); cursor: pointer; }

input, textarea, select {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--rust); box-shadow: 0 0 0 2px rgba(168,69,31,0.15); }

.btn { border: none; border-radius: 9px; padding: 11px 16px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-rust { background: var(--rust); color: #fff; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink-soft); }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; color: var(--ink-soft); font-size: 12px; text-decoration: underline; padding: 0; cursor: pointer; }

/* ---- Auth / entry screen ---- */
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); padding: 28px 24px; width: 100%; max-width: 360px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-logo img { width: 44px; height: 44px; }
.auth-title { text-align: center; font-family: var(--font-display); font-size: 18px; margin-bottom: 2px; }
.auth-sub { text-align: center; font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.auth-note { text-align: center; font-size: 11px; color: var(--ink-soft); margin-top: 14px; }
.auth-error { font-size: 12px; color: var(--rust); margin-bottom: 10px; }
.or-divider { text-align: center; font-size: 11px; color: var(--ink-soft); margin: 14px 0; text-transform: uppercase; letter-spacing: 0.04em; }
.segmented { display: flex; gap: 3px; background: var(--paper-2); border-radius: 8px; padding: 3px; margin-bottom: 14px; }
.segmented button { flex: 1; border: none; background: transparent; padding: 7px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.segmented button.active { background: var(--ink); color: var(--paper); }

/* ---- Home screen ---- */
.main-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px 8px; }
.main-header .brand { display: flex; align-items: center; gap: 8px; }
.main-header .brand img { width: 26px; height: 26px; border-radius: 6px; }
.main-header h1 { font-family: var(--font-display); font-size: 17px; }
.account-btn { background: var(--paper-2); border: none; border-radius: 50%; width: 36px; height: 36px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.back-link-row { padding: 0 16px 24px; }

.unfinished-banner { margin: 10px 16px; background: #412402; border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.unfinished-banner .title { font-size: 13px; font-weight: 700; color: #FAEEDA; margin: 0; }
.unfinished-banner .sub { font-size: 10px; color: #F0D9A8; margin: 2px 0 0; }

.sos-button { margin: 12px 16px; background: var(--rust); border-radius: 14px; padding: 18px; display: flex; align-items: center; gap: 14px; cursor: pointer; }
.sos-button .title { font-size: 16px; font-weight: 700; color: #fff; margin: 0; }
.sos-button .sub { font-size: 12px; color: #F5D9CC; margin: 2px 0 0; }

.history-section { padding: 8px 16px 32px; }
.history-section p.label { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); margin: 16px 0 8px; }
.history-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.history-card .title { font-size: 13px; font-weight: 700; }
.history-card .sub { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.empty { color: var(--ink-soft); font-size: 12px; }

/* ---- Incident type picker ---- */
.type-list { padding: 0 16px 32px; display: flex; flex-direction: column; gap: 8px; }
.type-option { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.type-option span { font-size: 13px; font-weight: 600; }
.type-option i { font-size: 20px; color: var(--rust); }

/* ---- Incident hub ---- */
.vheader { display: flex; align-items: center; gap: 10px; padding: 20px 16px 8px; }
.vheader h2 { font-family: var(--font-display); font-size: 16px; }
.timestamp-banner { margin: 0 16px 10px; background: var(--ink); border-radius: 8px; padding: 7px 10px; display: flex; align-items: center; gap: 6px; }
.timestamp-banner span { font-size: 10px; color: var(--paper); }
.reminder-banner { margin: 0 16px 12px; background: #412402; border-radius: 7px; padding: 8px 10px; }
.reminder-banner span { font-size: 10px; color: #FAEEDA; font-weight: 600; }

.progress-row { display: flex; align-items: center; gap: 8px; margin: 0 16px 12px; }
.progress-row span { font-size: 10px; color: var(--ink-soft); white-space: nowrap; }
.progress-track { flex: 1; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; }

.tile-section-label { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); margin: 0 16px 5px; }
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 16px 10px; }
.tile { border-radius: 10px; padding: 9px 10px; cursor: pointer; }
.tile.wide { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.tile.status-red { background: var(--red-bg); border-left: 4px solid var(--rust); }
.tile.status-amber { background: var(--amber-bg); border-left: 4px solid #EF9F27; }
.tile.status-green { background: var(--ok-bg); border-left: 4px solid var(--ok); }
.tile .tile-icon { font-size: 16px; }
.tile.status-red .tile-icon, .tile.status-red .tile-status { color: var(--red-text); }
.tile.status-amber .tile-icon, .tile.status-amber .tile-status { color: var(--amber-text); }
.tile.status-green .tile-icon, .tile.status-green .tile-status { color: var(--ok-text); }
.tile .tile-title { font-size: 11px; font-weight: 600; color: var(--ink); margin: 5px 0 1px; }
.tile.wide .tile-title { margin: 0; font-size: 13px; }
.tile .tile-status { font-size: 9px; font-weight: 700; }

.hub-footer { padding: 10px 16px 28px; }

/* ---- Generic sub-screen form ---- */
.sub-form { padding: 0 16px 32px; display: flex; flex-direction: column; gap: 10px; }
.two-col { display: flex; gap: 10px; }
.two-col .field { flex: 1; margin-bottom: 0; }
.radio-row { display: flex; gap: 6px; margin-bottom: 10px; }
.radio-opt { flex: 1; text-align: center; padding: 9px; border-radius: 8px; border: 1.5px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.radio-opt.selected { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---- Party / witness list ---- */
.done-banner { background: var(--ok-bg); border-radius: 9px; padding: 8px 10px; margin: 0 16px 12px; display: flex; align-items: center; gap: 8px; }
.done-banner span.msg { font-size: 11px; color: var(--ok-text); flex: 1; }
.done-banner span.undo { font-size: 10px; color: var(--ok); text-decoration: underline; cursor: pointer; }
.party-list { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.party-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; }
.party-card .top { display: flex; justify-content: space-between; align-items: center; }
.party-card .name { font-size: 12px; font-weight: 600; }
.party-card .detail { font-size: 11px; color: var(--ink-soft); margin-top: 2px; font-family: var(--font-mono); }
.party-card .remove { font-size: 11px; color: var(--rust); cursor: pointer; }
.add-row { margin: 10px 16px 28px; border: 1.5px dashed #B4B2A9; border-radius: var(--radius); padding: 11px; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.mark-done-row { margin: 0 16px 28px; border-radius: 9px; padding: 11px; text-align: center; background: var(--ink); cursor: pointer; }
.mark-done-row span { font-size: 12px; font-weight: 600; color: var(--paper); }

/* ---- Photos ---- */
.photo-list { padding: 0 16px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.photo-row { display: flex; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.photo-thumb { width: 44px; height: 44px; border-radius: 7px; background: var(--paper-2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; object-fit: cover; }
.photo-row .meta p { font-size: 11px; margin: 0; }
.photo-row .meta p.title { font-weight: 600; }
.photo-row .meta p.loc { color: var(--ok); margin-top: 2px; }
.photo-row .meta p.warn { color: var(--rust); margin-top: 2px; }
.photo-row .remove { margin-left: auto; font-size: 11px; color: var(--rust); cursor: pointer; align-self: center; }
.capture-row { display: flex; gap: 8px; margin: 0 16px 8px; }
.capture-row .btn { flex: 1; background: #fff; border: 1.5px solid var(--line); color: var(--ink); }

/* ---- Export screen ---- */
.export-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px; margin: 0 16px 8px; }
.export-card .row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.export-card .row:last-child { margin-bottom: 0; }
.export-card .row i { font-size: 20px; color: var(--ink-soft); }
.export-card .row.done i { color: var(--ok); }
.export-card .row p.title { font-size: 12px; font-weight: 600; margin: 0; }
.export-card .row p.sub { font-size: 10px; color: var(--ink-soft); margin: 2px 0 0; }
.export-card .row.done p.sub { color: var(--ok); }
.export-card .action-btn { border-radius: 8px; padding: 8px; text-align: center; margin-top: 8px; }

.offline-banner { background: var(--rust); color: #fff; font-size: 12px; text-align: center; padding: 6px; }
.toast { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 9px; font-size: 13px; z-index: 50; }
