:root {
  --bg: #f5efe2;
  --paper: #fffaf1;
  --paper-strong: #fffdf8;
  --paper-soft: #fbf2e1;
  --ink: #26231d;
  --ink-soft: #4d473c;
  --muted: #776f61;
  --line: #ded2be;
  --line-strong: #c9b28f;
  --herb: #2f6b4f;
  --herb-dark: #1e4938;
  --jade: #2f7770;
  --cinnabar: #b94735;
  --amber: #b8802f;
  --indigo: #3c5668;
  --success: #3f7c4a;
  --danger: #b94735;
  --warning: #a56f25;
  --shadow: 0 18px 34px rgba(47, 38, 24, 0.1);
  --shadow-soft: 0 10px 24px rgba(47, 38, 24, 0.07);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(145deg, rgba(255, 250, 241, 0.96), rgba(238, 226, 203, 0.88)),
    url("data:image/svg+xml,%3Csvg width='180' height='180' viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23c9b28f' stroke-opacity='.16' stroke-width='1'%3E%3Cpath d='M18 46c38 15 82 13 144-10M8 128c42-20 86-23 164-4M52 6c-14 48-9 96 14 154M130 16c-18 36-21 78-10 138'/%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg width='1180' height='520' viewBox='0 0 1180 520' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%232f6b4f' stroke-opacity='.12' stroke-width='2'%3E%3Cpath d='M0 410c118-86 214-92 326-28s178 76 292 8 192-146 304-94 172 88 258 34'/%3E%3Cpath d='M34 326c102-56 202-68 318-38s190 42 300-22 210-104 308-60'/%3E%3Cpath d='M808 116c-58 34-92 80-102 138 58-22 106-62 144-120'/%3E%3Cpath d='M874 150c-20 48-18 96 6 144 42-48 62-98 58-150'/%3E%3Cpath d='M130 96c50 12 84 40 102 84-58-2-100-28-126-78'/%3E%3C/g%3E%3C/svg%3E") top center / min(1180px, 100vw) auto no-repeat;
}

a {
  color: var(--herb);
  text-decoration: none;
}

a:hover {
  color: var(--cinnabar);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  padding: 0.72rem 0.82rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--jade);
  background: #fffdf8;
  box-shadow: 0 0 0 3px rgba(47, 119, 112, 0.14);
}

label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.92rem;
}

label span {
  color: var(--ink);
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 0.82rem;
  border-bottom: 1px solid rgba(201, 178, 143, 0.58);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: rgba(251, 242, 225, 0.7);
  font-size: 0.86rem;
  font-weight: 800;
}

tr:hover td {
  background: rgba(255, 250, 241, 0.72);
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.82rem 1.5rem;
  border-bottom: 1px solid rgba(201, 178, 143, 0.55);
  background: rgba(255, 250, 241, 0.86);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(47, 38, 24, 0.06);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.68rem;
  min-width: 0;
  color: var(--ink);
  font-weight: 900;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid rgba(185, 71, 53, 0.44);
  border-radius: 8px;
  background:
    linear-gradient(145deg, #c75642, #9e3328),
    var(--cinnabar);
  color: #fffaf1;
  box-shadow: inset 0 0 0 2px rgba(255, 250, 241, 0.22), 0 10px 18px rgba(185, 71, 53, 0.22);
  font-family: "SimSun", "STSong", serif;
  font-size: 1.12rem;
  font-weight: 900;
  flex: 0 0 auto;
}

.brand-text {
  font-size: 1.04rem;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 2.22rem;
  padding: 0.48rem 0.64rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 0.93rem;
  font-weight: 700;
}

.nav a:hover,
.nav .nav-action {
  border-color: rgba(47, 107, 79, 0.18);
  background: rgba(235, 244, 234, 0.72);
  color: var(--herb);
}

.nav .nav-action {
  color: var(--herb-dark);
}

.badge {
  position: absolute;
  top: 0.1rem;
  right: 0.12rem;
  min-width: 1rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: var(--cinnabar);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1rem;
  text-align: center;
}

.page {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.45rem 0 3.2rem;
}

.flash-stack {
  display: grid;
  gap: 0.72rem;
  margin-bottom: 1rem;
}

.flash {
  position: relative;
  padding: 0.82rem 1rem 0.82rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow-soft);
}

.flash::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 4px;
  border-radius: 999px;
  background: var(--jade);
}

.flash-success::before {
  background: var(--success);
}

.flash-warning::before {
  background: var(--warning);
}

.flash-danger::before {
  background: var(--danger);
}

.hero-band,
.page-head,
.panel,
.metric {
  border: 1px solid rgba(201, 178, 143, 0.72);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(255, 250, 241, 0.9)),
    var(--paper);
  box-shadow: var(--shadow);
}

.hero-band {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  min-height: 14rem;
  margin-bottom: 1rem;
  padding: 2.2rem;
  color: #fffaf1;
  overflow: hidden;
  isolation: isolate;
}

.hero-band::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    url("data:image/svg+xml,%3Csvg width='920' height='280' viewBox='0 0 920 280' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23fff4dc' stroke-opacity='.52' stroke-width='2'%3E%3Cpath d='M20 226c95-70 166-78 252-32s144 54 238 2 162-114 250-80 112 64 142 28'/%3E%3Cpath d='M88 82c48 0 82 22 104 66-58 2-96-20-118-64'/%3E%3Cpath d='M696 68c-46 42-66 92-62 150 54-38 88-86 102-144'/%3E%3Cpath d='M756 112c-12 44-6 82 18 116 32-40 46-80 42-120'/%3E%3C/g%3E%3C/svg%3E") center right / cover no-repeat;
}

.hero-band::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(105deg, rgba(30, 73, 56, 0.98), rgba(47, 107, 79, 0.88) 48%, rgba(185, 71, 53, 0.72));
}

.doctor-hero::after {
  background:
    linear-gradient(105deg, rgba(45, 55, 48, 0.98), rgba(63, 111, 83, 0.9) 48%, rgba(180, 128, 47, 0.76));
}

.hero-band h1,
.page-head h1,
.auth-copy h1 {
  margin: 0;
  font-size: 2.35rem;
  line-height: 1.14;
  letter-spacing: 0;
  font-weight: 900;
}

.page-head h1 {
  font-size: 2rem;
}

.hero-band p,
.auth-copy p {
  max-width: 42rem;
}

.hero-band .eyebrow,
.hero-band p {
  color: rgba(255, 250, 241, 0.88);
}

.page-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.2rem;
  overflow: hidden;
}

.page-head::after {
  content: "";
  position: absolute;
  right: 1rem;
  bottom: -1rem;
  width: 13rem;
  height: 6rem;
  pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg width='220' height='110' viewBox='0 0 220 110' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%232f6b4f' stroke-opacity='.16' stroke-width='2'%3E%3Cpath d='M10 88c44-36 72-40 112-18s58 22 88-16'/%3E%3Cpath d='M132 18c-24 18-34 42-30 72 24-12 44-34 58-66'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

.page-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--cinnabar);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

.grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

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

.align-start {
  align-items: start;
}

.panel {
  position: relative;
  padding: 1rem;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(185, 71, 53, 0.08), transparent 18%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.18), transparent);
  opacity: 0.7;
}

.panel > * {
  position: relative;
}

.panel h2,
.metric strong,
.record-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
  letter-spacing: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.88rem;
}

.section-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
}

.section-head h2::before {
  content: "";
  width: 0.58rem;
  height: 0.58rem;
  border: 2px solid var(--cinnabar);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(185, 71, 53, 0.08);
}

.section-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  min-height: 2.55rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.68rem 1rem;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.92);
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(47, 38, 24, 0.1);
}

.button.primary {
  border-color: rgba(255, 250, 241, 0.18);
  background: linear-gradient(135deg, var(--herb), var(--jade));
  color: #fffaf1;
}

.button.primary:hover {
  background: linear-gradient(135deg, var(--herb-dark), var(--herb));
  color: #fffaf1;
}

.button.secondary {
  border-color: rgba(180, 128, 47, 0.22);
  background: #f7ead4;
  color: #7b4f1d;
}

.button.ghost {
  border-color: rgba(201, 178, 143, 0.82);
  background: rgba(255, 253, 248, 0.72);
}

.button.danger {
  background: #fff0eb;
  color: var(--danger);
  border-color: rgba(185, 71, 53, 0.26);
}

.button.small {
  min-height: 2.1rem;
  padding: 0.45rem 0.72rem;
  font-size: 0.88rem;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 1.2rem;
  align-items: center;
  min-height: calc(100vh - 8rem);
}

.auth-copy {
  position: relative;
  padding: 1rem;
}

.auth-copy::before {
  content: "";
  display: block;
  width: 4.2rem;
  height: 4.2rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(47, 107, 79, 0.24);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(47, 107, 79, 0.12), rgba(185, 71, 53, 0.1)),
    url("data:image/svg+xml,%3Csvg width='68' height='68' viewBox='0 0 68 68' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%232f6b4f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M16 52c22-4 32-18 36-38-20 4-34 16-36 38z'/%3E%3Cpath d='M16 52c8-15 18-26 34-36'/%3E%3C/g%3E%3C/svg%3E") center / 54px 54px no-repeat;
}

.auth-form,
.booking-form,
.record-form {
  display: grid;
  gap: 0.9rem;
}

.compact {
  margin: 0;
}

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

.empty {
  margin: 0;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 0.65rem;
}

.list-row,
.appointment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.82rem;
  border: 1px solid rgba(201, 178, 143, 0.72);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.72);
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.list-row:hover,
.appointment-row:hover {
  border-color: rgba(47, 107, 79, 0.32);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.list-row > div,
.appointment-row > div:first-child {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.list-row span,
.appointment-row span,
.appointment-row small {
  color: var(--muted);
}

.list-row.unread {
  border-color: rgba(47, 119, 112, 0.42);
  background: #eef7f2;
}

.link-row {
  color: var(--ink);
}

.metric {
  position: relative;
  display: grid;
  gap: 0.38rem;
  min-height: 7.1rem;
  padding: 1.05rem 1.05rem 1rem 1.15rem;
  color: var(--ink);
  overflow: hidden;
}

.metric::before {
  content: "";
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(47, 107, 79, 0.16), rgba(185, 71, 53, 0.12)),
    url("data:image/svg+xml,%3Csvg width='36' height='36' viewBox='0 0 36 36' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%232f6b4f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 20h16M18 12v16'/%3E%3Ccircle cx='18' cy='18' r='12'/%3E%3C/g%3E%3C/svg%3E") center / 1.55rem no-repeat;
}

.metric::after {
  content: "";
  position: absolute;
  right: -1.5rem;
  bottom: -1.2rem;
  width: 7rem;
  height: 5rem;
  background:
    url("data:image/svg+xml,%3Csvg width='130' height='90' viewBox='0 0 130 90' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23b94735' stroke-opacity='.16' stroke-width='2'%3E%3Cpath d='M8 70c36-28 56-30 88-12s42 12 58-18'/%3E%3Cpath d='M66 14c-18 18-25 38-20 62 18-12 34-32 44-58'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  font-size: 2.05rem;
  line-height: 1;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.8rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.25rem 0.62rem;
  background: #efe8da;
  color: #5f5a52;
  font-size: 0.82rem;
  font-weight: 800;
}

.status-pending,
.status-reschedule_requested {
  background: #fff4dc;
  border-color: rgba(180, 128, 47, 0.22);
  color: var(--warning);
}

.status-confirmed {
  background: #e8f4ef;
  border-color: rgba(47, 107, 79, 0.2);
  color: var(--herb);
}

.status-rejected,
.status-cancelled {
  background: #fff0eb;
  border-color: rgba(185, 71, 53, 0.22);
  color: var(--danger);
}

.status-completed {
  background: #eef7e9;
  border-color: rgba(63, 124, 74, 0.22);
  color: var(--success);
}

.slot-list {
  display: grid;
  gap: 0.65rem;
}

.compact-slots {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.slot-pill,
.slot-option {
  position: relative;
  display: grid;
  gap: 0.18rem;
  min-height: 5.6rem;
  border: 1px solid rgba(201, 178, 143, 0.72);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.94), rgba(248, 235, 214, 0.72));
  padding: 0.78rem 0.82rem;
  overflow: hidden;
}

.slot-pill::after,
.slot-option::after {
  content: "";
  position: absolute;
  right: 0.7rem;
  top: 0.7rem;
  width: 1.35rem;
  height: 1.35rem;
  background:
    url("data:image/svg+xml,%3Csvg width='26' height='26' viewBox='0 0 26 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%232f7770' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='13' cy='13' r='9'/%3E%3Cpath d='M13 8v6l4 2'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.45;
}

.slot-pill strong,
.slot-option strong {
  font-size: 0.95rem;
}

.slot-pill span,
.slot-option small {
  color: var(--muted);
}

.slot-time,
.appointment-slot {
  color: var(--herb);
  font-weight: 900;
}

.selectable {
  max-height: 24rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.slot-option {
  cursor: pointer;
}

.slot-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.slot-option:has(input:checked) {
  border-color: var(--herb);
  background:
    linear-gradient(135deg, #edf7ef, #fff9ed);
  box-shadow: inset 0 0 0 1px rgba(47, 107, 79, 0.6), 0 10px 20px rgba(47, 107, 79, 0.12);
}

.inline-field {
  min-width: 13rem;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.checkbox-line input {
  width: auto;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.appointment-stack {
  display: grid;
  gap: 1rem;
}

.appointment-card {
  display: grid;
  gap: 1rem;
}

.appointment-main {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.appointment-main h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.18rem;
}

.appointment-main p {
  margin: 0.35rem 0 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  align-items: center;
}

.action-grid form {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.action-grid .compact-action {
  justify-content: flex-start;
}

.action-grid .inline-action {
  display: grid;
  grid-template-columns: minmax(11rem, 1fr) auto;
}

.action-grid .suggest-action {
  grid-column: span 2;
  grid-template-columns: minmax(10rem, 0.8fr) minmax(8rem, 0.7fr) minmax(12rem, 1fr) auto;
}

.action-grid .button {
  width: max-content;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(201, 178, 143, 0.56);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.52);
}

.table-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.record-card {
  display: grid;
  gap: 0.8rem;
}

.record-list {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.55rem 0.8rem;
  margin: 0;
}

.record-list dt {
  color: var(--cinnabar);
  font-weight: 850;
}

.record-list dd {
  margin: 0;
}

.visit-upload {
  min-width: 0;
  margin: 0;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.visit-upload legend,
.visit-history summary,
.observation-form summary {
  color: var(--herb-dark);
  font-weight: 700;
}

.visit-upload p {
  margin: 0 0 0.6rem;
  font-size: 0.86rem;
}

.visit-upload-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}

.visit-upload input,
.comparison-controls label,
.comparison-controls select {
  min-width: 0;
}

.appointment-row.visit-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.visit-history {
  grid-column: 1 / -1;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.visit-prefill-note {
  margin: 0;
  border-left: 3px solid var(--herb);
  padding: 0.55rem 0.75rem;
  background: var(--paper-soft);
}

.visit-history summary,
.observation-form summary {
  cursor: pointer;
}

.visit-history .record-list,
.observation-form form {
  margin-top: 0.8rem;
}

.visit-comparison {
  margin-bottom: 1rem;
  scroll-margin-top: 6rem;
}

.comparison-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.comparison-table {
  table-layout: fixed;
}

.comparison-label {
  width: 8rem;
}

.comparison-table td,
.visit-history dd {
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.comparison-table td,
.comparison-table th {
  vertical-align: top;
}

.comparison-table th strong,
.comparison-table th small {
  display: block;
}

.comparison-table th strong {
  color: var(--herb-dark);
  font-size: 1rem;
}

.visit-gallery,
.visit-observation,
.observation-form {
  white-space: normal;
}

.visit-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
  gap: 0.65rem;
}

.visit-gallery figure,
.visit-observation dl {
  margin: 0;
}

.visit-gallery img {
  display: block;
  width: 100%;
  height: clamp(6rem, 14vw, 10rem);
  border-radius: var(--radius);
  object-fit: contain;
  background: var(--paper-soft);
}

.visit-gallery figcaption span,
.visit-observation time {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.visit-observation {
  padding-bottom: 0.65rem;
}

.visit-observation dt {
  margin-top: 0.45rem;
  font-weight: 700;
}

.visit-observation dd {
  margin: 0;
  white-space: pre-line;
}

.observation-form {
  margin-top: 0.65rem;
}

.observation-form form {
  display: grid;
  gap: 0.65rem;
}

@media (max-width: 640px) {
  .comparison-label {
    width: 4.5rem;
  }

  .comparison-controls,
  .appointment-row.visit-history-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .visit-comparison {
    scroll-margin-top: 10rem;
  }

  .comparison-table:has(.observation-form[open]) {
    min-width: 36rem;
  }
}

.segmented {
  display: inline-flex;
  border: 1px solid rgba(201, 178, 143, 0.74);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255, 253, 248, 0.86);
}

.segmented a {
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  font-weight: 800;
}

.segmented a.active {
  background: var(--herb);
  color: #fffaf1;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 0.82rem 1rem;
  }

  .nav {
    justify-content: flex-start;
    width: 100%;
  }

  .nav a {
    font-size: 0.9rem;
  }

  .hero-band,
  .page-head,
  .section-head,
  .appointment-main,
  .list-row,
  .appointment-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-band {
    min-height: 15.5rem;
    padding: 1.25rem;
  }

  .hero-band h1,
  .page-head h1,
  .auth-copy h1 {
    font-size: 1.85rem;
  }

  .grid.two,
  .grid.three,
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .action-grid form {
    align-items: stretch;
  }

  .action-grid .inline-action,
  .action-grid .suggest-action {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .action-grid .button {
    width: 100%;
  }

  .row-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .page {
    width: min(100% - 1rem, 1180px);
    padding-top: 0.75rem;
  }

  .panel,
  .page-head {
    padding: 0.85rem;
  }

  .hero-band {
    padding: 1rem;
  }

  .brand-text {
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .record-list {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 0.65rem;
  }
}
