/* СметаСПб 2027 */
:root {
  --bg: #f2efe8;
  --panel: #ffffff;
  --ink: #14202e;
  --ink-soft: #334152;
  --muted: #6d7684;
  --muted-2: #939caa;
  --line: #e6e1d6;
  --line-soft: #f0ede5;
  --brand: #f2b01e;
  --brand-2: #f7c948;
  --brand-ink: #1a2432;
  --navy: #0e1c2c;
  --navy-2: #16293e;
  --green: #0f8a5f;
  --blue: #2477c9;
  --red: #b23c3c;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 32, 46, .05), 0 10px 28px rgba(20, 32, 46, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Inter", Arial, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(20, 32, 46, .045) 1px, transparent 1px);
  background-size: 22px 22px;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }
::selection { background: rgba(242, 176, 30, .35); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #d5d0c4 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #d5d0c4; border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: linear-gradient(180deg, #112236, #0c1826);
  box-shadow: 0 6px 24px rgba(10, 20, 32, .18);
}
.topbar::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, #d99a0b, var(--brand-2) 35%, var(--brand) 70%, #d99a0b);
}
.topbar-inner {
  max-width: 1800px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  color: #17212e;
  background: linear-gradient(135deg, #f9d568, #eaa60a);
  box-shadow: 0 6px 16px rgba(242, 176, 30, .3), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.logo svg { width: 25px; height: 25px; }
.brand-text { min-width: 0; }
.brand h1 {
  display: flex; align-items: center; gap: 8px;
  font-size: 19px; font-weight: 800; letter-spacing: .2px; color: #fff;
}
.year {
  font-size: 9.5px; font-weight: 800; letter-spacing: .12em;
  color: #1a2432; background: var(--brand);
  padding: 3px 7px; border-radius: 5px;
}
.brand p {
  margin-top: 1px;
  font-size: 11.5px; color: #94a6bb;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 12.5px; font-weight: 650;
  transition: background .15s, border-color .15s, transform .12s, box-shadow .15s, color .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn .chev { width: 13px; height: 13px; opacity: .7; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, #f9d163, #f0ae14);
  color: #18222f;
  box-shadow: 0 4px 14px rgba(240, 174, 20, .28);
}
.btn-primary:hover { filter: brightness(1.04); box-shadow: 0 6px 18px rgba(240, 174, 20, .35); }
.btn-dark { background: #1b3048; color: #eaf0f7; border-color: rgba(255, 255, 255, .14); }
.btn-dark:hover { background: #26415e; }
.btn-ghost { background: transparent; color: #c7d3e1; border-color: rgba(255, 255, 255, .16); }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.btn-light { background: #f8f6f1; color: #334152; border-color: var(--line); }
.btn-light:hover { background: #fff; border-color: #d8d2c5; }
.btn-sm { padding: 7px 10px; font-size: 12px; border-radius: 9px; }
.btn-sm svg { width: 14px; height: 14px; }
.only-mobile { display: none; }

.icon-btn {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: #fff; color: #7b8492;
  border-radius: 9px;
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: #faf7f0; color: #334152; }
.icon-btn.danger:hover { background: #fbecec; border-color: #f1d2d2; color: var(--red); }

.menu-wrap { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 214px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 44px rgba(10, 20, 32, .22);
  padding: 6px;
  opacity: 0; visibility: hidden;
  transform: translateY(-5px);
  transition: opacity .15s, transform .15s, visibility .15s;
  z-index: 100;
}
.menu-wrap.open .dropdown { opacity: 1; visibility: visible; transform: none; }
.dropdown button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px;
  background: transparent;
  font-size: 12.5px; font-weight: 600; color: #334152;
  text-align: left;
}
.dropdown button:hover { background: #f8f5ee; }
.dropdown svg { width: 15px; height: 15px; color: #7b8492; flex: none; }
.dropdown .sep { height: 1px; background: var(--line-soft); margin: 5px 6px; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1800px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.workspace { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Catalog ---------- */
.catalog {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 102px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.catalog-head { padding: 15px 15px 12px; border-bottom: 1px solid var(--line); }
.catalog-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.catalog-title h2 { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: .05em;
}
.chip-gold { background: #fdf3d8; color: #a2760b; border: 1px solid #f2e2b7; }
.search { position: relative; }
.search > svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: #9aa3af; pointer-events: none;
}
.search input {
  width: 100%;
  padding: 9px 32px 9px 33px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9f7f2;
  font-size: 12.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search input::placeholder { color: #a2aab5; }
.search input:focus { border-color: #e3bb56; background: #fff; box-shadow: 0 0 0 3px rgba(242, 176, 30, .14); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px;
  border: 0; border-radius: 7px; background: transparent;
  color: #8a94a3; font-size: 17px; line-height: 1;
}
.search-clear:hover { background: #eeeae1; color: #334152; }
.filters { display: flex; margin-top: 9px; }
.seg {
  display: flex; flex: 1; gap: 2px;
  background: #f1eee7; border-radius: 9px; padding: 3px;
}
.seg button {
  flex: 1; border: 0; border-radius: 7px;
  padding: 6px 4px;
  background: transparent;
  font-size: 11px; font-weight: 700; color: #77808e;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20, 32, 46, .12); }
.category-select {
  width: 100%;
  margin-top: 9px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
  outline: none;
}
.category-select:focus { border-color: #e3bb56; box-shadow: 0 0 0 3px rgba(242, 176, 30, .12); }
.catalog-count {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 9px 15px 5px;
  font-size: 10.5px; color: #8a94a3;
}
.catalog-count span:last-child { color: #b0b6bf; }
.catalog-list { flex: 1; overflow-y: auto; padding: 0 9px 9px; min-height: 120px; }
.cat-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 9px 8px;
  border: 0; border-bottom: 1px solid var(--line-soft);
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: background .13s;
}
.cat-item:last-child { border-bottom-color: transparent; }
.cat-item:hover { background: #faf7f0; }
.ci-main { flex: 1; min-width: 0; }
.ci-name { display: block; font-size: 12.3px; font-weight: 600; line-height: 1.3; color: #1d2a38; }
.ci-meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 10px; color: #8a94a3; }
.ci-meta i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.ci-side { display: flex; align-items: center; gap: 7px; flex: none; }
.ci-price { text-align: right; font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ci-price small { display: block; font-size: 9px; font-weight: 500; color: #9aa3af; }
.ci-add {
  width: 25px; height: 25px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 15px; line-height: 1;
  color: #8a94a3;
  transition: background .13s, color .13s, border-color .13s;
}
.cat-item:hover .ci-add { background: var(--brand); border-color: var(--brand); color: #1a2432; }
.catalog-empty { padding: 26px 12px; text-align: center; font-size: 12px; color: #8a94a3; }
.catalog-foot {
  padding: 9px 15px 12px;
  border-top: 1px solid var(--line);
  background: #fbf9f4;
  font-size: 10px; line-height: 1.45; color: #8a94a3;
}
.catalog-foot b { color: #6d7684; }

/* ---------- Document card ---------- */
.doc-card { padding: 17px 19px 18px; }
.doc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 13px; }
.eyebrow {
  display: block;
  font-size: 9.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: #b08525;
}
.doc-top h2 { margin-top: 2px; font-size: 18px; font-weight: 800; letter-spacing: -.015em; }
.doc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.autosave { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: #9aa3af; }
.autosave i { width: 6px; height: 6px; border-radius: 50%; background: #7ac6a1; box-shadow: 0 0 0 3px rgba(122, 198, 161, .16); }
.doc-fields {
  display: grid;
  grid-template-columns: minmax(170px, 2fr) minmax(120px, 1fr) minmax(150px, 1.4fr) 92px 138px;
  gap: 10px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span {
  font-size: 9.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: #939caa;
}
.field input, .field select {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfaf6;
  font-size: 12.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:hover { border-color: #dcd5c7; }
.field input:focus, .field select:focus { border-color: #e3bb56; background: #fff; box-shadow: 0 0 0 3px rgba(242, 176, 30, .13); }
.field input::placeholder { color: #b1b7c0; }
.field input[type="date"] { padding-right: 5px; }

/* ---------- Estimate ---------- */
.estimate-card { overflow: hidden; }
.estimate-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.estimate-toolbar h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.count-pill {
  padding: 2px 8px; border-radius: 999px;
  background: #f2efe7; color: #6d7684;
  font-size: 10.5px; font-weight: 700;
}
.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-total {
  display: flex; align-items: baseline; gap: 6px;
  padding: 0 4px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #9aa3af;
}
.live-total b { font-size: 14px; font-weight: 800; color: var(--ink); letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.estimate-scroll { overflow-x: auto; }
.estimate-inner { min-width: 700px; }
.items-head, .item-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 58px 88px 108px 112px 34px;
  gap: 8px;
  align-items: center;
}
.items-head {
  padding: 9px 16px;
  background: #fbf9f4;
  border-bottom: 1px solid var(--line);
  font-size: 9.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: #939caa;
}
.items-head span:nth-child(2) { text-align: center; }
.items-head span:nth-child(3),
.items-head span:nth-child(4),
.items-head span:nth-child(5) { text-align: right; }

.cat-group { border-bottom: 1px solid var(--line); }
.cat-group:last-child { border-bottom: 0; }
.cat-head {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  padding: 9px 16px;
  border: 0; border-left: 3px solid var(--cat, #ccc);
  background: var(--cat-bg, #faf8f3);
  text-align: left;
  transition: filter .13s;
}
.cat-head:hover { filter: brightness(.985); }
.cat-chevron { width: 13px; height: 13px; color: #7b8492; transition: transform .18s; flex: none; }
.cat-group.collapsed .cat-chevron { transform: rotate(-90deg); }
.cat-icon { font-size: 13px; line-height: 1; }
.cat-name { font-size: 12px; font-weight: 800; letter-spacing: .005em; color: var(--ink-soft); }
.cat-count {
  padding: 1px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  border: 1px solid rgba(20, 32, 46, .06);
  font-size: 9.5px; font-weight: 700; color: #8a94a3;
}
.cat-subtotal { margin-left: auto; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.cat-group.collapsed .cat-rows { display: none; }
.cat-rows { padding: 0 16px; }
.item-row { padding: 7px 0; border-top: 1px solid #f2efe8; }
.item-row:hover { background: #fffdf8; }
.item-row.flash { animation: flash 1s ease; }
@keyframes flash { 0% { background: #fff0b8; } 100% { background: transparent; } }
.item-row .name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.item-name { font-size: 12.3px; font-weight: 600; line-height: 1.3; }
.tag {
  flex: none;
  padding: 1px 5px; border-radius: 4px;
  font-size: 8.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.tag.work { background: #e7f5ee; color: #0b7a52; }
.tag.mat { background: #e9f1fb; color: #2367b4; }
.unit { text-align: center; font-size: 10.5px; color: #8a94a3; white-space: nowrap; }
.inp {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #f7f5f0;
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .13s, background .13s, box-shadow .13s;
}
.inp:hover { border-color: #e3ddd1; }
.inp:focus { border-color: #e3bb56; background: #fff; box-shadow: 0 0 0 2px rgba(242, 176, 30, .14); }
.inp::-webkit-outer-spin-button,
.inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inp { appearance: textfield; -moz-appearance: textfield; }
.sum { text-align: right; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-del {
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent;
  color: #bdc3cc; font-size: 17px; line-height: 1;
  transition: background .13s, color .13s, border-color .13s;
}
.item-row:hover .row-del { color: #c07a7a; }
.row-del:hover { background: #fbecec; border-color: #f1d2d2; color: var(--red); }

.empty { padding: 42px 24px 46px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.empty-icon {
  width: 62px; height: 62px; margin-bottom: 12px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #fdf4dc, #f9e9bf);
  border: 1px solid #f1dfae;
  font-size: 27px;
}
.empty h3 { font-size: 16px; font-weight: 800; }
.empty p { max-width: 420px; margin-top: 5px; font-size: 12.3px; color: #8a94a3; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }

/* ---------- Summary ---------- */
.summary { display: flex; flex-direction: column; gap: 13px; }
.summary-total {
  position: relative; overflow: hidden;
  padding: 20px;
  border-radius: var(--radius);
  background: radial-gradient(circle at 100% 0, #1f3a57 0, #10243a 48%, #0b1725 100%);
  color: #fff;
  box-shadow: 0 14px 32px rgba(11, 23, 37, .25);
}
.summary-total::after {
  content: "";
  position: absolute; right: -38px; top: -38px;
  width: 140px; height: 140px;
  border: 20px solid rgba(242, 176, 30, .13);
  border-radius: 50%;
  pointer-events: none;
}
.summary-total::before {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, #d99a0b, var(--brand-2), transparent);
  opacity: .85;
}
.st-label { font-size: 9.5px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; color: #9fb0c4; }
.st-value {
  margin: 7px 0 3px;
  font-size: 31px; font-weight: 800; line-height: 1.08; letter-spacing: -.02em;
  color: #ffd469;
  font-variant-numeric: tabular-nums;
}
.st-sub {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 11px; padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: 10.5px; color: #aab9ca;
}
.st-sub b { color: #fff; font-weight: 700; }
.panel-card {
  padding: 15px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-card h3 { margin-bottom: 10px; font-size: 12.5px; font-weight: 800; letter-spacing: .01em; }
.break-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 4.5px 0; font-size: 11.5px; color: #5b6675; }
.break-row b { font-size: 11.5px; font-weight: 750; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.break-row em { font-style: normal; font-size: 9.5px; color: #9aa3af; }
.break-row.sub { margin-top: 4px; padding-top: 8px; border-top: 1px dashed #e9e4da; font-weight: 650; color: var(--ink-soft); }
.break-row.total { margin-top: 7px; padding-top: 10px; border-top: 2px solid var(--ink); font-size: 12.5px; font-weight: 800; color: var(--ink); }
.break-row.total b { font-size: 14.5px; color: var(--green); }
.divider { height: 1px; background: var(--line-soft); margin: 7px 0; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.settings-grid .span2 { grid-column: 1 / -1; }
.settings-grid .field input, .settings-grid .field select { padding: 7px 8px; font-size: 12px; }
.hint { margin-top: 9px; font-size: 10px; line-height: 1.45; color: #9aa3af; }
.struct-list { display: flex; flex-direction: column; gap: 8px; }
.struct-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; align-items: center; }
.struct-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 10.8px; color: #5b6675; }
.struct-name i { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.struct-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.struct-val { font-size: 10.5px; font-weight: 750; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.struct-bar { grid-column: 1 / -1; height: 4px; border-radius: 99px; background: #f1ede5; overflow: hidden; }
.struct-bar i { display: block; height: 100%; border-radius: 99px; transition: width .35s ease; }
.note-card {
  padding: 13px 15px;
  border: 1px solid #f0e3c2;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fffaf0, #fff);
  font-size: 10.3px; line-height: 1.5; color: #8a7a57;
}
.note-card b { color: #6b5b37; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px;
  transform: translate(-50%, 16px);
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: #14202e;
  color: #fff;
  font-size: 12px; font-weight: 600;
  box-shadow: 0 12px 34px rgba(10, 20, 32, .3);
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 300;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10, 20, 32, .56);
  backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: opacity .18s, visibility .18s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  transform: translateY(10px) scale(.985);
  transition: transform .18s;
}
.modal-overlay.open .modal { transform: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 10px; }
.modal-head h2 { margin-top: 2px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.modal-head p { margin-top: 4px; font-size: 12px; color: #8a94a3; }
.modal-close {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fbf9f4; color: #7b8492;
  font-size: 18px; line-height: 1;
}
.modal-close:hover { background: #f3efe6; color: var(--ink); }
.modal-body { padding: 10px 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
  padding: 14px 22px 20px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.modal-foot .hint { margin: 0 auto 0 0; }
.modal .btn-light { background: #fff; border-color: var(--line); }
.modal .btn-light:hover { background: #faf8f3; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-grid .span2 { grid-column: 1 / -1; }
.modal .field input, .modal .field select { background: #fbfaf6; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.tpl-card {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdfcf8;
  text-align: left;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.tpl-card:hover { border-color: #e7c26a; background: #fffaf0; }
.tpl-card.selected { border-color: var(--brand); background: #fffaf0; box-shadow: 0 0 0 3px rgba(242, 176, 30, .16); }
.tpl-icon {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: #fdf1d2;
  font-size: 17px;
}
.tpl-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tpl-body strong { font-size: 12.5px; font-weight: 800; }
.tpl-body span { font-size: 10.5px; line-height: 1.35; color: #8a94a3; }
.tpl-body em { margin-top: 3px; font-style: normal; font-size: 9.5px; font-weight: 800; color: #b08525; text-transform: uppercase; letter-spacing: .05em; }
.saved-list { display: flex; flex-direction: column; gap: 7px; }
.saved-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fdfcf8;
}
.saved-main { flex: 1; min-width: 0; }
.saved-main strong { display: block; font-size: 12.5px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-main span { font-size: 10px; color: #8a94a3; }
.saved-sum { font-size: 12.5px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.saved-actions { display: flex; gap: 5px; flex: none; }
.empty-modal { padding: 22px 0 26px; text-align: center; font-size: 12.5px; color: #8a94a3; }

/* ---------- Responsive ---------- */
@media (max-width: 1420px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); }
  .summary { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); align-items: stretch; }
  .summary-total { min-height: 100%; }
  .note-card { min-height: 100%; }
}
@media (max-width: 1180px) {
  .doc-fields { grid-template-columns: 1fr 1fr 1fr; }
  .doc-fields .wide { grid-column: span 2; }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 12px 14px 32px; }
  .workspace { order: 1; }
  .catalog { order: 2; position: static; max-height: 470px; }
  .summary { order: 3; }
  .brand p { display: none; }
  .only-mobile { display: inline-flex; }
  .doc-fields { grid-template-columns: 1fr 1fr; }
  .doc-fields .wide { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .topbar-inner { padding: 9px 12px; gap: 10px; }
  .logo { width: 38px; height: 38px; border-radius: 10px; }
  .logo svg { width: 22px; height: 22px; }
  .brand h1 { font-size: 16.5px; }
  .brand .year { font-size: 8.5px; padding: 2px 5px; }
  .top-actions { gap: 6px; }
  .top-actions .btn { padding: 8px 10px; }
  .btn-label { display: none; }
  .btn .chev { display: none; }
  .layout { padding: 10px 10px 28px; gap: 11px; }
  .doc-card { padding: 14px; }
  .doc-fields { grid-template-columns: 1fr 1fr; }
  .doc-top h2 { font-size: 16px; }
  .autosave { display: none; }
  .estimate-toolbar { padding: 11px 12px; }
  .live-total { font-size: 9px; }
  .live-total b { font-size: 12.5px; }
  .toolbar-actions { gap: 6px; }
  .toolbar-actions .btn span { display: none; }
  .summary { grid-template-columns: 1fr; }
  .st-value { font-size: 28px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .tpl-grid { grid-template-columns: 1fr; }
  .modal-overlay { padding: 10px; }
  .modal-head { padding: 16px 16px 8px; }
  .modal-body { padding: 8px 16px; }
  .modal-foot { padding: 12px 16px 16px; flex-wrap: wrap; }
  .saved-row { flex-wrap: wrap; }
  .saved-actions { margin-left: auto; }
}
@media (max-width: 480px) {
  .doc-fields { grid-template-columns: 1fr; }
  .doc-fields .wide { grid-column: auto; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .estimate-inner { min-width: 660px; }
  .modal-foot .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
