:root {
  color-scheme: light;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #d8dee8;
  --panel: #ffffff;
  --page: #f6f8fb;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --teal: #0f766e;
  --amber: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  background: var(--brand-strong);
}

button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover {
  background: #f1f5f9;
}

button.icon {
  width: 36px;
  padding: 0;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 48px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.login-visual {
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.88), rgba(37, 99, 235, 0.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='700' viewBox='0 0 900 700'%3E%3Crect width='900' height='700' fill='%23e2e8f0'/%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.5' stroke-width='2'%3E%3Cpath d='M90 220h180v100H90zM330 120h260v150H330zM640 250h190v170H640zM160 390h310v150H160zM520 460h210v110H520z'/%3E%3Cpath d='M140 260h88M370 170h180M690 300h130M210 440h250M560 500h170M140 285h130M370 205h140M690 335h95M210 475h190'/%3E%3C/g%3E%3Cg fill='%23ffffff' fill-opacity='.72'%3E%3Ccircle cx='70' cy='80' r='5'/%3E%3Ccircle cx='260' cy='90' r='5'/%3E%3Ccircle cx='610' cy='88' r='5'/%3E%3Ccircle cx='820' cy='160' r='5'/%3E%3Ccircle cx='105' cy='610' r='5'/%3E%3Ccircle cx='760' cy='610' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e0f2fe;
  color: var(--brand);
  font-size: 26px;
  font-weight: 800;
}

.login-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.staging-banner {
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 800;
}

.login-form,
.stack {
  display: grid;
  gap: 14px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-title {
  font-weight: 800;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: #eef6ff;
  color: var(--brand);
}

.user-box {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.main {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

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

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(280px, 380px) 1fr;
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid > *,
.panel-body > * {
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 16px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 28px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 10px;
}

.patient-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 265px);
  overflow: auto;
}

.patient-row {
  min-height: 74px;
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.patient-row:hover,
.patient-row.active {
  border-color: var(--brand);
  background: #f8fbff;
}

.row-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.row-title > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.text-break {
  min-width: 0;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 22px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn {
  background: #fef3c7;
  color: var(--amber);
}

.badge.private {
  background: #fee2e2;
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px 0;
}

.tabs button {
  background: #fff;
  color: var(--muted);
  border-color: var(--line);
}

.tabs button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.record,
.audit-row,
.doc-row,
.assignment-row {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.record:last-child,
.audit-row:last-child,
.doc-row:last-child,
.assignment-row:last-child {
  border-bottom: 0;
}

.record-head,
.doc-row,
.assignment-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  margin: 0;
}

.kv dt {
  color: var(--muted);
  font-weight: 700;
}

.kv dd {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.span-two {
  grid-column: 1 / -1;
}

.error {
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff1f2;
  color: var(--danger);
  padding: 10px;
}

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

.interview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  align-items: start;
  gap: 20px;
}

.interview-primary,
.interview-side {
  min-width: 0;
}

.interview-side {
  align-content: start;
}

.transcript-box {
  max-width: 100%;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  line-height: 1.45;
}

.chat-message {
  overflow-wrap: anywhere;
}

@media (max-width: 1400px) {
  .interview-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .login-shell,
  .shell,
  .grid.two,
  .grid.three,
  .interview-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .login-visual {
    display: none;
  }

  .login-panel,
  .main {
    padding: 18px;
  }

  .sidebar {
    position: static;
    height: auto;
  }
}
