:root {
  color-scheme: dark;
  --bg: #071018;
  --bg-raise: #0d1722;
  --card: #121e2b;
  --ink: #e8f0f7;
  --muted: #93a4b5;
  --line: rgba(232, 240, 247, 0.1);
  --accent: #3ee0a0;
  --accent-ink: #04281a;
  --amber: #f0b429;
  --blue: #8eb7ff;
  --danger: #ffb4ab;
  --danger-bg: #3a1c1c;
  --ok-bg: #123226;
  --field: #0c1620;
  --field-line: #2c4154;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bar-h: 0px;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(62, 224, 160, 0.10), transparent 30%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.45;
  font-family: var(--font);
  overflow-x: hidden;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
img { max-width: 100%; }
a { color: var(--blue); }
h1, h2, h3 { letter-spacing: -0.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; white-space: nowrap;
}
.skip { position: absolute; left: 12px; top: -48px; background: #fff; color: #071018; padding: 8px 12px; z-index: 50; }
.skip:focus { top: 12px; }

.site-header {
  display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap;
  padding: 8px 16px; background: #050b12; color: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: #fff; text-decoration: none; min-height: 44px; }
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 1.2rem;
}
.brand-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-word { font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; font-size: 1.05rem; }
.brand-product { color: #fff; font-weight: 700; letter-spacing: 0.08em; font-size: 0.78rem; text-transform: uppercase; }
img.brand-logo { background: none; border-radius: 0; object-fit: contain; }
img.brand-wordmark { display: block; height: 16px; width: auto; max-width: 42vw; }
@media (min-width: 900px) { img.brand-wordmark { height: 20px; } }
.header-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.header-nav a { color: #d5e4ff; text-decoration: none; padding: 8px 10px; border-radius: 8px; min-height: 44px; display: inline-flex; align-items: center; }
.header-nav a:hover { background: #13212f; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { color: #9aafc3; font-size: 0.92rem; }

.sample-banner {
  margin: 0; padding: 6px 16px;
  background: var(--bg-raise); border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 0.8rem; line-height: 1.35;
  display: flex; align-items: center; gap: 8px;
}
.sample-banner .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex: 0 0 auto; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 8px; padding: 10px 14px; min-height: 44px;
  font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
}
.button:hover { background: #62ebb4; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-secondary { background: #1c2c3c; color: var(--ink); }
.button-secondary:hover { background: #274058; }
.button-ghost { background: transparent; color: var(--ink); border: 1px solid var(--field-line); }
.button-ghost:hover { background: #13212f; }
.button-block { width: 100%; }
.linkish {
  background: none; border: 0; padding: 0 4px; color: var(--blue); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; min-height: 32px;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 8px; border: 1px solid var(--line); background: #0f1a26;
  color: var(--ink); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: #1c2c3c; }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.remove:hover { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.page { width: min(1200px, 100%); margin: 0 auto; padding: 16px 16px 32px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--accent); font-weight: 700; }
.page-head h1 { margin: 2px 0 0; font-size: 1.7rem; letter-spacing: -0.03em; line-height: 1.15; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.save-state { color: var(--muted); font-size: 0.85rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
  background: #172536; color: #d5e4ff;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-draft { background: #3a2d12; color: #ffe1a8; }
.layout { display: flex; flex-direction: column; gap: 14px; }
.col { display: contents; }
.panel-client { order: 1; } .panel-search { order: 2; } .panel-lines { order: 3; } .panel-notes { order: 4; } .panel-totals { order: 5; }
.panel { scroll-margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-width: 0; }
.panel + .panel { margin-top: 14px; }
.layout .panel + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
.panel h2 { margin: 0 0 8px; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.panel-head h2 { margin: 0; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; background: #1c2c3c; color: var(--ink);
  font-size: 0.8rem; font-weight: 700; flex: 0 0 auto;
}
.tag {
  display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; vertical-align: 1px; white-space: nowrap;
  background: #172536; color: #b9cbe0;
}
.tag-service { background: #1f2440; color: #c9cdfb; }
.tag-notax { background: #2a2428; color: #eadfe2; }
.tag-custom { background: #123226; color: #b8ffdf; }
.tag-monthly { background: #143246; color: #b7e4ff; }
.muted { color: var(--muted); }
.soft { font-weight: 400; font-size: 0.95rem; }
.fine-num { font-size: 0.85rem; }
.tax-hint { font-size: 0.8rem; }
.pkg-list { display: contents; }
.option-static { cursor: default; }
.form-note { background: #123226; color: #b8ffdf; }
.form-note-info { background: #172536; color: #d5e4ff; }
.fine { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }

label.field-label, .field-label { display: block; margin: 0 0 6px; font-weight: 650; font-size: 0.95rem; }
input[type="text"], input[type="search"], input[type="email"], input[type="password"], textarea, select {
  width: 100%; border: 1px solid var(--field-line); border-radius: 8px;
  padding: 10px 12px; min-height: 44px; background: var(--field); color: var(--ink);
  font-size: 16px;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #6f8295; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-wrap input { padding-left: 38px; }
input[type="search"]::-webkit-search-cancel-button { filter: invert(0.7); }

.option-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.option {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); background: #0f1a26; color: inherit;
  border-radius: 10px; padding: 10px 12px; min-height: 52px; cursor: pointer;
}
.option:hover { background: #142434; border-color: rgba(62, 224, 160, 0.35); }
.option-main { flex: 1 1 auto; min-width: 0; }
.option-title { display: block; font-weight: 650; overflow-wrap: anywhere; }
.option-sub { display: block; color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option-price { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.option-add {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ok-bg); color: var(--accent);
}
.option-add svg { width: 18px; height: 18px; }
mark { background: rgba(62, 224, 160, 0.22); color: inherit; border-radius: 3px; padding: 0 1px; }

.client-card { border: 1px solid rgba(62, 224, 160, 0.35); background: #0f1f22; border-radius: 12px; padding: 12px 14px; }
.client-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.client-name { margin: 0; font-weight: 700; font-size: 1.05rem; }
.client-meta { margin: 2px 0 0; color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.property { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
fieldset.property { border: 0; padding: 10px 0 0; min-inline-size: 0; }
.property svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; color: var(--accent); }
.property-label { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.prop-choice { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.prop-choice input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }

.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 10px; padding: 4px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; }
.seg {
  border: 0; background: transparent; color: var(--muted); border-radius: 8px;
  padding: 6px 6px; min-height: 44px; cursor: pointer; font-weight: 650; font-size: 0.95rem; white-space: nowrap;
}
.seg:hover { color: var(--ink); background: #13212f; }
.seg .count { font-weight: 400; opacity: 0.8; margin-left: 2px; font-size: 0.85em; }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.results-meta { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.results { max-height: 420px; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.search-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.search-actions .button { flex: 1 1 auto; }
.pkg-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.pkg-row[hidden] { display: none; }
.pkg-row .field-label { margin: 0; font-size: 0.85rem; color: var(--muted); font-weight: 650; }
.pkg-chip { border: 1px dashed var(--field-line); background: transparent; color: var(--ink); border-radius: 999px; padding: 8px 14px; min-height: 44px; cursor: pointer; }
.pkg-chip:hover { border-color: var(--accent); }
.pkg-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; min-width: 32px; min-height: 44px; }

.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.line { padding: 12px 0; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; padding-top: 4px; }
.line-group { list-style: none; margin: 8px 0 0; padding: 8px 0 0; color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.line-head { display: flex; align-items: flex-start; gap: 8px; }
.line-title { flex: 1 1 auto; min-width: 0; }
.line-name { margin: 0; font-weight: 650; overflow-wrap: anywhere; line-height: 1.3; padding-top: 2px; }
.line-desc { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-tags { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.line-tools { display: flex; gap: 4px; }
.line-controls { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-top: 10px; }
.line-controls > * { min-width: 0; }
.line + .line .mini-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.mini-label { display: block; font-size: 0.72rem; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin: 0 0 4px; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty input { width: 54px; text-align: center; padding: 10px 4px; font-variant-numeric: tabular-nums; }
.money-field { position: relative; }
.money-field span.prefix { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money-field input { width: 100%; min-width: 0; padding-left: 20px; padding-right: 8px; text-align: right; font-variant-numeric: tabular-nums; }
.money-field input.changed { border-color: var(--amber); }
.line-total { text-align: right; min-width: 80px; }
.line-total output { display: block; font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; min-height: 44px; line-height: 44px; white-space: nowrap; }
.price-note { margin: 6px 0 0; font-size: 0.82rem; color: #ffe1a8; }
.line-note { width: 100%; margin-top: 8px; min-height: 72px; }
.billing-seg { grid-template-columns: 1fr 1fr; margin-top: 8px; max-width: 280px; }
.custom-fields { display: grid; gap: 8px; margin-top: 2px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 0.92rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.empty { text-align: center; padding: 22px 12px; color: var(--muted); border: 1px dashed var(--field-line); border-radius: 12px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 2px; }

.totals { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 0; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; padding-left: 12px; text-align: right; font-weight: 650; }
.totals .grand { padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); font-size: 1.3rem; color: var(--ink); font-weight: 800; }
.totals dt.grand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; }
.totals-h { margin: 14px 0 6px; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.monthly-h { margin-top: 16px; }
.tax-note { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }
.actions { display: grid; gap: 8px; margin-top: 14px; }
.actions .button { width: 100%; min-height: 50px; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 8px; margin: 10px 0 0; font-size: 0.92rem; }
.form-error[hidden] { display: none; }

.total-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(5, 11, 18, 0.96); border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.total-bar .tb-sum { flex: 1 1 auto; min-width: 0; line-height: 1.2; }
.total-bar .tb-label { display: block; font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.total-bar .tb-amount { font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.total-bar .button { flex: 0 0 auto; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bar-h) + 12px + env(safe-area-inset-bottom)); z-index: 30;
  background: #e8f0f7; color: #071018; font-weight: 650; font-size: 0.92rem;
  border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
}
.toast.show { opacity: 1; }

dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--card); color: var(--ink);
  width: min(460px, calc(100vw - 24px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(2, 6, 10, 0.72); }
.dlg-body { padding: 20px; }
.dlg-body h2 { margin: 0 0 8px; font-size: 1.25rem; }
.dlg-body p { margin: 0 0 12px; }
.dlg-actions { display: flex; flex-wrap: wrap-reverse; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dlg-actions .button { flex: 1 1 140px; }
.summary-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 10px; }
.summary-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 0.92rem; }
.summary-list li:first-child { border-top: 0; }
.summary-list li span:last-child { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

.auth-wrap { width: min(440px, 100%); margin: 24px auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.auth-wrap h1 { margin: 0 0 8px; }
.stack { display: grid; gap: 12px; margin: 14px 0; }
.quote-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.quote-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.quote-row:hover { border-color: rgba(62, 224, 160, 0.35); }
.quote-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

@media (max-width: 420px) {
  .page { padding: 12px 12px 24px; }
  .panel { padding: 14px; }
  .qty { gap: 2px; }
  .qty input { width: 46px; }
  .line-total output { font-size: 0.98rem; }
  .brand-product { display: none; }
  .who { display: none; }
}
@media (max-width: 374px) {
  .line-controls { grid-template-columns: auto minmax(0, 1fr); }
  .line-total { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .line-total .mini-label { margin: 0; }
  .line-total output { min-height: 0; line-height: 1.3; margin-left: auto; }
}
@media (max-width: 899px) {
  :root { --bar-h: 72px; }
  body { padding-bottom: calc(var(--bar-h) + 28px + env(safe-area-inset-bottom)); }
}
@media (min-width: 900px) {
  .page { padding: 22px 24px 48px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
  .col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
  .col-side { position: sticky; top: 16px; }
  .total-bar { display: none; }
  .results { max-height: max(200px, calc(100vh - 540px)); }
  .col-side .panel-totals { order: -1; }
  .page-head { margin: 0 0 12px; }
  .line-controls { grid-template-columns: auto 140px 1fr; }
  .brand-mark { width: 48px; height: 48px; font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
