:root {
  color-scheme: light;
  --blue: #0066cc;
  --navy: #0b3d66;
  --ink: #1e293b;
  --muted: #5c6d80;
  --canvas: #f1f5f9;
  --white: #ffffff;
  --line: #dfe7f0;
  --green: #10b981;
  --green-ink: #087455;
  --green-wash: #ecfdf5;
  --amber: #d97706;
  --amber-ink: #8b4a05;
  --amber-wash: #fff5e3;
  --red: #b42335;
  --red-wash: #fff0f1;
  --radius: 14px;
  --type: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --sheet-type: Calibri, Carlito, "Segoe UI", Arial, sans-serif;
  --sheet-line: #d0d0d0;
  --sheet-header: #f3f3f3;
  --sheet-blue: #deebf7;
  --sheet-row-height: 24px;
  --sheet-tabs-height: 42px;
  font-family: var(--type);
  font-synthesis: none;
  color: var(--ink);
  background: var(--canvas);
  scroll-padding-top: 82px;
  scroll-padding-bottom: calc(var(--sheet-tabs-height) + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
:focus-visible { outline: 3px solid #4599e7; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1, h2 { color: var(--navy); }
h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.12; letter-spacing: -.05em; overflow-wrap: anywhere; }
h2 { font-size: 18px; line-height: 1.3; letter-spacing: -.025em; }
p { color: var(--muted); }
strong, .numeric { font-variant-numeric: tabular-nums; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip-link { z-index: 10; position: fixed; top: 8px; left: 8px; background: var(--white); padding: 8px 14px; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 1px 5px #0b3d6626;
}
.header-inner, .shell { width: min(100% - 64px, 1360px); margin-inline: auto; }
.header-inner {
  display: grid;
  grid-template-columns: auto 1fr minmax(0, 350px);
  align-items: center;
  gap: 0 28px;
  min-height: 70px;
  padding-block: 8px;
}
.brand { color: var(--white); display: inline-flex; align-items: center; gap: 11px; font-weight: 730; font-size: 16px; white-space: nowrap; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { position: relative; display: grid; place-items: center; background: var(--blue); border-radius: 9px; width: 32px; height: 32px; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; border-radius: 2px; background: var(--white); }
.brand-mark::before { width: 15px; height: 3px; }
.brand-mark::after { width: 3px; height: 15px; }
.primary-nav { display: flex; align-items: center; align-self: stretch; gap: 4px; border-left: 1px solid #ffffff2b; padding-left: 20px; }
.primary-nav a { color: #e0ecf8; padding: 8px 12px; border-radius: 7px; font-weight: 600; }
.primary-nav a:hover { color: var(--white); background: #ffffff12; text-decoration: none; }
.primary-nav a[aria-current] { color: var(--white); background: #ffffff24; }
.header-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.logout-button { background: transparent; color: var(--white); border-color: #ffffff3d; }
.logout-button:hover { background: #ffffff1c; }
.specialty-nav { position: relative; justify-self: end; min-width: 0; max-width: 100%; width: 240px; }
.specialty-nav summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 12px;
  padding: 5px 12px;
  border: 1px solid #ffffff3d;
  border-radius: 8px;
  background: #ffffff0d;
  line-height: 1.3;
  cursor: pointer;
  list-style: none;
}
.specialty-nav summary::-webkit-details-marker { display: none; }
.specialty-nav summary:hover, .specialty-nav[open] summary { background: #ffffff1c; }
.specialty-nav summary::after {
  content: "";
  grid-area: 1 / 2 / span 2;
  width: 7px;
  height: 7px;
  margin: 0 2px 4px;
  border-right: 2px solid #e0ecf8;
  border-bottom: 2px solid #e0ecf8;
  transform: rotate(45deg);
}
.specialty-nav[open] summary::after { transform: rotate(225deg); margin-bottom: -4px; }
.specialty-label { color: #d0e4f6; font-size: 11px; }
.specialty-name { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 680; }
.specialty-menu {
  position: absolute;
  inset: calc(100% + 8px) 0 auto auto;
  width: min(290px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  box-shadow: 0 12px 30px #0b3d6629;
}
.specialty-menu ul { list-style: none; margin: 0; padding: 0; max-height: min(260px, 45vh); overflow-y: auto; }
.specialty-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--navy); overflow-wrap: anywhere; font-size: 13px; }
.specialty-menu a:hover, .specialty-menu a[aria-current] { background: #eaf2fb; text-decoration: none; }
.specialty-menu a:focus-visible { outline-offset: -2px; }
.specialty-menu a[aria-current] { font-weight: 680; }
.specialty-actions { padding-top: 4px; margin-top: 4px; border-top: 1px solid var(--line); }
.specialty-actions a { color: var(--blue); font-weight: 620; }
.shell { padding-top: 32px; padding-bottom: calc(var(--sheet-tabs-height) + 22px + env(safe-area-inset-bottom)); }
.page-heading { display: flex; gap: 20px; justify-content: space-between; align-items: center; margin: 5px 0 24px; }
.page-heading p { margin-top: 8px; font-size: 15px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 1px solid transparent; font-size: 14px; font-weight: 680; min-height: 42px; padding: 9px 15px; border-radius: 8px; white-space: nowrap; }
.button:hover { text-decoration: none; }
.button.primary { background: var(--blue); color: var(--white); }
.button.primary:hover { background: #0059b3; }
.button.secondary { color: var(--navy); background: var(--white); border-color: #cbd8e7; }
.button.secondary:hover { background: #edf5ff; }
.button.danger { color: var(--white); background: var(--red); }
.button.danger:hover { background: #961d2c; }
.button.small { min-height: 36px; padding-block: 5px; }
.back { display: inline-block; color: var(--navy); margin-bottom: 14px; font-weight: 650; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 14px; margin-bottom: 23px; }
.summary-card { display: grid; gap: 4px; background: var(--white); border: 1px solid var(--line); border-radius: 11px; padding: 14px 18px; }
.summary-card > span { font-size: 13px; font-weight: 620; color: var(--muted); }
.summary-card strong { font-size: 27px; color: var(--navy); line-height: 1.2; }
.status-label { display: inline-flex; gap: 7px; align-items: center; }
.status-label span { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-label.verde { color: var(--green-ink); }
.status-label.ambar { color: var(--amber-ink); }
.status-label.rojo { color: var(--red); }
.status-label.verde span { background: var(--green); }
.status-label.ambar span { background: var(--amber); }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow: clip; box-shadow: 0 2px 4px #0b3d6606; }
.panel-head { padding: 16px 20px; }
.panel-head p { margin-top: 4px; font-size: 13px; }
.gains-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 23px; }
.chart-panel { --chart-columns: minmax(0, 1fr) minmax(0, 1.15fr) 86px; }
.chart-panel .panel-head { min-height: 85px; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 13px;
  margin: 7px 0 0;
  padding: 0;
  color: var(--muted);
  list-style: none;
  font-size: 12px;
}
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend span { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.chart-axis { padding-block: 5px; background: #f5f8fc; border-block: 1px solid var(--line); overflow: hidden; scrollbar-gutter: stable; }
.chart-scale { grid-column: 2; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; white-space: nowrap; }
.chart-scale:has(> :nth-child(3)) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-scale > :nth-child(2):not(:last-child) { text-align: center; }
.chart-scale > :nth-child(3) { text-align: right; }
.chart-scroll { max-height: 330px; overflow-y: auto; scrollbar-gutter: stable; }
.chart-scroll:focus-visible { outline-offset: -3px; }
.chart-list { margin: 0; padding: 0; list-style: none; }
.chart-row { display: grid; grid-template-columns: var(--chart-columns); align-items: center; gap: 8px; padding-inline: 16px; }
.chart-list .chart-row { min-height: 34px; padding-block: 6px; border-bottom: 1px solid #edf1f7; }
.chart-list .chart-row:last-child { border-bottom: 0; }
.chart-name { color: var(--navy); overflow-wrap: anywhere; font-size: 11.5px; font-weight: 620; }
.chart-bar { display: block; width: 100%; height: 12px; overflow: hidden; border-radius: 3px; }
.chart-track { fill: #edf2f7; }
.chart-zero { stroke: #60768e; vector-effect: non-scaling-stroke; }
.margin-bar.rojo { fill: var(--red); }
.margin-bar.ambar { fill: var(--amber); }
.margin-bar.verde { fill: var(--green); }
.cost-materials { fill: var(--blue); background: var(--blue); }
.cost-specialist { fill: var(--navy); background: var(--navy); }
.cost-bank { fill: #9e5f20; background: #9e5f20; }
.cost-clinic { fill: #4a9991; background: #4a9991; }
.chart-value { text-align: right; overflow-wrap: anywhere; font-size: 12px; font-weight: 670; font-variant-numeric: tabular-nums; }
.chart-value sup { margin-left: 2px; line-height: 0; }
.chart-note { padding: 7px 16px; border-top: 1px solid var(--line); font-size: 11px; }
.chart-tooltip {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 10;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 24px));
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--navy);
  color: var(--white);
  font-size: 12px;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 12px #0b3d6633;
}
.specialty-breakdown {
  --chart-columns: minmax(0, 1.25fr) minmax(0, 2fr) 106px 100px;
  max-width: 960px;
}
.specialty-breakdown .panel-head { min-height: 0; }
.specialty-breakdown .chart-axis { scrollbar-gutter: auto; color: var(--muted); }
.breakdown-label { font-size: 12px; font-weight: 670; }
.specialty-breakdown .chart-name { font-size: inherit; }
.specialty-breakdown .chart-list .chart-row:hover { background: #f9fbfe; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search { display: block; min-width: min(100%, 230px); }
.search input { background-color: #fafcfe; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
thead { background: #f5f8fc; }
th, td { padding: 11px 13px; border-bottom: 1px solid #e9eef5; vertical-align: middle; }
thead th { color: #3c5066; font-weight: 680; font-size: 12.5px; white-space: nowrap; }
thead .groups th { color: var(--navy); background: #eaf2fb; border-top: 1px solid #e5edf6; font-weight: 700; padding-block: 8px; }
tbody th { color: var(--ink); font-weight: 620; }
tbody tr:last-child > * { border-bottom: 0; }
table:not(.sheet-grid) tbody tr:hover > * { background: #f9fbfe; }
table tr > :first-child { padding-left: 20px; }
table tr > :last-child { padding-right: 20px; }
.numeric { text-align: right; white-space: nowrap; }
.profit { font-weight: 700; }
.gains-table { min-width: 985px; }
.gains-table thead tr:not(.groups) th:nth-last-child(2) { white-space: normal; }
.gains-table th[scope="row"] { width: 27%; min-width: 200px; }
.gains-table th[scope="row"] a { display: inline-block; color: var(--navy); font-size: 12px; letter-spacing: .005em; }
.gains-table .group-start { border-left: 1px solid var(--line); }
.sort { display: inline-flex; align-items: center; gap: 5px; }
.status { display: inline-flex; justify-content: center; align-items: center; min-width: 60px; padding: 2px 7px; border-radius: 5px; font-weight: 680; font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status.verde { background: var(--green-wash); color: var(--green-ink); }
.status.ambar { background: var(--amber-wash); color: var(--amber-ink); }
.status.rojo { background: var(--red-wash); color: var(--red); }
.status.neutral { background: var(--canvas); color: var(--muted); }
.empty { color: var(--muted); padding-block: 22px; text-align: center; }
form { margin: 0; }
.form-card { padding: 21px; }
.form-card h2 { margin-bottom: 15px; }
.access-shell { width: min(440px, 100% - 32px); margin: clamp(28px, 10vh, 96px) auto; }
.access-brand { color: var(--navy); margin-bottom: 18px; }
.access-shell h1 { font-size: clamp(28px, 5vw, 36px); margin-bottom: 22px; }
.access-shell .form-actions .button { width: 100%; }
.narrow { max-width: 540px; }
.fields { display: grid; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 640; color: var(--ink); min-width: 0; }
.field > span:first-child:not(.input-box) { font-size: 13px; }
.bank-settings { margin-top: 21px; }
.bank-setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
input, select { width: 100%; min-width: 0; min-height: 39px; border: 1px solid #cbd8e7; border-radius: 7px; background: var(--white); color: var(--ink); padding: 7px 10px; font-weight: 450; }
input::placeholder { color: #67798d; }
.input-box { position: relative; display: block; }
.input-box:has(.input-unit) input { padding-right: 47px; }
.input-unit { color: var(--muted); position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; pointer-events: none; }
.form-actions, .modal-actions { display: flex; margin-top: 12px; gap: 8px; justify-content: flex-end; }
.form-message { font-size: 13px; font-weight: 620; color: var(--green-ink); }
.form-message:not(:empty) { margin-block: 10px; }
.form-message.error { color: var(--red); }
.save-status {
  position: fixed;
  pointer-events: none;
  z-index: 20;
  right: 12px;
  bottom: calc(var(--sheet-tabs-height) + 10px + env(safe-area-inset-bottom));
  max-width: min(340px, calc(100vw - 24px));
  padding: 5px 10px;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: var(--white);
  color: var(--green-ink);
  font-size: 13px;
}
.save-status.error { color: var(--red); }
.save-status:empty, .save-feedback:empty { display: none; }
.save-feedback { display: block; }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 650; border-radius: 4px; padding: 5px; }
.text-button:hover { text-decoration: underline; }
.red { color: var(--red); }
.muted { color: var(--muted); }
.count { font-weight: 500; font-size: 13px; }
.row-actions { white-space: nowrap; }
.row-actions button + button { margin-left: 7px; }
.config-grid { display: grid; grid-template-columns: minmax(0, 540px) minmax(260px, 390px); gap: 16px; align-items: start; }
.config-side { display: grid; gap: 16px; min-width: 0; }
.assistant-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 700px);
  gap: 16px;
  align-items: start;
}
.assistant-alerts { margin: 0; padding-left: 20px; }
.assistant-alerts li + li, .assistant-alerts ul { margin-top: 8px; }
.assistant-alerts ul { padding-left: 16px; overflow-wrap: anywhere; }
.assistant-low-margin { color: var(--red); white-space: nowrap; }
.assistant-config-link { margin-top: 14px; }
.assistant-messages {
  display: grid;
  gap: 12px;
  max-height: 460px;
  overflow-y: auto;
  padding: 1px;
  margin: 16px 0;
  list-style: none;
}
.assistant-messages:empty { display: none; }
.assistant-messages > li { padding: 10px 12px; border-radius: 8px; max-width: 100%; }
.assistant-question { justify-self: end; background: #e8f3ff; }
.assistant-answer { justify-self: start; background: var(--canvas); }
.assistant-message-content { display: grid; gap: 8px; margin-top: 3px; color: var(--ink); overflow-wrap: anywhere; }
.assistant-message-content p { color: inherit; white-space: pre-wrap; }
.assistant-message-content ul { margin: 0; padding-inline-start: 22px; list-style: disc; }
#assistant-chat > label { margin: 14px 0 5px; }
#assistant-chat textarea {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--ink);
  padding: 9px 10px;
  border: 1px solid #cbd8e7;
  border-radius: 7px;
  resize: vertical;
}
.assistant-chat-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.assistant-chat-actions button { margin-left: auto; }
.user-list { list-style: none; padding: 0; margin: 0 0 15px; }
.user-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 36px; padding-block: 3px; border-bottom: 1px solid var(--line); }
.user-list [data-user-name] { overflow-wrap: anywhere; }
.connection-mapping { margin-top: 16px; }
.mapping-table { min-width: 400px; }
.mapping-table td:last-child { width: 55%; }
.clinic-hours { margin-block: 4px; }
.clinic-hours caption { color: var(--navy); font-weight: 680; text-align: left; padding-block: 4px; }
.clinic-hours tr > :first-child { padding-left: 0; }
.clinic-hours tr > :last-child { padding-right: 0; text-align: right; width: 34%; }
.clinic-hours th, .clinic-hours td { padding-block: 4px; }
.clinic-hours tfoot { font-weight: 680; font-variant-numeric: tabular-nums; }
.clinic-hours tfoot tr:first-child > * { border-top: 1px solid var(--line); padding-top: 8px; }
.cost-card { background: var(--navy); color: var(--white); border-radius: var(--radius); padding: 24px; }
.cost-card h2, .cost-card p { color: #e0ecf8; }
.cost-card strong { display: block; margin-block: 7px; font-size: clamp(26px, 4vw, 36px); line-height: 1.2; }
.treatment-footer { margin-top: 14px; }
.modal { border: 1px solid var(--line); box-shadow: 0 18px 56px #112c4944; border-radius: 14px; padding: 22px; width: min(440px, calc(100% - 30px)); color: var(--ink); }
.modal h2 { margin-bottom: 12px; }
.modal::backdrop { background: #10274175; }

.worksheet-page { min-height: 100vh; background: var(--white); }
.worksheet-page .shell, .sheet-embed { font: 13px/1.35 var(--sheet-type); }
.worksheet-page .shell { padding-top: 16px; }
.treatment-page .shell { padding-top: 8px; }
.sheet-embed { min-width: 0; background: var(--white); }
.worksheet-heading { margin-bottom: 5px; }
.worksheet-heading h1 { color: var(--ink); font-size: 21px; letter-spacing: normal; }
.worksheet-heading p { margin-top: 3px; }
.sheet-toolbar { padding-block: 6px; }
.sheet-toolbar h2 { color: var(--ink); font-size: 14px; letter-spacing: normal; }
.worksheet-page .shell .button { min-height: 28px; padding: 3px 9px; border-radius: 2px; font-size: 13px; }
.sheet-toolbar .search input { min-height: 26px; padding: 2px 7px; border-radius: 0; }

.sheet-grid { border-collapse: collapse; background: var(--white); }
.sheet-grid :is(thead, tbody, tfoot) tr > * {
  height: var(--sheet-row-height);
  padding: 2px 7px;
  border: 1px solid #d0d0d0;
  font-size: 13px;
  line-height: 18px;
}
.sheet-grid thead, .sheet-grid tfoot { background: var(--sheet-header); }
.sheet-grid thead th { color: var(--ink); }
.sheet-grid tbody th { font-weight: 400; }
.sheet-grid .text-button { padding: 0 2px; }
.sheet-grid .sheet-key { background: var(--sheet-blue); }
.sheet-grid .sheet-input { padding: 0; }
.sheet-input input, .sheet-input select {
  display: block;
  min-height: calc(var(--sheet-row-height) - 1px);
  padding: 2px 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.sheet-input .input-box:has(.input-unit) input { padding-right: 34px; }
.sheet-input .input-unit { right: 6px; }
.sheet-input.numeric input { text-align: right; }
.sheet-input :focus-visible, .sheet-grid .text-button:focus-visible { outline-offset: -2px; }
.sheet-grid .status { min-width: 0; padding: 0 3px; border-radius: 0; font-size: inherit; }

.catalog-sheet { max-width: 780px; }
.catalog-sheet .sheet-grid { min-width: 595px; }
.catalog-sheet th:first-child { width: 37%; }
.catalog-sheet .sheet-grid .empty { padding: 7px; }

.formulation-grid {
  display: grid;
  grid-template-columns: minmax(195px, .8fr) minmax(270px, 1.1fr) minmax(430px, 1.9fr);
  align-items: start;
  gap: 12px;
  max-width: 1100px;
  margin-bottom: 12px;
}
.sheet-band {
  display: flex;
  align-items: center;
  height: var(--sheet-row-height);
  border: 1px solid var(--sheet-line);
  border-bottom: 0;
  padding-inline: 7px;
  background: var(--sheet-header);
  font-size: 13px;
  letter-spacing: normal;
}
.clinic-sheet-frame, .sheet-tabs-frame { display: block; width: 100%; border: 0; }
.clinic-sheet-frame { height: calc(2 * var(--sheet-row-height) + 1px); }
.clinic-sheet-grid { table-layout: fixed; }
.clinic-label { width: 52%; }
.clinic-sheet .clinic-sheet-grid tr > * { border-top: 0; }
.price-sheet { table-layout: fixed; }
.price-label { width: 57%; }
.discount-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.commission-sheet { max-width: 550px; }
.commission-sheet table { min-width: 378px; }
.commission-sheet td:nth-child(3):not([data-value]) { width: 21%; }
.materials-sheet, .treatment-footer { max-width: 790px; }
.materials-sheet { margin-top: 9px; }
.material-lines { min-width: 480px; table-layout: fixed; }
.material-name { width: 45%; }
.material-qty { width: 14%; }
.material-unit, .material-cost { width: 15%; }
.material-lines select { text-overflow: ellipsis; }
.line-note { display: block; color: var(--amber-ink); }
.notice { color: #75400b; background: var(--amber-wash); padding: 4px 7px; margin-bottom: 5px; }

.sheet-tabs-bar {
  position: fixed;
  z-index: 5;
  inset: auto 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--sheet-line);
  background: var(--sheet-header);
}
.sheet-tabs-frame, .sheet-tabs { height: var(--sheet-tabs-height); }
.sheet-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 0;
  margin: 0;
  padding-inline: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  background: var(--sheet-header);
  font: 13px/1.35 var(--sheet-type);
}
.sheet-tabs a {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--sheet-line);
  border-top: 2px solid transparent;
  border-radius: 0;
  color: var(--ink);
  background: #e9e9e9;
  font-weight: 600;
  scroll-margin-inline: 12px;
  white-space: nowrap;
}
.sheet-tabs a + a { border-left: 0; }
.sheet-tabs a:hover { color: var(--ink); background: var(--sheet-header); text-decoration: none; }
.sheet-tabs a[aria-current="page"] { border-top-color: var(--blue); color: var(--ink); background: var(--white); }
.sheet-tabs a:focus-visible { outline-offset: -3px; }
.sheet-tabs[data-tab-order] [data-treatment-tab] { cursor: grab; }
.sheet-tabs a.dragging { opacity: .55; cursor: grabbing; }
.sheet-tabs a.drop-before { box-shadow: inset 3px 0 var(--blue); }
.sheet-tabs a.drop-after { box-shadow: inset -3px 0 var(--blue); }

@media (max-width: 990px) {
  .formulation-grid { grid-template-columns: minmax(195px, 1fr) minmax(270px, 1.4fr); }
  .discount-grid { grid-column: 1 / -1; }
}
@media (max-width: 880px) {
  .header-inner, .shell { width: min(100% - 32px, 1360px); }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gains-charts { grid-template-columns: minmax(0, 1fr); }
  .chart-panel .panel-head { min-height: 0; }
}
@media (max-width: 1050px) {
  :root { scroll-padding-top: 116px; }
  .header-inner { grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; padding-block: 7px; }
  .primary-nav { grid-row: 2; grid-column: 1 / -1; border-left: 0; padding-left: 0; flex-wrap: wrap; }
  .primary-nav a { padding: 6px 10px; }
}
@media (max-width: 460px) {
  :root { scroll-padding-top: 166px; }
  .header-controls { display: contents; }
  .header-controls form { grid-area: 1 / 2; justify-self: end; }
  .header-controls .specialty-nav { grid-area: 2 / 1 / auto / -1; justify-self: stretch; width: auto; }
  .primary-nav { grid-row: 3; }
}
@media (max-width: 650px) {
  .shell { padding-top: 21px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
  .summary-card { padding: 10px 12px; }
  .summary-card > span { font-size: 12px; }
  .config-grid { grid-template-columns: 1fr; }
  .assistant-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 530px) {
  .primary-nav a { padding-inline: 7px; font-size: 13px; }
  .brand { gap: 7px; font-size: 14px; }
  .brand-mark { width: 28px; height: 28px; }
  .specialty-nav summary { padding-inline: 8px; gap: 0 6px; }
  .specialty-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 12px;
  }
  .chart-panel { --chart-columns: minmax(0, 1fr) minmax(0, .85fr) 66px; }
  .specialty-breakdown { --chart-columns: minmax(0, 1fr) 68px 76px; }
  .specialty-breakdown .chart-name { font-size: 12px; }
  .specialty-breakdown .chart-bar, .specialty-breakdown .chart-scale { grid-area: 2 / 1 / auto / -1; }
  .chart-row { padding-inline: 10px; gap: 5px; }
  .chart-value { font-size: 11px; }
  .formulation-grid { grid-template-columns: minmax(0, 1fr); }
  .clinic-sheet { max-width: 250px; }
  .discount-sheet tbody th { line-height: 15px; }
}
