:root {
  /* UI colours */
  --bg: #e6dfd2;
  --panel: #fbf7ef;
  --paper: #fffdf8;
  --ink: #171717;
  --muted: #71695f;
  --line: #c8b99f;
  --line-dark: #473f35;
  --soft: #f3eadb;
  --soft-2: #eadcc8;
  --dark: #111;
  --accent: #9b7b4f;
  --green: #dfead8;
  --danger: #8f1f1f;

  /* Plan / A4 typography system */
  --plan-font-family: Arial, Helvetica, sans-serif;
  --plan-font-size: 12px;
  --plan-font-size-sm: 11px;
  --plan-heading-font-size: 20px;
  --plan-section-font-size: 12px;
  --plan-logo-font-family: Georgia, "Times New Roman", serif;
  --plan-logo-font-size: 34px;
  --plan-total-font-size: 14px;
  --plan-line-height: 1.4;

  /* Design-mode CSS variables (overridable via applyDesignSettings) */
  --a4-padding-v: 36px;
  --a4-padding-h: 40px;
  --plan-header-gap: 12px;
  --plan-cell-pad-v: 5px;
  --plan-cell-pad-h: 6px;
  --plan-table-font-size: 12px;
  --plan-cat-font-size: 11px;
  --plan-total-spacing: 12px;
  --plan-sig-spacing: 36px;
  --left-panel-width: 320px;
  --right-panel-width: 330px;
  --shell-gap: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: auto;
}

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

button {
  border: 1px solid var(--dark);
  background: var(--dark);
  color: white;
  border-radius: 8px;
  padding: 8px 11px;
  cursor: pointer;
}

button.secondary {
  background: white;
  color: var(--ink);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.topbar {
  height: 46px;
  background: var(--dark);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
}

/* Compact brand */
.topbar-brand { display: flex; align-items: baseline; gap: 7px; flex-shrink: 0; }
.topbar-brand strong { font-size: 15px; letter-spacing: .04em; color: #fff; }
.topbar-brand span   { font-size: 11px; color: rgba(255,255,255,0.45); letter-spacing: .02em; }

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

/* Role badge */
.role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
}
.role-badge--doctor    { background: rgba(60,140,60,0.25);  color: #90e090; border: 1px solid rgba(80,180,80,0.3); }
.role-badge--admin     { background: rgba(60,100,200,0.25); color: #90b8ff; border: 1px solid rgba(80,120,220,0.3); }
.role-badge--developer { background: rgba(140,60,200,0.25); color: #d0a0ff; border: 1px solid rgba(160,80,220,0.3); }

/* Role select — minimal inline dropdown */
.role-select {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  max-width: 26px;
  overflow: hidden;
}
.role-select:focus { outline: none; border-color: rgba(255,255,255,0.5); max-width: none; }
.role-select option { background: #1a1a2e; color: #fff; font-size: 12px; }

/* Preview banner in header */
.preview-banner {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(200,150,20,0.25);
  border: 1px solid rgba(220,170,40,0.4);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  color: #f0cc60;
  white-space: nowrap;
}
.pb-icon { font-size: 11px; }
.pb-text { font-weight: 500; }
.pb-back {
  font-size: 10px;
  padding: 1px 6px;
  border: 1px solid rgba(220,170,40,0.4);
  border-radius: 4px;
  background: rgba(200,150,20,0.2);
  color: #f0cc60;
  cursor: pointer;
  margin-left: 2px;
}
.pb-back:hover { background: rgba(200,150,20,0.4); }

/* Undo/redo stubs */
.topbar-icon-btn {
  font-size: 14px;
  padding: 2px 6px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.4);
  cursor: not-allowed;
}
.topbar-icon-btn:not(:disabled) { cursor: pointer; color: rgba(255,255,255,0.8); }
.topbar-icon-btn:not(:disabled):hover { background: rgba(255,255,255,0.15); }

/* Action buttons in header */
.topbar-action-btn {
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  white-space: nowrap;
}
.topbar-action-btn:hover { background: rgba(255,255,255,0.2); }

/* Quieter print hint */
.print-color-hint {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.65;
}

/* Role selector in header */
.role-selector-wrap { display: flex; align-items: center; }
.role-selector { display: flex; align-items: center; gap: 6px; }
.role-selector-label { font-size: 11px; color: rgba(255,255,255,0.6); white-space: nowrap; }
.role-select {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
}
.role-select:focus { outline: none; border-color: rgba(255,255,255,0.6); }
.role-select option { background: #1a1a2e; color: #fff; }

/* Dev tools bar */
.dev-tools-bar {
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a4a;
  padding: 4px 12px;
}
.dtb-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.dtb-label {
  font-size: 10px;
  color: #7070a0;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-right: 2px;
  white-space: nowrap;
}
.dtb-sep { width: 1px; height: 16px; background: #2a2a4a; margin: 0 4px; flex-shrink: 0; }
.dtb-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #3a3a6a;
  background: #22224a;
  color: #aaaacc;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.dtb-btn:hover { background: #2a2a6a; color: #ccccff; border-color: #5a5a9a; }
.dtb-link { text-decoration: none; }
.dtb-role-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #3a3a5a;
  background: transparent;
  color: #8888aa;
  cursor: pointer;
  white-space: nowrap;
}
.dtb-role-btn:hover { background: #2a2a4a; color: #ccccee; }
.dtb-role-btn.active { background: #3a3a6a; color: #ccccff; border-color: #7070b0; }
.dtb-back { color: #cc8888; border-color: #6a3a3a; }
.dtb-back:hover { background: #4a2a2a; color: #ffaaaa; }

.version-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  background: #1e1e1e;
  border-bottom: 1px solid #333;
  font-size: 11px;
  color: #8a8a8a;
  font-family: monospace;
  letter-spacing: 0.04em;
}

.version-info {
  color: #aaa;
}

.version-btn {
  background: transparent;
  border: 1px solid #444;
  color: #bbb;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
}

.version-btn:hover {
  border-color: #888;
  color: white;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: #d9cebd;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  background: #f8f2e8;
  color: var(--ink);
  border-color: var(--line);
  white-space: nowrap;
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 7px;
  letter-spacing: 0.01em;
}

.tab.active {
  background: var(--dark);
  color: white;
  border-color: var(--dark);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--left-panel-width) minmax(850px, 1fr) var(--right-panel-width);
  gap: var(--shell-gap);
  padding: var(--shell-gap);
  min-height: calc(100vh - 112px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  height: calc(100vh - 140px);
  overflow: auto;
}

.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 0 0 12px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 8px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin: 8px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink);
  line-height: 1.5;
  flex-shrink: 0;
}

.chip-count {
  display: inline-block;
  background: rgba(0,0,0,0.12);
  border-radius: 999px;
  padding: 0 5px;
  font-size: 10px;
  line-height: 1.6;
  min-width: 16px;
  text-align: center;
}
.chip.active .chip-count {
  background: rgba(255,255,255,0.25);
}

.chip.active {
  background: var(--dark);
  color: white;
  border-color: var(--dark);
}

.service-card, .selected-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: var(--scard-padding, 9px);
  margin-bottom: var(--scard-gap, 8px);
}

/* ── Compact preset ── */
.service-list--compact .scard--compact {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  margin-bottom: 3px;
  border-radius: 5px;
}
.scard-compact-name { flex: 1; font-size: 12px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-btn--sm { padding: 2px 8px; font-size: 13px; }

/* ── Expandable preset ── */
.scard--expandable { padding: 0; overflow: hidden; }
.scard-expand-hdr {
  cursor: pointer;
  padding: 7px 9px;
  user-select: none;
}
.scard-expand-hdr:hover { background: #f4f4ff; }
.scard-chevron { font-size: 11px; color: var(--muted); margin-left: 4px; }
.scard-expand-body { padding: 0 9px 8px; border-top: 1px solid var(--line); }

/* ── Touch preset ── */
.service-list--touch .scard--touch {
  padding: 14px 12px;
  margin-bottom: 10px;
}
.service-list--touch .scard--touch .add-btn {
  padding: 10px 18px;
  font-size: 15px;
  margin-top: 8px;
  width: 100%;
}
.service-list--touch .scard--touch .qty-btn {
  width: 36px;
  height: 36px;
  font-size: 18px;
}
.service-list--touch .scard--touch .qty-input,
.service-list--touch .scard--touch .area-input {
  height: 34px;
  font-size: 14px;
}

.service-card strong,
.selected-card strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.service-card small,
.selected-card small {
  color: var(--muted);
}

.service-card .row,
.selected-card .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-top: 7px;
}

/* Inline qty/area controls inside service card */
.card-qty-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.qty-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  background: var(--soft-2);
  border: 1px solid var(--line);
  color: var(--ink);
  flex-shrink: 0;
}

.qty-input {
  width: 42px;
  text-align: center;
  padding: 3px 2px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: white;
  /* hide browser spinners */
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.svc-price {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.area-input {
  display: block;
  width: 100%;
  margin-top: 5px;
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--soft);
  box-sizing: border-box;
}

.area-input:focus {
  background: white;
  outline: none;
  border-color: var(--accent);
}

.add-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-size: 12px;
  padding: 5px;
  border-radius: 7px;
  text-align: center;
}

/* Added / undo state */
.card-added {
  border-color: #5a9a5a;
  background: #f0f9f0;
}

.card-added-badge {
  text-align: center;
  color: #2a6a2a;
  font-size: 13px;
  font-weight: bold;
  padding: 7px 0 3px;
  letter-spacing: 0.02em;
}

.undo-btn {
  display: block;
  width: 100%;
  margin-top: 5px;
  font-size: 12px;
  padding: 5px;
  border-radius: 7px;
  background: #fde8e8;
  border: 1px solid #c87070;
  color: var(--danger);
  text-align: center;
  cursor: pointer;
}

/* Service card: name + price top row */
.scard-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}
.scard-top strong { flex: 1; font-size: var(--scard-font-size, 13px); line-height: 1.25; }
.svc-price-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 1px;
}
.scard-cat { display: var(--scard-cat-display, block); color: var(--muted); font-size: 11px; margin-top: 2px; }

/* Area input inlined in qty row */
.area-inline {
  flex: 1;
  font-size: 11px;
  padding: 3px 6px;
  height: 26px;
  box-sizing: border-box;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--soft);
  min-width: 0;
}
.area-inline:focus { background: white; outline: none; border-color: var(--accent); }

/* Phase selector in service card */
.phase-select {
  display: block;
  width: 100%;
  margin-top: 5px;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  box-sizing: border-box;
}
.phase-select:focus { background: white; outline: none; border-color: var(--accent); }

/* Result count bar above service list */
.svc-count-bar {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 1px 6px;
  min-height: 18px;
}

/* Empty state */
.svc-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.svc-empty-icon { font-size: 26px; margin-bottom: 8px; }
.svc-clear-search {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 7px;
  background: var(--soft-2);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
}

/* Show more / show less button */
.show-more-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 7px;
  font-size: 12px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}
.show-more-btn:hover { background: var(--soft-2); }

.workspace {
  overflow: auto;
  padding-bottom: 60px;
  max-height: calc(100vh - 140px);
}

.patient-editor {
  width: 794px;
  margin: 0 auto 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.patient-editor label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.patient-editor input {
  margin-top: 4px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
}

.preview-zoom-bar {
  width: 794px;
  margin: 0 auto 6px;
}
.pzb-inner {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pzb-btn {
  font-size: 13px;
  padding: 3px 9px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  min-width: 32px;
  text-align: center;
}
.pzb-btn:hover:not(:disabled) { background: #e0e4ef; }
.pzb-btn:disabled { opacity: 0.4; cursor: default; }
.pzb-active { background: #e8f0fe !important; border-color: #1a56db !important; color: #1a56db !important; font-weight: 600; }
.pzb-pct {
  font-size: 12px;
  min-width: 42px;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pzb-fit { font-size: 11px; }
.a4-zoom-wrap {
  transform-origin: top center;
}

.plan-print-bar {
  width: 794px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.plan-print-bar button {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}

.print-color-hint {
  font-size: 10px;
  color: #7a5c00;
  background: #fffbe8;
  border: 1px solid #e0c840;
  border-radius: 4px;
  padding: 3px 8px;
  flex: 1;
  margin-left: 8px;
}

/* Preview tab */
.preview-tab-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.preview-print-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--dark);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  align-self: flex-start;
}
.preview-print-btn:hover { opacity: 0.88; }

.preview-color-hint {
  font-size: 11px;
  background: #fffbe8;
  border: 1px solid #e0c840;
  border-radius: 5px;
  padding: 7px 10px;
  color: #6a5000;
  line-height: 1.5;
}

.preview-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preview-step {
  font-size: 11px;
  color: var(--muted);
  padding: 3px 6px;
  background: var(--soft);
  border-radius: 4px;
  border-left: 2px solid var(--line-dark);
}

.page-break-label {
  width: 794px;
  margin: 10px auto 4px;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

.page-break {
  width: 794px;
  height: 22px;
  margin: 18px auto;
  border-top: 2px dashed #9e8f7e;
}

.a4-page {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid #b8aa98;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  padding: var(--a4-padding-v) var(--a4-padding-h);
  position: relative;
}

.ghost-page {
  min-height: 520px;
  opacity: .55;
}

.ghost-text {
  border: 1px dashed var(--line);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.plan-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding-bottom: var(--plan-header-gap);
  margin-top: var(--el-HEADER-mt, 0px);
}

.plan-brand-col {
  min-width: 100px;
}

.logo-text {
  font-family: var(--plan-logo-font-family);
  font-size: 26px;
  line-height: 1;
  letter-spacing: .02em;
}

.logo-sub {
  font-family: var(--plan-font-family);
  font-size: var(--plan-font-size-sm);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.plan-company-col {
  border-left: 2px solid var(--line);
  padding-left: 14px;
}

.plan-company-name {
  font-family: var(--plan-font-family);
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 2px;
}

.plan-doc-col {
  text-align: center;
}

.plan-doc-label {
  border: 2px solid var(--line-dark);
  padding: 7px 12px;
  font-family: var(--plan-font-family);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: .08em;
  line-height: 1.25;
  text-align: center;
}

.plan-header-rule {
  border: none;
  border-top: 2px solid var(--line-dark);
  margin: 0 0 14px;
}

.plan-patient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--el-PATIENT-fs, var(--plan-font-size));
  font-family: var(--plan-font-family);
  line-height: var(--plan-line-height);
  margin-top: var(--el-PATIENT-mt, 0px);
  margin-bottom: 14px;
}

.plan-patient-table td {
  border: 1px solid var(--line-dark);
  padding: 5px 8px;
  vertical-align: middle;
}

.pi-label {
  background: var(--soft);
  color: var(--muted);
  white-space: nowrap;
  width: 90px;
}

.pi-value {
  min-width: 140px;
}

/* Inline plan editing */
.plan-inline-input,
.plan-inline-select {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 1px 3px;
  font: inherit;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.12s, background 0.12s;
}

/* Document-style underline on hover */
.plan-inline-input:hover {
  border-color: transparent;
  border-bottom-color: #bbb;
  border-radius: 0;
  background: transparent;
}
.plan-inline-select:hover { border-color: var(--line); }

.plan-inline-input:focus,
.plan-inline-select:focus  {
  border-color: #4a90d9;
  background: #f0f7ff;
  outline: none;
  border-radius: 3px;
}

/* Hide number input spinners in plan cells */
.plan-cell-input[type="number"]::-webkit-inner-spin-button,
.plan-cell-input[type="number"]::-webkit-outer-spin-button { opacity: 0; }
.plan-cell-input[type="number"]:focus::-webkit-inner-spin-button,
.plan-cell-input[type="number"]:focus::-webkit-outer-spin-button { opacity: 1; }

.plan-inline-select { cursor: pointer; }

.pi-name-wrap {
  display: flex;
  gap: 4px;
}
.pi-name-wrap .plan-inline-input { flex: 1; min-width: 0; }

/* Service table cell inputs */
.plan-cell-input { width: 100%; min-width: 0; }
.plan-table td.c-qty   .plan-cell-input { text-align: center; }
.plan-table td.c-price .plan-cell-input { text-align: right; }

/* Make qty column slightly wider for the input */
.plan-table th.c-qty,
.plan-table td.c-qty { width: 46px; }

/* Notes textarea inline */
.plan-notes-textarea {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  font: inherit;
  color: inherit;
  padding: 2px 3px;
  resize: vertical;
  min-height: 36px;
  box-sizing: border-box;
  transition: border-color 0.1s;
}
.plan-notes-textarea:hover { border-color: var(--line); }
.plan-notes-textarea:focus { border-color: #4a90d9; outline: none; }

.info-grid {
  display: grid;
  grid-template-columns: 120px 1fr 90px 1fr;
  border-top: 1px solid var(--line-dark);
  border-left: 1px solid var(--line-dark);
  margin-bottom: 18px;
  font-size: var(--plan-font-size);
  font-family: var(--plan-font-family);
  line-height: var(--plan-line-height);
}

.info-grid div {
  border-right: 1px solid var(--line-dark);
  border-bottom: 1px solid var(--line-dark);
  padding: 7px;
  min-height: 30px;
}

.info-label {
  background: var(--soft);
  color: var(--muted);
}

.phase-block {
  margin-top: var(--plan-phase-gap, 16px);
}
.phase-block:first-child {
  margin-top: 0;
}

.cat-header-row td {
  padding-top: calc(var(--el-TABLE-cell-v, var(--plan-cell-pad-v)) + var(--plan-cat-gap, 0px)) !important;
}

.section-title {
  background: var(--soft-2);
  border: 1px solid var(--line-dark);
  padding: 7px;
  font-weight: bold;
  text-align: center;
  margin-top: var(--el-TABLE-mt, 14px);
  font-size: var(--plan-section-font-size);
  font-family: var(--plan-font-family);
  letter-spacing: 0.03em;
}
.phase-block:first-child .section-title:first-child {
  margin-top: 0;
}

.plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--el-TABLE-fs, var(--plan-table-font-size));
  font-family: var(--plan-font-family);
  line-height: var(--plan-line-height);
}

.plan-table th,
.plan-table td {
  border: 1px solid var(--line-dark);
  padding: var(--el-TABLE-cell-v, var(--plan-cell-pad-v)) var(--el-TABLE-cell-h, var(--plan-cell-pad-h));
  vertical-align: top;
}

.plan-table th {
  background: var(--soft);
  color: var(--muted);
  font-weight: normal;
  font-size: var(--plan-font-size-sm);
}

.plan-table th.c-nr,
.plan-table td.c-nr {
  width: 28px;
  text-align: center;
  color: var(--muted);
}

.plan-table th.c-area,
.plan-table td.c-area {
  width: 70px;
  text-align: center;
}

.plan-table th.c-qty,
.plan-table td.c-qty {
  width: 36px;
  text-align: center;
}

.plan-table th.c-price,
.plan-table td.c-price {
  width: 78px;
  text-align: right;
  white-space: nowrap;
}

.plan-table th.c-sum,
.plan-table td.c-sum {
  width: 78px;
  text-align: right;
  white-space: nowrap;
  font-weight: bold;
}

.plan-table td.price,
.plan-table td.qty,
.plan-table td.sum {
  text-align: right;
  white-space: nowrap;
}

.cat-header-row td {
  background: var(--soft-2);
  font-size: var(--el-TABLE-cat-fs, var(--plan-cat-font-size));
  font-weight: bold;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: var(--el-TABLE-cell-v, var(--plan-cell-pad-v)) var(--el-TABLE-cell-h, var(--plan-cell-pad-h));
  border-top: 1px solid var(--line-dark);
}

.cat-subtotal-row td {
  background: var(--soft);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-dark);
}

.subtotal-label {
  text-align: right;
  font-size: var(--plan-font-size-sm);
  color: var(--muted);
  font-style: italic;
}

.subtotal-val {
  text-align: right;
  font-weight: bold;
  white-space: nowrap;
  font-size: var(--plan-font-size);
}

.plan-row:hover td {
  background: #faf7f2;
}

.tools-col {
  width: 0;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

.tools-cell {
  position: relative;
  overflow: visible;
  width: 0;
  min-width: 0;
  padding: 2px 0 !important;
  border-top: none !important;
  border-bottom: none !important;
  border-right: none !important;
  border-left: 1px dashed var(--line) !important;
  background: transparent !important;
}

.row-tools {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  white-space: nowrap;
}

.tool-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  font-size: 14px;
  background: var(--soft-2);
  border: 1px solid var(--line);
  color: var(--ink);
  line-height: 1;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.tool-btn:hover {
  background: var(--soft);
  border-color: var(--line-dark);
}

.tool-btn--active {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: white !important;
}

.tool-btn--remove {
  background: #fde8e8;
  border-color: #c87070;
  color: var(--danger);
}

.tool-btn--remove:hover {
  background: #f5cece;
  border-color: #9b3c3c;
}

/* Active service row — screen only */
.plan-row--active > td {
  background-color: #fffbef !important;
}

.plan-row--active .tools-cell {
  border-left: 2px solid var(--accent) !important;
}

.tool-btn[data-plan-remove] {
  background: #fde8e8;
  border-color: #c87070;
  color: var(--danger);
}

.plan-total-block {
  margin-top: var(--el-TOTAL-mt, var(--plan-total-spacing));
}

.plan-requisites-block {
  margin-top: var(--el-REQ-mt, 10px);
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-family: var(--plan-font-family);
  font-size: var(--el-REQ-fs, var(--plan-font-size-sm));
  color: var(--muted);
  line-height: 1.5;
}

.plan-requisites-empty {
  font-style: italic;
}

.plan-vat-note {
  font-size: var(--plan-font-size-sm);
  font-family: var(--plan-font-family);
  color: var(--muted);
  font-style: italic;
  margin-bottom: 6px;
}

.total {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  font-family: var(--plan-font-family);
  font-weight: bold;
  border-top: 2px solid var(--line-dark);
  padding-top: 7px;
}

.plan-total-label {
  font-size: var(--plan-font-size);
  letter-spacing: .05em;
  font-weight: normal;
  color: var(--muted);
}

.plan-total-value {
  font-size: var(--plan-total-font-size);
}

/* ── Continuation page header (page 2+) ── */
.plan-cont-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 6px;
  font-family: var(--plan-font-family);
  font-size: var(--plan-font-size-sm);
  color: var(--muted);
}

.plan-cont-brand {
  font-weight: bold;
  font-size: var(--plan-font-size);
  color: var(--ink);
}

.plan-cont-patient {
  font-style: italic;
}

.plan-cont-page {
  font-weight: bold;
  color: var(--ink);
}

.signature-block {
  margin-top: var(--el-SIG-mt, var(--plan-sig-spacing));
}

.plan-sig-consent {
  font-size: var(--plan-font-size-sm);
  font-family: var(--plan-font-family);
  color: var(--muted);
  font-style: italic;
  text-align: center;
  margin-bottom: 28px;
}

.signature {
  margin-top: 0;
  display: grid;
  grid-template-columns: 2fr 1fr 2fr 1fr;
  gap: 20px;
}

.signature div {
  border-top: 1px solid var(--ink);
  padding-top: 8px;
  text-align: center;
  color: var(--muted);
  font-size: var(--plan-font-size-sm);
  font-family: var(--plan-font-family);
}

.phase-manager {
  margin-bottom: 14px;
}

.phase-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.phase-toggle-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.phase-toggle-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 5px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}
.phase-toggle-btn--on {
  background: #e8f5e9;
  border-color: #4caf50;
  color: #2e7d32;
  font-weight: 600;
}
.phase-off-msg {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  padding: 4px 0;
}
.phase-select--off {
  opacity: 0.4;
  cursor: not-allowed;
}

.phase-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 7px;
}

.phase-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.phase-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.phase-name-input {
  flex: 1;
  min-width: 0;
  width: auto;
  font-size: 13px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.phase-add-row {
  display: flex;
  gap: 6px;
}

.phase-add-row input {
  flex: 1;
  min-width: 0;
  width: auto;
  font-size: 13px;
  padding: 4px 7px;
}

.phase-add-row button {
  padding: 4px 12px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.edit-service-name {
  font-size: 13px;
  font-weight: bold;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 5px;
}

.edit-category-badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  display: inline-block;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.edit-panel {
  background: white;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 10px 10px 12px;
  margin-bottom: 14px;
}

.edit-panel label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.edit-panel input,
.edit-panel select,
.edit-panel textarea {
  margin-top: 4px;
}

.edit-actions {
  margin-top: 10px;
}

.apply-btn {
  width: 100%;
  padding: 8px 12px;
  background: var(--dark);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: .02em;
}

.apply-btn:hover {
  background: #333;
}

.edit-move-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  font-style: italic;
  line-height: 1.4;
}

.debug-box {
  background: #111;
  color: #d6f7d6;
  border-radius: 10px;
  padding: 10px;
  font-size: 11px;
  max-height: 180px;
  overflow: auto;
}

.elements-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.element-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  transition: opacity 0.15s;
}

.element-item.element-off {
  opacity: 0.55;
  background: var(--soft);
}

.element-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.el-order-btn {
  font-size: 11px;
  padding: 2px 7px;
  line-height: 1.3;
  border-radius: 3px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

.el-order-btn:hover:not([disabled]) {
  background: var(--dark);
  color: white;
  border-color: var(--dark);
}

.el-order-btn[disabled] {
  opacity: 0.3;
  cursor: default;
}

.element-info {
  flex: 1;
  min-width: 0;
}

.element-info strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
}

.element-desc {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
  white-space: normal;
}

.element-toggle {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--soft);
  border-color: var(--line);
  color: var(--muted);
}

.element-toggle.active {
  background: var(--dark);
  color: white;
  border-color: var(--dark);
}

.plan-header-contact {
  font-size: var(--plan-font-size-sm);
  color: var(--muted);
  margin-top: 3px;
  font-family: var(--plan-font-family);
}

.company-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.company-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.company-field input,
.company-field select {
  padding: 5px 8px;
  font-size: 13px;
}

.company-field--inline {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.company-field--inline input,
.company-field--inline select {
  width: auto;
}

.company-doc-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.company-msg {
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}

.company-msg.ok { color: #2a6a2a; }

/* Logo section */
.company-section-hdr {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 5px;
}

.company-logo-section {
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.company-logo-preview-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.company-logo-preview {
  max-height: 80px;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  object-fit: contain;
}

.company-logo-remove {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid #e57373;
  border-radius: 5px;
  background: #fde8e8;
  color: var(--danger);
  cursor: pointer;
}

.company-logo-empty {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.company-logo-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.company-logo-btn {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.company-logo-btn:hover { background: var(--soft-2); }

.company-logo-or { font-size: 11px; color: var(--muted); flex-shrink: 0; }

.company-logo-url-inp {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.company-logo-msg {
  font-size: 11px;
  min-height: 14px;
  color: var(--muted);
}
.company-logo-msg.warn { color: #9a6500; }
.company-logo-msg.error { color: var(--danger); }

.company-logo-hint { font-size: 10px; color: var(--muted); margin-top: 3px; }

.company-hdr-mode-btns {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.company-hdr-mode-btn {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
}
.company-hdr-mode-btn.active {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
}

/* Plan logo image (in printed header) */
.plan-logo-img {
  max-height: 64px;
  max-width: 160px;
  object-fit: contain;
  display: block;
}

.plan-logo-img--sm {
  max-height: 48px;
  max-width: 100px;
}

.plan-brand-col--both {
  display: flex;
  align-items: center;
  gap: 10px;
}

.doctors-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.doc-add-form {
  background: #fffbe8;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.doc-add-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}

.doc-add-actions {
  display: flex;
  gap: 7px;
  margin-top: 2px;
}

.doc-field--order {
  width: 60px;
}

.doctors-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

/* New doctor card styles */
.doctor-card {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.doctor-card--active {
  border-color: var(--dark);
  background: #f0f4ff;
}

.doctor-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.doctor-card-info { flex: 1; min-width: 0; }

.doctor-card-name {
  font-weight: 600;
  font-size: 13px;
}
.doctor-card-role {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.doctor-card-code {
  font-size: 10px;
  color: var(--muted);
  font-family: monospace;
  margin-top: 1px;
}

.doctor-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.doctor-card-badge {
  font-size: 11px;
  color: #2a6a2a;
  font-weight: 600;
}

.doctor-select-btn {
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--dark);
  color: #fff;
  cursor: pointer;
}
.doctor-select-btn:hover { opacity: 0.85; }

.doctor-plan-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.doctor-active-btn {
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid #b6d0a0;
  border-radius: 4px;
  background: #eaf5e2;
  color: #2a6a2a;
  cursor: pointer;
  white-space: nowrap;
}
.doctor-active-btn:hover { opacity: 0.8; }
.doctor-active-btn.inactive {
  border-color: var(--line);
  background: var(--soft-2, #f0f0f0);
  color: var(--muted);
}

.doctor-card--inactive {
  opacity: 0.7;
}
.doctor-card--inactive .doctor-card-name {
  text-decoration: line-through;
  color: var(--muted);
}

.doctor-fields {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.doc-field-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.doc-field {
  padding: 4px 7px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.doctor-plans-row { margin-bottom: 4px; }

.doctor-plans-btn {
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--soft-2, #f0f0f0);
  color: var(--ink);
  cursor: pointer;
}
.doctor-plans-btn:hover { background: var(--soft); }

.doctor-plans-list {
  margin-top: 6px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.doctor-plans-empty {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
}

.doctor-plan-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}
.doctor-plan-item:last-child { border-bottom: none; }

.doctor-plan-title { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doctor-plan-meta  { color: var(--muted); flex-shrink: 0; }

.doctor-save-row {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.plans-toolbar {
  margin-bottom: 10px;
}

.plans-save-btn {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--dark);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.plans-save-btn:hover { opacity: 0.85; }

.plans-empty {
  text-align: center;
  padding: 16px 0;
  font-size: 12px;
}

.plans-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plan-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.plan-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.plan-card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.plan-status {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ps-saved   { background: #dff0d8; color: #2a6a2a; }
.ps-draft   { background: #fef9e7; color: #7a6a10; }
.ps-tpl     { background: #e8eaf6; color: #3949ab; }

.plan-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--muted);
}

.plan-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.plan-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--soft);
  cursor: pointer;
  color: var(--text);
}

.plan-btn:hover  { background: var(--dark); color: white; border-color: var(--dark); }
/* Primary load action — dark green */
.plan-load       { background: #eaf4ea; color: #2a6a2a; border-color: #b2d8b2; font-weight: 600; }
.plan-load:hover { background: #2a6a2a; color: white; border-color: #2a6a2a; }
/* Services-only load — lighter green */
.plan-svc        { color: #3a7a3a; border-color: #c2dfc2; }
.plan-svc:hover  { background: #3a7a3a; color: white; border-color: #3a7a3a; }
/* Template mark toggle */
.plan-tpl        { color: #3949ab; border-color: #c5cae9; }
.plan-tpl:hover  { background: #3949ab; color: white; border-color: #3949ab; }
/* Delete */
.plan-del        { color: #c0392b; border-color: #f5c6c6; }
.plan-del:hover  { background: #c0392b; color: white; border-color: #c0392b; }

.notes-edit-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.notes-edit-block label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.notes-block {
  margin-top: var(--el-NOTES-mt, 18px);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 14px;
}

.notes-block-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 5px;
}

.notes-block-content {
  font-size: var(--el-NOTES-fs, 12px);
  min-height: 36px;
  white-space: pre-wrap;
}

/* Contenteditable notes block */
.plan-notes-editable {
  outline: none;
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 3px 4px;
  transition: border-color 0.1s;
  white-space: pre-wrap;
  word-break: break-word;
}
.plan-notes-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}
.plan-notes-editable:hover  { border-color: var(--line); }
.plan-notes-editable:focus  { border-color: #4a90d9; background: #f8fbff; }

/* Text style toolbar (right panel) */
.plan-field-context {
  border: 1px solid #c5d8f5;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f0f7ff;
  margin-bottom: 8px;
  font-size: 12px;
}
.pfc-title {
  font-weight: 600;
  color: #3a6ea8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 3px;
}
.pfc-field {
  color: var(--ink);
  font-size: 12px;
}

.plan-text-toolbar {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--soft);
  margin-bottom: 10px;
}

.plan-text-toolbar-hdr {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 6px;
}

.plan-text-toolbar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
}

.tb-btn {
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}
.tb-btn:hover  { background: var(--soft-2); border-color: var(--dark); }
.tb-btn:active { background: var(--dark); color: #fff; }

.tb-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 2px;
  flex-shrink: 0;
}

.tb-select {
  height: 26px;
  font-size: 11px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.changelog-entry {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}

.changelog-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.commit-badge {
  font-family: monospace;
  font-size: 11px;
  background: var(--soft-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.changelog-date {
  font-size: 11px;
  color: var(--muted);
}

.cl-task-id {
  font-size: 11px;
  font-weight: 600;
  background: #e8f0fe;
  color: #1a56db;
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.02em;
}

.cl-version {
  font-size: 11px;
  background: #ecfdf5;
  color: #059669;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: auto;
}

.changelog-title {
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 4px;
  line-height: 1.3;
}

.changelog-summary {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

.changelog-review {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.review-status-btns {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.review-status-btn {
  flex: 1;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--soft);
  border-color: var(--line);
  color: var(--muted);
}

.review-status-btn.active-pending {
  background: #fff8e1;
  border-color: #c49a00;
  color: #7a5f00;
}

.review-status-btn.active-reviewed {
  background: #d8edd8;
  border-color: #5a8a5a;
  color: #2a5a2a;
}

.review-status-btn.active-fix {
  background: #fde8e8;
  border-color: #c87070;
  color: var(--danger);
}

.review-comment {
  width: 100%;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
  resize: vertical;
  margin-bottom: 6px;
  box-sizing: border-box;
  font-family: inherit;
}

.review-submit-btn {
  width: 100%;
  font-size: 12px;
  padding: 6px;
  border-radius: 6px;
}

.review-msg {
  font-size: 12px;
  margin-top: 5px;
  min-height: 16px;
  text-align: center;
}

.review-msg.ok    { color: #2a6a2a; }
.review-msg.error { color: var(--danger); }

.changelog-entry.entry-submitted {
  border-color: #5a8a5a;
}

.changelog-entry.entry-needs-fix {
  border-color: #c87070;
  background: #fff8f8;
}

.review-workflow-note {
  margin-top: 14px;
  padding: 9px 11px;
  background: #f0f4ff;
  border: 1px solid #c5cae9;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.6;
  color: #3949ab;
}

.review-workflow-note code {
  background: #e8eaf6;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
}

/* ── Test Checklist ── */
.test-checklist {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-bottom: 8px;
}

.test-checklist-empty {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  padding: 4px 0 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.test-checklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.test-checklist-title {
  font-size: 11px;
  font-weight: bold;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.test-checklist-count {
  font-size: 11px;
  font-weight: bold;
  color: var(--muted);
  background: var(--soft);
  border-radius: 999px;
  padding: 1px 9px;
}

.test-checklist-count.all-checked {
  background: #d8edd8;
  color: #2a5a2a;
}

.test-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--ink);
  padding: 4px 0;
  cursor: pointer;
  line-height: 1.4;
  user-select: none;
}

.test-checklist-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  accent-color: var(--accent);
}

.test-checklist-item.item-checked span {
  text-decoration: line-through;
  color: var(--muted);
}

/* Fullscreen tool mode — left panel expands, workspace/right hidden */
.app-shell.fullscreen-tool {
  grid-template-columns: 1fr;
}
.app-shell.fullscreen-tool .workspace,
.app-shell.fullscreen-tool .right-panel {
  display: none;
}
.app-shell.fullscreen-tool .left-panel {
  height: calc(100vh - 140px);
  max-width: 860px;
}

/* UI density: compact */
.density-compact .panel    { padding: 8px; }
.density-compact .panel h2 { margin-bottom: 8px; }
.density-compact .service-card { padding: 5px 7px; }
.density-compact .phase-item   { padding: 4px 6px; }

/* Settings form */
.settings-section-hdr {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
  margin: 18px 0 12px;
}

.settings-section-hdr:first-child { margin-top: 0; }

.settings-section-hdr--dev {
  color: #5a3aaa;
  border-color: #c4b0ee;
  background: #f5f0ff;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid #c4b0ee;
}

.settings-subsection-hdr {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 14px 0 8px;
  opacity: 0.75;
}

.settings-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}

.settings-dev-reset-row {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.settings-group {
  margin-bottom: 20px;
}
.settings-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.settings-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.settings-opt {
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--fg);
  cursor: pointer;
}
.settings-opt.active {
  background: #e8f0fe;
  border-color: #1a56db;
  color: #1a56db;
  font-weight: 600;
}
.settings-patient-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--soft);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.settings-field-chk {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.settings-field-chk input[type="checkbox"] {
  cursor: pointer;
  accent-color: #1a56db;
}

/* Price list toolbar and import UI */
.price-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.price-source-badge {
  font-size: 11px;
  background: var(--soft-2, #f0f0f0);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
  margin-right: auto;
}

.price-tool-btn {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--soft);
  border: 1px solid var(--line);
  cursor: pointer;
}

.price-tool-btn.secondary {
  background: transparent;
  color: var(--muted);
}

.price-import-panel {
  background: #f8f9ff;
  border: 1px solid #c8d4f8;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.price-import-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
}

.price-import-hint code {
  font-family: monospace;
  background: var(--soft-2, #eee);
  padding: 1px 4px;
  border-radius: 3px;
}

.price-import-ta {
  width: 100%;
  font-size: 11px;
  font-family: monospace;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  resize: vertical;
  margin-bottom: 7px;
  box-sizing: border-box;
}

.price-import-actions {
  display: flex;
  gap: 7px;
  margin-bottom: 6px;
}

.price-import-msg {
  font-size: 12px;
  min-height: 16px;
}

.price-import-msg.ok    { color: #2a6a2a; }
.price-import-msg.error { color: var(--danger); }

.import-diff-panel {
  margin-bottom: 8px;
}

.import-diff-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
}

.import-diff-list {
  font-size: 12px;
  margin: 0 0 8px 0;
  padding: 0 0 0 16px;
  list-style: disc;
  color: var(--muted);
}

.import-diff-list li { margin-bottom: 3px; }
.diff-added   { color: #2a6a2a; }
.diff-removed { color: var(--danger); }
.diff-changed { color: #8a6000; }
.diff-locked  { color: #5a5aaa; }

/* Active/inactive filter chips */
.price-filter-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.price-filter-chip {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--soft-2, #f0f0f0);
  color: var(--muted);
  cursor: pointer;
}

.price-filter-chip.selected {
  background: var(--accent, #1a73e8);
  color: #fff;
  border-color: var(--accent, #1a73e8);
}

/* Service row with toggle */
.svc-pl-line {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  font-size: 12px;
}

.svc-pl-row-inactive { opacity: 0.6; }

.pl-toggle-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}

.pl-toggle {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--dark);
  flex-shrink: 0;
}

.pl-svc-id {
  font-size: 10px;
  color: var(--muted);
  font-family: monospace;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-svc-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pl-svc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-row-ts {
  font-size: 9px;
  color: var(--muted);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svc-pl-inactive {
  color: var(--muted);
  text-decoration: line-through;
  opacity: 0.7;
}

.pl-price-cell {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.pl-price-input {
  width: 68px;
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  color: var(--ink);
  text-align: right;
}

.pl-price-input:focus { outline: none; border-color: var(--dark); background: #fff; }

.pl-price-input.pl-price-pending {
  border-color: #e0a820;
  background: #fffbe8;
}

.pl-price-confirm, .pl-price-cancel {
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid;
  line-height: 1.4;
}

.pl-price-confirm { background: #e8f5e9; border-color: #81c784; color: #2a6a2a; }
.pl-price-confirm:hover { background: #c8e6c9; }
.pl-price-cancel  { background: #fde8e8; border-color: #e57373; color: var(--danger); }
.pl-price-cancel:hover  { background: #ffcdd2; }

/* Stats bar */
.pl-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 6px 0 4px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.pl-stat-item strong { color: var(--ink); }
.pl-stat-active strong { color: #2a6a2a; }
.pl-stat-inactive strong { color: var(--danger); }
.pl-stat-ts { font-variant-numeric: tabular-nums; }
.pl-stat-source strong { color: #5a5aaa; }

/* Service ID in search cards */
.scard-id { font-family: monospace; font-size: 10px; opacity: 0.7; }

.price-category-group {
  margin-bottom: 6px;
}

.price-category-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 3px 0 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1px;
}

/* Duplicate service panel */
.pl-dup-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 7px 10px;
  background: #fffbe8;
  border: 1px solid #ffe082;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}

.pl-dup-label { flex: 1; min-width: 0; }

.pl-dup-cat-select {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  max-width: 200px;
}

/* Duplicate button in table */
.pl-td-dup  { padding: 3px 4px; text-align: center; width: 28px; }
.pl-th-dup  { width: 28px; }

.pl-dup-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 1px 3px;
  opacity: 0.35;
  line-height: 1;
  border-radius: 3px;
  color: var(--ink);
}

.pl-dup-btn:hover { opacity: 1; background: var(--soft); }

/* Admin toolbar separator */
.price-admin-sep {
  flex: 1;
}

/* Import result report bar */
.pl-import-report {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f0f4ff;
  border: 1px solid #c8d4f8;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 11px;
}

.imp-rpt-item {
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  border: 1px solid;
}

.imp-rpt-updated { background: #e8f5e9; border-color: #81c784; color: #2a6a2a; }
.imp-rpt-added   { background: #e3f2fd; border-color: #64b5f6; color: #1565c0; }
.imp-rpt-locked  { background: #ede7f6; border-color: #9575cd; color: #4527a0; }
.imp-rpt-miss    { background: #fff3e0; border-color: #ffb74d; color: #e65100; }
.imp-rpt-warn    { background: #fff8e1; border-color: #ffd54f; color: #b8860b; }

.pl-rpt-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  padding: 0 2px;
}

/* Lock button */
.pl-td-lock { padding: 3px 4px; text-align: center; width: 30px; }
.pl-th-lock { width: 30px; }

.pl-lock-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 1px 3px;
  opacity: 0.4;
  line-height: 1;
  border-radius: 3px;
}

.pl-lock-btn:hover { opacity: 1; background: var(--soft); }
.pl-lock-btn--on   { opacity: 1; }

.pl-svc-row-locked .pl-td-name .pl-svc-name { color: #5a5aaa; }
.pl-svc-row-locked .pl-price-input { background: #f0eeff; border-color: #c0b0ee; color: #5a5aaa; }

/* Full-width price list table */
.pl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.pl-thead tr {
  background: var(--soft-2, #f0f0f0);
  border-bottom: 2px solid var(--line);
}

.pl-thead th {
  padding: 4px 6px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.pl-th-nr     { width: 32px; text-align: right; }
.pl-th-id     { width: 100px; }
.pl-th-toggle { width: 26px; }
.pl-th-name   { }
.pl-th-price  { width: 100px; text-align: right; }
.pl-th-ts     { width: 130px; }

.pl-cat-row .pl-cat-td {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: var(--soft-2, #f5f5f5);
  padding: 5px 6px 3px;
  border-top: 1px solid var(--line);
}

.pl-svc-row {
  border-bottom: 1px solid var(--line);
}

.pl-svc-row:hover {
  background: var(--soft, #f9f9f9);
}

.pl-td-nr {
  padding: 3px 6px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
  white-space: nowrap;
}

.pl-td-id {
  padding: 3px 6px;
  font-family: monospace;
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-td-toggle {
  padding: 3px 4px;
  text-align: center;
}

.pl-td-name {
  padding: 3px 6px;
  overflow: hidden;
}

.pl-td-name .pl-svc-name {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
}

.pl-td-price {
  padding: 3px 6px;
  text-align: right;
}

.pl-td-ts {
  padding: 3px 6px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-lite {
  font-size: 13px;
}

.table-lite .line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}

/* ── Print page size and margins ── */
@page {
  size: A4;
  margin: 0;
}

@media print {
  #a4ZoomWrap { zoom: 1 !important; }
  #previewZoomBar { display: none !important; }
}

@media print {
  /* Force color and background preservation */
  html, body, * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: white;
  }

  /* Hide all UI chrome */
  .topbar,
  .version-bar,
  .tabs,
  .panel,
  .patient-editor,
  .page-break-label,
  .ghost-page,
  .plan-print-bar,
  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .workspace {
    overflow: visible;
    padding: 0;
    max-height: none !important;
  }

  /* A4 page: let @page margins handle whitespace; keep internal padding */
  .a4-page {
    box-shadow: none;
    border: none;
    margin: 0;
    width: 100%;
    min-height: auto;
  }

  /* Preserve plan element backgrounds and borders explicitly */
  .plan-header          { background: white; }
  .pi-label             { background-color: var(--soft) !important; }
  .section-title        { background-color: var(--soft-2) !important; }
  .cat-header-row td    { background-color: var(--soft-2) !important; }
  .cat-subtotal-row td  { background-color: var(--soft) !important; }
  .plan-total-block     { background: white; }
  .plan-doc-label       { border-color: var(--line-dark) !important; }

  /* Logo image: preserve dimensions in print */
  .plan-logo-img {
    max-height: 64px;
    max-width: 160px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
  }
  .plan-logo-img--sm {
    max-height: 48px;
    max-width: 100px;
  }

  /* Hide all row edit controls */
  .row-tools,
  .tools-col,
  .tools-cell {
    display: none !important;
  }

  /* Inline editing inputs print as plain text */
  .plan-inline-input,
  .plan-inline-select,
  .plan-notes-textarea {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
    resize: none !important;
    padding: 0 !important;
  }

  /* Contenteditable notes block — print with styling but no edit UI */
  .plan-notes-editable {
    border: none !important;
    background: transparent !important;
    outline: none !important;
    padding: 0 !important;
  }
  .plan-notes-editable:empty::before { content: none; }

  /* ── Auto-generated page labels are screen-only ── */
  .plan-auto-label,
  .plan-auto-break {
    display: none !important;
  }

  /* ── Each auto continuation page starts on a new printed sheet ── */
  [data-auto-page] {
    break-before: page;
    page-break-before: always;
  }

  /* ── Page break hooks ── */
  .page-break,
  .plan-page-break {
    break-after: page;
    page-break-after: always;
    border: none;
    height: 0;
  }

  /* Utility class for future pagination use */
  .plan-avoid-break {
    break-inside: avoid;
  }

  /* ── Prevent awkward mid-element breaks ── */
  .plan-header        { break-inside: avoid; break-after: avoid; }
  .plan-header-rule   { break-before: avoid; }
  .plan-patient-table { break-inside: avoid; }
  .section-title      { break-after: avoid; }
  .cat-header-row     { break-after: avoid; }
  .cat-subtotal-row   { break-before: avoid; }
  .plan-table tr      { break-inside: avoid; }
  .plan-total-block   { break-inside: avoid; }
  .plan-vat-note      { break-after: avoid; }
  .signature-block    { break-inside: avoid; break-before: avoid; }
  .plan-cont-header   { break-inside: avoid; break-after: avoid; }

  /* Active row highlight must not print */
  .plan-row--active > td {
    background-color: transparent !important;
  }
  .plan-row--active .tools-cell {
    border-left: none !important;
  }
}

@media (max-width: 1250px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    height: auto;
  }

  .workspace {
    max-height: none;
  }

  .patient-editor,
  .a4-page,
  .page-break,
  .page-break-label {
    width: min(794px, 100%);
  }
}

/* ── Sticky search bar ─────────────────────────────────────────── */
.svc-search-bar {
  margin-bottom: 2px;
}
.svc-search-bar #serviceSearch {
  flex: 1;
  min-width: 0;
}
.svc-search-input-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.svc-picker-btn {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 8px;
  line-height: 1;
  flex-shrink: 0;
}
.svc-picker-btn--open { color: var(--accent); }
.svc-picker-btn:hover { color: var(--ink); }
.svc-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 100;
  background: white;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.15);
  max-height: 280px;
  overflow-y: auto;
}
.svc-suggestion {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.svc-suggestion:last-child { border-bottom: none; }
.svc-suggestion:hover { background: #eef2ff; }
.sug-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-meta { font-size: 10px; color: var(--muted); white-space: nowrap; }
.sug-price { font-size: 11px; color: #2a6a2a; white-space: nowrap; font-weight: 600; margin-left: auto; }

.sticky-search-on .svc-search-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  padding-bottom: 6px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}

/* ── Expanded categories (vertical list mode) ──────────────────── */
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 6px 0;
}

.cat-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  cursor: pointer;
  font-size: 12px;
  color: var(--ink);
  user-select: none;
}

.cat-list-row:hover:not(.active) { background: var(--soft-2); }

.cat-list-row.active {
  background: var(--dark);
  color: white;
  border-color: var(--dark);
}

.cat-list-count {
  font-size: 10px;
  background: rgba(0,0,0,0.10);
  border-radius: 999px;
  padding: 0 6px;
  line-height: 1.8;
  flex-shrink: 0;
}
.cat-list-row.active .cat-list-count { background: rgba(255,255,255,0.22); }

/* ── Included services section ─────────────────────────────────── */
.included-section {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 2px solid var(--line);
}

.included-section-hdr {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.included-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0f9f0;
  border: 1px solid #b2d8b2;
  border-radius: 7px;
  padding: 6px 8px;
  margin-bottom: 5px;
}

.included-card-info {
  flex: 1;
  min-width: 0;
}

.included-card-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.included-card-meta {
  font-size: 10px;
  color: #3a7a3a;
  margin-top: 1px;
}

.included-card-edit {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.included-card-edit:hover { background: var(--dark); color: white; border-color: var(--dark); }

.included-card-remove {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #fde8e8;
  border: 1px solid #c87070;
  color: var(--danger);
  cursor: pointer;
  flex-shrink: 0;
}
.included-card-remove:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* Included card — inline edit mode */
.included-card--edit {
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 7px 9px;
}
.inc-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.inc-name {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inc-edit-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.inc-lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.inc-input {
  font-size: 12px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--ink);
}
.inc-qty   { width: 54px; }
.inc-area  { width: 72px; }
.inc-price { width: 64px; }
.inc-price-ro {
  font-size: 12px;
  color: var(--muted);
  align-self: flex-end;
  padding-bottom: 3px;
}
.inc-phase {
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  width: 100%;
}

/* ── Dev / Design Mode outlines ── */
body.dev-mode .plan-header        { outline: 2px dashed #6060d0; outline-offset: 2px; }
body.dev-mode .plan-patient-table { outline: 2px dashed #2a8a2a; outline-offset: 2px; }
body.dev-mode .section-title      { outline: 2px dashed #d06060; outline-offset: 0; }
body.dev-mode .plan-total-block   { outline: 2px dashed #d09020; outline-offset: 2px; }
body.dev-mode .signature-block    { outline: 2px dashed #2090c0; outline-offset: 2px; }

@media print {
  body.dev-mode .plan-header,
  body.dev-mode .plan-patient-table,
  body.dev-mode .section-title,
  body.dev-mode .plan-total-block,
  body.dev-mode .signature-block   { outline: none; }
}

/* ── Design controls panel ── */
.design-panel {
  margin-top: 10px;
  background: #f0ecff;
  border: 1px solid #c0b4e8;
  border-radius: 10px;
  padding: 10px 12px 12px;
}
.design-section-hdr {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #6040b0;
  padding: 6px 0 4px;
  border-bottom: 1px solid #c0b4e8;
  margin-bottom: 6px;
}
.design-section-hdr:not(:first-child) { margin-top: 10px; }
.design-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.design-lbl {
  font-size: 11px;
  color: #3a2a70;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.design-val {
  font-family: monospace;
  font-weight: 700;
  color: #6040b0;
  min-width: 22px;
  display: inline-block;
  text-align: right;
}
.design-slider {
  width: 100%;
  margin: 0;
  padding: 0;
  height: 18px;
  accent-color: #6040b0;
  grid-column: 1 / -1;
}
.design-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}
.design-reset-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: white;
  border: 1px solid #c0b4e8;
  border-radius: 6px;
  color: #6040b0;
  cursor: pointer;
}
.design-reset-btn:hover { background: #6040b0; color: white; }
.design-preset-row {
  display: flex;
  gap: 5px;
  margin-bottom: 4px;
}
.design-preset-select {
  flex: 1;
  font-size: 11px;
  padding: 3px 5px;
  border: 1px solid #c0b4e8;
  border-radius: 5px;
  background: white;
  color: #3a2a70;
}
.design-preset-apply {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #c0b4e8;
  background: white;
  color: #6040b0;
  cursor: pointer;
  white-space: nowrap;
}
.design-preset-apply:hover { background: #6040b0; color: white; }
.design-export-row {
  display: flex;
  gap: 5px;
  margin-bottom: 4px;
}
.design-preset-name-input {
  flex: 1;
  font-size: 11px;
  padding: 3px 5px;
  border: 1px solid #c0b4e8;
  border-radius: 5px;
  background: white;
  color: #3a2a70;
  min-width: 0;
}
.design-export-btn {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #c0b4e8;
  background: white;
  color: #6040b0;
  cursor: pointer;
  white-space: nowrap;
}
.design-export-btn:hover { background: #6040b0; color: white; }
.design-import-ta {
  width: 100%;
  font-size: 10px;
  font-family: monospace;
  padding: 4px 6px;
  border: 1px solid #c0b4e8;
  border-radius: 5px;
  background: white;
  color: #3a2a70;
  resize: vertical;
  margin-bottom: 4px;
}
.design-import-btn {
  width: 100%;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid #c0b4e8;
  background: white;
  color: #6040b0;
  cursor: pointer;
}
.design-import-btn:hover { background: #6040b0; color: white; }
.design-msg {
  font-size: 10px;
  min-height: 14px;
  margin-bottom: 4px;
  color: #3a2a70;
}
.design-msg.ok    { color: #2a6a2a; }
.design-msg.error { color: var(--danger); }

/* ── Dev Mode: selected plan section highlight ── */
body.dev-mode [data-plan-section] {
  cursor: pointer;
  transition: outline 0.08s;
}
body.dev-mode [data-plan-section]:hover {
  outline: 1px dashed #9070d0;
  outline-offset: 1px;
}
body.dev-mode [data-plan-section].dev-selected {
  outline: 2px solid #6040b0 !important;
  outline-offset: 2px;
}
@media print {
  body.dev-mode [data-plan-section],
  body.dev-mode [data-plan-section]:hover,
  body.dev-mode [data-plan-section].dev-selected { outline: none; cursor: auto; }
}

/* ── Plan section contextual design panel ── */
.plan-section-design-panel {
  margin-bottom: 10px;
}
.psdp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #6040b0;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px 8px 0 0;
  letter-spacing: .04em;
}
.psdp-close {
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.7;
}
.psdp-close:hover { opacity: 1; }
.psdp-body {
  background: #f0ecff;
  border: 1px solid #c0b4e8;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 8px 10px 10px;
}
.psdp-vis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #c0b4e8;
}
.psdp-vis-label { font-size: 11px; color: #3a2a70; font-weight: 600; }
.psdp-vis-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid #c0b4e8;
  background: white;
  color: #6040b0;
}
.psdp-vis-btn:hover { background: #6040b0; color: white; }
.psdp-vis-btn.hidden-state { background: #fde8e8; border-color: #c87070; color: var(--danger); }
.psdp-reset {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #c0b4e8;
  background: white;
  color: #6040b0;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
}
.psdp-reset:hover { background: #6040b0; color: white; }


/* ============================================================
   DEV TERMINAL INTEGRATION
   ============================================================ */

.dev-terminal-tab[hidden],
.terminal-view[hidden] {
  display: none !important;
}

.terminal-view {
  width: 100%;
  min-height: calc(100vh - 170px);
  padding: 14px;
}

.terminal-shell {
  background: #f7f2e8;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 12px;
  min-height: calc(100vh - 210px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terminal-shell.terminal-fullscreen {
  position: fixed;
  z-index: 9999;
  inset: 0;
  border-radius: 0;
  min-height: 100vh;
  background: #f7f2e8;
}

.terminal-panel-header {
  background: #111;
  color: #f7f2e8;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.terminal-panel-header h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.terminal-panel-header p {
  margin: 4px 0 0;
  color: rgba(255,255,255,.65);
  font-size: 12px;
}

.terminal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.terminal-actions button,
.terminal-run-row button,
.terminal-presets button {
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 8px;
  background: #fffaf0;
  color: #111;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
}

.terminal-actions button {
  background: #222;
  color: #f7f2e8;
  border-color: rgba(255,255,255,.25);
}

.terminal-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  flex: 1;
  min-height: 0;
}

.terminal-presets {
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 10px;
  background: rgba(255,255,255,.45);
  padding: 12px;
  overflow: auto;
}

.terminal-presets h3 {
  margin: 10px 0 8px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #615846;
}

.terminal-presets button {
  width: 100%;
  text-align: left;
  margin: 4px 0;
}

.terminal-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #615846;
  background: rgba(0,0,0,.05);
  border-radius: 8px;
  padding: 8px;
}

.terminal-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.terminal-label {
  display: block;
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #615846;
}

.terminal-command {
  min-height: 150px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 10px;
  padding: 10px;
  background: #111;
  color: #f7f2e8;
}

.terminal-password {
  width: 100%;
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 8px;
  padding: 9px 10px;
}

.terminal-run-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 140px 100px;
  gap: 8px;
  align-items: end;
  margin: 10px 0;
}

.terminal-run-btn {
  background: #111 !important;
  color: #fffaf0 !important;
}

.terminal-output {
  flex: 1;
  min-height: 280px;
  max-height: calc(100vh - 430px);
  overflow: auto;
  background: #070707;
  color: #f7f2e8;
  border: 1px solid rgba(0,0,0,.3);
  border-radius: 10px;
  padding: 12px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.terminal-fullscreen .terminal-output {
  max-height: none;
}

.terminal-msg-ok {
  color: #89d185;
}

.terminal-msg-warn {
  color: #e8bf65;
}

.terminal-msg-err {
  color: #ff8c8c;
}

@media (max-width: 900px) {
  .terminal-grid {
    grid-template-columns: 1fr;
  }

  .terminal-run-row {
    grid-template-columns: 1fr;
  }

  .terminal-actions {
    flex-wrap: wrap;
  }
}

@media print {
  .terminal-view,
  .dev-terminal-tab {
    display: none !important;
  }
}


/* ============================================================
   DEV TERMINAL RIGHT DRAWER FIX
   Terminal must NOT participate in main page grid/layout.
   ============================================================ */

#terminalView,
.terminal-view {
  position: fixed !important;
  top: 118px !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  width: min(520px, 96vw) !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: 9997 !important;
  background: transparent !important;
  display: block !important;
  overflow: hidden !important;
  pointer-events: auto !important;
}

#terminalView[hidden],
.terminal-view[hidden] {
  display: none !important;
}

#terminalView .terminal-shell,
.terminal-view .terminal-shell {
  height: 100% !important;
  min-height: 0 !important;
  border-radius: 12px 0 0 12px !important;
  border-right: 0 !important;
  box-shadow: -12px 0 40px rgba(0,0,0,.22) !important;
  background: #f7f2e8 !important;
  overflow: hidden !important;
}

#terminalView .terminal-grid,
.terminal-view .terminal-grid {
  display: grid !important;
  grid-template-columns: 150px minmax(0, 1fr) !important;
  gap: 8px !important;
  height: calc(100% - 62px) !important;
  min-height: 0 !important;
  padding: 8px !important;
}

#terminalView .terminal-presets,
.terminal-view .terminal-presets {
  min-width: 0 !important;
  max-width: 150px !important;
  height: 100% !important;
  overflow: auto !important;
  padding: 8px !important;
}

#terminalView .terminal-main,
.terminal-view .terminal-main {
  min-width: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
}

#terminalView .terminal-command,
.terminal-view .terminal-command {
  min-height: 96px !important;
  height: 120px !important;
  width: 100% !important;
  resize: vertical !important;
  writing-mode: horizontal-tb !important;
  white-space: pre-wrap !important;
  overflow: auto !important;
}

#terminalView textarea,
#terminalView input,
#terminalView button,
.terminal-view textarea,
.terminal-view input,
.terminal-view button {
  writing-mode: horizontal-tb !important;
  transform: none !important;
  min-width: 0 !important;
}

#terminalView .terminal-run-row,
.terminal-view .terminal-run-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 86px 70px !important;
  gap: 6px !important;
  margin: 8px 0 !important;
}

#terminalView .terminal-output,
.terminal-view .terminal-output {
  min-height: 160px !important;
  max-height: none !important;
  height: calc(100% - 255px) !important;
  width: 100% !important;
  overflow: auto !important;
  writing-mode: horizontal-tb !important;
  white-space: pre-wrap !important;
}

#terminalView .terminal-panel-header,
.terminal-view .terminal-panel-header {
  min-height: 62px !important;
  padding: 8px 10px !important;
}

#terminalView .terminal-panel-header h2,
.terminal-view .terminal-panel-header h2 {
  font-size: 12px !important;
}

#terminalView .terminal-panel-header p,
.terminal-view .terminal-panel-header p {
  display: none !important;
}

#terminalView .terminal-actions,
.terminal-view .terminal-actions {
  gap: 6px !important;
}

#terminalView .terminal-actions button,
.terminal-view .terminal-actions button {
  padding: 7px 8px !important;
  font-size: 12px !important;
  width: auto !important;
}

#terminalView .terminal-fullscreen,
.terminal-view .terminal-fullscreen,
.terminal-shell.terminal-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
}

body.terminal-drawer-open {
  overflow-x: hidden !important;
}

body.terminal-drawer-open::after {
  content: "";
  position: fixed;
  inset: 118px 0 0 0;
  background: rgba(0,0,0,.08);
  pointer-events: none;
  z-index: 9996;
}

@media (max-width: 900px) {
  #terminalView,
  .terminal-view {
    top: 96px !important;
    width: min(430px, 98vw) !important;
  }

  #terminalView .terminal-grid,
  .terminal-view .terminal-grid {
    grid-template-columns: 1fr !important;
  }

  #terminalView .terminal-presets,
  .terminal-view .terminal-presets {
    max-width: none !important;
    height: 140px !important;
  }

  #terminalView .terminal-output,
  .terminal-view .terminal-output {
    height: calc(100% - 400px) !important;
  }
}

/* ============================================================
   DEV TERMINAL TOOLBAR PLACEMENT
   ============================================================ */

.terminal-command-toolbar,
.terminal-output-toolbar {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin: 8px 0 10px !important;
}

.terminal-command-toolbar {
  justify-content: flex-start !important;
  padding-bottom: 8px !important;
  border-bottom: 1px solid rgba(0,0,0,.08) !important;
}

.terminal-output-toolbar {
  justify-content: flex-end !important;
  padding-top: 4px !important;
}

.terminal-command-toolbar button,
.terminal-output-toolbar button {
  width: auto !important;
  min-width: 0 !important;
  white-space: nowrap !important;
  padding: 8px 10px !important;
  font-size: 12px !important;
  border-radius: 8px !important;
}

#terminalRunBtn {
  background: #111 !important;
  color: #fffaf0 !important;
  border-color: #111 !important;
}

#terminalClearCommandBtn,
#terminalCopyOutputBtn,
#terminalClearBtn {
  background: #fffaf0 !important;
  color: #111 !important;
  border: 1px solid rgba(0,0,0,.18) !important;
}

#terminalAutoClearLabel {
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  margin: 0 !important;
  font-size: 12px !important;
  color: #615846 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  white-space: nowrap !important;
}

#terminalAutoClearLabel input {
  width: auto !important;
  margin: 0 !important;
}

#terminalView .terminal-run-row,
.terminal-view .terminal-run-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 8px !important;
  margin: 8px 0 !important;
}

#terminalView .terminal-run-row > button,
.terminal-view .terminal-run-row > button {
  width: auto !important;
}

#terminalView .terminal-output,
.terminal-view .terminal-output {
  margin-top: 0 !important;
}

@media (max-width: 900px) {
  .terminal-command-toolbar,
  .terminal-output-toolbar {
    align-items: stretch !important;
  }

  .terminal-command-toolbar button,
  .terminal-output-toolbar button {
    flex: 1 1 auto !important;
  }

  #terminalAutoClearLabel {
    width: 100% !important;
  }
}

/* ── Audit Log ── */
.audit-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.audit-count {
  font-size: 0.82em;
  color: #888;
  flex: 1;
}
.audit-clear-btn {
  font-size: 0.8em;
  padding: 3px 10px;
  border: 1px solid #c00;
  background: #fff0f0;
  color: #c00;
  border-radius: 4px;
  cursor: pointer;
}
.audit-clear-btn:hover { background: #fdd; }
.audit-list {
  width: 100%;
  font-size: 0.78em;
}
.audit-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 4px;
  border-bottom: 1px solid #eee;
  flex-wrap: wrap;
}
.audit-row:hover { background: #f8f8ff; }
.audit-ts    { color: #888; white-space: nowrap; font-family: monospace; font-size: 0.95em; }
.audit-type  { font-weight: 600; color: #3355aa; white-space: nowrap; }
.audit-role  { color: #666; white-space: nowrap; }
.audit-target { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-details { color: #555; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-empty {
  padding: 24px;
  text-align: center;
  color: #aaa;
  font-size: 0.9em;
}


/* TASK-068 — plan action toolbar */
.plan-action-toolbar {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  margin: 8px auto 12px;
  padding: 8px 10px;
  max-width: min(760px, 100%);
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 18px;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 10px 30px rgba(15,23,42,0.06);
  backdrop-filter: blur(10px);
}

.plan-action-toolbar:empty {
  display: none;
}

.plan-action-btn {
  position: relative;
  min-width: 74px;
  min-height: 56px;
  padding: 8px 9px 7px;
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, opacity .12s ease;
}

.plan-action-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(37,99,235,.28);
  box-shadow: 0 10px 24px rgba(37,99,235,.11);
}

.plan-action-btn:disabled {
  opacity: .38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.plan-action-icon {
  font-size: var(--plan-action-icon-size, 21px);
  line-height: 1;
}

.plan-action-label {
  font-size: var(--plan-action-label-size, 10px);
  line-height: 1.1;
  opacity: .64;
  white-space: nowrap;
}

.plan-action-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%) translateY(4px);
  min-width: 150px;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15,23,42,.96);
  color: white;
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 50;
  box-shadow: 0 16px 36px rgba(15,23,42,.24);
}

.plan-action-btn:hover .plan-action-tooltip,
.plan-action-btn:focus-visible .plan-action-tooltip,
.plan-action-btn:active .plan-action-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.plan-action-btn--minimal {
  background: transparent;
  box-shadow: none;
}

.plan-action-btn--solid {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
}

.plan-action-btn--soft {
  background: #eef4ff;
  border-color: rgba(37,99,235,.18);
  color: #1e3a8a;
}

.plan-action-toolbar[data-preset="compact"] {
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
}

.plan-action-toolbar[data-preset="compact"] .plan-action-btn {
  min-width: 48px;
  min-height: 42px;
  padding: 6px;
  border-radius: 12px;
}

.plan-action-toolbar[data-preset="compact"] .plan-action-label {
  display: none;
}

.plan-action-toolbar[data-preset="large"] .plan-action-btn {
  min-width: 92px;
  min-height: 66px;
}

.plan-action-toolbar[data-preset="large"] .plan-action-icon {
  font-size: calc(var(--plan-action-icon-size, 21px) + 4px);
}

.plan-action-toolbar[data-preset="icon-only"] .plan-action-btn {
  min-width: 48px;
  min-height: 44px;
}

.plan-action-toolbar[data-preset="icon-only"] .plan-action-label {
  display: none;
}

.plan-action-toolbar[data-style="minimal"] .plan-action-btn {
  background: transparent;
  box-shadow: none;
}

.plan-action-toolbar[data-style="solid"] .plan-action-btn {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
}

.plan-action-toolbar[data-style="soft"] .plan-action-btn {
  background: #eef4ff;
  border-color: rgba(37,99,235,.18);
  color: #1e3a8a;
}

.plan-action-toolbar-designer {
  margin-top: 10px;
}

.plan-action-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px dashed rgba(15,23,42,.16);
  border-radius: 14px;
  background: rgba(248,250,252,.8);
}

.plan-action-icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.plan-action-icon-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.plan-action-icon-grid input {
  width: 100%;
}

@media (max-width: 900px) {
  .plan-action-toolbar {
    gap: 6px;
    padding: 6px;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .plan-action-btn {
    min-width: 58px;
    min-height: 48px;
    flex: 0 0 auto;
  }
  .plan-action-label {
    font-size: 9px;
  }
}


/* TASK-069A — safe top navigation plan toolbar */
.plan-action-toolbar--top-nav {
  margin: 0 auto !important;
  padding: 0 !important;
  max-width: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  flex: 0 0 auto !important;
}

.plan-action-toolbar--top-nav .plan-action-btn {
  min-width: 42px;
  min-height: 34px;
  padding: 4px 7px;
  border-radius: 10px;
}

.plan-action-toolbar--top-nav .plan-action-icon {
  font-size: 16px;
}

.plan-action-toolbar--top-nav .plan-action-label {
  display: none;
}

.plan-action-toolbar--top-nav .plan-action-tooltip {
  bottom: auto;
  top: calc(100% + 8px);
}

@media (max-width: 900px) {
  .plan-action-toolbar--top-nav {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start !important;
    order: 99;
    padding-top: 6px !important;
  }
}


/* TASK-070A — safe service picker and selected count */
.safe-selected-services-count {
  margin: 8px 0 0;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(37,99,235,.08);
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.safe-service-picker-btn {
  margin-left: 6px;
  min-width: 34px;
  height: 34px;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 10px;
  background: white;
  cursor: pointer;
}

.safe-service-picker-dropdown {
  display: none;
  position: sticky;
  top: 10px;
  z-index: 40;
  margin-top: 10px;
  max-height: min(68vh, 720px);
  overflow: auto;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 16px;
  background: white;
  box-shadow: 0 18px 50px rgba(15,23,42,.14);
}

.safe-service-picker-open .safe-service-picker-dropdown {
  display: block;
}

.safe-picker-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid rgba(15,23,42,.08);
}

.safe-picker-head button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: #f1f5f9;
  cursor: pointer;
  font-size: 20px;
}

.safe-picker-body {
  padding: 10px;
  display: grid;
  gap: 10px;
}

.safe-picker-group {
  border: 1px solid rgba(15,23,42,.09);
  border-radius: 14px;
  overflow: hidden;
}

.safe-picker-group-title {
  width: 100%;
  border: 0;
  background: #f8fafc;
  padding: 9px 11px;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 800;
}

.safe-picker-group-title::before {
  content: "▾";
  color: #64748b;
}

.safe-picker-group.is-collapsed .safe-picker-group-title::before {
  content: "▸";
}

.safe-picker-group.is-collapsed .safe-picker-group-body {
  display: none;
}

.safe-picker-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto 26px;
  gap: 8px;
  align-items: center;
  border: 0;
  border-top: 1px solid rgba(15,23,42,.06);
  background: white;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}

.safe-picker-row:hover {
  background: #f8fbff;
}

.safe-picker-row.is-added {
  background: rgba(22,163,74,.08);
}

.safe-picker-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.safe-picker-row small {
  color: #0f172a;
  font-weight: 800;
}

.safe-picker-row b {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
}


/* TASK-071C — safe tab layout separation */
.app-shell.tab-layout-tool {
  display: block !important;
}

.app-shell.tab-layout-tool .workspace,
.app-shell.tab-layout-tool .right-panel {
  display: none !important;
}

.app-shell.tab-layout-tool .left-panel {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  display: block !important;
  min-height: calc(100vh - 128px);
  overflow: auto;
}

.app-shell.tab-layout-tool .left-panel > .panel-section:first-child,
.app-shell.tab-layout-tool .left-panel > .service-search-card,
.app-shell.tab-layout-tool .left-panel > .safe-selected-services-count,
.app-shell.tab-layout-tool .left-panel > #safeSelectedServicesCount,
.app-shell.tab-layout-tool .left-panel > #serviceResults,
.app-shell.tab-layout-tool .left-panel > .service-list,
.app-shell.tab-layout-tool .left-panel > #safeServicePickerDropdown {
  display: none !important;
}

.app-shell.tab-layout-tool .tab-view {
  display: none !important;
}

.app-shell.tab-layout-tool .tab-view.active {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
}

.app-shell.tab-layout-tool #priceListView,
.app-shell.tab-layout-tool #doctorsView,
.app-shell.tab-layout-tool #companyForm,
.app-shell.tab-layout-tool #settingsView,
.app-shell.tab-layout-tool #changelogView,
.app-shell.tab-layout-tool #auditLogView,
.app-shell.tab-layout-tool #templatesView,
.app-shell.tab-layout-tool #elementsView {
  width: 100% !important;
  max-width: none !important;
}

.topbar,
.app-topbar,
.header,
.tabs,
.top-tabs,
.tabbar {
  position: sticky;
  top: 0;
  z-index: 120;
}

.app-shell.tab-layout-plan {
  display: grid;
}


/* TASK-071E — stronger tool tab separation after active tab changes */
.app-shell.tab-layout-tool {
  display: block !important;
}

.app-shell.tab-layout-tool .workspace,
.app-shell.tab-layout-tool .right-panel {
  display: none !important;
}

.app-shell.tab-layout-tool .left-panel {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  overflow: visible !important;
}

.app-shell.tab-layout-tool #safeSelectedServicesCount,
.app-shell.tab-layout-tool .safe-selected-services-count,
.app-shell.tab-layout-tool #safeServicePickerDropdown,
.app-shell.tab-layout-tool .safe-service-picker-dropdown,
.app-shell.tab-layout-tool #serviceResults,
.app-shell.tab-layout-tool #serviceSearch {
  display: none !important;
}

.app-shell.tab-layout-tool .tab-view.active {
  width: 100% !important;
  max-width: none !important;
}

.app-shell.tab-layout-tool .tab-view.active * {
  max-width: none;
}

/* TASK-071F — price list full-width overflow fix */
.app-shell.tab-layout-tool #priceListView,
.app-shell.tab-layout-tool .price-list-admin,
.app-shell.tab-layout-tool .price-list-view,
.app-shell.tab-layout-tool .admin-price-list,
.app-shell.tab-layout-tool .price-table-wrap,
.app-shell.tab-layout-tool .table-wrap {
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
}

.app-shell.tab-layout-tool #priceListView table,
.app-shell.tab-layout-tool #priceListView .table-lite,
.app-shell.tab-layout-tool #priceListView .price-table {
  width: 100% !important;
  min-width: 980px;
  table-layout: auto !important;
  box-sizing: border-box !important;
}

.app-shell.tab-layout-tool #priceListView td,
.app-shell.tab-layout-tool #priceListView th {
  white-space: nowrap;
  box-sizing: border-box !important;
}

.app-shell.tab-layout-tool #priceListView input,
.app-shell.tab-layout-tool #priceListView select,
.app-shell.tab-layout-tool #priceListView button {
  max-width: 100%;
  box-sizing: border-box !important;
}

.app-shell.tab-layout-tool #priceListView input[type="number"],
.app-shell.tab-layout-tool #priceListView .price-input {
  width: 88px !important;
  min-width: 72px;
}

.app-shell.tab-layout-tool #priceListView .category-row,
.app-shell.tab-layout-tool #priceListView .price-category-row {
  width: 100% !important;
  box-sizing: border-box !important;
}

.app-shell.tab-layout-tool .left-panel {
  padding-right: 16px !important;
  box-sizing: border-box !important;
}


/* TASK-071G — robust tool tab isolation + price width */
.app-shell.tab-layout-tool {
  display: block !important;
}

.app-shell.tab-layout-tool .workspace,
.app-shell.tab-layout-tool .right-panel {
  display: none !important;
}

.app-shell.tab-layout-tool .left-panel {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

.app-shell.tab-layout-tool #serviceSearch,
.app-shell.tab-layout-tool #safeSelectedServicesCount,
.app-shell.tab-layout-tool .safe-selected-services-count,
.app-shell.tab-layout-tool #safeServicePickerDropdown,
.app-shell.tab-layout-tool #serviceResults {
  display: none !important;
}

body[data-safe-tab071c="prices"] .tab-view.active,
body[data-active-tab="prices"] .tab-view.active,
.app-shell.tab-layout-tool .tab-view.active {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

body[data-safe-tab071c="prices"] .tab-view.active > *,
body[data-active-tab="prices"] .tab-view.active > * {
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box !important;
}

body[data-safe-tab071c="prices"] table,
body[data-active-tab="prices"] table,
body[data-safe-tab071c="prices"] .table-lite,
body[data-active-tab="prices"] .table-lite {
  width: 100% !important;
  min-width: 1120px !important;
  table-layout: auto !important;
  box-sizing: border-box !important;
}

body[data-safe-tab071c="prices"] .tab-view.active,
body[data-active-tab="prices"] .tab-view.active {
  overflow-x: auto !important;
}

body[data-safe-tab071c="prices"] td,
body[data-safe-tab071c="prices"] th,
body[data-active-tab="prices"] td,
body[data-active-tab="prices"] th {
  box-sizing: border-box !important;
  white-space: nowrap;
}

body[data-safe-tab071c="prices"] input[type="number"],
body[data-active-tab="prices"] input[type="number"] {
  width: 90px !important;
  min-width: 76px !important;
}

/* TASK-071H — price tab actual white block is aside.panel.left-panel */
body[data-safe-tab071c="prices"] aside.panel.left-panel,
body[data-active-tab="prices"] aside.panel.left-panel,
body[data-safe-tab071c="prices"] .panel.left-panel,
body[data-active-tab="prices"] .panel.left-panel {
  width: calc(100vw - 28px) !important;
  max-width: calc(100vw - 28px) !important;
  min-width: calc(100vw - 28px) !important;
  margin: 0 14px !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
}

body[data-safe-tab071c="prices"] .app-shell,
body[data-active-tab="prices"] .app-shell {
  display: block !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body[data-safe-tab071c="prices"] aside.panel.left-panel > *,
body[data-active-tab="prices"] aside.panel.left-panel > * {
  max-width: none !important;
  box-sizing: border-box !important;
}

body[data-safe-tab071c="prices"] aside.panel.left-panel table,
body[data-active-tab="prices"] aside.panel.left-panel table,
body[data-safe-tab071c="prices"] aside.panel.left-panel .table-lite,
body[data-active-tab="prices"] aside.panel.left-panel .table-lite {
  min-width: 1320px !important;
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box !important;
}

body[data-safe-tab071c="prices"] .workspace,
body[data-active-tab="prices"] .workspace,
body[data-safe-tab071c="prices"] .right-panel,
body[data-active-tab="prices"] .right-panel {
  display: none !important;
}


/* TASK-075 — Clean Plan Workspace V2 */
body.toga-plan-layout-v2 .app-shell.tab-layout-plan.toga-plan-layout-v2-shell {
  display: grid !important;
  grid-template-columns:
    minmax(220px, var(--toga-v2-left, 27%))
    minmax(300px, var(--toga-v2-mid, 31%))
    minmax(520px, var(--toga-v2-a4, 42%)) !important;
  grid-template-areas: "catalog results a4" !important;
  gap: 10px !important;
  align-items: start !important;
  position: relative !important;
}

body.toga-plan-layout-v2 .app-shell.tab-layout-plan .left-panel {
  grid-area: catalog !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

body.toga-plan-layout-v2 #togaPlanMiddleV2 {
  grid-area: results !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  max-height: calc(100vh - 150px);
  overflow: hidden;
}

body.toga-plan-layout-v2 .app-shell.tab-layout-plan .workspace {
  grid-area: a4 !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  padding-left: 12px;
}

.toga-middle-title-v2 {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.toga-results-head-v2,
.toga-included-controls-v2 {
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  margin-bottom: 10px;
  padding: 10px;
}

.toga-results-head-v2 strong {
  display: block;
  font-size: 13px;
}

.toga-results-head-v2 small {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 11px;
}

.toga-included-controls-v2 {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.toga-included-title-v2 {
  font-size: 12px;
  font-weight: 900;
  color: #334155;
  text-align: center;
}

.toga-included-buttons-v2 {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.toga-included-buttons-v2 button {
  width: 38px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(15,23,42,.14);
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  font-size: 24px;
  font-weight: 1000;
  line-height: 1;
  padding: 0;
}

.toga-included-buttons-v2 button.active {
  background: #0f172a !important;
  color: #fff !important;
  border-color: #0f172a !important;
  box-shadow: 0 0 0 3px rgba(15,23,42,.16);
}

#togaResultsSlotV2 {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  scrollbar-width: thin;
}

#togaIncludedSlotV2 {
  flex: 0 0 auto;
  overflow: auto;
  scrollbar-width: thin;
  max-height: 190px;
}

body[data-toga-included-mode-v2="hidden"] #togaIncludedSlotV2 {
  display: none !important;
}

body[data-toga-included-mode-v2="top"] #togaIncludedSlotV2 {
  order: 1;
  margin: 0 0 10px;
  max-height: 280px;
}

body[data-toga-included-mode-v2="top"] .toga-results-head-v2 {
  order: 2;
}

body[data-toga-included-mode-v2="top"] #togaResultsSlotV2 {
  order: 3;
}

body[data-toga-included-mode-v2="bottom"] .toga-results-head-v2 {
  order: 1;
}

body[data-toga-included-mode-v2="bottom"] #togaResultsSlotV2 {
  order: 2;
}

body[data-toga-included-mode-v2="bottom"] #togaIncludedSlotV2 {
  order: 3;
  margin-top: 10px;
}

body.toga-plan-layout-v2 #togaResultsSlotV2 #serviceResults {
  max-height: none !important;
  overflow: visible !important;
}

body.toga-plan-layout-v2 #togaIncludedSlotV2 .included-section {
  display: block !important;
}

body.toga-plan-layout-v2 .right-panel.toga-stages-inside-left-v2 {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  margin-top: 12px;
  box-shadow: none;
  border-radius: 14px;
  overflow: visible;
  max-height: none;
}

.toga-hide-v2 {
  display: none !important;
}

.toga-resize-grip-v2 {
  position: fixed;
  z-index: 9999;
  width: 18px;
  display: none;
  place-items: center;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}

.toga-resize-grip-v2 span {
  width: 18px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(15,23,42,.18);
  color: rgba(15,23,42,.75);
  font-size: 26px;
  line-height: 1;
  font-weight: 1000;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
}

.toga-resize-grip-v2:hover span,
body.toga-resizing-v2 .toga-resize-grip-v2 span {
  background: rgba(37,99,235,.22);
  color: #1d4ed8;
  box-shadow: 0 0 0 4px rgba(37,99,235,.10), 0 8px 24px rgba(15,23,42,.16);
}

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

.app-shell.tab-layout-tool #togaPlanMiddleV2,
.app-shell.tab-layout-tool .toga-resize-grip-v2 {
  display: none !important;
}

@media (max-width: 1180px) {
  body.toga-plan-layout-v2 .app-shell.tab-layout-plan.toga-plan-layout-v2-shell {
    grid-template-columns: minmax(270px, 1fr) minmax(330px, 1.2fr) !important;
    grid-template-areas:
      "catalog results"
      "a4 a4" !important;
  }

  .toga-resize-grip-v2 {
    display: none !important;
  }
}

@media (max-width: 760px) {
  body.toga-plan-layout-v2 .app-shell.tab-layout-plan.toga-plan-layout-v2-shell {
    display: block !important;
  }

  body.toga-plan-layout-v2 .left-panel,
  body.toga-plan-layout-v2 #togaPlanMiddleV2,
  body.toga-plan-layout-v2 .workspace {
    margin-bottom: 14px;
    max-height: none;
  }
}


/* TASK-076 — resize only via grips + natural included/results flow */

/* Disable accidental resizing/dragging from whole zones */
body.toga-plan-layout-v2 .left-panel,
body.toga-plan-layout-v2 #togaPlanMiddleV2,
body.toga-plan-layout-v2 .workspace,
body.toga-plan-layout-v2 .panel,
body.toga-plan-layout-v2 .toga-results-slot-v2,
body.toga-plan-layout-v2 .toga-included-slot-v2 {
  resize: none !important;
  cursor: default;
}

/* Only grips are draggable */
body.toga-plan-layout-v2 .toga-resize-grip-v2,
body.toga-plan-layout-v2 .toga-resize-grip-v2 *,
body.toga-plan-layout-v2 [data-toga-resize-v2],
body.toga-plan-layout-v2 [data-togaResizeV2] {
  cursor: col-resize !important;
  pointer-events: auto !important;
  touch-action: none !important;
}

/* Make middle column a single clear vertical flow */
body.toga-plan-layout-v2 #togaPlanMiddleV2 {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
}

body.toga-plan-layout-v2 #togaIncludedControlsV2,
body.toga-plan-layout-v2 #togaIncludedSlotV2,
body.toga-plan-layout-v2 #togaResultsSlotV2,
body.toga-plan-layout-v2 #togaPlanMiddleV2 .toga-results-head-v2 {
  order: unset !important;
}

body.toga-plan-layout-v2 #togaResultsSlotV2 {
  flex: 1 1 auto !important;
  min-height: 180px;
  overflow: auto !important;
  max-height: none !important;
}

body.toga-plan-layout-v2 #togaIncludedSlotV2 {
  flex: 0 0 auto !important;
  overflow: auto !important;
  max-height: none !important;
}

body[data-toga-included-mode-v2="hidden"] #togaIncludedSlotV2 {
  display: none !important;
}

body[data-toga-included-mode-v2="top"] #togaIncludedSlotV2 {
  display: block !important;
  margin: 0 0 10px 0 !important;
}

body[data-toga-included-mode-v2="bottom"] #togaIncludedSlotV2 {
  display: block !important;
  margin: 10px 0 0 0 !important;
}

/* Prevent old controls from fighting */
#toggleIncludedTop073B,
#includedControls073E,
#includedPositionControls073C {
  display: none !important;
}


/* TASK-077 — category clicks must not add services + unified middle scroll */

/* Only middle column scrolls; results/included are natural content */
body.toga-plan-layout-v2 #togaPlanMiddleV2.toga-middle-one-scroll-077 {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: calc(100vh - 150px) !important;
  scrollbar-width: thin;
}

body.toga-plan-layout-v2 #togaResultsSlotV2.toga-no-inner-scroll-077,
body.toga-plan-layout-v2 #togaIncludedSlotV2.toga-no-inner-scroll-077 {
  overflow: visible !important;
  max-height: none !important;
  min-height: 0 !important;
  flex: 0 0 auto !important;
}

body.toga-plan-layout-v2 #serviceResults.toga-service-results-expanded-077 {
  overflow: visible !important;
  max-height: none !important;
  height: auto !important;
}

/* Absolutely no browser-native resize on zones */
body.toga-plan-layout-v2 .toga-no-zone-resize-077,
body.toga-plan-layout-v2 .toga-no-zone-resize-077 *,
body.toga-plan-layout-v2 .left-panel,
body.toga-plan-layout-v2 #togaPlanMiddleV2,
body.toga-plan-layout-v2 .workspace,
body.toga-plan-layout-v2 .panel,
body.toga-plan-layout-v2 textarea {
  resize: none !important;
}

/* Normal cursor everywhere except grips */
body.toga-plan-layout-v2 .left-panel,
body.toga-plan-layout-v2 #togaPlanMiddleV2,
body.toga-plan-layout-v2 .workspace,
body.toga-plan-layout-v2 .panel {
  cursor: default !important;
}

body.toga-plan-layout-v2 .toga-resize-grip-v2,
body.toga-plan-layout-v2 .toga-resize-grip-v2 *,
body.toga-plan-layout-v2 [data-togaResizeV2],
body.toga-plan-layout-v2 [data-toga-resize-v2] {
  cursor: col-resize !important;
}

/* Hide old internal split-scroll behavior */
body.toga-plan-layout-v2 #togaResultsSlotV2 {
  flex: 0 0 auto !important;
}

body.toga-plan-layout-v2 #togaIncludedSlotV2 {
  flex: 0 0 auto !important;
}

body[data-toga-included-mode-v2="bottom"] #togaIncludedSlotV2 {
  margin-top: 10px !important;
}

body[data-toga-included-mode-v2="top"] #togaIncludedSlotV2 {
  margin-bottom: 10px !important;
}


/* TASK-078 — hide useless white arrow/ghost controls near search */
.toga-search-ghost-hidden-078 {
  display: none !important;
}

body.toga-plan-layout-v2 #togaResultsSlotV2 #serviceResults {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body.toga-plan-layout-v2 #togaResultsSlotV2 {
  min-height: 260px !important;
}


/* TASK-080 — direct service results renderer */
.toga-direct-results-080 {
  display: grid !important;
  gap: 8px;
  visibility: visible !important;
  opacity: 1 !important;
}

.toga-direct-results-count-080 {
  font-size: 12px;
  font-weight: 900;
  color: #475569;
  padding: 4px 2px;
}

.toga-direct-service-card-080 {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 13px;
  background: #fff;
}

.toga-direct-service-main-080 {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.toga-direct-service-main-080 strong {
  font-size: 13px;
  color: #0f172a;
}

.toga-direct-service-main-080 span {
  font-size: 11px;
  color: #64748b;
}

.toga-direct-service-side-080 {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.toga-direct-service-side-080 b {
  font-size: 12px;
}

.toga-direct-service-side-080 button {
  border: 0;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
}

.toga-no-results-080 {
  padding: 18px;
  text-align: center;
  color: #64748b;
}


/* TASK-081 — single service results controller */
.toga081-old-results-hidden {
  display: none !important;
}

.toga-service-results-081 {
  display: grid;
  gap: 8px;
}

.toga081-count {
  font-size: 12px;
  font-weight: 900;
  color: #475569;
  padding: 4px 2px;
}

.toga081-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 13px;
  background: #fff;
}

.toga081-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.toga081-info strong {
  font-size: 13px;
  color: #0f172a;
}

.toga081-info span {
  font-size: 11px;
  color: #64748b;
}

.toga081-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.toga081-side b {
  font-size: 12px;
}

.toga081-side button {
  border: 0;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
}

.toga-search-suggest-081 {
  position: fixed;
  z-index: 20000;
  overflow: auto;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(15,23,42,.14);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15,23,42,.18);
}

.toga-search-suggest-081[hidden] {
  display: none !important;
}

.toga-search-suggest-081 button {
  display: grid;
  gap: 2px;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 8px 10px;
  cursor: pointer;
}

.toga-search-suggest-081 button:hover {
  background: #f1f5f9;
}

.toga-search-suggest-081 strong {
  font-size: 13px;
  color: #0f172a;
}

.toga-search-suggest-081 span {
  font-size: 11px;
  color: #64748b;
}

.toga081-empty {
  padding: 18px;
  text-align: center;
  color: #64748b;
}

body.toga-plan-layout-v2 .left-panel,
body.toga-plan-layout-v2 #togaPlanMiddleV2,
body.toga-plan-layout-v2 .workspace,
body.toga-plan-layout-v2 .panel {
  resize: none !important;
  cursor: default !important;
}

body.toga-plan-layout-v2 .toga-resize-grip-v2,
body.toga-plan-layout-v2 .toga-resize-grip-v2 * {
  cursor: col-resize !important;
}


/* TASK-082 — restore native service results, disable custom TASK-081 layer */
#togaServiceResults081,
#togaSearchSuggest081 {
  display: none !important;
}

#serviceResults {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body.toga-plan-layout-v2 #togaResultsSlotV2 #serviceResults {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

body.toga-plan-layout-v2 .toga081-old-results-hidden {
  display: block !important;
}

#svcPickerBtn {
  display: none !important;
}

.svc-dropdown {
  z-index: 25000 !important;
  max-height: min(520px, calc(100vh - 220px)) !important;
  overflow: auto !important;
}
