:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #dbe3ee;
  --text: #0f172a;
  --text-muted: #64748b;
  --indigo: #4f46e5;
  --indigo-dark: #3730a3;
  --indigo-soft: #eef2ff;
  --lavender: #9ea4f0;
  --teal: #0f766e;
  --cyan: #22d3ee;
  --cyan-dark: #0891b2;
  --peach: #ffa57a;
  --red: #dc2626;
  --shadow: 0 6px 22px rgba(15, 23, 42, 0.07);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--indigo-dark);
  line-height: 1.15;
}

.patient-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-weight: 600;
}

.stat-bop strong { color: var(--red); }
.stat-plaque strong { color: var(--cyan-dark); }
.stat-pd5 strong { color: #b45309; }

.topbar-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--indigo);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- Buttons ---- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn:hover { background: var(--surface-alt); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #ffffff;
}
.btn-primary:hover { background: var(--indigo-dark); }

.btn-voice-pill {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.btn-voice-pill.active {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.btn-install {
  background: #f0fdfa;
  border-color: #99f6e4;
  color: var(--teal);
}

.btn-danger-outline {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}
.btn-danger-outline:hover { background: #ffe4e6; }

.btn-dir-toggle {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}
.btn-dir-toggle:hover { background: #e0e7ff; }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn-icon {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
}

.btn-file { cursor: pointer; }

/* ---- Main Workspace & Split Mode ---- */
.main-workspace {
  max-width: 1520px;
  margin: 0 auto;
  padding: 14px 14px 190px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main-workspace.split-mode {
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(520px, 1.08fr) minmax(480px, 0.92fr);
  align-items: start;
  gap: 14px;
}

.main-workspace.split-mode .panel-chart {
  position: sticky;
  top: 66px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

/* ---- Patient Meta Card ---- */
.patient-card { padding: 0; overflow: hidden; }

.dept-banner {
  background: linear-gradient(90deg, #9ea4f0 0%, #818cf8 100%);
  color: #ffffff;
  padding: 9px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.dept-banner span:first-child {
  font-family: "Times New Roman", Georgia, serif;
  font-size: 19px;
  font-weight: 700;
}

.dept-sub {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.92;
}

.meta-grid {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
}

.meta-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.meta-field span {
  min-width: 122px;
  font-weight: 700;
  color: #334155;
  flex-shrink: 0;
}

.meta-field input,
.meta-field select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-alt);
}

.meta-field input:focus,
.meta-field select:focus {
  outline: 2px solid var(--indigo);
  background: #ffffff;
}

.meta-readonly strong {
  font-size: 14px;
  font-weight: 800;
}

.text-red { color: var(--red); }
.text-cyan { color: var(--cyan-dark); }

.meta-toggles {
  grid-column: span 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.chk-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

/* ---- 8-Stage Workflow Stepper ---- */
.workflow-card {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workflow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.workflow-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #334155;
}

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

.stage-step {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: #475569;
  border-radius: 9px;
  padding: 7px 5px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-step:hover { border-color: var(--indigo); color: var(--indigo-dark); }

.stage-step.active {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.25);
}

.workflow-hint {
  font-size: 12px;
  color: var(--teal);
  font-weight: 600;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 8px;
  padding: 5px 10px;
}

/* ---- Form Toolbar ---- */
.form-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.form-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.inline-select {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inline-select select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12.5px;
  background: var(--surface);
}

.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.seg-btn.active {
  background: var(--indigo);
  color: #ffffff;
}

/* ---- Focus Tooth Card ---- */
.focus-card {
  padding: 12px 14px;
}

.focus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.focus-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.focus-badge {
  background: var(--indigo-soft);
  color: var(--indigo-dark);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}

.focus-nav {
  display: flex;
  gap: 6px;
}

.tooth-strip {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  scrollbar-width: thin;
}

.tooth-pill {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 5px 7px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tooth-pill.active {
  border-color: var(--indigo);
  background: var(--indigo);
  color: #ffffff;
}

.tooth-pill.is-missing {
  opacity: 0.5;
  text-decoration: line-through;
}

.tooth-pill .tp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}
.tooth-pill .tp-dot.pd5 { background: #ef4444; }
.tooth-pill .tp-dot.imp { background: #22c55e; }
.tooth-pill.active .tp-dot.pd5 { background: #fecaca; }

.focus-body {
  display: grid;
  grid-template-columns: 165px 1fr;
  gap: 14px;
  align-items: start;
}

.focus-visual-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.focus-sprite-img {
  height: 92px;
  width: auto;
  object-fit: contain;
}

.focus-sprite-img.is-missing {
  filter: grayscale(100%) opacity(0.45);
}

.focus-flag-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  width: 100%;
}

.flag-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  padding: 5px 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.flag-toggle.on-missing { background: #475569; color: #fff; border-color: #475569; }
.flag-toggle.on-implant { background: #16a34a; color: #fff; border-color: #16a34a; }
.flag-toggle.on-rct { background: #2563eb; color: #fff; border-color: #2563eb; }
.flag-toggle.on-crown { background: #eab308; color: #0f172a; border-color: #eab308; }

.focus-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 2px;
}

.focus-extras label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex: 1;
  min-width: 58px;
}

.focus-extras input,
.focus-extras select {
  margin-top: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 5px;
  font-size: 12px;
  font-weight: 700;
}

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

.focus-surf-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--surface-alt);
}

.focus-surf-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--indigo-dark);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.focus-site-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.focus-site-table th,
.focus-site-table td {
  padding: 4px 3px;
  text-align: center;
}

.focus-site-table th {
  font-size: 11px;
  color: var(--text-muted);
}

.focus-site-table td:first-child {
  text-align: left;
  font-weight: 700;
  width: 44px;
}

.f-num-input {
  width: 46px;
  height: 32px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  background: #ffffff;
}

.f-num-input.cursor-active {
  outline: 2.5px solid var(--indigo);
  background: #eef2ff;
}

.f-num-input.pd-high { color: var(--red); background: #fef2f2; }

.f-chk-btn {
  width: 34px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
}
.f-chk-btn.bop-on { background: #fb923c; border-color: #ea580c; color: #fff; }
.f-chk-btn.plq-on { background: #22d3ee; border-color: #0891b2; color: #fff; }
.f-chk-btn.cursor-active { outline: 2.5px solid var(--indigo); }

/* ---- Desktop Spreadsheet Table ---- */
.sheet-card { padding: 10px 12px; }

.sheet-card-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--indigo-dark);
  margin-bottom: 8px;
}

.table-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.perio-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11.5px;
}

.perio-table th,
.perio-table td {
  border: 1px solid #cbd5e1;
  padding: 0;
  text-align: center;
  height: 24px;
}

.perio-table .row-label {
  width: 78px;
  text-align: left;
  padding: 0 6px;
  font-weight: 800;
  position: sticky;
  left: 0;
  z-index: 3;
  background: #ffffff;
}

.row-missing .row-label { background: #475569; color: #fff; }
.row-missing td:not(.row-label) { background: #64748b; }

.row-implant .row-label { background: #22c55e; color: #fff; }
.row-implant td:not(.row-label) { background: #4ade80; }

.row-rct .row-label { background: #2563eb; color: #fff; }
.row-rct td:not(.row-label) { background: #3b82f6; }

.row-crown .row-label { background: #eab308; color: #0f172a; }
.row-crown td:not(.row-label) { background: #fde047; }

.row-tooth th,
.row-tooth td {
  background: var(--lavender);
  color: #ffffff;
  font-weight: 800;
  font-size: 12.5px;
}

.row-tooth .tooth-hdr-cell.is-missing-hdr {
  background: #94a3b8;
}

.row-gm .row-label { background: #22d3ee; color: #ffffff; }
.row-pd .row-label { background: #ffa57a; color: #ffffff; }

.cell-missing { background: #94a3b8 !important; }

.tbl-chk {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #0f172a;
}
.tbl-chk.cursor-active {
  outline: 2.5px solid var(--indigo);
  outline-offset: 2px;
  border-radius: 3px;
}

.tbl-bop { accent-color: #f97316; }
.tbl-plq { accent-color: #06b6d4; }

.tbl-input {
  width: 100%;
  height: 23px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  padding: 0;
}

.tbl-input:focus {
  outline: 2px solid var(--indigo);
  background: #eef2ff;
  position: relative;
  z-index: 2;
}

.tbl-input.cursor-active {
  background: #e0e7ff;
  box-shadow: inset 0 0 0 2px var(--indigo);
}

.tbl-input.pd-high {
  color: var(--red);
  font-weight: 800;
}

.tbl-select {
  width: 100%;
  height: 23px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.cal-val {
  display: inline-block;
  width: 100%;
  font-weight: 600;
  color: #334155;
}

.furc-cell-wrap {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  overflow: hidden;
}

.furc-slot {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1.05;
}

.furc-slot select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  font-size: 10.5px;
  font-weight: 800;
  color: #b91c1c;
  padding: 0;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
}

/* ---- Chart View ---- */
.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
}

.chart-toolbar-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.chart-toolbar-actions {
  display: flex;
  gap: 6px;
}

.chart-viewport {
  background: #e2e8f0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px;
  overflow: auto;
  max-height: calc(100vh - 165px);
}

.chart-stage {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.12);
  margin: 0 auto;
  overflow: hidden;
}

.chart-stage.zoom-fit svg { width: 100%; height: auto; display: block; }
.chart-stage.zoom-100 { width: 1380px; }
.chart-stage.zoom-135 { width: 1863px; }
.chart-stage.zoom-100 svg,
.chart-stage.zoom-135 svg { width: 100%; height: auto; display: block; }

/* ---- Cases Panel ---- */
.cases-header-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cases-header-card h2 { margin: 0 0 4px; font-size: 18px; }
.muted { margin: 0; font-size: 13px; color: var(--text-muted); }

.cases-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.case-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.case-item.is-active {
  border: 2px solid var(--indigo);
  background: #fafaff;
}

.case-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.case-item-title { font-size: 16px; font-weight: 800; }
.case-item-sub { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.case-item-stats { display: flex; gap: 8px; font-size: 12px; font-weight: 700; }
.case-item-btns { display: flex; gap: 6px; margin-top: 4px; }

/* ---- Voice & Quick Numpad Dock ---- */
.voice-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-top: 2px solid var(--indigo);
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.14);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

.voice-dock.collapsed .voice-dock-body {
  display: none;
}

.voice-dock-top {
  max-width: 1400px;
  margin: 0 auto 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voice-cursor-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.cursor-pill {
  background: var(--indigo);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}

.voice-feedback {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 520px;
}

.voice-dock-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.select-compact {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 12px;
  font-weight: 600;
}

.voice-dock-body {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 188px 1fr;
  gap: 10px;
  align-items: center;
}

.voice-mic-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.btn-mic {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #4f46e5 0%, #0f766e 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-mic.listening {
  background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
  animation: pulse-mic 1.3s infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
  50% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
}

.voice-step-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.quick-numpad {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.numpad-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.num-btn {
  flex: 1 1 42px;
  min-width: 38px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

.num-btn:hover { background: #e2e8f0; }
.num-btn:active { transform: scale(0.95); }
.num-btn.num-danger { color: var(--red); background: #fef2f2; border-color: #fecaca; }
.num-btn.num-neg { color: #0369a1; background: #f0f9ff; border-color: #bae6fd; }
.num-btn.num-bop { color: #c2410c; background: #fff7ed; border-color: #fed7aa; font-size: 12px; flex: 1 1 84px; }
.num-btn.num-plq { color: #0e7490; background: #ecfeff; border-color: #a5f3fc; font-size: 12px; flex: 1 1 84px; }
.num-btn.num-miss { color: #475569; background: #f1f5f9; font-size: 11.5px; flex: 1 1 70px; }
.num-btn.num-mob { color: #92400e; background: #fffbeb; border-color: #fde68a; flex: 1.4 1 82px; }
.num-btn.num-furc { color: #991b1b; background: #fef2f2; border-color: #fecaca; font-size: 12px; flex: 1.3 1 78px; }
.numpad-note {
  font-size: 11.5px;
  font-weight: 700;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 7px;
  padding: 4px 9px;
  display: inline-flex;
  align-items: center;
}

/* ---- Modals ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  width: min(680px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.modal-card.modal-sm { width: min(520px, 100%); }

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 17px; }

.modal-body { padding: 16px 18px; }

.export-options-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.export-options-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
}

.export-options-row select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}

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

.export-tile {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s ease;
}

.export-tile:hover {
  border-color: var(--indigo);
  background: var(--indigo-soft);
}

.exp-ico { font-size: 22px; }
.export-tile strong { font-size: 13.5px; color: var(--text); }
.export-tile small { font-size: 11.5px; color: var(--text-muted); }

.voice-help-body ul {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-help-body code {
  background: var(--indigo-soft);
  color: var(--indigo-dark);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

.muted-note {
  margin: 0;
  font-size: 12px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 8px 10px;
  border-radius: 8px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 90;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}

/* ---- Print ---- */
.print-only { display: none; }

@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: #ffffff; margin: 0; }
  #print-container svg {
    width: 100%;
    height: auto;
    page-break-inside: avoid;
  }
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .workflow-stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  .hide-mobile { display: none !important; }
  .topbar { padding: 8px 10px; gap: 6px; min-width: 0; max-width: 100%; }
  .topbar-stats { flex-wrap: wrap; }
  .topbar-tabs { width: 100%; justify-content: space-between; }
  .tab-btn { flex: 1; padding: 6px 6px; font-size: 12px; }
  .main-workspace { padding: 10px 10px 285px; max-width: 100%; overflow-x: hidden; }
  .panel { min-width: 0; max-width: 100%; }
  .card, .sheet-card { min-width: 0; max-width: 100%; padding: 11px; }
  .workflow-stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .stage-step { font-size: 11px; padding: 6px 3px; }
  .table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .form-toolbar, .form-toolbar-right, .inline-select { max-width: 100%; width: 100%; }
  .form-toolbar-right select { flex: 1; min-width: 0; max-width: 100%; }
  .meta-grid { grid-template-columns: 1fr; padding: 10px; gap: 7px; }
  .meta-field { gap: 6px; font-size: 12px; }
  .meta-field span { min-width: 108px; font-size: 12px; }
  .meta-field input, .meta-field select { width: 100%; min-width: 0; }
  .meta-toggles { grid-column: span 1; gap: 6px; }
  .focus-header { flex-wrap: wrap; }
  .focus-body { grid-template-columns: 1fr; }
  .focus-surfaces-grid { grid-template-columns: 1fr; }
  .voice-dock { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); max-width: 100vw; overflow-x: hidden; }
  .voice-dock-top { gap: 4px; margin-bottom: 5px; }
  .voice-feedback { max-width: 100%; font-size: 11.5px; }
  .voice-dock-controls { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .voice-dock-body { grid-template-columns: 1fr; gap: 6px; }
  .voice-mic-col { display: flex; flex-direction: column; gap: 5px; }
  .btn-mic { padding: 8px 10px; font-size: 13px; width: 100%; }
  .voice-step-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; width: 100%; }
  .voice-step-btns .btn-xs { padding: 5px 4px; font-size: 11px; white-space: nowrap; }
  .export-options-row,
  .export-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .quick-numpad {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  .numpad-row {
    display: contents;
  }
  .num-btn {
    padding: 8px 3px;
    font-size: 12px;
    min-width: 0;
  }
  .num-btn.num-bop, .num-btn.num-plq, .num-btn.num-miss {
    font-size: 11px;
  }
  .numpad-note {
    grid-column: 1 / -1;
    font-size: 11px;
  }
}
