:root {
  --bg: #eef3f0;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-strong: #ffffff;
  --ink: #24323a;
  --muted: #5f7177;
  --line: #c8d4d1;
  --accent: #2d6a63;
  --accent-deep: #214f4a;
  --accent-soft: #dfeee9;
  --warning: #f7f0d8;
  --success: #e2f3e8;
  --danger: #f9e1e1;
  --triangle: #4c5358;
  --vital: #f5edb3;
  --balance: #dbdbdb;
  --shadow: 0 24px 60px rgba(34, 51, 59, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --col-1-width: clamp(180px, 17vw, 220px);
  --col-2-width: clamp(132px, 12vw, 170px);
  --col-3-width: clamp(42px, 4vw, 56px);
  --hour-cell-size: clamp(24px, 2.3vw, 34px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: auto;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(45, 106, 99, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(161, 199, 191, 0.2), transparent 25%),
    linear-gradient(180deg, #eef3f0 0%, #f7f8f7 45%, #edf4f2 100%);
}

body.body--drawer-open {
  overflow: hidden;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px clamp(10px, 2vw, 24px);
  border-bottom: 1px solid rgba(203, 216, 212, 0.9);
  background: rgba(247, 250, 249, 0.88);
  backdrop-filter: blur(14px);
  transition: padding 0.2s ease, gap 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.app-header__brand,
.app-header__user {
  min-width: 0;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-deep);
  text-decoration: none;
  transition: font-size 0.2s ease;
}

.app-header__note,
.app-header__profile-meta span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-header__user {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.app-header__profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.app-header__profile-meta {
  display: grid;
  min-width: 0;
  transition: opacity 0.2s ease;
}

.app-header__profile-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  display: inline-flex;
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(203, 216, 212, 0.9);
  background: linear-gradient(135deg, rgba(223, 238, 233, 0.95), rgba(255, 255, 255, 0.98));
  box-shadow: 0 10px 24px rgba(34, 51, 59, 0.08);
  transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease, flex-basis 0.2s ease;
}

.user-avatar img,
.user-avatar__placeholder {
  width: 100%;
  height: 100%;
}

.user-avatar img {
  display: block;
  object-fit: cover;
}

.user-avatar__placeholder {
  display: grid;
  place-items: center;
  color: var(--accent-deep);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.app-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  min-width: 0;
}

.app-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(203, 216, 212, 0.86);
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent-deep);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
}

.app-nav__link--active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 12px 26px rgba(45, 106, 99, 0.18);
}

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

.page-glow {
  position: fixed;
  inset: auto;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(82px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

.page-glow--left {
  top: -8rem;
  left: -6rem;
  background: rgba(45, 106, 99, 0.22);
}

.page-glow--right {
  top: 8rem;
  right: -6rem;
  background: rgba(186, 214, 208, 0.45);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  min-width: 0;
  padding-inline: clamp(8px, 1.4vw, 20px);
  margin: clamp(10px, 2vw, 24px) auto clamp(24px, 4vw, 48px);
}

.hero-card,
.surface-card,
.message-box {
  animation: rise 0.45s ease both;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 28px 30px;
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 247, 243, 0.95));
  border: 1px solid rgba(203, 216, 212, 0.9);
  box-shadow: var(--shadow);
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 700;
}

.hero-card h1,
.surface-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.hero-card h1 {
  font-size: clamp(2rem, 3vw, 2.85rem);
}

.hero-copy,
.section-note {
  margin: 10px 0 0;
  line-height: 1.55;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.message-box {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(190, 201, 196, 0.9);
  background: var(--warning);
  line-height: 1.5;
}

.message-box--success {
  background: var(--success);
}

.message-box--info {
  background: rgba(223, 238, 233, 0.78);
}

.message-box--error {
  background: var(--danger);
}

.message-box a {
  margin-left: 8px;
  color: var(--accent-deep);
  font-weight: 700;
}

.workspace {
  margin-top: 18px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

.card-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: rgba(28, 29, 31, 0.96);
  box-shadow: 0 18px 30px rgba(17, 21, 24, 0.24);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.card-sidebar-toggle:hover,
.card-sidebar-toggle:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 22px 36px rgba(17, 21, 24, 0.28);
}

.card-sidebar-toggle__lines {
  display: grid;
  gap: 10px;
}

.card-sidebar-toggle__lines span {
  display: block;
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.card-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 0.28fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.card-workspace__main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.card-sidebar {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.card-sidebar__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-sidebar__head h2 {
  font-size: 1.35rem;
  margin: 0;
}

.card-sidebar__close {
  display: none;
}

.card-sidebar__nav {
  display: grid;
  gap: 10px;
}

.card-sidebar__link {
  display: inline-flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid rgba(203, 216, 212, 0.9);
  background: rgba(248, 251, 250, 0.96);
  color: var(--accent-deep);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.card-sidebar__link:hover {
  transform: translateY(-1px);
  border-color: rgba(45, 106, 99, 0.3);
  box-shadow: 0 10px 24px rgba(34, 51, 59, 0.08);
}

.card-sidebar__link--nested {
  padding-left: 22px;
  font-size: 0.94rem;
}

.card-sidebar-backdrop {
  display: none;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 80px);
}

.auth-card {
  width: min(100%, 520px);
  padding: clamp(22px, 3vw, 34px);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 248, 245, 0.94));
  border: 1px solid rgba(203, 216, 212, 0.9);
  box-shadow: var(--shadow);
}

.auth-form,
.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form--compact {
  gap: 12px;
}

.surface-card {
  padding: clamp(18px, 2vw, 24px);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid rgba(203, 216, 212, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  min-width: 0;
}

.sheet-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 249, 0.95)),
    linear-gradient(90deg, rgba(45, 106, 99, 0.03), transparent);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
  min-width: 0;
}

.section-head h2 {
  font-size: 1.55rem;
}

.section-head > * {
  min-width: 0;
}

.patient-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field span {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field textarea,
.field select,
.matrix-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.matrix-input:focus {
  border-color: rgba(45, 106, 99, 0.76);
  box-shadow: 0 0 0 4px rgba(45, 106, 99, 0.12);
  transform: translateY(-1px);
}

.field--wide {
  grid-column: span 2;
}

.field--compact {
  max-width: 320px;
}

.field--date input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  min-height: 48px;
  text-align: left;
  text-align-last: left;
}

.field--date input[type="date"]::-webkit-date-and-time-value,
.field--date input[type="date"]::-webkit-datetime-edit {
  text-align: left;
}

.field--date input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

.field--date input[type="date"]::-webkit-calendar-picker-indicator {
  margin: 0;
  opacity: 0.88;
}

.catalog-layout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
}

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

.profile-card {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.profile-card__avatar {
  width: 148px;
  aspect-ratio: 1;
  border-radius: 30px;
  border: 1px solid rgba(203, 216, 212, 0.9);
  background: linear-gradient(135deg, rgba(223, 238, 233, 0.95), rgba(255, 255, 255, 0.98));
  color: var(--accent-deep);
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 16px 34px rgba(34, 51, 59, 0.08);
}

.profile-card__avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.profile-card__avatar span {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.catalog-search {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.catalog-search input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  padding: 12px 14px;
}

.catalog-list {
  display: grid;
  gap: 12px;
}

.catalog-list--forms {
  gap: 14px;
}

.catalog-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(203, 216, 212, 0.86);
  border-radius: 18px;
  background: rgba(248, 251, 250, 0.92);
}

.catalog-item--form {
  display: block;
}

.catalog-item__meta {
  display: grid;
  gap: 4px;
}

.catalog-item__meta span {
  color: var(--muted);
  font-size: 0.92rem;
}

.catalog-item__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form {
  margin: 0;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(177, 194, 188, 0.9);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.76);
}

.empty-state--left {
  text-align: left;
}

.lookup-panel {
  display: grid;
  gap: 14px;
}

.lookup-panel__field {
  position: relative;
}

.lookup-panel__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(223, 238, 233, 0.45);
  border: 1px solid rgba(203, 216, 212, 0.86);
  color: var(--muted);
  font-weight: 600;
}

.inline-chip--active {
  background: rgba(223, 238, 233, 0.9);
  color: var(--accent-deep);
}

.search-input-shell {
  position: relative;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 12;
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(203, 216, 212, 0.92);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 40px rgba(34, 51, 59, 0.12);
}

.search-results:empty {
  display: none;
}

.search-results--inline {
  top: calc(100% + 6px);
}

.search-results__item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(203, 216, 212, 0.86);
  border-radius: 14px;
  background: rgba(248, 251, 250, 0.94);
  text-align: left;
  cursor: pointer;
}

.search-results__item--compact {
  padding: 10px 12px;
}

.search-results__item strong {
  color: var(--accent-deep);
}

.search-results__item span,
.search-results__empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.search-results__empty {
  padding: 8px 10px;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar--tight {
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 14px 30px rgba(45, 106, 99, 0.22);
}

.secondary-button {
  color: var(--accent-deep);
  background: rgba(223, 238, 233, 0.94);
  border-color: rgba(45, 106, 99, 0.14);
}

.secondary-button--active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #ffffff;
  border-color: transparent;
}

.ghost-button {
  color: #9b4343;
  background: rgba(249, 225, 225, 0.72);
  border-color: rgba(155, 67, 67, 0.12);
  min-height: 40px;
  padding: 0 14px;
}

.ghost-button--small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.secondary-button--small {
  min-height: 40px;
  padding: 0 14px;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.editor-list {
  display: grid;
  gap: 14px;
}

.editor-group {
  display: grid;
  gap: 14px;
}

.editor-group__title {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(223, 238, 233, 0.76);
  border: 1px solid rgba(203, 216, 212, 0.86);
  font-weight: 700;
  color: var(--accent-deep);
}

.editor-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(203, 216, 212, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.94));
}

.editor-card__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.editor-card__index {
  font-weight: 700;
  color: var(--accent-deep);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.editor-grid--orders .field--wide {
  grid-column: span 2;
}

.patient-preview {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.preview-chip {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(203, 216, 212, 0.9);
  background: rgba(248, 251, 250, 0.92);
}

.preview-chip span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.preview-chip strong {
  font-size: 0.96rem;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 18px;
  border: 1px solid rgba(203, 216, 212, 0.9);
  background: rgba(255, 255, 255, 0.95);
}

.table-scroll--editor {
  overflow: hidden;
  padding: 12px;
}

.table-scroll--sheet {
  max-width: 100%;
  overflow-x: hidden;
  padding: 10px;
}

.sheet-fit-frame {
  position: relative;
  width: max-content;
  transform-origin: top left;
}

.card-preview-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.card-preview-overlay > * {
  pointer-events: none;
}

.card-preview-overlay svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  shape-rendering: geometricPrecision;
}

.card-preview-overlay line,
.card-preview-overlay polyline,
.card-preview-overlay polygon,
.card-preview-overlay line,
.card-preview-overlay circle {
  stroke: var(--triangle);
  stroke-width: 2.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-preview-overlay .card-preview-overlay__continuous-arrow {
  position: absolute;
  height: 0;
  border-top: 3px solid var(--triangle);
  transform: translateY(-50%);
  z-index: 3;
}

.card-preview-overlay .card-preview-overlay__continuous-arrow::after {
  content: "";
  position: absolute;
  right: calc(-1 * var(--arrow-head-width));
  top: 50%;
  width: 0;
  height: 0;
  border-top: calc(var(--arrow-head-height) / 2) solid transparent;
  border-bottom: calc(var(--arrow-head-height) / 2) solid transparent;
  border-left: var(--arrow-head-width) solid var(--triangle);
  transform: translateY(-50%);
}

.table-scroll--sheet[data-scale-state="scaled"] {
  overflow: hidden;
}

.matrix-host {
  min-width: 0;
  width: 100%;
}

.responsive-editor {
  display: grid;
  gap: 14px;
}

.hourly-card {
  border: 1px solid rgba(203, 216, 212, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  padding: 14px;
}

.hourly-card--vital {
  background: linear-gradient(180deg, rgba(245, 237, 179, 0.34), rgba(255, 255, 255, 0.96));
}

.hourly-card--input {
  background: linear-gradient(180deg, rgba(223, 238, 233, 0.34), rgba(255, 255, 255, 0.96));
}

.hourly-card--output {
  background: linear-gradient(180deg, rgba(219, 219, 219, 0.3), rgba(255, 255, 255, 0.96));
}

.hourly-card__head {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(120px, 0.6fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.hourly-card__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hourly-card__title {
  font-weight: 700;
  color: var(--accent-deep);
}

.hourly-card__summary {
  font-size: 0.88rem;
  color: var(--muted);
}

.hour-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.hour-chip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(203, 216, 212, 0.76);
  background: rgba(248, 251, 250, 0.92);
}

.hour-chip span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.hour-chip input {
  min-width: 0;
  padding: 10px 8px;
  text-align: center;
}

.preview-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.preview-hint {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(203, 216, 212, 0.9);
  background: rgba(223, 238, 233, 0.5);
  color: var(--accent-deep);
  line-height: 1.45;
}

.matrix-table,
.sheet-table {
  border-collapse: collapse;
  min-width: 100%;
  width: max-content;
  background: var(--surface-strong);
}

.matrix-table th,
.matrix-table td,
.sheet-table th,
.sheet-table td {
  border: 1px solid rgba(177, 194, 188, 0.84);
  text-align: center;
  vertical-align: middle;
}

.matrix-table th,
.sheet-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--accent-deep);
  color: #ffffff;
  font-weight: 700;
  padding: 10px 12px;
}

.audit-table {
  width: 100%;
  min-width: 980px;
}

.audit-table td {
  padding: 12px;
  text-align: left;
  vertical-align: top;
  background: rgba(255, 255, 255, 0.97);
}

.table-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.audit-meta {
  margin: 0;
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  color: var(--accent-deep);
}

.audit-pagination {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-frame {
  display: block;
  width: 100%;
  min-height: 72vh;
  border: 1px solid rgba(203, 216, 212, 0.9);
  border-radius: 18px;
  background: #ffffff;
}

.session-reset-frame {
  position: absolute;
  width: 0;
  height: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.matrix-table__sticky,
.sticky-col--1 {
  position: sticky;
  left: 0;
  z-index: 2;
}

.sticky-col--2 {
  position: sticky;
  left: var(--col-1-width);
  z-index: 2;
}

.sticky-col--3 {
  position: sticky;
  left: calc(var(--col-1-width) + var(--col-2-width));
  z-index: 2;
}

.matrix-table__sticky {
  background: #f7faf8;
}

.matrix-table th.matrix-table__sticky,
.sheet-table th.sticky-col {
  background: var(--accent-deep);
  color: #ffffff;
  z-index: 4;
}

.matrix-table__label {
  min-width: 180px;
  text-align: left;
  font-weight: 700;
}

.matrix-table__row--vital td {
  background: rgba(245, 237, 179, 0.48);
}

.matrix-table__row--input td {
  background: rgba(223, 238, 233, 0.35);
}

.matrix-table__row--output td {
  background: rgba(219, 219, 219, 0.42);
}

.matrix-input {
  min-width: 74px;
  padding: 8px 10px;
  border-radius: 10px;
}

.matrix-input--hour {
  min-width: 58px;
  text-align: center;
  padding-inline: 6px;
}

.matrix-input--comment {
  min-width: 160px;
}

.matrix-input--label {
  min-width: 230px;
}

.matrix-input--unit {
  min-width: 70px;
  text-align: center;
}

.matrix-table__total {
  min-width: 86px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.94);
}

.sheet-table--kit th,
.sheet-table--kit td {
  padding: 0;
}

.sheet-table--kit {
  font-size: clamp(0.58rem, 0.72vw, 0.82rem);
}

.sheet-table--kit .left-cell,
.sheet-table--kit .detail-cell,
.sheet-table--kit .scale-cell,
.sheet-table--kit .total-cell {
  padding: 8px 10px;
}

.sheet-table--kit .left-cell {
  width: var(--col-1-width);
  min-width: var(--col-1-width);
  text-align: left;
}

.sheet-table--kit .detail-cell {
  width: var(--col-2-width);
  min-width: var(--col-2-width);
  text-align: left;
}

.sheet-table--kit .scale-cell {
  width: var(--col-3-width);
  min-width: var(--col-3-width);
  text-align: center;
  background: rgba(246, 248, 247, 0.96);
  color: var(--muted);
  font-weight: 700;
}

.sheet-table--kit .total-cell {
  min-width: 76px;
  width: 76px;
  font-weight: 700;
  background: rgba(250, 251, 250, 0.98);
}

.sticky-col {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 1px 0 0 rgba(177, 194, 188, 0.6);
}

.section-row td {
  padding: 10px 12px;
  background: var(--accent-soft);
  font-weight: 700;
  text-align: left;
}

.band-row td {
  padding: 10px 12px;
  font-weight: 700;
  text-align: left;
}

.band-row--vital td {
  background: rgba(245, 237, 179, 0.82);
}

.band-row--balance td {
  background: rgba(219, 219, 219, 0.82);
}

.sheet-main-text {
  font-weight: 700;
}

.sheet-sub-text {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.sheet-sub-text--success {
  color: var(--accent-deep);
  font-weight: 600;
}

.hour-cell {
  position: relative;
  width: var(--hour-cell-size);
  min-width: var(--hour-cell-size);
  height: clamp(32px, 2.8vw, 46px);
  background: #ffffff;
  user-select: none;
  overflow: visible;
}

.hour-cell--vital {
  background: rgba(245, 237, 179, 0.56);
  font-weight: 700;
}

.hour-cell--balance {
  background: rgba(219, 219, 219, 0.42);
}

.hour-cell__label {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.hour-cell__label--corner {
  inset: 4px auto auto 5px;
  width: auto;
  height: auto;
  display: block;
  font-size: 0.66rem;
  text-align: left;
}

.hour-cell__label--below {
  inset: auto 2px 3px 2px;
  width: auto;
  height: auto;
  display: block;
  font-size: 0.64rem;
  text-align: center;
}

.hour-cell__label--center-note {
  font-size: 0.66rem;
  color: var(--accent-deep);
}

.marker {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.hour-cell--mark,
.hour-cell--single,
.hour-cell--text {
  background: #ffffff;
}

.marker--text {
  display: none;
}

.marker--token {
  color: var(--accent-deep);
}

.hour-cell--triangle {
  background: rgba(226, 243, 232, 0.92);
}

.hour-cell--arrow {
  background: rgba(90, 125, 116, 0.92);
}

.hour-cell--arrow .marker--token,
.hour-cell--arrow .hour-cell__label {
  color: #ffffff;
}

.hour-cell--preview-arrow-slot {
  background: #ffffff;
}

.hour-cell--preview-arrow-slot .marker--token {
  display: none;
}

.hour-cell--single {
  background: rgba(230, 239, 236, 0.98);
}

.hour-cell--interactive {
  cursor: crosshair;
}

.hour-cell--active-mark {
  cursor: pointer;
}

.hour-cell--drag-hover {
  background: rgba(45, 106, 99, 0.18);
}

.vital-row .sticky-col {
  background: rgba(245, 237, 179, 0.92);
}

.balance-row--input .sticky-col {
  background: rgba(223, 238, 233, 0.9);
}

.balance-row--output .sticky-col {
  background: rgba(219, 219, 219, 0.88);
}

.summary-row td {
  padding: 8px 10px;
  font-weight: 700;
}

.summary-row--input td {
  background: rgba(226, 243, 232, 0.88);
}

.summary-row--input .sticky-col {
  background: rgba(226, 243, 232, 0.98);
}

.summary-row--output td {
  background: rgba(249, 225, 225, 0.88);
}

.summary-row--output .sticky-col {
  background: rgba(249, 225, 225, 0.98);
}

.summary-row--positive td {
  background: rgba(223, 238, 233, 0.92);
}

.summary-row--positive .sticky-col {
  background: rgba(223, 238, 233, 0.98);
}

.summary-row--negative td {
  background: rgba(249, 225, 225, 0.92);
}

.summary-row--negative .sticky-col {
  background: rgba(249, 225, 225, 0.98);
}

.summary-cards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(223, 238, 233, 0.82), rgba(255, 255, 255, 0.94));
  border: 1px solid rgba(203, 216, 212, 0.86);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.summary-card strong {
  font-size: 1.35rem;
}

.footer-panel {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  align-items: center;
  padding: 20px 22px;
  border-radius: 20px;
  border: 1px solid rgba(203, 216, 212, 0.88);
  background: rgba(255, 255, 255, 0.92);
}

.footer-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.footer-actions--between {
  justify-content: space-between;
}

.inline-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(223, 238, 233, 0.72);
}

.is-hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .app-header,
  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .card-workspace {
    grid-template-columns: 1fr;
  }

  .card-sidebar {
    position: static;
  }

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

  .profile-card {
    grid-template-columns: 124px minmax(0, 1fr);
  }

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

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

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .lookup-panel__actions,
  .catalog-item {
    align-items: stretch;
    flex-direction: column;
  }

  .footer-panel,
  .hero-card,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 980px) {
  .card-sidebar-toggle {
    display: inline-flex;
    position: fixed;
    left: 10px;
    top: calc(env(safe-area-inset-top, 0px) + 188px);
    z-index: 39;
  }

  .card-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 360px);
    z-index: 41;
    border-radius: 0 28px 28px 0;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-108%);
    transition: transform 0.24s ease;
    overflow-y: auto;
  }

  .card-sidebar__close {
    display: inline-flex;
  }

  .card-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    background: rgba(21, 34, 38, 0.34);
    opacity: 0;
    pointer-events: none;
  }

  .card-workspace--drawer-open .card-sidebar {
    display: grid;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .card-workspace--drawer-open .card-sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  body.body--drawer-open .card-sidebar-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.96);
  }
}

@media (max-width: 760px) {
  :root {
    --col-1-width: 170px;
    --col-2-width: 120px;
    --col-3-width: 40px;
    --hour-cell-size: 24px;
  }

  .page-shell {
    width: 100%;
    margin: 8px auto 24px;
    padding-inline: 8px;
  }

  .surface-card,
  .hero-card {
    padding: 18px;
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand user"
      "nav nav";
    gap: 12px;
    align-items: center;
    padding: 12px 8px;
    background: #f7faf9;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 18px rgba(34, 51, 59, 0.06);
  }

  .app-header__brand {
    grid-area: brand;
  }

  .app-nav {
    grid-area: nav;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .app-nav::-webkit-scrollbar {
    display: none;
  }

  .app-header__user {
    grid-area: user;
    justify-content: flex-end;
    align-self: start;
  }

  .app-header__profile {
    width: auto;
  }

  .patient-grid,
  .editor-grid,
  .patient-preview {
    grid-template-columns: 1fr;
  }

  .hourly-card__head,
  .hour-grid {
    grid-template-columns: 1fr;
  }

  .field--wide {
    grid-column: span 1;
  }

  .profile-card {
    grid-template-columns: 1fr;
  }

  .profile-card__avatar {
    width: min(180px, 100%);
    justify-self: center;
  }

  .catalog-search,
  .lookup-panel__actions {
    flex-direction: column;
  }

  .matrix-input--label {
    min-width: 180px;
  }

  .app-header--mobile-compact {
    gap: 8px;
    padding: 8px 8px 10px;
    background: #f7faf9;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 10px 24px rgba(34, 51, 59, 0.08);
  }

  .app-header--mobile-compact .app-logo {
    font-size: 1.08rem;
  }

  .app-header--mobile-compact .app-header__note,
  .app-header--mobile-compact .app-header__profile-meta {
    display: none;
  }

  .app-header--mobile-compact .app-header__user {
    gap: 8px;
    align-self: center;
  }

  .app-header--mobile-compact .user-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
  }

  .app-header--mobile-compact .secondary-button--small {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.92rem;
  }

  .app-header--mobile-compact .app-nav {
    gap: 8px;
  }

  .app-header--mobile-compact .app-nav__link {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.92rem;
  }

  .card-sidebar-toggle {
    width: 60px;
    height: 60px;
    left: 8px;
    top: calc(env(safe-area-inset-top, 0px) + 154px);
    border-radius: 18px;
  }

  .app-header--mobile-compact ~ .page-shell .card-sidebar-toggle,
  .app-header--mobile-compact + .page-shell .card-sidebar-toggle {
    top: calc(env(safe-area-inset-top, 0px) + 98px);
  }

  .card-sidebar-toggle__lines {
    gap: 8px;
  }

  .card-sidebar-toggle__lines span {
    width: 30px;
    height: 3px;
  }
}
