/* ==========================================================================
   اطلس — clinical reporting assistant stylesheet
   Persian RTL first; no external fonts, scripts or CDNs.
   ========================================================================== */

@font-face {
  font-family: "Iranian Sans";
  src: url("../fonts/IRANSans.860ad172ae5c.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Iranian Sans";
  src: url("../fonts/IRANSans-Bold.da941c58b167.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Design tokens ---------- */
:root {
  --ink: #10202b;
  --muted: #5b6b78;
  --surface: #ffffff;
  --canvas: #eef4f8;
  --brand: #0e6ba8;
  --brand-dark: #0a5080;
  --brand-deep: #083d63;
  --accent: #e3f0fa;
  --accent-strong: #c9e3f6;
  --success: #157347;
  --warning: #9a6700;
  --danger: #b42318;
  --line: #d9e2ea;
  --shadow: 0 12px 32px rgba(8, 61, 99, .08);
  --card-border: #e3eaf1;
  --tint-gray: #edf2f7;
  --tint-green: #e6f4ec;
  --tint-amber: #fcf3dd;
  --tint-red: #fbe8e6;
  --tint-blue: #e3f0fa;
  font-family: "Iranian Sans", Tahoma, Arial, sans-serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.75;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 1px; border-radius: 4px; }

/* ---------- Application bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  backdrop-filter: blur(10px) saturate(1.15);
  border-bottom: 1px solid var(--line);
}
.appbar-inner {
  width: min(1240px, calc(100% - 32px));
  margin-inline: auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); flex: 0 0 auto; }
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #1179bd, #083d63);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), 0 4px 12px rgba(8, 61, 99, .28);
}
.brand-text strong { display: block; font-size: 17px; line-height: 1.35; letter-spacing: 0; }
.brand-text small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.appbar-nav { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nav-link {
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
  transition: color .15s ease, background-color .15s ease;
}
.nav-link:hover { color: var(--brand-dark); background: var(--accent); }
.nav-link.is-active {
  color: var(--brand-deep);
  background: var(--accent);
  box-shadow: inset 0 -2px 0 var(--brand);
}
.appbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.appbar-end form { margin: 0; }
.tool-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.tool-link:hover { color: var(--brand-dark); border-color: var(--line); background: var(--surface); }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 4px;
  border-radius: 99px;
  background: var(--tint-gray);
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #1179bd, #083d63);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.user-name { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.logout-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}
.logout-button:hover { color: var(--danger); background: var(--tint-red); }

/* ---------- Page shell & messages ---------- */
.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 40px auto;
  flex: 1 0 auto;
}
.messages { display: grid; gap: 10px; margin-bottom: 24px; }
.message {
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--accent);
  border: 1px solid var(--accent-strong);
  border-inline-start: 4px solid var(--brand);
  color: var(--brand-deep);
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(8, 61, 99, .06);
}

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner {
  width: min(1240px, calc(100% - 32px));
  margin-inline: auto;
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 20px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12.5px;
}
.footer-conf { color: var(--brand-dark); font-weight: 700; }

/* ---------- Typography ---------- */
h1 { margin: 6px 0 10px; font-size: clamp(24px, 3vw, 34px); font-weight: 800; line-height: 1.4; letter-spacing: 0; }
h2 { margin-top: 0; font-size: 20px; font-weight: 800; line-height: 1.5; }
h3 { font-weight: 800; }
.muted { color: var(--muted); line-height: 1.9; }
.eyebrow, .step { color: var(--brand); font-weight: 800; font-size: 14px; }
.block-muted { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.ltr-numbers { direction: ltr; unicode-bidi: isolate; text-align: right; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: 18px; box-shadow: var(--shadow); }
.hero-row { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 26px; }
.narrow-card { width: min(660px, 100%); margin: 0 auto; padding: clamp(24px, 6vw, 48px); }
.empty-state { text-align: center; padding: 70px 20px; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 22px; }
.action-row form { margin: 0; }
.action-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.table-actions { min-width: 250px; }

/* ---------- Buttons ---------- */
.button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  line-height: 1.6;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.button-primary {
  color: #fff;
  background: linear-gradient(180deg, #1179bd, #0e6ba8);
  box-shadow: 0 1px 2px rgba(8, 61, 99, .3), inset 0 1px 0 rgba(255, 255, 255, .14);
}
.button-primary:hover { color: #fff; background: linear-gradient(180deg, #0d639e, #0a5080); }
.button-secondary { color: #fff; background: var(--brand); }
.button-secondary:hover { color: #fff; background: var(--brand-dark); }
.button-ghost { background: transparent; color: var(--ink); border: 1px solid transparent; }
.button-ghost:hover { background: var(--surface); border-color: var(--line); color: var(--brand-dark); }
.button-outline { color: var(--brand-dark); background: var(--surface); border: 1px solid var(--line); }
.button-outline:hover { background: var(--accent); border-color: var(--brand); }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { background: #93190f; }
.button-compact { min-height: 36px; padding: 8px 12px; border-radius: 9px; font-size: 13px; white-space: nowrap; }
.button-record { color: #fff; background: var(--ink); min-width: 150px; }
.button-record:hover { background: #1c3444; }

/* ---------- Tables ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: right; padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  background: #f6f9fc;
  text-transform: uppercase;
  letter-spacing: .02em;
  white-space: nowrap;
}
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background: #f8fbfe; }
tbody tr:last-child td { border-bottom: 0; }
td small, td .block-muted { white-space: nowrap; }

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  color: #46545f;
  background: var(--tint-gray);
}
.status-ready, .status-confirmed { color: var(--success); background: var(--tint-green); }
.status-processing, .status-pending, .status-uploaded { color: var(--warning); background: var(--tint-amber); }
.status-failed { color: var(--danger); background: var(--tint-red); }
.status-queued, .status-none { color: #46545f; background: var(--tint-gray); }
.status-review { color: var(--brand-dark); background: var(--tint-blue); }

/* ---------- Callouts ---------- */
.callout {
  padding: 16px;
  border-radius: 12px;
  background: var(--accent);
  border-inline-start: 3px solid var(--brand);
  line-height: 1.9;
}
.callout.warning { background: var(--tint-amber); border-inline-start-color: var(--warning); }
.callout.danger { color: var(--danger); background: var(--tint-red); border-inline-start-color: var(--danger); }

/* ---------- Forms ---------- */
.stack-form { display: grid; gap: 20px; margin-top: 30px; }
.stack-form > div { display: grid; gap: 8px; }
label { font-size: 14px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
  font: inherit;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-strong); border-color: var(--brand); }
.errorlist, .form-errors { color: var(--danger); }
.errorlist { margin: 0; padding-inline-start: 20px; }

/* ---------- Patient chip & recorder ---------- */
.patient-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--accent);
  border: 1px solid var(--accent-strong);
  padding: 14px 16px;
  border-radius: 12px;
  margin: 24px 0;
}
.recorder {
  padding: 28px;
  border: 1px dashed #b7cfe0;
  border-radius: 16px;
  background: #f5f9fc;
  display: grid !important;
  justify-items: center;
  text-align: center;
}
.record-orb { width: 58px; height: 58px; border-radius: 50%; background: #cddce8; box-shadow: inset 0 0 0 16px #fff; border: 2px solid #cddce8; }
.is-recording .record-orb { background: #e5484d; border-color: #e5484d; animation: pulse 1.4s infinite; }
.timer { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.recorder audio { width: 100%; }

/* ---------- Details grid ---------- */
.details-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.details-grid div { background: #f6fafd; border: 1px solid var(--card-border); border-radius: 12px; padding: 15px; }
dt { color: var(--muted); font-size: 12px; }
dd { margin: 6px 0 0; font-weight: 700; }

/* ---------- Review layout ---------- */
.review-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 24px; align-items: start; }
.review-main, .evidence-panel { padding: 32px; }
.evidence-panel { position: sticky; top: 84px; line-height: 2; }
.evidence-panel audio { width: 100%; margin-top: 16px; }
.transcript-warnings, .transcript-segments { display: grid; gap: 10px; margin-top: 22px; }
.transcript-warning, .transcript-segment { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f7fafd; }
.transcript-warning { display: grid; gap: 6px; }
.transcript-warning.is-critical { border-color: #f0b3ae; background: #fdf3f2; }
.transcript-warning span, .transcript-warning small { color: var(--muted); }
.transcript-segment { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; }
.transcript-segment p { margin: 0; }
.timestamp-button {
  border: 1px solid var(--accent-strong);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--surface);
  color: var(--brand-dark);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.timestamp-button:hover { background: var(--accent); border-color: var(--brand); }

/* ---------- Dataset lab ---------- */
.dataset-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .5fr); gap: 24px; align-items: start; }
.dataset-grid audio { width: 100%; }
.run-history { margin-top: 32px; display: grid; gap: 16px; }
.run-card { padding: 24px; }
.run-card header { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.run-card header div { display: flex; align-items: center; gap: 10px; }
.run-card details { margin-top: 18px; }
.run-editor { margin-top: 14px; }
.run-editor > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-dark);
  padding: 10px 12px;
  background: #f2f7fb;
  border: 1px solid var(--card-border);
  border-radius: 10px;
}
.benchmark-review { margin-top: 36px; }
.section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 18px; }
.section-heading p { max-width: 560px; margin: 0; }
.benchmark-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.benchmark-card { padding: 22px; min-width: 0; }
.benchmark-card header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.benchmark-card textarea { min-height: 310px; line-height: 2; resize: vertical; }

/* ---------- Labeling / blind review ---------- */
.label-progress-card { padding: 18px 22px; margin-bottom: 22px; display: grid; grid-template-columns: auto minmax(180px, 1fr); gap: 24px; align-items: center; }
.label-progress-card div:first-child { display: grid; gap: 4px; }
.label-progress-card small { color: var(--muted); }
.progress-track { height: 10px; border-radius: 99px; background: #e2ecf4; overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1179bd, var(--brand-dark)); }
.label-layout { display: grid; grid-template-columns: minmax(280px, .65fr) minmax(0, 1.35fr); gap: 22px; align-items: start; }
.label-audio-panel, .label-editor-panel { padding: 26px; }
.label-audio-panel { position: sticky; top: 84px; }
.label-audio-panel audio { width: 100%; margin: 12px 0 20px; }
.label-help { padding: 16px; border-radius: 12px; background: #f5f9fc; border: 1px solid var(--card-border); line-height: 1.9; }
.label-help ul { margin-bottom: 0; padding-right: 20px; }
.label-skip { width: 100%; margin-top: 18px; }
.label-editor-panel .stack-form { margin-top: 0; }
.label-editor-panel textarea { min-height: 510px; line-height: 2.1; font-size: 16px; resize: vertical; }
.label-editor-heading { display: flex !important; grid-template-columns: 1fr auto; flex-direction: row; justify-content: space-between; }
.label-save-actions { justify-content: flex-end; }
.blind-review-layout .label-editor-panel textarea { min-height: 430px; }
.blind-inline-help { margin: -4px 0 0; font-size: 14px; }
.blind-confirmation { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; line-height: 1.8; cursor: pointer; }
.blind-confirmation input { width: 20px; height: 20px; margin: 4px 0 0; flex: 0 0 auto; accent-color: var(--brand); }
.blind-audio-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: -4px 0 18px; }
.blind-audio-tools label { margin-right: auto; font-size: 13px; color: var(--muted); }
.blind-audio-tools select { width: 78px; padding: 8px; font-size: 13px; }
.shortcut-hint { margin-right: 8px; opacity: .72; direction: ltr; }

/* ---------- Candidates ---------- */
.candidate-section { margin-top: 34px; }
.candidate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.candidate-card { padding: 20px; min-width: 0; }
.candidate-card header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.candidate-card p { max-height: 260px; overflow: auto; white-space: pre-wrap; line-height: 2; background: #f6fafd; border: 1px solid var(--card-border); border-radius: 12px; padding: 14px; }
.transcript-copy { white-space: pre-wrap; line-height: 2; background: #f6fafd; border: 1px solid var(--card-border); padding: 16px; border-radius: 12px; }

/* ---------- Clinical dashboard ---------- */
.hero-card { padding: clamp(24px, 5vw, 44px); margin-bottom: 34px; }
.hero-top { display: flex; justify-content: space-between; align-items: start; gap: 24px; flex-wrap: wrap; }
.search-box { display: flex; gap: 10px; margin-top: 26px; max-width: 620px; }
.search-box input { flex: 1 1 auto; min-width: 0; }
.search-box .button { flex: 0 0 auto; }
.patient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.patient-card { padding: 22px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.patient-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.patient-head h3 { margin: 0 0 4px; font-size: 18px; letter-spacing: 0; }
.patient-id { color: var(--muted); font-weight: 700; font-size: 13px; }
.patient-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--muted); font-size: 14px; }
.patient-meta strong { color: var(--ink); }
.patient-actions { margin-top: 4px; }
.patient-empty { margin-top: 18px; }
.encounter-history { margin-top: 34px; overflow: hidden; }
.encounter-history > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 24px; cursor: pointer; list-style: none; }
.encounter-history > summary::-webkit-details-marker { display: none; }
.encounter-history > summary h2 { margin: 0; font-size: 20px; }
.history-chev { flex: 0 0 auto; width: 9px; height: 9px; border-inline-end: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s ease; }
.encounter-history[open] > summary { border-bottom: 1px solid var(--line); }
.encounter-history[open] .history-chev { transform: rotate(225deg); }
.history-empty-row > td { text-align: center; color: var(--muted); padding: 34px 20px; }

/* Empty-state toggles: the sections above render guard markup that CSS reveals
   only when the corresponding list has no rows (needs :has, cosmetic fallback). */
.patient-grid:not(:has(.patient-card)) { display: none; }
.patient-grid:has(.patient-card) + .patient-empty { display: none; }
.history-empty-row { display: none; }
.history-table tbody:not(:has(.history-row)) .history-empty-row { display: table-row; }

/* ---------- Login ---------- */
.auth-body {
  background:
    radial-gradient(900px 480px at 50% -160px, var(--accent-strong), rgba(201, 227, 246, 0) 70%),
    var(--canvas);
}
.auth-body .page-shell { display: flex; flex-direction: column; justify-content: center; }
.auth-card { width: min(520px, 100%); margin: 0 auto; padding: clamp(28px, 6vw, 48px); text-align: center; }
.auth-card h1 { margin-inline: auto; }
.auth-card .stack-form { text-align: right; margin-top: 26px; }
.auth-card .button { width: 100%; }
.auth-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #1179bd, #083d63);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), 0 8px 20px rgba(8, 61, 99, .28);
}

/* ---------- Animations ---------- */
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(229, 72, 77, .13), inset 0 0 0 16px #fff; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .appbar-inner { flex-wrap: wrap; padding-block: 8px; row-gap: 6px; min-height: 0; }
  .appbar-nav {
    order: 3;
    width: 100%;
    margin-inline-start: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
  }
  .appbar-nav::-webkit-scrollbar { display: none; }
  .appbar-end { order: 2; }
  .brand-text small, .user-name, .tool-link span { display: none; }
  .tool-link { padding: 8px; }
  .user-chip { padding: 3px; }
}

@media (max-width: 760px) {
  .page-shell { margin: 28px auto; width: min(1240px, calc(100% - 32px)); }
  .hero-row { align-items: stretch; flex-direction: column; }
  .hero-top { flex-direction: column; align-items: stretch; }
  .hero-top .button { width: 100%; }
  .search-box { flex-direction: column; max-width: none; }
  .review-layout, .details-grid, .dataset-grid, .benchmark-grid, .label-layout, .candidate-grid { grid-template-columns: 1fr; }
  .patient-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .label-progress-card { grid-template-columns: 1fr; }
  .label-audio-panel { position: static; }
  .evidence-panel { position: static; }
  .table-card { overflow-x: auto; }
  .encounter-history > summary { padding: 16px 18px; }
}

/* ---------- Clinical workspace refinements ---------- */
:root {
  --ink: #182b31;
  --muted: #53676c;
  --surface: #fff;
  --canvas: #f2f6f5;
  --brand: #14736d;
  --brand-dark: #105b57;
  --brand-deep: #104b49;
  --accent: #e6f2f0;
  --accent-strong: #a9d0ca;
  --success: #176342;
  --warning: #755100;
  --danger: #a32720;
  --line: #d4e1df;
  --card-border: #dce7e5;
  --tint-gray: #edf2f1;
  --tint-green: #e7f4ed;
  --tint-amber: #fbf3dc;
  --tint-red: #f9e9e7;
  --tint-blue: #e6f2f0;
  --shadow: 0 8px 24px rgba(25, 67, 64, .055);
}

body { min-height: 100vh; min-height: 100dvh; background: var(--canvas); font-size: 16px; }
.appbar { background: rgba(255, 255, 255, .96); -webkit-backdrop-filter: none; backdrop-filter: none; }
.brand-mark, .user-avatar, .auth-logo { background: var(--brand); box-shadow: none; }
.appbar-inner { min-height: 68px; }
.page-shell { width: min(1180px, calc(100% - 40px)); margin-block: 32px 44px; }
.site-footer { margin-top: 32px; }
.card { border-radius: 14px; box-shadow: var(--shadow); }
.button {
  min-height: 46px;
  border-radius: 10px;
  touch-action: manipulation;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.button-primary { background: var(--brand); box-shadow: none; }
.button-primary:hover { background: var(--brand-dark); }
.button-compact { min-height: 44px; }
.button-record { min-width: 176px; background: #913b35; }
.button-record:hover { background: #762e29; }
.button:disabled, button:disabled { cursor: not-allowed; opacity: .55; }
.nav-link, .logout-button, .tool-link { min-height: 44px; display: inline-flex; align-items: center; }
.nav-link { padding-inline: 12px; }
.page-shell:focus { outline: none; }
.skip-link {
  position: fixed;
  z-index: 1000;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  transform: translateY(-150%);
  padding: 10px 14px;
  color: #fff;
  background: var(--brand-deep);
  border-radius: 8px;
}
.skip-link:focus { transform: translateY(0); color: #fff; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
:focus-visible { outline: 3px solid #14736d; outline-offset: 3px; border-radius: 5px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(20, 115, 109, .22); border-color: var(--brand); }
input, select, textarea { min-height: 46px; font-size: 16px; border-radius: 9px; }
textarea { min-height: 110px; }
.stack-form { gap: 18px; margin-top: 24px; }
.stack-form > div { gap: 7px; min-width: 0; }
.stack-form label { color: #263c40; }
.field-help, .helptext { display: block; margin: -12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.form-errors, .errorlist { padding: 12px 14px; border-radius: 9px; background: var(--tint-red); color: #7d201b; line-height: 1.8; }
.dashboard-intro { padding: clamp(18px, 2.5vw, 24px); margin-bottom: 24px; }
.dashboard-intro h1 { margin-top: 2px; font-size: clamp(24px, 2.5vw, 29px); }
.hero-top { align-items: center; }
.hero-top > div { min-width: 0; }
.hero-top .button { min-width: 170px; }
.search-box { max-width: 740px; margin-top: 14px; }
.search-box input { min-height: 48px; }
.section-heading { margin-bottom: 14px; }
.section-heading h2 { margin-bottom: 2px; }
.section-heading p { font-size: 14px; }
.patient-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.patient-card { padding: 20px; gap: 16px; border-radius: 12px; box-shadow: 0 2px 8px rgba(25, 67, 64, .035); }
.patient-head { align-items: center; }
.patient-head h3 { line-height: 1.55; }
.patient-id { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.patient-id bdi, .patient-chip bdi { color: var(--ink); font-weight: 700; }
.meta-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; font-weight: 500; }
.patient-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; font-size: 14px; }
.patient-meta > span { min-width: 0; }
.patient-meta strong { display: block; overflow-wrap: anywhere; }
.patient-actions { margin-top: 0; }
.patient-actions .button { flex: 1 1 132px; }
.status-badge { min-height: 32px; padding: 5px 10px; border-radius: 7px; }
.encounter-history { margin-top: 28px; border-radius: 12px; box-shadow: 0 2px 8px rgba(25, 67, 64, .035); }
.encounter-history > summary { min-height: 62px; }
.encounter-history > summary h2 { font-size: 18px; }
th { background: #f3f7f6; text-transform: none; letter-spacing: 0; }
tbody tr:hover { background: #f7faf9; }
.table-scroll { max-width: 100%; }
.narrow-card { border-radius: 14px; }
.narrow-card h1 { margin-top: 8px; }
.patient-chip {
  align-items: flex-start;
  background: #f4f8f7;
  border-color: var(--line);
  padding: 14px 16px;
  margin-block: 20px 8px;
}
.patient-chip > div { min-width: 0; }
.patient-chip strong { display: block; overflow-wrap: anywhere; }
.recorder {
  justify-items: stretch;
  gap: 12px;
  padding: 20px;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf9;
}
.recorder-status-row { display: flex; align-items: flex-start; gap: 10px; }
.recorder-status-row strong { min-width: 0; font-size: 15px; line-height: 1.8; }
.record-indicator { width: 11px; height: 11px; flex: 0 0 auto; margin-top: 8px; border-radius: 50%; background: #738488; }
.recorder[data-state="ready"] .record-indicator { background: var(--success); }
.recorder[data-state="recording"] .record-indicator { background: #a32720; animation: recorder-pulse 1.3s ease-in-out infinite; }
.recorder[data-state="error"] .record-indicator { background: var(--danger); }
.recorder-help { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.timer { justify-self: start; padding: 3px 10px; border-radius: 7px; background: #edf2f1; font-size: 24px; }
.recorder-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.recorder-actions .button { min-width: 130px; }
.button-discard { color: var(--danger); }
.recorder audio { display: block; width: 100%; min-height: 44px; margin-top: 2px; }
.recorder audio[hidden] { display: none; }
.details-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); }
.details-grid div { background: #f6f9f8; }
.recording-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.recording-heading h1 { margin-bottom: 0; }
.recording-actions { padding-top: 18px; border-top: 1px solid var(--line); }
.review-main, .evidence-panel { padding: clamp(18px, 3vw, 28px); }
.auth-body { background: var(--canvas); }
.auth-card { box-shadow: 0 12px 34px rgba(25, 67, 64, .08); }
.auth-card .muted { max-width: 36ch; margin-inline: auto; }
.auth-logo { border-radius: 12px; }
.message { background: var(--accent); border-color: var(--accent-strong); color: var(--brand-deep); box-shadow: none; }
.site-footer { background: transparent; }

@keyframes recorder-pulse { 50% { box-shadow: 0 0 0 5px rgba(163, 39, 32, .15); } }

@media (max-width: 760px) {
  .page-shell { width: calc(100% - 28px); margin-block: 22px 32px; }
  .appbar-inner { width: calc(100% - 28px); }
  .appbar-nav { gap: 4px; padding-inline: 2px; }
  .nav-link { padding-inline: 10px; }
  .hero-top { gap: 14px; }
  .hero-top .button { width: auto; }
  .search-box { gap: 8px; }
  .search-box .button { width: 100%; }
  .patient-grid { grid-template-columns: 1fr; }
  .patient-card { padding: 17px; }
  .patient-chip { flex-direction: column; gap: 12px; }
  .review-main, .evidence-panel { padding: 18px; }
  .table-card { overflow-x: auto; }
  .recording-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 420px) {
  .page-shell { width: calc(100% - 24px); margin-block: 16px 26px; }
  .appbar-inner { width: calc(100% - 24px); gap: 10px; }
  .brand-mark { width: 34px; height: 34px; }
  .appbar-end { gap: 4px; }
  .logout-button { padding-inline: 8px; }
  .dashboard-intro { padding: 18px; }
  .hero-top .button { width: 100%; }
  .patient-head { align-items: flex-start; flex-direction: column; }
  .patient-meta { grid-template-columns: 1fr; gap: 8px; }
  .patient-actions { flex-direction: column; align-items: stretch; }
  .patient-actions .button { width: 100%; }
  .narrow-card { padding: 20px 16px; }
  .recorder { padding: 16px; }
  .recorder-actions { display: grid; grid-template-columns: 1fr; }
  .recorder-actions .button { width: 100%; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
