:root {
  --ink: #18211f;
  --muted: #6d7773;
  --line: #e3e7e5;
  --soft: #f4f6f5;
  --green: #26785c;
  --green-dark: #1b5e48;
  --green-soft: #eaf4ef;
  --cream: #faf9f6;
  --white: #fff;
  --shadow: 0 12px 32px rgba(21, 35, 30, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1120px;
  color: var(--ink);
  background: var(--cream);
  font-family: "Manrope", sans-serif;
  font-size: 14px;
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
}

.brand, .topbar-actions, .mode-switch, .panel-header, .header-controls,
.price-toolbar, .checkbox-line, .dialog-header, .dialog-actions {
  display: flex;
  align-items: center;
}

.brand { gap: 11px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 11px; background: var(--green); color: white;
  font-weight: 700; font-size: 19px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-subtitle { color: var(--muted); font-size: 11px; margin-top: 1px; }
.topbar-actions { gap: 10px; }

.mode-switch { padding: 3px; border-radius: 10px; background: var(--soft); }
.mode-button {
  border: 0; border-radius: 8px; padding: 8px 13px; background: transparent; color: var(--muted);
}
.mode-button.active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.button {
  border: 1px solid transparent; border-radius: 9px; padding: 10px 15px;
  font-weight: 600; transition: .18s ease;
}
.button:disabled { opacity: .45; cursor: default; }
.button.secondary { background: white; border-color: var(--line); color: var(--ink); }
.button.primary { background: var(--green); color: white; }
.button.primary:hover:not(:disabled) { background: var(--green-dark); }
.button.ghost { width: 38px; padding: 9px; background: white; border-color: var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #dceae4; color: var(--green-dark); font-size: 12px; font-weight: 700; }

.workspace {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 340px minmax(520px, 1fr) 276px;
  gap: 1px;
  background: var(--line);
}

.panel, .summary-panel { min-height: 0; background: white; }
.panel { display: flex; flex-direction: column; }
.panel-header { justify-content: space-between; padding: 22px 22px 16px; }
.panel-header h1, .panel-header h2, .summary-panel h2, .dialog-card h2 { margin: 3px 0 0; font-size: 19px; letter-spacing: -.03em; }
.eyebrow { margin: 0; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.counter { color: var(--muted); font-size: 11px; background: var(--soft); border-radius: 20px; padding: 5px 8px; }
.search-wrap { position: relative; padding: 0 16px 14px; }
.search-wrap input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px 10px 35px; outline: none; background: var(--soft);
}
.search-wrap input:focus { border-color: #9fc6b7; background: white; box-shadow: 0 0 0 3px var(--green-soft); }
.search-icon { position: absolute; left: 28px; top: 8px; color: var(--muted); font-size: 19px; }

.tree-scroll { overflow: auto; flex: 1; padding: 0 10px 18px; }
.tree-node { user-select: none; }
.tree-row {
  min-height: 36px; display: flex; align-items: center; gap: 8px;
  padding: 5px 9px; border-radius: 8px; color: #34403c;
}
.tree-row:hover { background: var(--soft); }
.tree-row.selected { background: var(--green-soft); color: var(--green-dark); }
.tree-row.muted { opacity: .45; }
.tree-toggle {
  width: 17px; height: 17px; border: 0; padding: 0; background: transparent;
  color: #87918d; font-size: 12px; transform: rotate(0deg);
}
.tree-toggle.expanded { transform: rotate(90deg); }
.tree-spacer { width: 17px; }
.node-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.node-icon { width: 18px; color: #7f8985; text-align: center; font-size: 12px; }
.tree-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
.tree-level-0 > .tree-row { font-weight: 700; margin-top: 4px; }
.tree-level-1 > .tree-row { font-weight: 600; }
.node-meta { font-size: 10px; color: #949c99; }

.price-header { align-items: flex-start; }
.selection-context { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.header-controls { gap: 12px; margin-top: 7px; }
.link-button { border: 0; background: none; color: var(--green); padding: 3px; font-size: 11px; font-weight: 600; }
.info-banner { margin: 0 22px 14px; padding: 10px 12px; border: 1px solid #d9eae3; border-radius: 9px; background: #f4faf7; color: #436457; font-size: 11px; }
.info-banner.hidden { display: none; }
.price-toolbar { justify-content: space-between; margin: 0 18px 8px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.checkbox-line { gap: 9px; font-weight: 600; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--green); }
.selected-chip { color: var(--green-dark); background: var(--green-soft); padding: 5px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.price-tree { padding: 0 18px 18px; }
.price-tree .tree-row { min-height: 38px; }
.price-tree .tree-label { font-size: 13px; }
.price-check { margin: 0; flex: 0 0 auto; }
.lock-icon { width: 16px; color: #a7aeab; font-size: 10px; text-align: center; }
.panel-footer { min-height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 12px 22px; border-top: 1px solid var(--line); background: #fcfdfc; }
.save-status { color: var(--muted); font-size: 11px; }
.save-status.dirty { color: #a56523; }

.summary-panel { padding: 24px 20px; }
.summary-panel h2 { margin-bottom: 20px; }
.context-card { border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: #fcfdfc; }
.context-label { display: block; color: var(--muted); font-size: 10px; margin-bottom: 7px; text-transform: uppercase; letter-spacing: .08em; }
.context-card strong { display: block; line-height: 1.35; }
.type-badge { display: inline-block; margin-top: 10px; padding: 4px 7px; background: var(--soft); color: var(--muted); border-radius: 6px; font-size: 10px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.metric { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.metric span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.metric strong { font-size: 20px; }
.rule-card { display: flex; gap: 10px; margin-top: 18px; padding: 13px; border-radius: 11px; background: var(--soft); }
.rule-icon { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: white; color: var(--green); font-weight: 700; }
.rule-card strong { font-size: 11px; }
.rule-card p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.basket-button { width: 100%; display: flex; justify-content: space-between; margin-top: 18px; background: var(--ink); color: white; }
.basket-hint { color: var(--muted); font-size: 9px; line-height: 1.5; text-align: center; }

.empty-state { min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; gap: 6px; }
.empty-state strong { color: var(--ink); }
.empty-state span { max-width: 270px; font-size: 11px; }
.empty-symbol { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); color: var(--green); font-size: 20px; margin-bottom: 5px; }

dialog { border: 0; padding: 0; border-radius: 15px; box-shadow: var(--shadow); width: min(520px, calc(100vw - 40px)); }
dialog::backdrop { background: rgba(16, 27, 23, .35); backdrop-filter: blur(2px); }
.dialog-card { padding: 24px; }
.dialog-header { justify-content: space-between; align-items: flex-start; }
.dialog-close { border: 0; background: var(--soft); width: 32px; height: 32px; border-radius: 8px; color: var(--muted); font-size: 19px; }
.dialog-card > p { color: var(--muted); line-height: 1.6; }
.dropzone { min-height: 150px; border: 1.5px dashed #b7c3be; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; background: #fbfcfb; }
.dropzone:hover { border-color: var(--green); background: var(--green-soft); }
.dropzone span { color: var(--muted); font-size: 11px; }
.upload-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: white; color: var(--green) !important; font-size: 19px !important; }
.template-link { display: inline-block; margin-top: 12px; color: var(--green); font-size: 12px; }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 24px; }
.basket-dialog { max-height: 75vh; display: flex; flex-direction: column; }
.basket-list { overflow: auto; margin-top: 18px; }
.product-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.product-row strong { font-size: 12px; }
.product-row span { color: var(--muted); font-size: 10px; }
.product-price { grid-row: 1 / 3; grid-column: 2; align-self: center; color: var(--ink) !important; font-size: 12px !important; font-weight: 700; }
.help-list { padding-left: 20px; color: var(--muted); line-height: 1.7; }
.toast { position: fixed; right: 22px; bottom: 22px; transform: translateY(20px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 11px 15px; border-radius: 9px; box-shadow: var(--shadow); transition: .2s ease; z-index: 20; }
.toast.visible { transform: translateY(0); opacity: 1; }

@media (max-width: 1200px) {
  .workspace { grid-template-columns: 310px minmax(500px, 1fr) 250px; }
}

