/* ============================================================
   病痛經絡成方查詢系統 — Design System
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  /* Palette */
  --clr-bg: #0f1923;
  --clr-bg-2: #162032;
  --clr-bg-3: #1e2d42;
  --clr-surface: #243348;
  --clr-surface-2: #2c3e55;
  --clr-border: #34495e;
  --clr-border-2: #4a6278;

  --clr-gold: #f0c040;
  --clr-gold-dim: #c9952a;
  --clr-gold-hover: #ffd060;

  --clr-text: #e8edf3;
  --clr-text-dim: #9db5cc;
  --clr-text-muted: #5a7a96;

  --clr-accent: #4ea8de;
  --clr-accent-2: #3d8bbd;

  --clr-success: #2ecc71;
  --clr-warning: #f39c12;
  --clr-danger: #e74c3c;
  --clr-info: #3498db;

  /* Tab colors (has data) */
  --tab-dong: #e74c3c;
  --tab-zheng: #e67e22;
  --tab-jing14: #f1c40f;
  --tab-xue: #2ecc71;
  --tab-jiu: #1abc9c;
  --tab-yao: #9b59b6;

  /* Typography */
  --font-main: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --fs-xs: 0.75rem;
  /* 12px */
  --fs-sm: 0.8125rem;
  /* 13px */
  --fs-base: 0.9375rem;
  /* 15px */
  --fs-md: 1rem;
  /* 16px */
  --fs-lg: 1.125rem;
  /* 18px */
  --fs-xl: 1.25rem;
  /* 20px */

  /* Spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;

  /* Layout */
  --nav-h: 52px;
  --status-h: 28px;
  --sidebar-w: 280px;

  /* Radii */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .6);

  /* Transitions */
  --tr-fast: 120ms ease;
  --tr-med: 220ms ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  font-size: var(--fs-base);
  color: var(--clr-text);
  background: var(--clr-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input,
select,
textarea {
  font-family: inherit;
}

/* ── TOP NAV ────────────────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: linear-gradient(90deg, #0d1a28 0%, #162032 60%, #1a2a3e 100%);
  border-bottom: 2px solid var(--clr-gold-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-5);
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.nav-brand .nav-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 6px var(--clr-gold));
}

.nav-brand h1 {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--clr-gold);
  letter-spacing: 0.05em;
  text-shadow: 0 0 16px rgba(240, 192, 64, .4);
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--tr-fast);
  white-space: nowrap;
}

.nav-btn-icon {
  font-size: 0.9rem;
}

.admin-btn {
  background: var(--clr-gold);
  color: #1a1200;
}

.admin-btn:hover {
  background: var(--clr-gold-hover);
  box-shadow: 0 0 12px rgba(240, 192, 64, .5);
  transform: translateY(-1px);
}

.print-btn {
  background: var(--clr-surface-2);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
}

.print-btn:hover {
  background: var(--clr-border);
  transform: translateY(-1px);
}

.sys-btn {
  background: transparent;
  color: var(--clr-text-dim);
  border: 1px solid var(--clr-border);
}

.sys-btn:hover {
  border-color: var(--clr-accent);
  color: var(--clr-accent);
}

.sys-btn.logged-in {
  color: var(--clr-success);
  border-color: var(--clr-success);
}

/* ── APP LAYOUT ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex: 1;
  margin-top: var(--nav-h);
  margin-bottom: var(--status-h);
  height: calc(100vh - var(--nav-h) - var(--status-h));
  overflow: hidden;
}

/* ── SEARCH PANEL ───────────────────────────────────────────── */
.search-panel {
  width: var(--sidebar-w);
  min-width: 220px;
  max-width: 320px;
  background: var(--clr-bg-2);
  border-right: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.search-section {
  padding: var(--sp-4);
  background: var(--clr-bg-3);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.field-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.field-row label {
  font-size: var(--fs-sm);
  color: var(--clr-text-dim);
  white-space: nowrap;
  min-width: 44px;
  text-align: right;
}

.select-input,
.text-input {
  flex: 1;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  color: var(--clr-text);
  padding: 5px 8px;
  font-size: var(--fs-sm);
  transition: border-color var(--tr-fast);
  outline: none;
}

.select-input:focus,
.text-input:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 2px rgba(78, 168, 222, .15);
}

.select-input option {
  background: var(--clr-surface);
}

.query-btn {
  background: linear-gradient(135deg, var(--clr-gold) 0%, var(--clr-gold-dim) 100%);
  color: #1a1200;
  padding: 7px 20px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.15em;
  transition: all var(--tr-fast);
  align-self: stretch;
}

.query-btn:hover {
  background: linear-gradient(135deg, var(--clr-gold-hover) 0%, var(--clr-gold) 100%);
  box-shadow: 0 3px 10px rgba(240, 192, 64, .4);
  transform: translateY(-1px);
}

.query-btn:active {
  transform: translateY(0);
}

/* ── RESULTS PANEL ──────────────────────────────────────────── */
.results-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-4);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
}

.results-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--clr-gold);
  letter-spacing: 0.1em;
}

.results-count {
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
}

.disease-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}

.disease-list::-webkit-scrollbar {
  width: 5px;
}

.disease-list::-webkit-scrollbar-track {
  background: transparent;
}

.disease-list::-webkit-scrollbar-thumb {
  background: var(--clr-border);
  border-radius: 99px;
}

.disease-list li {
  padding: 7px var(--sp-4);
  font-size: var(--fs-sm);
  border-bottom: 1px solid rgba(52, 73, 94, .4);
  cursor: pointer;
  transition: background var(--tr-fast);
  line-height: 1.5;
  color: var(--clr-text-dim);
}

.disease-list li:hover {
  background: var(--clr-surface);
  color: var(--clr-text);
}

.disease-list li.active {
  background: linear-gradient(90deg, rgba(78, 168, 222, .2) 0%, transparent 100%);
  color: var(--clr-accent);
  border-left: 3px solid var(--clr-accent);
  font-weight: 500;
}

.disease-list .empty-hint {
  color: var(--clr-text-muted);
  text-align: center;
  padding: var(--sp-6);
  font-size: var(--fs-sm);
  cursor: default;
  line-height: 1.8;
}

mark.hl {
  background: rgba(240, 192, 64, .35);
  color: var(--clr-gold-hover);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── TREATMENT PANEL ────────────────────────────────────────── */
.treatment-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--clr-bg);
}

/* Tab bar */
.tab-bar {
  display: flex;
  background: var(--clr-bg-3);
  border-bottom: 2px solid var(--clr-border);
  overflow-x: auto;
  flex-shrink: 0;
}

.tab-bar::-webkit-scrollbar {
  height: 3px;
}

.tab-bar::-webkit-scrollbar-thumb {
  background: var(--clr-border);
}

.tab-btn {
  flex: 1;
  min-width: 90px;
  padding: 10px var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--clr-text-muted);
  border-bottom: 3px solid transparent;
  transition: all var(--tr-fast);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--clr-surface);
  color: var(--clr-text);
}

.tab-btn.has-data[data-tab="1"] {
  color: var(--tab-dong);
}

.tab-btn.has-data[data-tab="2"] {
  color: var(--tab-zheng);
}

.tab-btn.has-data[data-tab="3"] {
  color: var(--tab-jing14);
}

.tab-btn.has-data[data-tab="4"] {
  color: var(--tab-xue);
}

.tab-btn.has-data[data-tab="5"] {
  color: var(--tab-jiu);
}

.tab-btn.has-data[data-tab="6"] {
  color: var(--tab-yao);
}

.tab-btn.active[data-tab="1"] {
  border-bottom-color: var(--tab-dong);
  background: rgba(231, 76, 60, .08);
}

.tab-btn.active[data-tab="2"] {
  border-bottom-color: var(--tab-zheng);
  background: rgba(230, 126, 34, .08);
}

.tab-btn.active[data-tab="3"] {
  border-bottom-color: var(--tab-jing14);
  background: rgba(241, 196, 15, .08);
}

.tab-btn.active[data-tab="4"] {
  border-bottom-color: var(--tab-xue);
  background: rgba(46, 204, 113, .08);
}

.tab-btn.active[data-tab="5"] {
  border-bottom-color: var(--tab-jiu);
  background: rgba(26, 188, 156, .08);
}

.tab-btn.active[data-tab="6"] {
  border-bottom-color: var(--tab-yao);
  background: rgba(155, 89, 182, .08);
}

/* Tab content */
.tab-content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}

.tab-content-area::-webkit-scrollbar {
  width: 6px;
}

.tab-content-area::-webkit-scrollbar-thumb {
  background: var(--clr-border);
  border-radius: 99px;
}

.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--clr-text-muted);
  gap: var(--sp-4);
}

.welcome-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.welcome-screen p {
  text-align: center;
  line-height: 2;
  font-size: var(--fs-base);
}

/* Treatment tables */
.treatment-table-wrap {
  animation: fadeIn 200ms ease;
}

.treatment-empty {
  color: var(--clr-text-muted);
  font-size: var(--fs-sm);
  padding: var(--sp-6);
  text-align: center;
}

/* 3-column table (前3 Tab) */
.treat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  table-layout: fixed;
}

.treat-table thead th {
  background: var(--clr-surface);
  color: var(--clr-gold);
  font-weight: 600;
  padding: 8px 10px;
  border: 1px solid var(--clr-border);
  text-align: left;
  letter-spacing: 0.08em;
}

.treat-table thead th:nth-child(1) {
  width: 110px;
}

.treat-table thead th:nth-child(3) {
  width: 200px;
}

.treat-table tbody td {
  padding: 8px 10px;
  border: 1px solid rgba(52, 73, 94, .6);
  vertical-align: top;
  color: var(--clr-text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.treat-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, .02);
}

.treat-table tbody tr:hover td {
  background: rgba(78, 168, 222, .05);
}

.td-principle {
  color: var(--clr-gold-dim);
  font-weight: 500;
  white-space: nowrap;
}

/* Single-column table (後3 Tab) */
.treat-table-single {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.treat-table-single thead th {
  background: var(--clr-surface);
  color: var(--clr-gold);
  font-weight: 600;
  padding: 8px 10px;
  border: 1px solid var(--clr-border);
  letter-spacing: 0.08em;
}

.treat-table-single tbody td {
  padding: 8px 12px;
  border: 1px solid rgba(52, 73, 94, .6);
  vertical-align: top;
  color: var(--clr-text);
  line-height: 1.8;
  white-space: pre-wrap;
}

.treat-table-single tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, .02);
}

.treat-table-single tbody tr:hover td {
  background: rgba(78, 168, 222, .05);
}

/* Condition title above table */
.condition-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--clr-gold);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--clr-gold-dim);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.condition-cat-badge {
  display: inline-block;
  font-size: var(--fs-xs);
  background: var(--clr-surface-2);
  color: var(--clr-text-dim);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 400;
}

/* ── STATUS BAR ─────────────────────────────────────────────── */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--status-h);
  background: var(--clr-bg-3);
  border-top: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
  z-index: 50;
}

.login-indicator {
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
}

.login-indicator.logged-in {
  color: var(--clr-success);
}

/* ── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 150ms ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: var(--clr-bg-2);
  border: 1px solid var(--clr-border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 420px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 200ms ease;
}

.modal-wide {
  width: 640px;
}

.modal-narrow {
  width: 340px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--clr-gold);
}

.modal-close {
  color: var(--clr-text-muted);
  font-size: var(--fs-md);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  transition: color var(--tr-fast), background var(--tr-fast);
}

.modal-close:hover {
  color: var(--clr-danger);
  background: rgba(231, 76, 60, .1);
}

.modal-body {
  padding: var(--sp-4) var(--sp-5);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--clr-border);
  border-radius: 99px;
}

.modal-field-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.modal-input {
  flex: 1;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  color: var(--clr-text);
  padding: 7px 10px;
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--tr-fast);
}

.modal-input:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 2px rgba(78, 168, 222, .15);
}

.flex-1 {
  flex: 1;
}

.modal-select {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  color: var(--clr-text);
  padding: 6px 8px;
  font-size: var(--fs-sm);
  outline: none;
  flex: 1;
}

.modal-select:focus {
  border-color: var(--clr-accent);
}

.modal-select option {
  background: var(--clr-surface);
}

.modal-select:disabled {
  opacity: 0.5;
}

.modal-textarea {
  width: 100%;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  color: var(--clr-text);
  padding: 8px 10px;
  font-size: var(--fs-sm);
  resize: vertical;
  outline: none;
  line-height: 1.6;
  transition: border-color var(--tr-fast);
}

.modal-textarea:focus {
  border-color: var(--clr-accent);
}

.modal-cascade {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: var(--sp-2);
}

.tr-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.tr-field label {
  font-size: var(--fs-xs);
  color: var(--clr-text-dim);
  font-weight: 500;
}

.field-hint {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--clr-text-muted);
  margin-left: 4px;
}

.tr-fields-advanced {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}

.modal-list-header {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  padding: 6px 10px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--clr-gold);
  letter-spacing: 0.08em;
}

.modal-list-header--two {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: var(--sp-3);
}

.modal-list {
  border: 1px solid var(--clr-border);
  border-top: none;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.modal-list::-webkit-scrollbar {
  width: 5px;
}

.modal-list::-webkit-scrollbar-thumb {
  background: var(--clr-border);
}

.modal-list li {
  padding: 7px 10px;
  font-size: var(--fs-sm);
  color: var(--clr-text-dim);
  border-bottom: 1px solid rgba(52, 73, 94, .4);
  cursor: pointer;
  transition: background var(--tr-fast);
}

.modal-list li:hover {
  background: var(--clr-surface);
  color: var(--clr-text);
}

.modal-list li.active {
  background: rgba(78, 168, 222, .15);
  color: var(--clr-accent);
  font-weight: 500;
}

.modal-list li.empty {
  cursor: default;
  color: var(--clr-text-muted);
  text-align: center;
}

.modal-list--two li {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: var(--sp-3);
}

.modal-list--two .col-cat {
  color: var(--clr-gold-dim);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn-primary {
  background: var(--clr-accent);
  color: #fff;
  padding: 7px 18px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--tr-fast);
}

.btn-primary:hover {
  background: var(--clr-accent-2);
}

.btn-secondary {
  background: var(--clr-surface-2);
  color: var(--clr-text-dim);
  border: 1px solid var(--clr-border);
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  transition: all var(--tr-fast);
}

.btn-secondary:hover {
  background: var(--clr-border);
  color: var(--clr-text);
}

.btn-warning {
  background: rgba(243, 156, 18, .15);
  color: var(--clr-warning);
  border: 1px solid rgba(243, 156, 18, .4);
  padding: 6px 16px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--tr-fast);
}

.btn-warning:hover {
  background: rgba(243, 156, 18, .3);
}

.btn-danger {
  background: rgba(231, 76, 60, .15);
  color: var(--clr-danger);
  border: 1px solid rgba(231, 76, 60, .4);
  padding: 6px 16px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--tr-fast);
}

.btn-danger:hover {
  background: rgba(231, 76, 60, .3);
}

.btn-success {
  background: rgba(46, 204, 113, .15);
  color: var(--clr-success);
  border: 1px solid rgba(46, 204, 113, .4);
  padding: 6px 16px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--tr-fast);
}

.btn-success:hover {
  background: rgba(46, 204, 113, .3);
}

/* Login form */
.login-error {
  color: var(--clr-danger);
  font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-3);
  background: rgba(231, 76, 60, .1);
  border-radius: var(--r-sm);
  border: 1px solid rgba(231, 76, 60, .3);
}

.login-error[hidden] {
  display: none;
}

/* ── TOAST ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--status-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--clr-surface-2);
  color: var(--clr-text);
  padding: 10px 24px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--clr-border-2);
  opacity: 0;
  transition: all 250ms ease;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--clr-success);
  color: var(--clr-success);
}

.toast.error {
  border-color: var(--clr-danger);
  color: var(--clr-danger);
}

/* ── LOADING ────────────────────────────────────────────────── */
.loading-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
}

.loading-dots span {
  width: 7px;
  height: 7px;
  background: var(--clr-accent);
  border-radius: 50%;
  animation: bounce 1s infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: .15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: .30s;
}

/* ── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

/* ── SCROLLBAR GLOBAL ───────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--clr-border);
  border-radius: 99px;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 220px;
  }

  .nav-brand h1 {
    font-size: var(--fs-base);
  }

  .admin-btn .nav-btn-icon {
    display: none;
  }

  .nav-btn {
    padding: 6px 8px;
    font-size: var(--fs-xs);
  }

  .modal-cascade {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {

  /* Nav bar: allow horizontal scroll so all buttons are reachable */
  .top-nav {
    padding: 0 var(--sp-2);
    overflow-x: auto;
    gap: var(--sp-2);
    justify-content: flex-start;
  }

  .nav-brand {
    flex-shrink: 0;
  }

  .nav-brand h1 {
    font-size: var(--fs-sm);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-actions {
    flex-shrink: 0;
    gap: var(--sp-1);
  }

  /* Show icons only on very small screens */
  .nav-btn {
    padding: 6px 8px;
    font-size: 0;
    /* hide text */
    gap: 0;
    min-width: 36px;
    justify-content: center;
  }

  .nav-btn-icon {
    font-size: 1rem;
    /* keep icon visible */
    display: inline !important;
  }

  /* Full-column layout */
  .app-layout {
    flex-direction: column;
    height: auto;
    overflow: auto;
    margin-top: var(--nav-h);
  }

  .search-panel {
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--clr-border);
    max-height: 50vh;
  }

  .treatment-panel {
    min-height: 60vh;
  }

  .tab-btn {
    font-size: 0.7rem;
    padding: 8px 6px;
    min-width: 70px;
  }

  /* Make 3-col table scrollable horizontally */
  .tab-content-area {
    overflow-x: auto;
    padding: var(--sp-2);
  }

  .treat-table {
    min-width: 520px;
  }
}