:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #697386;
  --line: #dde3ec;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --brand: #1459d9;
  --brand-dark: #0b3f9f;
  --success: #147a4b;
  --warning: #a45b00;
  --danger: #b42318;
  --shadow: 0 16px 45px rgba(21, 35, 58, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.4rem, 3vw, 2rem); }
h2 { margin-bottom: 0; font-size: 1.25rem; }
button, input { font: inherit; }
select, textarea { font: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.3rem clamp(1rem, 5vw, 4rem);
  background: #0f1d36;
  color: #fff;
}

.topbar .eyebrow { color: #8fb7ff; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.topbar-actions > a { padding: .45rem .1rem; border-bottom: 2px solid transparent; color: #b9c5d9; font-size: .9rem; font-weight: 700; text-decoration: none; }
.topbar-actions > a:hover, .topbar-actions > a.active { border-bottom-color: #8fb7ff; color: #fff; }
.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 2rem auto 4rem; }
.narrow-shell { width: min(920px, calc(100% - 2rem)); }
.form-shell { width: min(760px, calc(100% - 2rem)); }

.eyebrow {
  margin-bottom: .35rem;
  color: var(--brand);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.summary-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.summary-card span { display: block; color: var(--muted); font-size: .85rem; }
.summary-card strong { display: block; margin-top: .4rem; font-size: 1.8rem; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; padding: 1.35rem 1.5rem; border-bottom: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem 1.5rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .9rem; }
td small { display: block; margin-top: .25rem; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faff; }

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: .3rem .6rem;
  border-radius: 999px;
  background: #edf1f7;
  color: #465269;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.badge-completed, .badge-low { background: #e5f6ed; color: var(--success); }
.badge-normal, .badge-in_progress { background: #e8f0ff; color: var(--brand-dark); }
.badge-high { background: #fff0d8; color: var(--warning); }
.badge-emergency, .badge-failed { background: #fee9e7; color: var(--danger); }
.action-cell { text-align: right; }
.detail-link, .back-link { color: var(--brand); font-weight: 750; text-decoration: none; }
.detail-link:hover, .back-link:hover { text-decoration: underline; }
.back-link { display: inline-block; margin-bottom: 1rem; }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 10px;
  padding: .75rem 1rem;
  cursor: pointer;
  font-weight: 750;
}

.primary-button { background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-dark); }
.secondary-button { border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; }
.primary-link { display: inline-flex; padding: .7rem 1rem; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 750; text-decoration: none; }
.primary-link:hover { background: var(--brand-dark); }
.danger-button { border: 1px solid #f3aaa4; border-radius: 10px; padding: .7rem 1rem; background: #fff; color: var(--danger); cursor: pointer; font: inherit; font-weight: 750; }
.danger-button:hover { background: #fff4f3; }
.cancel-link { color: var(--muted); font-weight: 700; text-decoration: none; }
.cancel-link:hover { color: var(--ink); }

.login-page { display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at top, #dce9ff, var(--canvas) 55%); }
.login-card { width: min(420px, 100%); padding: 2.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 1.5rem; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 900; }
.login-form { display: grid; gap: .7rem; margin-top: 1.5rem; }
.login-form label { margin-top: .35rem; font-size: .84rem; font-weight: 750; }
.login-form input { width: 100%; padding: .8rem .9rem; border: 1px solid #cbd3df; border-radius: 10px; background: #fff; }
.login-form input:focus { outline: 3px solid #dbe8ff; border-color: var(--brand); }
.login-form button { margin-top: .65rem; }
.alert { margin-top: 1rem; padding: .8rem; border-radius: 10px; background: #fee9e7; color: var(--danger); }
.success-alert { margin-bottom: 1rem; padding: .85rem 1rem; border: 1px solid #b9e4ca; border-radius: 12px; background: #eaf8f0; color: var(--success); font-weight: 700; }
.empty-state { padding: 4rem 1.5rem; text-align: center; color: var(--muted); }
.inactive-row { opacity: .62; }

.detail-hero { display: flex; align-items: start; justify-content: space-between; gap: 2rem; margin-bottom: 1.25rem; padding: 1.5rem; border-radius: 18px; background: #0f1d36; color: #fff; }
.detail-hero .muted { color: #b9c5d9; margin: .5rem 0 0; }
.badge-stack { display: flex; flex-wrap: wrap; gap: .5rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.detail-card, .content-panel { padding: 1.5rem; }
.content-panel { margin-bottom: 1rem; }
dl { display: grid; grid-template-columns: 115px 1fr; gap: .65rem 1rem; margin: 1rem 0 0; }
dt { color: var(--muted); font-size: .82rem; }
dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.prose { margin: 1rem 0 0; line-height: 1.65; }
.transcript { margin: 1rem 0 0; padding: 1rem; overflow-x: auto; white-space: pre-wrap; border-radius: 12px; background: #f6f8fc; color: var(--ink); font: inherit; line-height: 1.7; }
audio { width: 100%; margin-top: 1rem; }
.form-panel { padding: 1.5rem; }
.form-panel > .muted { margin-top: .5rem; }
.contact-form { margin-top: 1.5rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { display: grid; gap: .45rem; }
.field-wide { grid-column: 1 / -1; }
.field label { font-size: .84rem; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; padding: .8rem .9rem; border: 1px solid #cbd3df; border-radius: 10px; background: #fff; color: var(--ink); }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid #dbe8ff; border-color: var(--brand); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; margin-top: 1.5rem; }
.status-action { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.status-action p { margin: .3rem 0 0; }

@media (max-width: 820px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  th, td { padding: .85rem 1rem; }
}

@media (max-width: 560px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; }
  .topbar-actions { align-items: flex-end; flex-direction: column; gap: .45rem; }
  .detail-hero { flex-direction: column; }
  .login-card { padding: 1.5rem; }
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .status-action { align-items: flex-start; flex-direction: column; }
}
