.demo-top {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 10px 28px rgb(31 107 86 / 10%);
  padding: 0.65rem max(var(--pad), calc((100% - 1100px) / 2)) 0.75rem;
}
.demo-clinic {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.demo-live {
  display: none;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
}
.demo-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
}
.demo-user {
  margin-left: auto;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  background: var(--soft);
  padding: 0.25rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
}
.demo-top-row {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.8rem;
  flex-wrap: wrap;
}
.demo-top-row .brand { margin: 0; }
.demo-top-row .menu { margin-left: 0.35rem; }
@media (min-width: 801px) {
  .demo-live { display: inline-flex; }
}
.demo-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.45rem;
}
.demo-nav button, .demo-sub button {
  min-height: 2.75rem;
  padding: 0 0.8rem;
  border-radius: var(--radius);
  font-size: 1.125rem;
  font-weight: 700;
}
.demo-nav button[aria-current="page"], .demo-sub button[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.demo-flag {
  margin-top: 0.55rem;
  font-size: 1.05rem;
  line-height: 1.4;
  max-width: 62rem;
}
.demo-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  width: min(1100px, calc(100% - 2 * var(--pad)));
  margin: 0.8rem auto 0;
}
.demo-main {
  width: min(1100px, calc(100% - 2 * var(--pad)));
  margin: 0 auto;
  padding: 1.15rem 0 13rem;
}
.demo-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}
.demo-heading h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.05;
}
.demo-lead {
  margin: 0.7rem 0 1rem;
  font-size: 1.2rem;
  line-height: 1.45;
  max-width: 44rem;
}
.demo-search, .field select {
  width: 100%;
  min-height: 3.15rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
}
.demo-search { max-width: 24rem; margin-bottom: 0.85rem; background: var(--surface); }
.demo-scroll { overflow-x: auto; }
.demo-table {
  width: 100%;
  min-width: 36rem;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
}
.demo-table th, .demo-table td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  font-size: 1.125rem;
  vertical-align: middle;
}
.demo-table th { font-weight: 700; color: var(--muted); background: var(--bg); }
.demo-table tbody tr + tr td { border-top: 1px solid var(--line); }
.demo-k { display: none; }
.demo-open {
  min-height: 2.75rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
@media (hover: hover) and (pointer: fine) {
  .demo-nav button:hover, .demo-sub button:hover, .demo-day button:hover, .demo-stats button:hover, button.demo-cal-n:hover, .demo-file button:hover { background: var(--soft); }
  .demo-nav button[aria-current="page"]:hover, .demo-sub button[aria-current="page"]:hover,
  .demo-file button[aria-selected="true"]:hover, button.demo-cal-n[aria-pressed="true"]:hover { background: #185646; color: var(--accent-ink); }
}
.demo-empty { margin-top: 0.8rem; font-size: 1.125rem; }
.demo-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
}
.demo-stats, .demo-periods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 0.65rem;
  margin: 0.4rem 0 1.1rem;
}
.demo-stats button, .demo-stat, .demo-periods button {
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  min-height: 5.4rem;
}
.demo-periods button { min-height: 3.15rem; font-weight: 700; font-size: 1.125rem; }
.demo-periods button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.demo-stats strong, .demo-stat strong {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.demo-day { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.demo-day button {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  align-items: center;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.55rem 0.85rem;
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 1.15rem;
}
.demo-day time { width: 3.6rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }
.demo-day b { min-width: 4.5rem; }
.demo-day i {
  margin-left: auto;
  font-style: normal;
  font-weight: 700;
  background: var(--mint);
  border-radius: var(--radius);
  padding: 0.15rem 0.55rem;
}
.demo-split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(16rem, 0.9fr);
  gap: 1rem;
  align-items: start;
}
.demo-panel-card, .demo-note-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.15rem;
}
.demo-note-card p + p, .demo-panel-card p + p { margin-top: 0.45rem; }
.demo-fields { display: grid; grid-template-columns: 1fr; gap: 0.7rem; }
.demo-fields .is-wide { grid-column: 1 / -1; }
.demo-dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.25rem 1rem calc(6.25rem + env(safe-area-inset-bottom));
  background: rgb(55 48 72 / 46%);
}
.demo-dialog[hidden] { display: none; }
.demo-sheet {
  display: flex;
  flex-direction: column;
  width: min(40rem, 100%);
  max-height: 100%;
  margin: auto;
  background: var(--surface);
  border-radius: 1.25rem;
  box-shadow: 0 28px 70px rgb(55 48 72 / 28%);
  overflow: hidden;
  overscroll-behavior: contain;
}
.demo-main h1 { scroll-margin-top: 12rem; }
.demo-sheet-body { overflow: auto; padding: 1.4rem 1.45rem 0.85rem; }
.demo-sheet h2 { font-size: clamp(1.7rem, 3vw, 2.2rem); line-height: 1.1; }
.demo-sheet .demo-lead { margin-top: 0.55rem; }
.demo-sheet-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1.45rem 1.15rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.demo-heading h2 { font-size: 1.45rem; line-height: 1.2; }
.demo-dl { display: grid; gap: 0.55rem; margin: 0.9rem 0 0.2rem; }
.demo-dl div { display: grid; gap: 0.1rem; }
.demo-dl dt { font-weight: 700; color: var(--muted); font-size: 1.05rem; }
.demo-dl dd { margin: 0; font-size: 1.15rem; }
.demo-tone { width: 100%; border-collapse: collapse; margin-top: 0.8rem; font-variant-numeric: tabular-nums; }
.demo-tone th, .demo-tone td { text-align: left; padding: 0.4rem 0.5rem; }
.demo-tone th { color: var(--muted); font-size: 1.05rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 1rem; }
.demo-warn {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.8rem max(var(--pad), calc((100% - 1100px) / 2)) calc(0.8rem + env(safe-area-inset-bottom));
  background: var(--ink);
  color: var(--accent-ink);
}
.demo-warn p {
  margin: 0;
  max-width: 46rem;
  font-size: 1.05rem;
  line-height: 1.35;
}
.demo-warn .button { background: var(--surface); color: var(--ink); flex: none; }
@media (hover: hover) and (pointer: fine) {
  .demo-warn .button:hover { background: var(--soft); color: var(--ink); }
}

@media (min-width: 760px) {
  .demo-fields { grid-template-columns: 1fr 1fr; }
}

.demo-home {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(14rem, 0.8fr);
  gap: 1rem;
  align-items: start;
}
.demo-panel h2 {
  margin: 0 0 0.7rem;
  font-size: 1.35rem;
}
.demo-cal {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.demo-cal-title { margin: 0 0 0.55rem; font-weight: 700; }
.demo-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.2rem;
}
.demo-cal-dow, .demo-cal-n {
  display: grid;
  place-items: center;
  min-height: 2.35rem;
  font-size: 1rem;
}
.demo-cal-dow { color: var(--muted); font-weight: 700; font-size: 0.9rem; }
button.demo-cal-n {
  border-radius: 0.55rem;
  font-weight: 700;
  background: var(--soft);
  color: var(--accent);
}
button.demo-cal-n.is-today { outline: 2px solid var(--accent); }
button.demo-cal-n[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.demo-file { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.8rem; }
.demo-file button {
  min-height: 2.6rem;
  padding: 0 0.8rem;
  border-radius: var(--radius);
  font-weight: 700;
}
.demo-file button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.demo-help { position: relative; }
.demo-help-btn {
  min-height: 2.6rem;
  padding: 0 0.85rem;
  border-radius: var(--radius);
  color: var(--accent);
  font-weight: 700;
}
.demo-help-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 8;
  width: min(22rem, calc(100vw - 2rem));
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.demo-help-panel p { margin: 0; font-size: 1.05rem; line-height: 1.4; }
@media (max-width: 800px) {
  .demo-home { grid-template-columns: 1fr; }
  .demo-nav { display: none; margin-top: 0.55rem; }
  .demo-warn .button { width: 100%; }
  .demo-nav.open {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .demo-nav button { width: 100%; }
  .demo-split { grid-template-columns: 1fr; }
  .demo-sheet-foot .button, .demo-heading .button { width: 100%; }
}

@media (max-width: 720px) {
  .demo-scroll { overflow: visible; }
  .demo-table { min-width: 0; background: transparent; }
  .demo-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .demo-table, .demo-table tbody, .demo-table tr, .demo-table td { display: block; width: 100%; }
  .demo-table tr {
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 0.55rem;
    padding: 0.35rem 0;
  }
  .demo-table td, .demo-table tbody tr + tr td {
    display: grid;
    grid-template-columns: 7.2rem minmax(0, 1fr);
    gap: 0.35rem;
    align-items: center;
    border: 0;
    padding: 0.3rem 0.85rem;
  }
  .demo-k { display: block; font-weight: 700; color: var(--muted); font-size: 1rem; }
  .demo-day i { margin-left: 0; }
}

@media (max-width: 420px) {
  .demo-table td, .demo-table tbody tr + tr td { grid-template-columns: 1fr; }
}
