:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --line: #dfe4f0;
  --line-strong: #cbd4e6;
  --text: #121826;
  --muted: #737c91;
  --faint: #a9b2c6;
  --blue: #3f82f6;
  --blue-soft: #eaf2ff;
  --violet: #7c68ee;
  --green: #00a991;
  --orange: #f59e0b;
  --red: #ef4444;
  --sidebar: #f3f5fa;
  --shadow: 0 10px 30px rgba(19, 33, 68, 0.08);
}

@media (max-width: 700px) {
  .app-shell.is-chart-detail {
    min-height: 100svh;
    padding-bottom: 0;
    background: #fff;
  }

  .app-shell.is-chart-detail .main {
    min-height: 100svh;
    padding-bottom: 0;
  }

  .app-shell.is-chart-detail .page-head,
  .app-shell.is-chart-detail .sidebar,
  .app-shell.is-chart-detail .chart-bottom.bottom-bar {
    display: none !important;
  }

  .app-shell.is-chart-detail .content {
    min-height: 100svh;
  }

  .app-shell.is-chart-detail .enhanced-chart-topbar.chart-topbar {
    position: static;
    padding: 8px 10px 7px;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }

  .app-shell.is-chart-detail .enhanced-chart-topbar .chart-patient-summary {
    gap: 2px 7px;
  }

  .app-shell.is-chart-detail .enhanced-chart-topbar .patient-name {
    font-size: 16px;
  }

  .app-shell.is-chart-detail .enhanced-chart-topbar .clinical-note {
    min-height: 24px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.25;
  }

  .app-shell.is-chart-detail .enhanced-chart-topbar .chart-top-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .app-shell.is-chart-detail .enhanced-chart-topbar .chart-top-actions .btn {
    min-height: 42px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.1;
  }

  .app-shell.is-chart-detail .mobile-chart-tabs {
    top: 0;
    z-index: 70;
    gap: 5px;
    padding: 6px 8px;
  }

  .app-shell.is-chart-detail .mobile-chart-tabs button {
    min-height: 46px;
    padding: 4px 3px;
    border-radius: 8px;
  }

  .app-shell.is-chart-detail .mobile-chart-tabs strong {
    font-size: 13px;
  }

  .app-shell.is-chart-detail .mobile-chart-tabs span {
    display: none;
  }

  .app-shell.is-chart-detail .enhanced-chart-detail.chart-detail {
    padding-bottom: 16px;
  }

  .app-shell.is-chart-detail .chart-main {
    padding: 0;
  }

  .app-shell.is-chart-detail .mobile-touch-chart-pad {
    gap: 6px;
    margin: 8px 10px 10px;
    padding: 8px;
    border-radius: 8px;
  }

  .app-shell.is-chart-detail .mobile-touch-pad-head {
    align-items: center;
  }

  .app-shell.is-chart-detail .mobile-touch-pad-head span {
    display: none;
  }

  .app-shell.is-chart-detail .mobile-touch-pad-head strong {
    font-size: 14px;
  }

  .app-shell.is-chart-detail .mobile-touch-chip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .app-shell.is-chart-detail .mobile-touch-order-row,
  .app-shell.is-chart-detail .mobile-touch-action-row {
    gap: 6px;
  }

  .app-shell.is-chart-detail .mobile-touch-chip {
    min-height: 46px;
    padding: 5px 4px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.18;
  }

  .app-shell.is-chart-detail .mobile-touch-chip.soft {
    min-height: 44px;
  }

  .app-shell.is-chart-detail .chart-console-head {
    margin: 0 10px 8px;
    padding: 8px 0 0;
    gap: 8px;
  }

  .app-shell.is-chart-detail .chart-console-head h2 {
    font-size: 16px;
  }

  .app-shell.is-chart-detail .chart-console-head .tiny {
    font-size: 11px;
  }

  .app-shell.is-chart-detail .chart-console-head .chart-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .app-shell.is-chart-detail .chart-console-head .chart-actions .btn {
    min-height: 40px;
    padding: 0 4px;
    font-size: 12px;
  }

  .app-shell.is-chart-detail .chart-work-upload,
  .app-shell.is-chart-detail .memo-grid,
  .app-shell.is-chart-detail .record-card,
  .app-shell.is-chart-detail .diagnosis-box,
  .app-shell.is-chart-detail .finish-panel {
    margin-left: 10px;
    margin-right: 10px;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: white;
  color: var(--blue);
  font-weight: 800;
}

.collapse {
  margin-left: auto;
  color: var(--faint);
}

.nav-scroll {
  flex: 1;
  overflow: auto;
  padding: 10px 8px;
}

.nav-section {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.nav-group {
  position: relative;
  margin-bottom: 2px;
}

.nav-item {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #596174;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #e8edf7;
  color: #111827;
  font-weight: 700;
}

.nav-icon {
  width: 18px;
  color: #9aa5bb;
  text-align: center;
  font-size: 14px;
}

.chev {
  margin-left: auto;
  color: #9aa5bb;
}

.nav-chevron {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #9aa5bb;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.nav-chevron:hover {
  background: #dfe6f4;
  color: #42506a;
}

.nav-submenu {
  display: grid;
  gap: 2px;
  padding: 2px 0 8px 30px;
}

.nav-subitem {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #596174;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.nav-subitem:hover,
.nav-subitem.active {
  background: #e8edf7;
  color: #111827;
}

.nav-subitem em {
  color: #8a6df1;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.profile {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eadfff;
  color: #6d4dd8;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}

.main {
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
}

.page-head {
  height: 70px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 800;
}

.head-tabs {
  display: flex;
  align-items: center;
  gap: 14px;
}

.head-tab {
  border: 0;
  background: transparent;
  padding: 8px 0;
  color: #c2cad9;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.head-tab:hover,
.head-tab.active {
  color: #111827;
  border-bottom-color: #245fc8;
}

.content {
  min-width: 0;
}

.toolbar {
  min-height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
}

.toolbar.spread {
  justify-content: space-between;
}

.mobile-label {
  display: none;
}

.mobile-board-list {
  display: none;
}

.board-with-queue {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 7px var(--board-panel-w, 460px);
  height: calc(100vh - 122px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.board-with-queue.queue-collapsed {
  grid-template-columns: 54px minmax(0, 1fr) 7px var(--board-panel-w, 460px);
}

.board-left-queue {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  min-width: 0;
}

.queue-collapsed .board-left-queue {
  overflow: hidden;
}

.queue-collapsed .board-left-queue > *:not(.queue-title) {
  display: none;
}

.queue-title {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
}

.queue-title strong {
  white-space: nowrap;
}

.queue-title .btn {
  margin-left: auto;
}

.queue-tabs.slim {
  padding: 8px;
}

.board-workspace {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.board-panel-resizer {
  min-width: 7px;
  cursor: col-resize;
  background: #f7f9fd;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  position: relative;
  touch-action: none;
  z-index: 3;
}

.board-panel-resizer::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-left: 1px solid #c8d3e6;
  opacity: 0;
  transition: opacity 0.12s ease, border-color 0.12s ease;
}

.board-panel-resizer:hover,
.board-panel-resizing .board-panel-resizer {
  background: #e8f0ff;
}

.board-panel-resizer:hover::after,
.board-panel-resizing .board-panel-resizer::after {
  opacity: 1;
  border-left-color: #3f82f6;
}

.board-panel-resizing,
.board-panel-resizing * {
  cursor: col-resize !important;
  user-select: none;
}

.enhanced-board .board-grid {
  flex: 1;
  min-height: 0;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  overflow: auto;
}

.density-compact .enhanced-card {
  padding-top: 8px;
  padding-bottom: 8px;
}

.enhanced-card {
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.board-patient-card {
  cursor: pointer;
  min-height: 116px;
}

.board-patient-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(63, 130, 246, 0.16);
}

.reservation-card {
  border-color: #cbd8f1;
  background: #fbfdff;
}

.reservation-card .reservation-wait {
  color: #3f82f6;
}

.ai-workbench {
  height: 100%;
  min-height: 0;
  overflow: auto;
  background: #f7f9fc;
  padding: 18px 20px 28px;
}

.ai-hero,
.ai-panel {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
}

.ai-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 12px;
}

.ai-hero h2 {
  margin: 4px 0 6px;
  font-size: 24px;
  letter-spacing: 0;
}

.ai-hero-actions,
.ai-command-row,
.ai-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-panel {
  padding: 16px;
  margin-bottom: 12px;
}

.ai-panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-controls label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #566175;
}

.ai-controls .select {
  min-width: 180px;
}

.ai-check {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 6px !important;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcff;
}

.ai-status-grid,
.ai-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.ai-status-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #dbe3f1;
  border-radius: 8px;
  background: #fbfdff;
}

.ai-status-card strong,
.ai-status-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-prompt {
  min-height: 112px;
  width: 100%;
  margin-bottom: 10px;
  resize: vertical;
}

.ai-result {
  min-height: 180px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid #dbe3f1;
  border-radius: 8px;
  background: #fbfdff;
}

.ai-result.loading {
  background: #f3f7ff;
}

.ai-result pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  color: #27344a;
}

@media (max-width: 760px) {
  .ai-workbench {
    padding: 12px;
  }

  .ai-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-hero-actions,
  .ai-command-row {
    width: 100%;
  }

  .ai-hero-actions .btn,
  .ai-command-row .btn {
    flex: 1 1 130px;
  }
}

.planner-link-line {
  margin: 7px 0 0;
  color: #7a86a0;
  font-size: 11px;
  font-weight: 800;
}

.board-patient-card .card-top {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px 6px;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.board-patient-card .board-name-hit,
.board-patient-card .card-hover-icons,
.board-patient-card .card-hover-icons * {
  pointer-events: auto;
}

.board-name-hit {
  flex: 1 1 calc(100% - 58px);
  max-width: calc(100% - 58px);
  cursor: pointer;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}

.board-name-hit strong {
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  word-break: keep-all;
}

.card-hover-icons {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  position: relative;
  z-index: 8;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.reservation-card .card-hover-icons {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.board-patient-card:hover .card-hover-icons,
.board-patient-card:focus-within .card-hover-icons,
.board-patient-card.selected .card-hover-icons {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.card-icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid #d6dfef;
  border-radius: 6px;
  background: white;
  color: #61708a;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.card-icon-btn:hover,
.card-icon-btn:focus-visible {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #245fc8;
}

.wait-label {
  flex: 0 0 100%;
  margin-left: 0;
  color: #ff9f1a;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.board-patient-card.done .wait-label,
.board-patient-card.danger .wait-label {
  color: #e85050;
}

.card-demographic {
  margin: 7px 0 10px;
  color: #44516a;
  font-weight: 800;
}

.card-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 5px;
  font-size: 12px;
  font-weight: 900;
}

.actual-time {
  color: #f59e0b;
}

.reserved-time {
  color: #00a991;
}

.board-care-line {
  margin: 4px 0 0;
  color: #5f6d85;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.enhanced-card:hover {
  border-color: #a9b9d4;
  box-shadow: 0 8px 22px rgba(20, 36, 70, 0.11);
  transform: translateY(-1px);
}

.enhanced-card.danger {
  border-color: #ffd1d1;
}

.enhanced-card.done {
  background: #fbfffd;
}

.important-line {
  min-height: 22px;
  margin: 7px 0;
  padding: 5px 8px;
  border-radius: 7px;
  background: #fff8e7;
  color: #866000;
  font-weight: 700;
}

.hover-actions {
  display: flex;
  gap: 5px;
  margin: 8px 0;
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.enhanced-card:hover .hover-actions,
.enhanced-card:focus-within .hover-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.state-chip {
  font-size: 11px;
}

.state-chip.active {
  background: var(--blue-soft);
  color: #245fc8;
  border-color: #b8d0ff;
}

.enhanced-context {
  width: 286px;
}

.board-patient-panel {
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.board-patient-panel.empty {
  display: grid;
  place-items: center;
  padding: 24px;
}

.board-patient-top {
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.board-patient-top strong {
  display: inline-block;
  margin: 0 4px;
}

.board-patient-top .muted {
  display: block;
  margin-top: 3px;
}

.board-patient-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.board-patient-meta span {
  min-width: 0;
  color: #44516a;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-patient-meta b {
  color: #8a96aa;
  margin-right: 6px;
}

.board-patient-split {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(108px, 190px);
}

.board-visit-pane,
.board-record-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.board-record-pane {
  border-left: 1px solid var(--line);
  background: #fafbff;
}

.board-pane-head {
  min-height: 44px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.board-pane-head strong {
  margin-right: auto;
}

.board-visit-list,
.board-record-list {
  min-height: 0;
  overflow: auto;
}

.board-visit-card {
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  cursor: pointer;
  background: #fff;
}

.board-visit-card:hover,
.board-visit-card.active {
  border-left-color: var(--blue);
  background: #f1f6ff;
}

.board-visit-card p {
  margin: 5px 0;
  line-height: 1.45;
}

.board-record-card {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.board-record-card strong {
  display: inline-block;
  margin-left: 4px;
}

.board-record-card p {
  margin: 7px 0;
  line-height: 1.45;
}

.board-record-input {
  padding: 10px;
  border-top: 1px solid var(--line);
  background: white;
}

.board-record-input .textarea {
  width: 100%;
  min-height: 86px;
}

.board-record-input .btn {
  width: 100%;
  margin-top: 8px;
}

.enhanced-chart-topbar {
  position: sticky;
  top: 0;
  z-index: 8;
}

.enhanced-chart-detail {
  grid-template-columns: 230px 250px minmax(430px, 1fr) 300px 270px 48px;
}

.phrase-bank {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.phrase-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.phrase-tabs button,
.phrase-chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  min-height: 28px;
  padding: 0 9px;
  color: #566177;
  font-weight: 700;
}

.phrase-tabs button.active {
  color: #245fc8;
  border-color: #b8d0ff;
  background: var(--blue-soft);
}

.phrase-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.phrase-chip:hover {
  border-color: #b8d0ff;
}

.enhanced-order-pills {
  align-items: flex-start;
}

.order-row-pill {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.order-row-pill button {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
}

.memo-all .record-note {
  border-left: 3px solid var(--blue);
}

.enhanced-planner .planner-warning {
  min-height: 34px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #fffdf7;
}

.enhanced-schedule .enhanced-slot {
  min-height: 72px;
}

.enh-plan-card {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.enh-plan-card:active {
  cursor: grabbing;
}

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

.active-card {
  border-color: #b8d0ff;
  background: var(--blue-soft);
}

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

.order-admin-layout {
  height: calc(100vh - 122px);
  grid-template-columns: 340px minmax(0, 1fr);
}

.realtime-dock {
  min-height: 0;
  display: none !important;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
  overflow-x: auto;
}

.realtime-dock strong {
  flex: 0 0 auto;
}

.realtime-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: white;
  color: #5e687b;
  font-size: 12px;
}

.realtime-pill b {
  color: #245fc8;
}

.model-fragment-strip {
  display: flex;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
}

.model-fragment-strip span {
  flex: 0 0 auto;
  border: 1px solid #e3e8f3;
  border-radius: 7px;
  padding: 5px 8px;
  color: #667085;
  background: #fafbfe;
  font-size: 12px;
}

.chart-load-sequence {
  border-bottom: 1px solid var(--line);
  background: #f9fbff;
}

.load-sequence-head {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
}

.load-sequence-head .btn {
  margin-left: auto;
}

.load-step-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
  gap: 6px;
  padding: 0 12px 10px;
  overflow-x: auto;
}

.load-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  min-height: 72px;
  padding: 8px;
  text-align: left;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 2px 7px;
}

.load-step span {
  grid-row: span 3;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #edf2ff;
  color: #245fc8;
  font-weight: 900;
}

.load-step strong,
.load-step em,
.load-step small {
  min-width: 0;
}

.load-step em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.load-step.loaded {
  border-color: #b8d0ff;
}

.load-step.pending {
  opacity: 0.62;
}

.fsm-panel,
.image-compare-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

.fsm-head,
.image-compare-head {
  min-height: 38px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.fsm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.fsm-rail {
  border: 1px solid #e4e9f3;
  border-radius: 8px;
  padding: 8px;
  background: #fbfcff;
}

.fsm-rail > span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 6px;
}

.fsm-rail div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.fsm-rail button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: #647086;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.fsm-rail button.active {
  border-color: #a8c5ff;
  background: var(--blue-soft);
  color: #245fc8;
}

.fsm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 10px 10px;
  color: var(--muted);
}

.fsm-meta span {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  background: white;
}

.image-compare-head .segmented {
  margin-left: auto;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
}

.compare-grid.overlay {
  grid-template-columns: 1fr;
}

.compare-shot {
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  padding: 12px;
  display: grid;
  align-content: end;
  color: white;
  overflow: hidden;
  position: relative;
}

.compare-shot::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.88;
  background:
    linear-gradient(135deg, rgba(63, 130, 246, 0.18), rgba(0, 169, 145, 0.28)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.2) 0 7px, rgba(255,255,255,0.08) 7px 14px);
}

.compare-shot.after::before {
  background:
    linear-gradient(135deg, rgba(0, 169, 145, 0.22), rgba(245, 158, 11, 0.24)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.2) 0 7px, rgba(255,255,255,0.08) 7px 14px);
}

.compare-shot > * {
  position: relative;
}

.compare-shot span {
  font-weight: 900;
  font-size: 12px;
  opacity: 0.9;
}

.compare-shot strong {
  font-size: 18px;
}

.compare-shot em {
  font-style: normal;
  opacity: 0.86;
}

.input,
.select,
.textarea {
  border: 1px solid var(--line-strong);
  background: white;
  border-radius: 8px;
  color: var(--text);
  min-height: 34px;
  padding: 0 11px;
  outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.textarea {
  min-height: 92px;
  padding: 10px;
  resize: vertical;
}

.plain-textarea {
  width: 100%;
  min-height: 88px;
  border: 0;
  background: transparent;
  padding: 10px 0 0;
  resize: vertical;
  color: var(--text);
  outline: none;
  line-height: 1.5;
}

.plain-textarea:focus {
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px #c9dbff;
}

.record-textarea {
  min-height: 180px;
  font-size: 14px;
}

.btn {
  border: 1px solid var(--line-strong);
  background: white;
  min-height: 34px;
  border-radius: 8px;
  padding: 0 12px;
  color: #384155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}

.btn:hover {
  border-color: #aeb9cf;
}

.btn:active,
.chip:active,
.touch-btn:active,
.order-template-card:active,
.time-chip:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn.icon {
  width: 34px;
  padding: 0;
}

.btn.small {
  min-height: 28px;
  border-radius: 7px;
  padding: 0 9px;
  font-size: 12px;
}

.segmented {
  display: inline-flex;
  background: #eef2f9;
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  border: 0;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  background: transparent;
  color: #748099;
  font-weight: 800;
}

.segmented button.active {
  color: var(--text);
  background: white;
  box-shadow: 0 1px 2px rgba(19, 33, 68, 0.08);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  background: #edf1f8;
  color: #677187;
}

.badge.blue {
  background: var(--blue-soft);
  color: #245fc8;
}

.badge.green {
  background: #e7fbf6;
  color: #007c6b;
}

.badge.orange {
  background: #fff4da;
  color: #b46b00;
}

.badge.violet {
  background: #f0edff;
  color: #6453d1;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.tiny {
  color: var(--faint);
  font-size: 12px;
}

.dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr 280px;
  min-height: calc(100vh - 70px);
}

.dash-col {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px;
}

.dash-title {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 24px;
}

.notice-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 24px 0 30px;
}

.month-btn {
  border: 0;
  border-radius: 8px;
  min-height: 62px;
  background: white;
  color: #737c91;
  font-weight: 800;
}

.month-btn.active {
  background: var(--blue);
  color: white;
}

.planner {
  display: grid;
  grid-template-columns: 240px minmax(860px, 1fr);
  height: calc(100vh - 70px);
  overflow: hidden;
}

.planner-left {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.planner-search {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.mini-cal {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
}

.mini-cal-head {
  display: flex;
  justify-content: center;
  gap: 14px;
  color: #475167;
  font-weight: 900;
  margin-bottom: 14px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-grid span {
  min-height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #2f394d;
  font-size: 12px;
}

.cal-grid .dim {
  color: #bcc4d4;
}

.cal-grid .sun {
  color: var(--red);
}

.cal-grid .today {
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.category-list {
  padding: 12px;
}

.cat-row {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  border-radius: 8px;
}

.cat-row:hover {
  background: #f1f4fa;
}

.planner-main {
  min-width: 0;
  overflow: auto;
  background: #fbfcff;
}

.planner-head {
  min-width: 1060px;
  height: 52px;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.timeline,
.schedule-grid {
  min-width: 1060px;
  display: grid;
  grid-template-columns: 72px repeat(4, minmax(230px, 1fr));
  align-items: start;
}

.time-col,
.schedule-col {
  border-right: 1px solid var(--line);
}

.time-head,
.schedule-head {
  height: 44px;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-weight: 900;
}

.time-slot {
  height: 84px;
  border-bottom: 1px solid var(--line);
  color: #7b8497;
  padding: 8px 8px;
}

.slot {
  position: relative;
  height: 84px;
  border-bottom: 1px solid var(--line);
  padding: 4px;
}

.slot:hover {
  background: #f4f8ff;
}

.appt {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--violet);
  background: white;
  border-radius: 7px;
  min-height: 42px;
  padding: 6px 8px;
  margin-bottom: 4px;
  box-shadow: 0 1px 1px rgba(20, 30, 55, 0.04);
}

.appt .time {
  color: var(--green);
  float: right;
  font-weight: 900;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 390px;
  height: 100vh;
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 40px rgba(20, 30, 55, 0.14);
  z-index: 30;
  display: flex;
  flex-direction: column;
  animation: drawerIn 0.16s ease-out;
}

@keyframes drawerIn {
  from {
    transform: translateX(18px);
    opacity: 0.84;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.wide-drawer {
  width: 430px;
}

.drawer-head {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  padding: 18px;
  overflow: auto;
  flex: 1;
}

.drawer-tab-page {
  display: grid;
  gap: 12px;
}

.drawer-foot {
  height: 64px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
}

.time-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.time-chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  min-height: 30px;
  padding: 0 10px;
  color: #536079;
  font-size: 12px;
  font-weight: 900;
}

.time-chip:hover,
.time-chip.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #245fc8;
}

.choice-strip,
.template-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.choice-chip,
.template-chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  min-height: 30px;
  padding: 0 10px;
  color: #536079;
  font-size: 12px;
  font-weight: 900;
}

.choice-chip:hover,
.choice-chip.active,
.template-chip:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #245fc8;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
  color: #4b5567;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.board-page {
  height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
}

.board-tabs {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 0;
  background: white;
}

.board-tabs button {
  border: 0;
  background: transparent;
  min-height: 38px;
  font-weight: 900;
  color: #96a0b4;
  border-bottom: 2px solid transparent;
}

.board-tabs button.active {
  color: #111827;
  border-bottom-color: #111827;
}

.board-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: 8px;
  padding: 12px 14px 18px;
  overflow: auto;
  background: white;
}

.toolbar-spacer {
  flex: 1;
}

.board-col {
  background: #f8faff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 540px;
}

.col-head {
  display: flex;
  justify-content: space-between;
  font-weight: 900;
  margin-bottom: 10px;
}

.patient-card {
  background: white;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: grab;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.patient-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow);
}

.patient-card:active {
  cursor: grabbing;
}

.card-patient-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.drag-grip {
  color: #9aa6ba;
  font-weight: 900;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.patient-card:hover .drag-grip,
.patient-card:focus-within .drag-grip {
  opacity: 1;
}

.patient-card.just-moved {
  animation: movedPulse 0.9s ease-out;
}

@keyframes movedPulse {
  0% {
    background: #eaf3ff;
    border-color: var(--blue);
    transform: translateY(-2px);
  }
  100% {
    background: #fff;
    transform: translateY(0);
  }
}

.mini-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.patient-card:hover .mini-actions,
.patient-card:focus-within .mini-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.status-flow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.patient-card:hover .status-flow,
.patient-card:focus-within .status-flow {
  opacity: 1;
  pointer-events: auto;
}

.status-dot {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  min-height: 24px;
  color: #67738b;
  font-size: 10px;
  font-weight: 900;
}

.status-dot:hover,
.status-dot.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #245fc8;
}

.mobile-status-flow {
  opacity: 1;
  pointer-events: auto;
}

.patient-card.dragging {
  opacity: 0.52;
  border-style: dashed;
  transform: scale(0.985);
}

.board-col.drop-target {
  border-color: var(--blue);
  background: #eef6ff;
  box-shadow: inset 0 0 0 2px #9fc4ff;
}

.chip,
.order-pill {
  border: 1px solid var(--line-strong);
  background: #fff;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  color: #536079;
  font-size: 12px;
  font-weight: 800;
}

.chip:hover,
.order-pill:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.primary-chip {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #245fc8;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 900;
}

.context-menu {
  position: fixed;
  z-index: 40;
  width: 276px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.menu-label {
  padding: 7px 10px 5px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 900;
}

.work-menu-head {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px 10px;
  margin-bottom: 4px;
}

.menu-divider {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 9px;
}

.context-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  min-height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding: 0 10px;
}

.context-menu button small {
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.context-menu .primary-menu-action {
  background: var(--blue-soft);
  color: #245fc8;
  font-weight: 900;
}

.context-menu button:hover {
  background: #f1f5ff;
}

.more-menu-button {
  border-top: 1px solid var(--line) !important;
  margin-top: 6px;
  color: var(--blue);
  font-weight: 900;
}

.chart-detail {
  display: grid;
  grid-template-columns:
    170px
    190px
    minmax(430px, 1fr)
    260px
    190px
    32px;
  height: calc(100vh - 70px);
  overflow: hidden;
  background: white;
}

.chart-panel {
  border-right: 1px solid var(--line);
  overflow: auto;
  min-width: 0;
}

.panel-head {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-weight: 900;
}

.queue-group {
  padding: 10px;
}

.queue-row {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  margin-bottom: 8px;
  font-weight: 800;
}

button.queue-row {
  width: 100%;
  background: white;
  cursor: pointer;
}

.queue-row.active,
.condition-row.active,
.condition-row[data-selected="true"] {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.condition-group-list {
  padding: 0 0 12px;
}

.condition-row {
  min-height: 58px;
  align-items: center;
}

.condition-row > span:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: left;
}

.condition-row small {
  color: #78849b;
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.condition-summary {
  min-height: 68px;
}

.condition-summary p {
  margin: 4px 0 0;
}

.visit-card {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
}

.visit-card.active {
  background: #edf5ff;
  border-left: 4px solid var(--blue);
}

.chart-main {
  overflow: auto;
  padding: 14px 16px 86px;
}

.encounter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.upload-box {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.memo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.memo-box {
  min-height: 140px;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.memo-box:last-child {
  border-right: 0;
}

.record-box {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px;
  min-height: 280px;
  margin-bottom: 12px;
}

.quick-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.order-layout {
  display: grid;
  grid-template-columns: 92px 1fr;
  height: calc(100% - 52px);
}

.order-cats {
  border-right: 1px solid var(--line);
  background: #f8faff;
}

.order-cat {
  width: 100%;
  min-height: 38px;
  border: 0;
  background: transparent;
  padding: 0 12px;
  text-align: left;
  font-weight: 800;
}

.order-cat.active {
  background: #eaf2ff;
}

.order-items {
  padding: 12px;
}

.order-item {
  width: 100%;
  border: 0;
  background: transparent;
  min-height: 36px;
  text-align: left;
  border-radius: 7px;
  padding: 0 8px;
}

.order-item:hover {
  background: #f0f5ff;
}

.order-cat.add {
  color: var(--blue);
}

.order-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
}

.record-timeline {
  padding: 16px;
}

.record-note {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.record-input {
  position: sticky;
  bottom: 0;
  background: white;
  padding: 12px 0 0;
}

.icon-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  background: white;
}

.rail-btn {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #778197;
}

.rail-btn.active {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.bottom-bar {
  position: fixed;
  left: 168px;
  right: 0;
  bottom: 0;
  height: 58px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  z-index: 20;
}

.chart-topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  overflow: hidden;
}

.chart-patient-summary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.chart-patient-summary .muted,
.clinical-note {
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-id {
  color: #7990b8;
  font-size: 12px;
  font-weight: 800;
}

.patient-name {
  font-size: 14px;
}

.clinical-note {
  color: #69758f;
  font-size: 12px;
}

.chart-top-actions,
.chart-actions,
.section-line,
.order-items-head,
.record-note-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-top-actions {
  flex-shrink: 0;
}

.chart-detail {
  grid-template-columns: 145px 210px minmax(462px, 1fr) 238px 181px 36px;
  height: calc(100vh - 70px - 52px - 58px);
  background: #fff;
}

.chart-detail.enhanced-chart-detail {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  grid-template-columns:
    var(--chart-queue-w, 124px)
    6px
    var(--chart-history-w, 174px)
    6px
    var(--chart-main-w, 365px)
    6px
    var(--chart-order-w, 326px)
    6px
    var(--chart-memo-w, 150px)
    6px
    var(--chart-rail-w, 84px);
  height: calc(100vh - 70px - 52px - 58px);
  overflow: hidden;
}

.chart-resizer {
  width: 6px;
  background: #f2f5fa;
  border-right: 1px solid var(--line);
  cursor: col-resize;
  position: relative;
  touch-action: none;
}

.chart-resizer::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-left: 1px solid transparent;
}

.chart-resizer:hover,
.chart-resizing .chart-resizer {
  background: #e8f0ff;
}

.chart-resizer:hover::after,
.chart-resizing .chart-resizer::after {
  border-left-color: #3f82f6;
}

.chart-resizing,
.chart-resizing * {
  cursor: col-resize !important;
  user-select: none;
}

.chart-panel {
  background: #fff;
}

.enhanced-chart-detail,
.enhanced-chart-detail button,
.enhanced-chart-detail input,
.enhanced-chart-detail textarea {
  word-break: keep-all;
}

.panel-head-compact {
  height: 44px;
  padding: 0 10px;
  font-size: 13px;
}

.panel-icons {
  color: #3e6fc8;
  font-weight: 900;
}

.queue-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.queue-tabs button {
  border: 0;
  background: transparent;
  min-height: 48px;
  color: #76829a;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-tabs button.active {
  color: #111827;
  box-shadow: inset 0 -2px 0 #111827;
}

.queue-tabs strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
}

.queue-group.compact {
  padding: 8px 8px 6px;
}

.queue-accordion {
  display: grid;
  gap: 6px;
}

.queue-accordion-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.queue-accordion-item.open {
  border-color: #c8d8f4;
  box-shadow: 0 4px 12px rgba(32, 57, 104, 0.06);
}

.queue-group.compact .queue-row {
  min-height: 36px;
  margin-bottom: 6px;
  border-radius: 7px;
  padding: 0 9px;
  overflow: hidden;
}

.queue-accordion .queue-row {
  border: 0;
  border-radius: 0;
  margin-bottom: 0;
}

.queue-group.compact .queue-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-row.dense strong {
  color: #56627a;
}

.queue-caret {
  flex: 0 0 auto;
  color: #98a3b8;
  font-size: 14px;
  font-style: normal;
  line-height: 1;
}

.queue-accordion-list {
  border-top: 1px solid var(--line);
  padding: 0;
}

.queue-accordion-list .mini-patient {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}

.queue-accordion-list .mini-patient:last-child {
  border-bottom: 0;
}

.queue-empty {
  padding: 12px 8px;
  margin: 0;
}

.mini-patient-list {
  border-top: 1px solid var(--line);
  padding: 7px 8px 12px;
}

.mini-patient {
  width: 100%;
  border: 1px solid transparent;
  background: white;
  border-radius: 7px;
  min-height: 44px;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-areas:
    "time name"
    "time status";
  text-align: left;
  gap: 1px 6px;
  margin-bottom: 5px;
}

.mini-patient:hover,
.mini-patient.active {
  border-color: #bcd3ff;
  background: #edf5ff;
}

.mini-time {
  grid-area: time;
  align-self: center;
  color: #3f82f6;
  font-size: 12px;
  font-weight: 900;
}

.mini-name {
  grid-area: name;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.mini-status {
  grid-area: status;
  color: var(--muted);
  font-size: 11px;
}

.history-tools {
  display: flex;
  gap: 5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.tool-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  min-height: 26px;
  padding: 0 9px;
  color: #69758f;
  font-size: 12px;
  font-weight: 800;
}

.tool-chip.active {
  border-color: #bcd3ff;
  background: var(--blue-soft);
  color: #245fc8;
}

.visit-list {
  padding-bottom: 60px;
}

.chart-detail .visit-card {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  cursor: pointer;
}

.chart-detail .visit-card:hover {
  background: #f8fbff;
}

.chart-detail .visit-card.active {
  border-left: 3px solid var(--blue);
  background: #edf5ff;
  padding-left: 11px;
}

.visit-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.chart-detail .visit-card p {
  margin: 8px 0 0;
  line-height: 1.45;
}

.block-label {
  display: block;
  margin-top: 12px;
  color: #9aa6bb;
  font-weight: 900;
}

.visit-orders {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

.visit-orders span {
  color: #273144;
  font-weight: 700;
}

.history-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 9px 10px;
}

.history-footer .btn {
  flex: 1;
}

.chart-main {
  padding: 12px 16px 22px;
  background: #fff;
}

.encounter-head {
  min-height: 58px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.chart-console-head {
  align-items: flex-start;
  min-height: 58px;
}

.chart-work-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  gap: 3px;
  min-height: 30px;
  margin-bottom: 7px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9fd;
}

.chart-work-tabs button {
  border: 0;
  border-radius: 5px;
  background: transparent;
  min-height: 24px;
  padding: 0 9px;
  color: #66728a;
  font-size: 12px;
  font-weight: 900;
}

.chart-work-tabs button.active {
  background: #fff;
  color: #1f5fbf;
  box-shadow: 0 1px 4px rgba(31, 44, 71, 0.08);
}

.encounter-head h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.05;
  white-space: nowrap;
}

.encounter-head p {
  margin: 6px 0 0;
}

.chart-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  min-height: 64px;
}

.chart-work-upload {
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.chart-input-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.compact-upload p {
  grid-column: 1 / -1;
  margin: 0;
}

.memo-grid {
  border-radius: 7px;
  margin-bottom: 10px;
}

.memo-box {
  min-height: 116px;
  padding: 10px 12px;
}

.memo-box .plain-textarea {
  min-height: 70px;
}

.record-box {
  border-radius: 7px;
  padding: 12px;
  margin-bottom: 10px;
}

.chart-record-box {
  min-height: 270px;
}

.section-line {
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.chart-record-box .record-textarea {
  min-height: 168px;
  border: 1px solid #cbd8ee;
  border-radius: 6px;
  background: #fbfdff;
  padding: 10px 12px;
  line-height: 1.6;
}

.chart-record-box .record-textarea:focus {
  background: #fff;
  border-color: #3f82f6;
  box-shadow: 0 0 0 3px rgba(63, 130, 246, 0.12);
}

.chart-record-box .template-strip {
  padding-top: 2px;
}

.dense-buttons {
  gap: 6px;
  margin-top: 10px;
}

.dense-buttons .btn {
  min-height: 28px;
}

.dense-buttons .btn.active {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.diagnosis-box {
  min-height: 116px;
}

.diagnosis-box .input {
  width: 100%;
  margin-bottom: 10px;
}

.diagnosis-results {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  max-height: 172px;
  overflow: auto;
}

.diagnosis-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  width: 100%;
  border: 1px solid #d7e0f1;
  border-radius: 7px;
  background: #fbfdff;
  padding: 8px 10px;
  text-align: left;
}

.diagnosis-result:hover,
.diagnosis-result:focus-visible {
  border-color: var(--blue);
  background: #f1f6ff;
}

.diagnosis-result strong,
.diagnosis-result span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diagnosis-result span {
  color: #61708a;
  font-size: 12px;
}

.diagnosis-result em {
  align-self: center;
  grid-row: 1 / span 2;
  grid-column: 2;
  color: var(--blue);
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
}

.task-box {
  min-height: 96px;
}

.task-line {
  margin: 8px 0 0;
}

.task-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid #d7e0f1;
  border-radius: 7px;
  background: #fbfdff;
  color: #44516a;
  padding: 7px 9px;
  text-align: left;
}

.task-chip:hover,
.task-chip:focus-visible {
  border-color: #f08b8b;
  background: #fff7f7;
}

.task-chip span {
  color: #d04747;
  font-weight: 900;
}

.chart-lower-stack {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-bottom: 12px;
}

.lower-card {
  border: 1px solid #d5dfef;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.lower-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid #e2e8f3;
}

.lower-head strong {
  margin-right: auto;
}

.task-entry-box {
  margin: 12px;
  border: 1px solid #dce5f3;
  border-radius: 8px;
  background: #fbfdff;
}

.task-entry-box textarea {
  width: 100%;
  min-height: 86px;
  border: 0;
  background: transparent;
  resize: vertical;
}

.task-entry-footer {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 10px;
}

.task-entry-icons {
  display: flex;
  gap: 6px;
  margin-right: auto;
}

.icon-soft {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: #eef5ff;
  color: #6f7b91;
  font-weight: 900;
}

.empty-center {
  min-height: 132px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: #8a96aa;
}

.empty-center.small {
  min-height: 82px;
}

.empty-center span {
  color: #9aa7bd;
  font-size: 18px;
}

.empty-center p {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
}

.payment-card {
  padding-bottom: 10px;
}

.payment-alert {
  margin: 10px 12px;
  border-radius: 8px;
  background: #fff8e6;
  padding: 12px;
  color: #6d5b25;
}

.payment-alert strong {
  display: block;
  margin-bottom: 5px;
  color: #5b4714;
}

.payment-alert p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.payment-alert div {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.payment-row {
  min-height: 42px;
  margin: 0 12px 8px;
  border: 1px solid #e0e7f2;
  border-radius: 7px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  color: #44516a;
}

.payment-row.child {
  width: calc(100% - 24px);
  text-align: left;
  cursor: pointer;
}

.payment-row strong {
  color: #1f2a3d;
}

.text-link {
  border: 0;
  background: transparent;
  color: #3975e8;
  font-weight: 900;
  padding: 0;
}

.text-link.strong {
  color: var(--blue);
}

.add-payment,
.receipt-add {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 0 12px 8px;
}

.documents-card {
  min-height: 132px;
}

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

.doc-shortcut {
  min-height: 48px;
  border: 1px solid #dce5f3;
  border-radius: 8px;
  background: #fbfdff;
  text-align: left;
  padding: 7px 9px;
}

.doc-shortcut strong,
.doc-shortcut span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-shortcut span {
  margin-top: 3px;
  color: #7d8aa0;
  font-size: 11px;
}

.order-head {
  height: 44px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 32px;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
}

.order-head > button:not(.btn) {
  border: 0;
  background: transparent;
  min-height: 32px;
  border-radius: 7px;
  padding: 0 4px;
  color: #78849b;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.order-head > button.active {
  background: #eef4ff;
  color: #245fc8;
}

.order-search {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.order-search .input {
  width: 100%;
}

.order-layout {
  grid-template-columns: 92px minmax(0, 1fr);
  height: calc(100% - 99px);
}

.order-cats {
  overflow: auto;
}

.order-cat {
  min-height: 40px;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-cat.active {
  border-left: 3px solid var(--blue);
  padding-left: 6px;
  color: #245fc8;
}

.order-items {
  padding: 10px;
  overflow: auto;
}

.order-items-head {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 6px;
}

.order-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
}

.order-item small {
  color: var(--blue);
  opacity: 0;
}

.order-item:hover small {
  opacity: 1;
}

.order-template-card {
  min-height: 72px;
  align-items: flex-start;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "main add"
    "meta meta";
}

.order-template-card:hover {
  border-color: #bcd3ff;
  background: #f6f9ff;
}

.order-template-card:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.order-template-main {
  grid-area: main;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.order-template-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-template-main span {
  color: #66728a;
  font-size: 11px;
  line-height: 1.35;
}

.order-template-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.order-template-meta em {
  border-radius: 999px;
  background: #edf1f8;
  color: #66728a;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  padding: 2px 6px;
}

.order-template-card small {
  grid-area: add;
  align-self: start;
}

.order-empty {
  margin: 12px 8px;
  color: #7c8798;
  font-size: 12px;
  font-weight: 800;
}

.template-panel {
  padding: 12px;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.template-card {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
  min-height: 70px;
  padding: 10px;
  display: grid;
  gap: 5px;
  text-align: left;
}

.template-card:hover {
  border-color: #bcd3ff;
  background: #f6f9ff;
}

.template-card strong {
  font-weight: 900;
}

.template-card span {
  color: #66728a;
  font-size: 12px;
  line-height: 1.4;
}

.add-order-button {
  width: 100%;
  margin-top: 8px;
}

.record-profile {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 3px;
}

.patient-record-panel .record-timeline {
  padding: 10px 12px 22px;
}

.patient-record-panel .record-note {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.record-note-head {
  align-items: flex-start;
}

.record-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #eef4ff;
  color: #245fc8;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  flex: 0 0 auto;
}

.patient-record-panel .record-note p {
  margin: 8px 0 0 30px;
  line-height: 1.5;
}

.empty-note {
  padding: 14px 0;
}

.patient-record-panel .record-input {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  padding: 10px 0 0;
}

.patient-record-panel .record-input .textarea {
  width: 100%;
  min-height: 90px;
}

.patient-record-panel .record-input .btn {
  float: right;
  margin-top: 8px;
}

.icon-rail {
  border-left: 1px solid var(--line);
  gap: 8px;
  align-items: stretch;
  padding: 12px 6px 0;
}

.rail-btn {
  width: 100%;
  min-width: 0;
  height: 30px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bottom {
  justify-content: flex-end;
}

.bottom-bar .btn,
.bottom-bar .select {
  flex: 0 0 auto;
}

.bottom-context {
  margin-right: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #66728a;
  font-weight: 800;
}

.compact-select {
  min-width: 108px;
}

.split-page {
  display: grid;
  grid-template-columns: 300px minmax(900px, 1fr);
  height: calc(100vh - 70px);
  overflow: hidden;
}

.left-list {
  background: white;
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 18px;
}

.table-wrap {
  background: white;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1050px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: #8791a6;
  font-weight: 900;
  background: #fbfcff;
}

.library-page {
  height: calc(100vh - 70px);
  background: white;
  overflow: auto;
}

.library-narrow {
  max-width: 720px;
  border-right: 1px solid var(--line);
  min-height: 100%;
}

.list-card {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  margin: 10px 20px;
  background: white;
}

.tab-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 18px;
}

.compact-table {
  min-width: 760px;
}

.tab-content-pad {
  padding: 18px;
}

.inline-card {
  width: calc(100% - 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
}

.editor-panel {
  padding: 24px;
  overflow: auto;
  background: white;
}

.editor-list {
  max-width: 780px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  align-items: start;
  gap: 0;
  min-height: calc(100vh - 70px);
  background: white;
}

.settings-col {
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 70px);
  padding: 18px;
}

.setting-card {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.crm-page {
  grid-template-columns: 260px minmax(880px, 1fr);
}

.crm-left h3 {
  margin: 0 0 14px;
}

.crm-content {
  background: #fff;
}

.crm-panel {
  min-height: 100%;
}

.crm-rules-grid {
  grid-template-columns: 360px minmax(420px, 1fr) 420px;
  min-height: calc(100vh - 126px);
}

.crm-rules-grid .settings-col {
  min-height: calc(100vh - 126px);
}

.crm-rules-grid .inline-card {
  width: 100%;
  margin: 10px 0;
}

.module-page {
  grid-template-columns: 260px minmax(880px, 1fr);
}

.single-module-page,
.crm-page-full {
  display: block;
  height: calc(100vh - 70px);
  overflow: hidden;
  background: #fff;
}

.module-left h3 {
  margin: 0 0 14px;
}

.module-content {
  background: #fff;
  overflow: auto;
  height: 100%;
}

.module-panel {
  min-height: 100%;
  background: #fff;
}

.full-search {
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  min-height: 44px;
}

.phrase-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.phrase-row {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
}

.phrase-row b {
  color: var(--blue);
}

.phrase-row em {
  font-style: normal;
  color: var(--muted);
  font-weight: 800;
}

.form-setting-page {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  min-height: calc(100vh - 70px);
}

.form-list-pane {
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}

.form-detail-pane {
  background: #fff;
  overflow: auto;
}

.local-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.module-panel > .toolbar {
  border-top: 0;
}

.module-panel .order-admin-layout {
  height: calc(100vh - 178px);
  grid-template-columns: 320px minmax(680px, 1fr);
  min-width: 0;
}

.management-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  min-height: calc(100vh - 124px);
}

.management-grid .settings-col {
  min-height: calc(100vh - 124px);
}

.toggle {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #cfd6e4;
  position: relative;
  display: inline-block;
}

.toggle-button {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 20px;
}

.toggle::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: white;
}

.toggle.on {
  background: var(--blue);
}

.toggle.on::after {
  left: 16px;
}

.empty-page {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  color: var(--muted);
  background: white;
}

.inline-toolbar {
  border: 0;
  background: transparent;
  padding: 0;
}

.task-list {
  margin: 18px 0;
}

.task-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.task-row .done {
  color: var(--muted);
  text-decoration: line-through;
}

.add-box {
  width: 100%;
  min-height: 64px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: white;
  color: var(--faint);
  font-weight: 900;
}

.money-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  background: var(--panel-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
  max-width: 980px;
}

.stats-grid.wide {
  max-width: none;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: white;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.stat-card strong {
  display: block;
  font-size: 26px;
  margin-top: 8px;
}

.generate-card {
  width: 780px;
  max-width: calc(100% - 32px);
  height: 320px;
  margin: 0 16px 16px;
  display: grid;
  place-items: center;
  border-color: var(--blue);
}

.stats-page,
.alerts-page {
  height: calc(100vh - 70px);
  overflow: auto;
  background: #f7f9fd;
}

.drp-page-panel {
  min-height: calc(100vh - 70px);
  background: #fff;
}

.drp-stat-head {
  padding: 18px 22px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.drp-stat-head strong {
  display: block;
  font-size: 15px;
  margin-bottom: 12px;
}

.drp-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.drp-filter-row.padded {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.drp-report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(340px, 1fr));
  gap: 20px;
  padding: 18px 22px;
  align-items: start;
}

.report-card {
  min-height: 380px;
}

.stats-toolbar,
.alerts-hero {
  min-height: 76px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.stats-toolbar h2,
.alerts-hero h2 {
  margin: 2px 0 0;
  font-size: 19px;
}

.stats-subtabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stats-content {
  padding: 0 0 28px;
}

.stats-two-col,
.alerts-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr);
  gap: 14px;
  padding: 0 16px 16px;
}

.alerts-grid {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  padding-top: 16px;
}

.alert-kpis {
  display: grid;
  grid-template-columns: repeat(3, 160px);
  gap: 10px;
  margin-left: auto;
}

.stats-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  min-height: 220px;
}

.stats-panel .data-table {
  min-width: 640px;
}

.stats-panel .toolbar {
  border-bottom: 1px solid var(--line);
}

.stats-bars {
  padding: 14px 16px 18px;
  display: grid;
  gap: 12px;
}

.stats-bar-row,
.stats-list-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.stats-bar-track {
  height: 8px;
  border-radius: 99px;
  background: #edf2fb;
  overflow: hidden;
}

.stats-bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7df6, #73a8ff);
}

.stats-list {
  padding: 10px 14px 16px;
  display: grid;
  gap: 8px;
}

.stats-list-row {
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
  color: inherit;
  text-align: left;
}

button.stats-list-row {
  cursor: pointer;
}

.stats-list-row span,
.stats-list-row small {
  display: block;
}

.stats-list-row small {
  color: var(--muted);
  margin-top: 3px;
}

.stats-list-row em {
  font-style: normal;
  font-weight: 900;
  color: var(--blue);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 78px;
  z-index: 80;
  min-height: 42px;
  max-width: 360px;
  border-radius: 8px;
  background: #162033;
  color: white;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 800;
}

.toast.toast-above-sheet {
  top: 78px;
  bottom: auto;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.22);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bottom-sheet {
  width: min(480px, 100%);
  max-height: min(82vh, 720px);
  overflow-y: auto;
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 10px 16px 18px;
  box-shadow: 0 -18px 50px rgba(15, 23, 42, 0.22);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #d4dbea;
  margin: 0 auto 14px;
}

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

.sheet-head h3 {
  margin: 0 0 4px;
}

.sheet-head p {
  margin: 0;
}

.sheet-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.sheet-actions button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 900;
}

.sheet-actions button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.sheet-more {
  width: 100%;
  margin-top: 10px;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .chart-detail,
  .chart-topbar,
  .planner,
  .split-page,
  .settings-grid,
  .dashboard {
    min-width: 1180px;
  }

  .main {
    overflow: auto;
  }

  .bottom-bar {
    left: 150px;
  }

  .chart-detail,
  .chart-topbar {
    min-width: 1272px;
  }
}

@media (max-width: 700px) {
  .app-shell {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand span:not(.brand-mark),
  .nav-item span:not(.nav-icon),
  .profile strong,
  .chev {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
    width: 44px;
    min-height: 44px;
    margin: 0 auto 2px;
  }

  .profile {
    justify-content: center;
    padding: 0;
  }

  .page-head {
    padding: 0 12px;
    gap: 10px;
  }

  .page-head .btn {
    min-height: 44px;
  }

  .head-tabs {
    display: none;
  }

  .desktop-label,
  .desktop-only {
    display: none !important;
  }

  .mobile-label {
    display: inline;
  }

  .board-page {
    height: calc(100vh - 70px);
    overflow: auto;
    background: white;
  }

  .board-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px 58px 92px;
    gap: 8px;
    padding: 8px 12px;
    min-height: auto;
  }

  .board-search {
    width: 100%;
    min-width: 0;
  }

  .board-new,
  .board-next,
  .board-status-select {
    min-height: 44px;
  }

  .board-new {
    width: 44px;
  }

  .board-new.btn.icon {
    width: 44px;
  }

  .board-next {
    padding: 0 10px;
  }

  .board-status-select {
    width: 92px;
    padding: 0 8px;
  }

  .toolbar-spacer {
    display: none;
  }

  .board-tabs {
    padding: 10px 14px 0;
    gap: 12px;
    overflow-x: auto;
  }

  .board-tabs button {
    min-height: 44px;
    white-space: nowrap;
  }

  .board-grid {
    display: none;
  }

  .mobile-board-list {
    display: grid;
    gap: 10px;
    padding: 12px 14px 24px;
    background: white;
  }

  .mobile-patient-row {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
  }

  .mobile-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-patient-row p {
    margin: 8px 0 0;
  }

  .mobile-row-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
  }

  .touch-btn,
  .chip {
    min-height: 44px;
    min-width: 44px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: white;
    font-weight: 900;
    color: #536079;
  }

  .touch-btn.primary-chip,
  .chip.primary-chip {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: #245fc8;
  }

  .mobile-empty {
    padding: 24px 4px;
  }

  .context-menu {
    max-height: min(520px, calc(100vh - 24px));
  }

  .toast {
    left: 70px;
    right: 12px;
    bottom: 18px;
    max-width: none;
    min-height: 44px;
  }

  .toast.toast-above-sheet {
    top: 82px;
    bottom: auto;
  }

  .bottom-bar {
    left: 58px;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .chart-topbar {
    min-width: 0;
    width: 100%;
    height: auto;
    min-height: 72px;
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 12px;
    gap: 8px;
  }

  .chart-patient-summary {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px 8px;
    white-space: normal;
  }

  .chart-top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 44px;
  }

  .chart-top-actions .btn {
    min-height: 44px;
  }

  .chart-detail {
    min-width: 0;
    width: 100%;
    height: calc(100vh - 70px - 72px - 58px);
    display: flex;
    flex-direction: column;
    overflow: auto;
    background: #f6f7fb;
  }

  .chart-main {
    order: 1;
    padding: 12px 12px 18px;
    overflow: visible;
  }

  .order-panel {
    order: 2;
  }

  .patient-record-panel {
    order: 3;
  }

  .history-panel {
    order: 4;
  }

  .chart-queue-panel {
    order: 5;
  }

  .chart-panel {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .icon-rail {
    display: none;
  }

  .encounter-head {
    display: grid;
    gap: 10px;
  }

  .encounter-head h2 {
    font-size: 20px;
    white-space: normal;
  }

  .chart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chart-actions .btn,
  .compact-upload .btn,
  .dense-buttons .btn,
  .order-head .btn,
  .order-items-head .btn,
  .order-item,
  .tool-chip,
  .queue-row {
    min-height: 44px;
  }

  .btn.icon,
  .btn.icon.small,
  .section-line .btn.icon.small,
  .chart-top-actions .btn.icon.small,
  .order-head .btn.icon.small {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .queue-group.compact .queue-row,
  .history-footer .btn,
  .section-line .btn.small,
  .order-head > button:not(.btn),
  .diagnosis-box .input,
  .order-search .input,
  .add-order-button,
  .patient-record-panel .record-input .btn,
  .bottom-bar .btn,
  .bottom-bar .select,
  .time-chip,
  .order-pill {
    min-height: 44px;
  }

  .compact-upload {
    grid-template-columns: 1fr;
  }

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

  .memo-box {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .memo-box:last-child {
    border-bottom: 0;
  }

  .chart-record-box .record-textarea {
    min-height: 170px;
  }

  .order-layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .order-cats {
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .order-cat {
    flex: 0 0 142px;
    min-height: 48px;
  }

  .order-items {
    max-height: none;
  }

  .order-template-card {
    min-height: 88px;
  }

  .patient-record-panel .record-timeline {
    padding-bottom: 18px;
  }

  .bottom-context {
    display: none;
  }

  .drawer,
  .wide-drawer {
    width: min(430px, calc(100vw - 58px));
  }

  .bottom-sheet .btn {
    min-height: 44px;
  }

  .bottom-sheet {
    max-height: min(64vh, 540px);
    padding: 10px 12px 18px;
  }

  .sheet-backdrop {
    z-index: 140;
  }

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

  .sheet-actions button {
    min-height: 48px;
    padding: 0 10px;
  }
}

@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  body {
    background: #fff;
  }

  button,
  .btn,
  .chip,
  .touch-btn,
  .tool-chip,
  .segmented button,
  .order-cat,
  .order-item,
  .load-step,
  .fsm-rail button {
    min-height: 44px;
    touch-action: manipulation;
  }

  .app-shell {
    display: block;
    min-height: 100svh;
    padding-bottom: 68px;
  }

  .main {
    width: 100%;
    min-height: calc(100svh - 68px);
    padding-bottom: 68px;
    overflow: visible;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 90;
    height: 68px;
    min-height: 0;
    display: block;
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(248, 250, 255, 0.98);
    box-shadow: 0 -8px 22px rgba(19, 33, 68, 0.08);
  }

  .brand,
  .profile {
    display: none;
  }

  .nav-scroll {
    height: 68px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 6px 8px 8px;
    scrollbar-width: none;
  }

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

  .nav-section {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
    padding: 0;
    margin: 0;
    border-top: 0;
  }

  .nav-group {
    flex: 0 0 auto;
    margin-bottom: 0;
  }

  .nav-chevron,
  .nav-submenu {
    display: none;
  }

  .nav-item {
    flex: 0 0 58px;
    width: 58px;
    min-height: 54px;
    margin: 0;
    padding: 4px 3px;
    border-radius: 10px;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    line-height: 1.15;
  }

  .nav-item span:not(.nav-icon) {
    display: block;
    max-width: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-icon {
    width: auto;
    font-size: 15px;
  }

  .page-head {
    position: sticky;
    top: 0;
    z-index: 50;
    height: auto;
    min-height: 56px;
    padding: 8px 12px;
    gap: 8px;
    overflow-x: auto;
  }

  .stats-page,
  .alerts-page {
    height: auto;
    min-height: calc(100vh - 124px);
    padding-bottom: 74px;
  }

  .stats-toolbar,
  .alerts-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-subtabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .stats-grid.wide,
  .alert-kpis,
  .stats-two-col,
  .alerts-grid,
  .drp-report-grid,
  .form-setting-page {
    grid-template-columns: 1fr;
  }

  .single-module-page,
  .crm-page-full {
    height: auto;
    min-height: calc(100vh - 124px);
    padding-bottom: 74px;
    overflow: visible;
  }

  .form-list-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .alert-kpis {
    width: 100%;
    margin-left: 0;
  }

  .stats-two-col,
  .alerts-grid {
    padding: 0 10px 12px;
  }

  .page-title {
    font-size: 18px;
    white-space: nowrap;
  }

  .content {
    width: 100%;
  }

  .enhanced-board.board-page {
    display: block;
    height: auto;
    min-height: calc(100svh - 124px);
    overflow: visible;
    background: #fff;
  }

  .enhanced-board .board-toolbar {
    position: sticky;
    top: 56px;
    z-index: 45;
    grid-template-columns: 44px minmax(0, 1fr) 44px 64px;
    padding: 8px 10px;
    gap: 7px;
    box-shadow: 0 3px 10px rgba(19, 33, 68, 0.05);
  }

  .enhanced-board .board-next {
    min-width: 0;
    padding: 0 8px;
  }

  .enhanced-board .realtime-dock {
    min-height: 34px;
    padding: 5px 10px;
    font-size: 11px;
    border-bottom-color: #edf1f8;
  }

  .enhanced-board .realtime-dock strong {
    display: none;
  }

  .realtime-pill {
    min-width: max-content;
    white-space: nowrap;
  }

  .realtime-dock .btn {
    flex: 0 0 auto;
    min-width: max-content;
    white-space: nowrap;
  }

  .realtime-dock [data-v3-action="simulate-realtime"] {
    display: none;
  }

  .enhanced-board .board-with-queue {
    display: none;
  }

  .enhanced-board .mobile-board-list {
    display: grid;
    gap: 10px;
    padding: 10px 10px 88px;
    background: #fff;
  }

  .enhanced-board .mobile-patient-row {
    border: 1px solid var(--line-strong);
    border-left: 4px solid var(--blue);
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(19, 33, 68, 0.04);
  }

  .mobile-row-main {
    align-items: flex-start;
  }

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

  .mobile-row-actions .touch-btn {
    width: 100%;
  }

  .enhanced-chart-topbar.chart-topbar {
    position: sticky;
    top: 56px;
    z-index: 45;
    min-height: 0;
    height: auto;
    padding: 8px 10px;
    gap: 8px;
    overflow: visible;
    box-shadow: 0 3px 10px rgba(19, 33, 68, 0.05);
  }

  .enhanced-chart-topbar .chart-patient-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 8px;
  }

  .enhanced-chart-topbar .patient-name {
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .enhanced-chart-topbar .chart-patient-summary > .muted,
  .enhanced-chart-topbar .chart-patient-summary > .badge:not(.violet) {
    display: none;
  }

  .enhanced-chart-topbar .clinical-note {
    grid-column: 1 / -1;
    max-width: none;
    min-height: 30px;
    display: flex;
    align-items: center;
    white-space: normal;
  }

  .enhanced-chart-topbar .chart-top-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 44px;
    gap: 6px;
  }

  .model-fragment-strip {
    display: none;
  }

  .chart-load-sequence {
    background: #fff;
  }

  .load-sequence-head {
    min-height: 40px;
    padding: 6px 10px;
  }

  .load-sequence-head .muted {
    display: none;
  }

  .load-sequence-head .btn {
    min-height: 44px;
  }

  .load-step-row {
    display: flex;
    gap: 6px;
    padding: 0 10px 8px;
    overflow-x: auto;
  }

  .load-step {
    flex: 0 0 92px;
    min-height: 54px;
    grid-template-columns: 20px 1fr;
    padding: 7px;
  }

  .load-step span {
    width: 20px;
    height: 20px;
  }

  .load-step em {
    display: none;
  }

  .enhanced-chart-detail.chart-detail {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: #f6f7fb;
    padding-bottom: 86px;
  }

  .chart-resizer {
    display: none;
  }

  .enhanced-chart-detail .chart-main {
    order: 1;
    padding: 10px 10px 16px;
    overflow: visible;
    width: 100%;
    max-width: 100%;
  }

  .chart-console-head {
    min-height: 0;
  }

  .chart-work-tabs {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chart-work-tabs button {
    min-height: 38px;
    padding: 0 4px;
  }

  .chart-work-upload {
    grid-template-columns: 1fr;
  }

  .chart-input-toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .enhanced-chart-detail .order-panel {
    order: 2;
  }

  .enhanced-chart-detail .patient-record-panel {
    order: 3;
  }

  .enhanced-chart-detail .history-panel {
    order: 4;
  }

  .enhanced-chart-detail .chart-queue-panel {
    order: 5;
  }

  .enhanced-chart-detail .chart-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  .fsm-grid,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .fsm-rail div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fsm-rail button {
    width: 100%;
    border-radius: 8px;
  }

  .fsm-meta {
    display: grid;
    grid-template-columns: 1fr;
  }

  .image-compare-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .image-compare-head .segmented {
    margin-left: 0;
    width: 100%;
  }

  .image-compare-head .segmented button {
    flex: 1;
  }

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

  .lower-head {
    flex-wrap: wrap;
  }

  .task-entry-footer {
    align-items: stretch;
  }

  .payment-alert div {
    justify-content: flex-start;
  }

  .document-shortcuts {
    grid-template-columns: 1fr;
  }

  .section-line,
  .order-head,
  .order-items-head,
  .history-footer {
    gap: 8px;
    flex-wrap: wrap;
  }

  .section-actions,
  .chart-actions,
  .dense-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .section-actions .btn,
  .chart-actions .btn,
  .dense-buttons .btn {
    width: 100%;
  }

  .order-layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .order-cats {
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .order-cat {
    flex: 0 0 128px;
    text-align: center;
  }

  .order-items {
    max-height: none;
  }

  .bottom-bar {
    left: 0;
    right: 0;
    bottom: 68px;
    height: auto;
    min-height: 58px;
    padding: 8px 10px;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
  }

  .bottom-bar .btn,
  .bottom-bar .select {
    flex: 0 0 auto;
  }

  .chart-bottom.bottom-bar {
    display: grid;
    grid-template-columns: 52px 62px minmax(0, 1fr) minmax(0, 1fr) 64px;
    align-items: center;
    overflow: visible;
  }

  .chart-bottom.bottom-bar .btn,
  .chart-bottom.bottom-bar .select {
    width: 100%;
    min-width: 0;
    padding-left: 6px;
    padding-right: 6px;
  }

  .chart-bottom.bottom-bar .compact-select {
    min-width: 0;
  }

  .drawer,
  .wide-drawer {
    width: 100vw;
    max-width: 100vw;
  }

  .planner {
    display: block;
    height: auto;
    min-width: 0;
    overflow: visible;
  }

  .planner-left {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .mini-cal {
    padding: 10px;
  }

  .category-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    gap: 8px;
    padding: 8px 10px 10px;
  }

  .cat-row {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    border: 1px solid var(--line);
    background: #fff;
  }

  .planner-main {
    overflow: visible;
  }

  .planner-head {
    min-width: 0;
    height: auto;
    min-height: 56px;
    padding: 8px 10px;
    flex-wrap: wrap;
  }

  .planner-head .segmented {
    overflow-x: auto;
  }

  .planner-head .segmented button {
    min-width: 44px;
  }

  .timeline,
  .schedule-grid {
    min-width: 0;
    display: block;
  }

  .time-col {
    display: none;
  }

  .schedule-col {
    border-right: 0;
    margin: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
  }

  .time-head,
  .schedule-head {
    min-height: 44px;
  }

  .slot {
    height: auto;
    min-height: 76px;
  }
}

.mobile-chart-tabs,
.mobile-touch-chart-pad {
  display: none;
}

@media (max-width: 700px) {
  .mobile-chart-tabs {
    position: sticky;
    top: 132px;
    z-index: 46;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 4px 14px rgba(19, 33, 68, 0.05);
  }

  .mobile-chart-tabs button {
    display: grid;
    place-items: center;
    gap: 2px;
    min-width: 0;
    min-height: 58px;
    padding: 6px 4px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    color: #657089;
    font-weight: 900;
    touch-action: manipulation;
  }

  .mobile-chart-tabs button.active {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--blue);
    box-shadow: inset 0 0 0 1px rgba(43, 122, 255, 0.14);
  }

  .mobile-chart-tabs strong {
    font-size: 14px;
    line-height: 1.1;
  }

  .mobile-chart-tabs span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: inherit;
    font-size: 10px;
    line-height: 1.1;
    opacity: 0.78;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .enhanced-chart-detail.chart-detail {
    display: block;
    width: 100%;
    max-width: 100%;
    padding-bottom: 142px;
    overflow: visible;
  }

  .enhanced-chart-detail [data-mobile-chart-panel] {
    display: none;
  }

  .enhanced-chart-detail.mobile-chart-active-record [data-mobile-chart-panel="record"],
  .enhanced-chart-detail.mobile-chart-active-order [data-mobile-chart-panel="order"],
  .enhanced-chart-detail.mobile-chart-active-memo [data-mobile-chart-panel="memo"],
  .enhanced-chart-detail.mobile-chart-active-patient [data-mobile-chart-panel="patient"] {
    display: block;
  }

  .enhanced-chart-detail .chart-resizer,
  .enhanced-chart-detail .icon-rail {
    display: none !important;
  }

  .mobile-touch-chart-pad {
    display: grid;
    gap: 8px;
    margin: 0 0 10px;
    padding: 10px;
    border: 1px solid #cfe0ff;
    border-radius: 10px;
    background: #f8fbff;
  }

  .mobile-touch-pad-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-touch-pad-head strong {
    font-size: 15px;
  }

  .mobile-touch-pad-head span {
    color: #7a8499;
    font-size: 11px;
    text-align: right;
  }

  .mobile-touch-chip-grid,
  .mobile-touch-order-row,
  .mobile-touch-action-row {
    display: grid;
    gap: 7px;
  }

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

  .mobile-touch-order-row,
  .mobile-touch-action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mobile-touch-chip {
    min-width: 0;
    min-height: 54px;
    padding: 7px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    color: #2f3b53;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    touch-action: manipulation;
  }

  .mobile-touch-chip.order {
    border-color: #cfe0ff;
    background: #eef5ff;
    color: var(--blue);
  }

  .mobile-touch-chip.soft {
    min-height: 48px;
    background: #f5f7fb;
    color: #556176;
  }

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

  .mobile-row-actions .touch-btn {
    min-height: 52px;
    padding: 0 4px;
    font-size: 13px;
    white-space: nowrap;
  }

  .enhanced-chart-detail textarea,
  .enhanced-chart-detail input,
  .enhanced-chart-detail select {
    font-size: 16px;
  }

  .enhanced-chart-detail .record-textarea {
    min-height: 220px;
    line-height: 1.55;
  }

  .enhanced-chart-detail .plain-textarea,
  .patient-record-panel textarea {
    min-height: 96px;
  }

  .diagnosis-box .input,
  .order-search .input,
  .patient-record-panel .record-input textarea {
    min-height: 50px;
  }

  .order-item,
  .order-template-card,
  .template-card,
  .phrase-bank button,
  .order-pill button {
    min-height: 50px;
  }

  .order-item {
    padding: 11px;
  }

  .chart-bottom.bottom-bar {
    position: sticky;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    left: 0;
    right: 0;
    bottom: 68px;
    gap: 6px;
    min-height: 64px;
    padding: 8px 10px;
    overflow: visible;
    box-sizing: border-box;
  }

  .chart-bottom.bottom-bar .bottom-context {
    display: none;
  }

  .chart-bottom.bottom-bar .btn,
  .chart-bottom.bottom-bar .select {
    min-height: 48px;
    width: 100%;
    min-width: 0;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .bottom-sheet {
    max-height: min(82svh, 660px);
    padding: 12px 12px 20px;
    border-radius: 16px 16px 0 0;
  }

  .sheet-actions button {
    min-height: 54px;
    font-size: 13px;
  }
}

@media (max-width: 700px) {
  .app-shell.is-chart-detail .enhanced-chart-topbar .clinical-note {
    display: none;
  }

  .app-shell.is-chart-detail .enhanced-chart-topbar.chart-topbar {
    padding-bottom: 6px;
  }

  .app-shell.is-chart-detail .mobile-chart-tabs {
    min-height: 0;
  }

  .app-shell.is-chart-detail .chart-main {
    display: flex;
    flex-direction: column;
  }

  .app-shell.is-chart-detail .mobile-touch-chart-pad {
    order: 1;
  }

  .app-shell.is-chart-detail .chart-record-box {
    order: 2;
    margin-left: 10px;
    margin-right: 10px;
  }

  .app-shell.is-chart-detail .chart-console-head {
    order: 3;
  }

  .app-shell.is-chart-detail .chart-work-upload {
    order: 4;
  }

  .app-shell.is-chart-detail .memo-grid {
    order: 5;
  }

  .app-shell.is-chart-detail .diagnosis-box {
    order: 6;
  }

  .app-shell.is-chart-detail .task-box {
    order: 7;
    margin-left: 10px;
    margin-right: 10px;
  }

  .app-shell.is-chart-detail .chart-lower-stack {
    order: 8;
  }

  .app-shell.is-chart-detail .mobile-touch-chip-grid {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
  }

  .app-shell.is-chart-detail .mobile-touch-chip-grid::-webkit-scrollbar {
    display: none;
  }

  .app-shell.is-chart-detail .mobile-touch-chip-grid .mobile-touch-chip {
    flex: 0 0 104px;
  }

  .app-shell.is-chart-detail .chart-record-box .section-line {
    align-items: flex-start;
    gap: 6px;
  }

  .app-shell.is-chart-detail .chart-record-box .section-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 5px;
  }

  .app-shell.is-chart-detail .chart-record-box .section-actions .btn {
    min-height: 38px;
    padding: 0 4px;
    font-size: 12px;
  }

  .app-shell.is-chart-detail .enhanced-chart-detail .record-textarea {
    min-height: 260px;
  }

  .enhanced-board .mobile-board-list.mobile-board-accordion {
    display: grid;
    gap: 8px;
    padding: 10px 10px 88px;
    background: #fff;
  }

  .mobile-queue-section {
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(19, 33, 68, 0.035);
  }

  .mobile-queue-section.open {
    border-color: #bed4ff;
    box-shadow: 0 4px 14px rgba(43, 122, 255, 0.08);
  }

  .mobile-queue-toggle {
    width: 100%;
    min-height: 50px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 18px;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 0;
    background: #f8faff;
    color: #152033;
    font-weight: 900;
    text-align: left;
  }

  .mobile-queue-toggle span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-queue-toggle strong {
    color: #58657c;
  }

  .mobile-queue-toggle em {
    color: #91a0bb;
    font-style: normal;
    text-align: right;
  }

  .mobile-queue-patients {
    display: grid;
    border-top: 1px solid var(--line);
  }

  .mobile-queue-patients .mobile-patient-row {
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-queue-patients .mobile-patient-row:last-child {
    border-bottom: 0;
  }

  .mobile-patient-row.compact {
    padding: 10px;
  }

  .mobile-patient-row.compact p {
    margin: 6px 0 8px;
    color: #5f6b82;
    font-size: 12px;
    line-height: 1.3;
  }

  .app-shell:not(.is-chart-detail),
  .app-shell:not(.is-chart-detail) .main {
    padding-bottom: 104px;
  }

  .dashboard {
    display: block;
    min-width: 0;
    min-height: auto;
  }

  .dash-col {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 22px 20px;
  }

  .dash-title {
    font-size: 24px;
    line-height: 1.2;
  }

  .alerts-page,
  .stats-page,
  .single-module-page,
  .crm-page-full,
  .enhanced-board.board-page {
    padding-bottom: 118px;
  }

  .alerts-hero {
    padding: 20px;
  }

  .alerts-hero h2 {
    font-size: 26px;
  }

  .alert-kpis {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .alert-kpis .stat-card {
    min-height: 96px;
  }

  .alerts-grid {
    padding-bottom: 120px;
  }

  .split-page.patient-condition-page,
  .split-page {
    display: block;
    height: auto;
    min-width: 0;
    min-height: calc(100svh - 61px);
    overflow: visible;
  }

  .patient-condition-page .left-list,
  .split-page .left-list {
    width: 100%;
    min-width: 0;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
    overflow: visible;
  }

  .patient-condition-page .table-wrap,
  .split-page .table-wrap {
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .patient-condition-page .condition-summary,
  .patient-condition-page .table-wrap .toolbar {
    min-height: 0;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
  }

  .patient-condition-page .table-wrap .input,
  .split-page .table-wrap .input {
    width: 100% !important;
    min-width: 0;
  }

  .patient-condition-page .data-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .patient-condition-page .data-table thead {
    display: none;
  }

  .patient-condition-page .data-table tbody {
    display: grid;
  }

  .patient-condition-page .data-table tr {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 2px 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }

  .patient-condition-page .data-table td {
    display: block;
    min-width: 0;
    border: 0;
    padding: 2px 0;
    word-break: keep-all;
  }

  .patient-condition-page .data-table td:first-child {
    grid-row: 1 / span 8;
    align-self: start;
    padding-top: 6px;
  }

  .patient-condition-page .data-table td:nth-child(2),
  .patient-condition-page .data-table td:nth-child(3) {
    font-size: 15px;
    font-weight: 900;
  }

  .patient-condition-page .data-table td:nth-child(n+4) {
    color: #647089;
    font-size: 12px;
  }

  .enhanced-board .mobile-board-list.mobile-board-accordion {
    padding-bottom: 122px;
  }
}
