:root {
  color-scheme: light;
  --ink: #2b211b;
  --muted: #7a685d;
  --line: #ead7c7;
  --paper: #fff8f1;
  --band: #ffe4bd;
  --apricot: #f6a23a;
  --apricot-soft: #fff1df;
  --apricot-deep: #bf5b18;
  --accent: #e8751a;
  --accent-dark: #8f3f12;
  --alert: #b13a24;
  --amber: #c96812;
  --blue: #285d8f;
  --white: #ffffff;
  --shadow: 0 16px 50px rgba(82, 45, 18, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 236, 211, 0.92), rgba(255, 248, 241, 0.98)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cpath d='M0 70c44 16 84 14 120-6s69-21 100-3v42c-34-19-67-18-99 4S48 131 0 114z' fill='%23ffd391'/%3E%3Cpath d='M0 132c38 10 72 8 101-7s68-16 119 4v34c-46-17-82-17-109 0s-64 19-111 6z' fill='%23f8b85a'/%3E%3C/svg%3E");
  background-size: cover, 420px 420px;
}

.login-panel {
  width: min(100%, 440px);
  padding: 24px;
  border: 1px solid #e9c39e;
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.login-header {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 16px;
  align-items: start;
}

.login-logo {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  object-fit: cover;
}

.login-panel h1 {
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.login-copy {
  margin-bottom: 22px;
  color: var(--muted);
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--white);
  border-left: 1px solid #e8cdb8;
  border-right: 1px solid #e8cdb8;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  background: var(--apricot);
  border-bottom: 1px solid #d87c22;
  color: #2b1709;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-brand > div {
  min-width: 0;
}

.topbar-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--apricot-deep);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(143, 63, 18, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 800;
}

.text-button {
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid rgba(143, 63, 18, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 800;
}

.event-band {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(180deg, var(--band), var(--apricot-soft));
  border-bottom: 1px solid #efc698;
}

.date {
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-weight: 700;
}

.event-band h2 {
  margin-bottom: 3px;
  font-size: 1.35rem;
}

.event-band p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.event-counts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.event-counts span,
.metric {
  min-height: 72px;
  padding: 12px;
  border: 1px solid #e7c8ad;
  border-radius: 8px;
  background: var(--white);
}

.event-counts strong {
  display: block;
  font-size: 1.35rem;
}

.primary-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 18px;
}

.new-incident-button,
.save-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fffdf9;
  font-weight: 800;
}

.new-incident-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.05rem;
}

.new-incident-button span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.secondary-button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #e7c8ad;
  border-radius: 8px;
  background: #fffaf4;
  color: var(--ink);
  font-weight: 700;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0 18px 14px;
  gap: 6px;
}

.tab {
  min-height: 42px;
  border: 1px solid #e7c8ad;
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  border-color: var(--accent);
  background: var(--apricot-soft);
  color: var(--accent-dark);
}

.view {
  display: none;
  padding: 0 18px 28px;
}

.view.active-view {
  display: block;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.82rem;
}

.incident-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed #e7c8ad;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.incident-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border: 1px solid #e7c8ad;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--white);
  color: inherit;
  text-align: left;
}

.incident-card.high {
  border-left-color: var(--amber);
}

.incident-card.critical {
  border-left-color: var(--alert);
}

.incident-card h3 {
  margin-bottom: 5px;
  font-size: 1rem;
}

.incident-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  align-self: start;
  padding: 5px 8px;
  border-radius: 999px;
  background: #fff0dc;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.metric span {
  display: block;
  font-size: 1.5rem;
  font-weight: 900;
}

.metric p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric.serious span {
  color: var(--alert);
}

.summary-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #e7c8ad;
  border-radius: 8px;
  background: var(--white);
}

.summary-panel h3 {
  margin-bottom: 10px;
  font-size: 0.98rem;
}

.summary-panel ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

textarea,
input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid #e7c8ad;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}

#incidentSeverity.severity-low {
  border-color: #62a66e;
  background: #edf8ee;
  color: #174a24;
  font-weight: 800;
}

#incidentSeverity.severity-medium {
  border-color: #d79a32;
  background: #fff2d8;
  color: #714400;
  font-weight: 800;
}

#incidentSeverity.severity-high {
  border-color: #c9563f;
  background: #ffe9e3;
  color: #7a1f13;
  font-weight: 800;
}

textarea {
  resize: vertical;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 32, 43, 0.34);
  z-index: 10;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(100%, 520px);
  max-height: 92vh;
  overflow: auto;
  transform: translateX(-50%);
  padding: 18px;
  border: 1px solid #e7c8ad;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: var(--white);
  box-shadow: var(--shadow);
}

.witness-sheet {
  z-index: 25;
  max-height: 78vh;
}

.small-sheet {
  top: 18vh;
  bottom: auto;
  z-index: 25;
  max-height: 58vh;
  border-bottom: 1px solid #e7c8ad;
  border-radius: 14px;
}

.hidden {
  display: none !important;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.sheet-header h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.textarea-field {
  gap: 8px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.textarea-tools {
  display: flex;
  gap: 8px;
}

.voice-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d98f4f;
  border-radius: 8px;
  background: #fff4e6;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.voice-button.listening {
  background: var(--accent);
  color: #fffdf9;
}

.voice-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.voice-status {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.voice-status.listening {
  color: var(--accent-dark);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid #e7c8ad;
  border-radius: 8px;
}

legend {
  padding: 0 5px;
  font-weight: 800;
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.person-detail-list {
  display: grid;
  gap: 10px;
}

.person-detail-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.remove-person-button {
  width: 42px;
  min-height: 44px;
  padding: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.form-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding-bottom: 6px;
}

.report-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.report-actions .save-button,
.report-actions .secondary-button {
  min-height: 46px;
}

.report-actions .save-button {
  grid-column: 1 / -1;
}

.report-actions .complete-button {
  grid-column: 1 / -1;
}

.danger-button {
  border-color: #dcaa91;
  color: var(--alert);
}

.danger-save-button {
  background: var(--alert);
}

.confirm-copy {
  margin-bottom: 16px;
  color: var(--muted);
}

.complete-button {
  border-color: var(--accent);
  background: var(--apricot-soft);
  color: var(--accent-dark);
}

.full-width {
  width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  width: min(calc(100% - 32px), 420px);
  transform: translateX(-50%);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  font-weight: 800;
  text-align: center;
}

@media (min-width: 720px) {
  body {
    background: #ffe6c4;
  }

  .app-shell {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
  }
}

@media (max-width: 380px) {
  .primary-action,
  .field-row,
  .person-detail-row,
  .option-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .remove-person-button {
    width: 100%;
  }

  .tabs {
    gap: 4px;
  }

  .tab {
    font-size: 0.9rem;
  }
}
