:root {
  --ink: #172033;
  --ink-2: #3d4659;
  --muted: #778197;
  --line: #e7eaf0;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --nav: #0d1321;
  --nav-soft: #161f34;
  --brand: #5b5df0;
  --brand-dark: #4648d5;
  --brand-soft: #eeeeff;
  --green: #16835a;
  --green-soft: #e7f7f0;
  --amber: #a86700;
  --amber-soft: #fff4d7;
  --red: #c3424e;
  --red-soft: #ffebee;
  --blue: #3574d4;
  --blue-soft: #eaf2ff;
  --shadow: 0 12px 40px rgba(35, 46, 72, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; background: var(--nav); color: #fff; padding: 28px 20px 22px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.brand strong { font-size: 17px; letter-spacing: -0.02em; }
.brand small { color: #8490aa; font-size: 11px; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px; display: inline-grid; place-items: center; color: #fff; background: linear-gradient(145deg, #7476ff, #4c4ed8); font-size: 13px; font-weight: 800; letter-spacing: .06em; box-shadow: 0 8px 20px rgba(91,93,240,.35); }
.brand-mark.small { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; font-size: 10px; }
.nav-list { display: grid; gap: 7px; }
.nav-list a { display: flex; align-items: center; gap: 12px; padding: 12px 13px; color: #aeb8cc; border-radius: 11px; font-size: 14px; font-weight: 650; transition: .18s ease; }
.nav-list a:hover { background: #121b2e; color: #fff; }
.nav-list a.active { background: var(--nav-soft); color: #fff; box-shadow: inset 3px 0 var(--brand); }
.nav-icon { width: 20px; text-align: center; color: #8894ae; font-size: 17px; }
.nav-list a.active .nav-icon { color: #a8a9ff; }
.sidebar-card { margin-top: auto; padding: 16px; background: #121a2d; border: 1px solid #202a40; border-radius: 14px; }
.sidebar-card-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: #1f755a; margin-bottom: 10px; font-size: 12px; }
.sidebar-card strong { font-size: 12px; }
.sidebar-card p { margin: 7px 0 0; color: #8792aa; font-size: 11px; line-height: 1.55; }
.sidebar-footer { padding: 20px 8px 0; color: #748099; font-size: 11px; display: flex; align-items: center; gap: 7px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #37c993; box-shadow: 0 0 0 4px rgba(55,201,147,.08); }

.main-content { margin-left: 248px; min-height: 100vh; }
.view { width: min(1360px, 100%); margin: 0 auto; padding: 44px 46px 70px; }
.mobile-bar { display: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading.compact { align-items: center; }
.page-heading h1 { margin: 3px 0 6px; font-size: clamp(27px, 3vw, 36px); letter-spacing: -.045em; line-height: 1.08; }
.page-heading p { margin: 0; }
.eyebrow { color: var(--brand); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.subtle { color: var(--muted); font-size: 14px; line-height: 1.55; }
.heading-actions { display: flex; gap: 10px; }
.back-link { border: 0; background: transparent; padding: 0 0 8px; color: var(--muted); font-weight: 650; font-size: 12px; }
.back-link:hover { color: var(--brand); }

.button { border: 1px solid transparent; min-height: 42px; padding: 0 16px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 750; font-size: 13px; transition: .16s ease; }
.button.primary { color: #fff; background: var(--brand); box-shadow: 0 8px 20px rgba(91,93,240,.18); }
.button.primary:hover { background: var(--brand-dark); transform: translateY(-1px); }
.button.ghost { color: var(--ink-2); background: #fff; border-color: #dfe3eb; }
.button.ghost:hover { border-color: #c9cfdb; background: #fafbfe; }
.button.small { min-height: 34px; padding: 0 11px; font-size: 11px; border-radius: 8px; }
.button.full { width: 100%; margin-top: 10px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.metric-card { min-width: 0; display: flex; align-items: center; gap: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 15px rgba(35,46,72,.025); }
.metric-icon { width: 39px; height: 39px; flex: 0 0 39px; display: grid; place-items: center; border-radius: 11px; background: var(--brand-soft); color: var(--brand); font-weight: 850; }
.metric-card > div:last-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.metric-card span { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-card strong { font-size: 23px; letter-spacing: -.035em; overflow: hidden; text-overflow: ellipsis; }
.metric-card small { color: #9aa2b3; font-size: 10px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 18px rgba(35,46,72,.03); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .form-panel h2 { margin: 0 0 3px; font-size: 16px; letter-spacing: -.02em; }
.panel-heading p, .form-panel p { margin: 0; color: var(--muted); font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 18px; background: #fbfcfe; color: #8b94a7; text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .09em; border-bottom: 1px solid var(--line); }
td { padding: 15px 18px; border-bottom: 1px solid #eef0f4; font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.money { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 750; }
.customer-cell { display: flex; flex-direction: column; gap: 3px; }
.customer-cell span { color: var(--muted); font-size: 10px; }
.link-button { border: 0; background: none; padding: 0; color: var(--brand); }
.link-button:hover { text-decoration: underline; }
.actions-cell { white-space: nowrap; text-align: right; }
.icon-button { width: 31px; height: 31px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); margin-left: 2px; }
.icon-button:hover { background: #f0f2f7; color: var(--ink); }
.icon-button.danger:hover { background: var(--red-soft); color: var(--red); }
.status { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; letter-spacing: .02em; }
.status-draft { color: #667085; background: #eef1f5; }
.status-sent { color: var(--blue); background: var(--blue-soft); }
.status-accepted { color: var(--green); background: var(--green-soft); }
.status-declined { color: var(--red); background: var(--red-soft); }
.empty-state { padding: 58px 20px; text-align: center; }
.empty-icon { width: 48px; height: 48px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 14px; background: var(--brand-soft); color: var(--brand); font-size: 22px; }
.empty-state h3 { margin: 0 0 5px; font-size: 15px; }
.empty-state p { max-width: 390px; margin: 0 auto 17px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.editor-main { display: grid; gap: 18px; }
.form-panel { padding: 22px; }
.section-title { display: flex; gap: 11px; align-items: center; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid #eef0f4; }
.step { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 10px; font-weight: 850; }
.form-grid { display: grid; gap: 15px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; display: grid; gap: 6px; }
.field > span, .line-total > span { color: #566074; font-size: 10px; font-weight: 750; }
input, select, textarea { width: 100%; border: 1px solid #dfe3eb; border-radius: 9px; background: #fff; color: var(--ink); outline: none; transition: .15s ease; }
input, select { height: 40px; padding: 0 11px; }
textarea { resize: vertical; padding: 10px 11px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #9c9df8; box-shadow: 0 0 0 3px rgba(91,93,240,.08); }
input::placeholder, textarea::placeholder { color: #b4bbc8; }
.has-error input { border-color: #e18b93; background: #fffafb; }
.has-error-box { border: 1px solid #efb5bb !important; padding: 12px; border-radius: 12px; }
.money-input { position: relative; }
.money-input b { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #8a93a5; font-size: 11px; }
.money-input input { padding-left: 24px; }
.line-items-wrap { margin-top: 22px; border-top: 1px solid #eef0f4; padding-top: 18px; }
.line-items-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.line-items-heading h3 { margin: 0; font-size: 12px; }
.line-item { display: grid; grid-template-columns: minmax(180px, 2fr) 75px 120px 105px 30px; gap: 9px; align-items: end; padding: 10px 0; border-bottom: 1px solid #f0f2f5; }
.line-item:last-of-type { border-bottom: 0; }
.line-total { min-height: 40px; display: grid; align-content: center; gap: 5px; text-align: right; }
.line-total strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.remove-item { width: 30px; height: 40px; border: 0; background: transparent; color: #a1a9b8; border-radius: 8px; font-size: 18px; }
.remove-item:hover { background: var(--red-soft); color: var(--red); }
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 13px; max-width: 510px; margin: 18px 0 0 auto; }
.editor-sidebar { min-width: 0; }
.sticky-card { position: sticky; top: 24px; }
.summary-card { padding: 20px; }
.summary-brand { display: flex; align-items: center; gap: 10px; padding-bottom: 17px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.summary-brand > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.summary-brand strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.summary-brand small { color: var(--muted); font-size: 9px; }
.summary-row, .summary-total { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 11px; }
.summary-row span { color: var(--muted); }
.summary-row.muted strong { color: #667085; }
.summary-total { margin: 8px 0 12px; padding: 14px 0 0; border-top: 1px solid var(--line); align-items: baseline; }
.summary-total span { font-weight: 800; }
.summary-total strong { color: var(--brand); font-size: 23px; letter-spacing: -.04em; }
.autosave-note { margin: 12px 0 0 !important; text-align: center; color: #9aa2b3 !important; font-size: 9px !important; line-height: 1.45; }
.alert { display: flex; align-items: center; gap: 9px; margin: -10px 0 16px; padding: 12px 14px; border-radius: 10px; font-size: 11px; }
.alert.error { color: #9d303b; background: var(--red-soft); border: 1px solid #f4c6cb; }
.alert span { color: #b44b55; }

.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.preview-toolbar > div { display: flex; gap: 9px; }
.quote-document { max-width: 940px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 5px; box-shadow: var(--shadow); padding: 50px 54px 36px; }
.document-header { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 32px; border-bottom: 2px solid var(--ink); }
.document-brand { display: flex; align-items: center; gap: 14px; }
.document-logo { width: 48px; height: 48px; flex-basis: 48px; border-radius: 12px; }
.document-brand h2 { margin: 0 0 5px; font-size: 16px; }
.document-brand p { margin: 2px 0; color: var(--muted); font-size: 9px; }
.document-title { text-align: right; }
.document-title h1 { margin: 8px 0 2px; font-size: 31px; letter-spacing: .08em; font-weight: 300; }
.document-title > strong { font-size: 10px; color: var(--muted); }
.document-meta { display: flex; justify-content: space-between; gap: 30px; padding: 28px 0 25px; }
.document-meta > div:first-child { max-width: 50%; }
.document-meta span, .document-notes span { color: #939bac; font-size: 8px; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.document-meta h3 { margin: 6px 0; font-size: 14px; }
.document-meta p { margin: 3px 0; color: var(--muted); font-size: 9px; }
.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.date-grid > div { display: flex; flex-direction: column; gap: 7px; text-align: right; }
.date-grid strong { font-size: 10px; }
.document-table-wrap { overflow-x: auto; }
.document-table th { background: var(--ink); color: #fff; border: 0; padding: 10px 12px; }
.document-table td { padding: 13px 12px; font-size: 10px; }
.document-table tbody tr:hover { background: transparent; }
.document-bottom { display: grid; grid-template-columns: 1fr 280px; gap: 40px; padding: 28px 0; }
.document-notes { display: grid; align-content: start; gap: 18px; }
.document-notes p { margin: 6px 0 0; color: #626c7f; font-size: 9px; line-height: 1.55; }
.document-totals { display: grid; align-content: start; }
.document-totals > div { display: flex; justify-content: space-between; padding: 7px 0; color: #6e7789; font-size: 10px; }
.document-totals .grand-total { border-top: 1px solid #cfd4de; margin-top: 5px; padding-top: 12px; color: var(--ink); align-items: baseline; font-weight: 800; }
.document-totals .grand-total strong { font-size: 20px; color: var(--brand); }
.document-footer { display: flex; justify-content: space-between; gap: 20px; padding-top: 20px; border-top: 1px solid var(--line); color: #9aa2b2; font-size: 8px; }
.document-footer p { margin: 0; }

.settings-layout { max-width: 860px; display: grid; gap: 18px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 9px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 10px; box-shadow: 0 12px 30px rgba(14,22,39,.25); font-size: 11px; font-weight: 700; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1080px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-sidebar { order: -1; }
  .sticky-card { position: static; }
  .summary-card { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 16px; align-items: center; }
  .summary-brand { grid-column: 1 / -1; }
  .summary-total { margin: 0; padding-top: 7px; border-top: 0; }
  .summary-card .button, .autosave-note { display: none; }
}

@media (max-width: 780px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .mobile-bar { height: 62px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .mobile-brand { padding: 0; }
  .view { padding: 28px 18px 50px; }
  .page-heading { align-items: flex-start; }
  .page-heading > .button { display: none; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 15px; }
  .metric-card strong { font-size: 18px; }
  .panel-heading .button { display: none; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: minmax(0, 1fr) 70px 100px 30px; }
  .line-total { display: none; }
  .pricing-grid { grid-template-columns: 1fr; max-width: none; }
  .summary-card { grid-template-columns: repeat(2, 1fr); }
  .summary-brand { grid-column: 1 / -1; }
  .quote-document { padding: 30px 24px; }
  .document-header, .document-meta { flex-direction: column; }
  .document-title, .date-grid > div { text-align: left; }
  .document-meta > div:first-child { max-width: none; }
  .document-bottom { grid-template-columns: 1fr; gap: 25px; }
}

@media (max-width: 520px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card { padding: 14px 16px; }
  .page-heading h1 { font-size: 27px; }
  .heading-actions .ghost { display: none; }
  .line-item { grid-template-columns: minmax(0, 1fr) 64px 30px; }
  .item-rate { grid-column: 1 / 3; }
  .remove-item { grid-column: 3; grid-row: 1 / 3; align-self: center; }
  .preview-toolbar { align-items: flex-start; }
  .preview-toolbar .ghost { display: none; }
  .quote-document { margin-inline: -8px; padding: 24px 18px; }
  .date-grid { grid-template-columns: 1fr; gap: 14px; }
  .document-table { min-width: 560px; }
}

@media print {
  @page { size: letter; margin: 0.45in; }
  body { background: #fff; }
  .no-print, .sidebar, .mobile-bar, .toast { display: none !important; }
  .main-content { margin: 0; }
  .view { width: 100%; margin: 0; padding: 0; }
  .quote-document { max-width: none; border: 0; box-shadow: none; padding: 0; }
  .document-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .status, .brand-mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
