@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/AtkinsonHyperlegible-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/AtkinsonHyperlegible-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #102c2c;
  --ink-soft: #35504e;
  --paper: #f2f0e9;
  --panel: #fbfaf6;
  --line: #d8d5ca;
  --muted: #626963;
  --mint: #dce9e2;
  --teal: #0d5a55;
  --coral: #c75b45;
  --amber: #efc64a;
  --white: #fff;
  --shadow: 0 20px 60px rgba(16, 44, 44, .10);
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font: 400 15px/1.45 "Atkinson Hyperlegible", "Avenir Next", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.demo-strip { height: 32px; display: flex; align-items: center; justify-content: center; gap: 14px; background: var(--amber); border-bottom: 1px solid #b39024; font-size: 12px; letter-spacing: .03em; }
.demo-strip strong { background: var(--ink); color: white; padding: 3px 8px; font: 700 10px/1.2 ui-monospace, monospace; letter-spacing: .13em; }
.topbar { height: 64px; display: grid; grid-template-columns: 260px 1fr auto; align-items: center; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.03em; }
.brand > span:last-child span { font-weight: 400; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; background: var(--ink); color: white; border-radius: 50% 50% 50% 8px; font: italic 700 18px/1 Georgia, serif; }
.visit-meta { justify-self: center; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #4f9576; box-shadow: 0 0 0 4px #dcebe3; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.repo-link { color: var(--teal); font-size: 13px; font-weight: 700; text-decoration: none; }
.type-button { min-width: 42px; height: 34px; border: 1px solid var(--line); border-radius: 7px; color: var(--teal); background: white; font-weight: 700; cursor: pointer; }
.type-button[aria-pressed="true"] { color: white; background: var(--teal); border-color: var(--teal); }

.app-shell { min-height: calc(100vh - 96px); display: grid; grid-template-columns: 64px 285px minmax(0, 1fr); }
.rail { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px 0; color: #c9d8d4; background: var(--ink); }
.rail-button { border: 0; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: inherit; background: transparent; cursor: pointer; font-size: 18px; transition: .18s ease; }
.rail-button:hover, .rail-button.active { color: var(--ink); background: var(--amber); transform: translateY(-1px); }
.rail-spacer { flex: 1; }
.version { font: 10px ui-monospace, monospace; opacity: .7; writing-mode: vertical-rl; }

.patient-list { min-height: 100%; padding: 25px 18px 18px; background: #e9e7df; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.list-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 3px 16px; }
.eyebrow { margin: 0 0 6px; color: var(--teal); font: 700 10px/1.2 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Iowan Old Style, Baskerville, Georgia, serif; }
.list-heading h2 { margin: 0; font-size: 22px; font-weight: 500; }
.square-button, .close-button { border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.square-button { width: 34px; height: 34px; border-radius: 8px; font-size: 20px; }
.search-field { display: flex; align-items: center; gap: 8px; padding: 9px 11px; background: rgba(255,255,255,.64); border: 1px solid var(--line); border-radius: 8px; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.patient-cards { display: grid; gap: 8px; margin-top: 13px; }
.patient-card { width: 100%; border: 1px solid transparent; border-radius: 10px; padding: 13px; background: transparent; text-align: left; cursor: pointer; transition: .18s ease; }
.patient-card:hover { background: rgba(255,255,255,.55); }
.patient-card.active { border-color: var(--line); background: var(--panel); box-shadow: 0 8px 24px rgba(16,44,44,.06); }
.patient-card strong { display: block; font: 600 15px Iowan Old Style, Georgia, serif; }
.patient-card span { color: var(--muted); font-size: 12px; }
.privacy-note { margin-top: auto; display: flex; gap: 10px; padding: 14px 8px 2px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.privacy-note p { margin: 0; }
.lock { color: var(--teal); font-size: 18px; }

.workspace { min-width: 0; padding: clamp(24px, 4vw, 56px); overflow: hidden; }
.workspace-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.workspace-head h1 { margin: 0 0 7px; font-weight: 500; font-size: clamp(30px, 3vw, 44px); letter-spacing: -.04em; }
.subtitle { color: var(--muted); font-size: 14px; }
.button { border: 1px solid var(--line); border-radius: 8px; padding: 10px 15px; cursor: pointer; font-weight: 700; font-size: 12px; }
.button.primary { color: white; background: var(--teal); border-color: var(--teal); }
.button.ghost { background: transparent; }
.button.danger { color: var(--coral); background: #fff4f1; border-color: #efc7bd; }
.button:hover { filter: brightness(.96); transform: translateY(-1px); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.metric { min-height: 118px; padding: 18px; background: var(--panel); }
.metric-label { color: var(--muted); font: 700 10px ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.metric-value { margin-top: 17px; font: 500 29px Iowan Old Style, Georgia, serif; letter-spacing: -.04em; }
.metric-unit { color: var(--muted); font-size: 12px; }
.unavailable { color: #959995; font-size: 14px; font-style: italic; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr); gap: 18px; margin-top: 18px; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 10px 35px rgba(16,44,44,.035); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel h3 { margin: 0; font: 600 18px Iowan Old Style, Georgia, serif; }
.source-chip, .status-chip { padding: 4px 7px; border-radius: 5px; font: 700 9px ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; }
.source-chip { color: var(--teal); background: var(--mint); }
.status-chip.pending { color: #755d0f; background: #f9edbd; }
.status-chip.confirmed { color: #286049; background: #dcece4; }
.status-chip.rejected { color: #8c3b2c; background: #f6dcd6; }

.chart { min-height: 230px; position: relative; padding-top: 10px; }
.chart svg { width: 100%; height: 190px; overflow: visible; }
.chart .grid-line { stroke: #dfddd5; stroke-width: 1; stroke-dasharray: 3 5; }
.chart .trend-line { fill: none; stroke: var(--teal); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart circle { fill: var(--panel); stroke: var(--teal); stroke-width: 3; }
.axis-labels { display: flex; justify-content: space-between; color: var(--muted); font: 10px ui-monospace, monospace; }
.chart-legend { position: absolute; top: 14px; right: 0; color: var(--muted); font-size: 10px; }

.problem-list { display: grid; gap: 9px; }
.problem { display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; }
.problem-dot { width: 8px; height: 8px; border: 2px solid var(--teal); border-radius: 50%; }
.problem strong { font-size: 12px; }
.problem small { margin-left: auto; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 20px; }
.step { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 11px; }
.step.done { color: var(--teal); background: var(--mint); }
.step.current { color: var(--ink); border-color: var(--amber); box-shadow: inset 0 -3px var(--amber); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 7px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,90,85,.1); }
.span-two { grid-column: 1 / -1; }
.inline-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px; color: var(--muted); font: 700 9px ui-monospace, monospace; letter-spacing: .08em; text-align: left; text-transform: uppercase; border-bottom: 1px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid #e9e6de; }
.table-actions { display: flex; gap: 5px; }
.mini-button { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: white; cursor: pointer; font-size: 10px; }
.empty-state { padding: 35px 10px; color: var(--muted); text-align: center; }
.safety-card { max-width: 760px; padding: clamp(24px, 5vw, 54px); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.safety-card h1 { font-size: 38px; }
.safety-card li { margin: 10px 0; line-height: 1.55; }
.safety-rule { margin-top: 28px; padding: 16px; border-left: 3px solid var(--amber); background: #fbf4d8; font-family: Iowan Old Style, Georgia, serif; }

dialog { width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 13px; padding: 0; color: var(--ink); background: var(--panel); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16,44,44,.48); backdrop-filter: blur(3px); }
dialog form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; font-size: 27px; }
.close-button { width: 32px; height: 32px; border-radius: 7px; font-size: 20px; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.form-warning { margin: 17px 0; padding: 10px; color: #755d0f; background: #fbf2d4; font-size: 11px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: 360px; padding: 13px 16px; color: white; background: var(--ink); border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .22s ease-out; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

:focus-visible { outline: 3px solid #bf4d37; outline-offset: 3px; }
.large-type .workspace { font-size: 18px; }
.large-type .subtitle, .large-type label, .large-type table, .large-type .patient-card span { font-size: 15px; }
.large-type .button { font-size: 14px; }
.large-type .metric-label, .large-type .source-chip, .large-type .status-chip { font-size: 11px; }

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

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 56px 240px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; }
  .visit-meta { display: none; }
  .app-shell { grid-template-columns: 52px minmax(0, 1fr); }
  .patient-list { display: none; }
  .workspace { padding: 22px 15px; }
  .workspace-head { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .form-grid, .two-cols { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
}
