:root {
  --wine: #55162d;
  --wine-2: #7c2442;
  --berry: #aa4764;
  --cream: #fffaf5;
  --paper: #ffffff;
  --ink: #2b2024;
  --muted: #776b70;
  --line: #eadfe2;
  --gold: #c99a43;
  --green: #157a55;
  --shadow: 0 18px 60px rgba(62, 21, 37, .10);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; max-width: 100%; overflow-x: hidden; color: var(--ink); background: #f8f3f1; font: 16px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { height: 76px; padding: 0 max(24px, calc((100vw - 1440px)/2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.brand { display: flex; gap: 12px; align-items: center; color: var(--wine); text-decoration: none; letter-spacing: .11em; font-size: 13px; line-height: 1.15; }
.brand-mark { width: 40px; height: 40px; border: 1.5px solid var(--wine); border-radius: 50%; display: grid; place-items: center; font-family: Georgia, serif; font-style: italic; letter-spacing: 0; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 5px; font-weight: 700; font-size: 11px; letter-spacing: .19em; color: var(--berry); }
.topbar-note { color: var(--muted); font-family: Georgia, serif; font-style: italic; display: flex; align-items: center; gap: 9px; }
.topbar-note span { width: 7px; height: 7px; background: var(--gold); border-radius: 50%; }
.app-shell { max-width: 1440px; margin: 0 auto; padding: 28px 24px 52px; }
.intro-card { min-height: 168px; border-radius: 24px; overflow: hidden; background: var(--wine); color: #fff; display: grid; grid-template-columns: 1fr 250px; align-items: center; margin-bottom: 24px; box-shadow: var(--shadow); }
.intro-card > div { padding: 28px 38px; max-width: 860px; }
.intro-card h1 { font: 500 clamp(28px, 3vw, 46px)/1.07 Georgia, serif; margin: 7px 0 10px; letter-spacing: -.025em; }
.intro-card p:last-child { margin: 0; color: #eadce1; }
.intro-card img { width: 100%; height: 100%; min-height: 168px; object-fit: cover; object-position: 50% 43%; mask-image: linear-gradient(to right, transparent, black 32%); }
.eyebrow { margin: 0; color: var(--berry); letter-spacing: .16em; font-weight: 800; font-size: 12px; }
.intro-card .eyebrow { color: #f0b0bf; }
.workspace { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(440px, .9fr); gap: 24px; align-items: start; }
.editor-panel, .preview-panel { width: 100%; min-width: 0; max-width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 12px 40px rgba(54, 24, 35, .055); }
.editor-panel { padding: 30px; }
.preview-panel { padding: 26px; position: sticky; top: 100px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-heading > div { display: flex; align-items: center; gap: 13px; }
.section-heading h2, .preview-top h2 { margin: 0; font: 600 23px/1.2 Georgia, serif; color: var(--wine); }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.step-number { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; display: grid; place-items: center; background: #f5e8ec; color: var(--wine-2); font-weight: 800; font-size: 14px; }
.divider { height: 1px; background: var(--line); margin: 30px 0; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; color: #5f5055; font-size: 14px; font-weight: 700; position: relative; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #ddcfd4; color: var(--ink); background: #fff; border-radius: 10px; padding: 12px 13px; outline: none; transition: .18s ease; font-weight: 500; }
.field textarea { resize: vertical; min-height: 82px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--berry); box-shadow: 0 0 0 3px rgba(170,71,100,.12); }
.field > small { position: absolute; right: 10px; bottom: 7px; color: #a7979d; font-size: 11px; font-weight: 500; }
.upload-field { margin-top: 16px; min-height: 66px; border: 1px dashed #d7bdc6; border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; background: #fffafb; color: var(--wine); cursor: pointer; }
.upload-field input { position: absolute; opacity: 0; pointer-events: none; }
.upload-field strong, .upload-field small { display: block; }
.upload-field small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.upload-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--wine-2); font-size: 22px; font-weight: 300; }
.text-button { margin-left: auto; border: 0; background: none; color: var(--wine-2); font-weight: 800; font-size: 13px; }
.palette-fieldset { border: 0; padding: 0; margin: 22px 0 0; }
.palette-fieldset legend { color: #5f5055; font-size: 14px; font-weight: 800; padding: 0; }
.palette-fieldset > p { margin: 3px 0 12px; color: var(--muted); font-size: 13px; }
.palette-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.palette-option { min-width: 0; padding: 11px; border: 1px solid #e5dadd; border-radius: 12px; background: #fff; cursor: pointer; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.palette-option:hover { transform: translateY(-1px); border-color: #cdb8bf; }
.palette-option:has(input:checked) { border-color: var(--wine-2); box-shadow: 0 0 0 2px rgba(124,36,66,.11); background: #fffafb; }
.palette-option input { position: absolute; opacity: 0; pointer-events: none; }
.palette-option strong, .palette-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-option strong { margin-top: 8px; color: #4a393f; font-size: 12px; }
.palette-option small { color: #8a7d82; font-size: 10px; margin-top: 2px; }
.palette-swatches { display: flex; height: 17px; }
.palette-swatches i { width: 25px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(38,20,26,.16); }
.palette-swatches i + i { margin-left: -6px; }
.palette-swatches i:nth-child(1) { background: var(--swatch-1); }
.palette-swatches i:nth-child(2) { background: var(--swatch-2); }
.palette-swatches i:nth-child(3) { background: var(--swatch-3); }
.custom-colors { margin-top: 10px; padding: 12px 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; background: #faf6f7; border: 1px solid var(--line); border-radius: 12px; }
.custom-colors[hidden] { display: none; }
.custom-colors label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #64565b; font-size: 12px; font-weight: 700; }
.custom-colors input[type="color"] { width: 38px; height: 32px; padding: 2px; border: 1px solid #d9c9ce; border-radius: 8px; background: #fff; cursor: pointer; }
.secondary-button { border: 1px solid #d7bdc6; background: #fffafb; color: var(--wine-2); border-radius: 10px; padding: 10px 13px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.secondary-button:hover { background: #f8e9ee; }
.secondary-button span { font-size: 18px; vertical-align: -1px; margin-right: 3px; }
.items-list { display: grid; gap: 12px; }
.item-card { border: 1px solid var(--line); border-radius: 14px; background: #fffcfc; padding: 14px; display: grid; grid-template-columns: 1.8fr .7fr .85fr auto; gap: 10px; align-items: end; }
.item-card .details { grid-column: 1 / -1; }
.remove-item { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #ead5da; border-radius: 10px; color: #a33b56; background: #fff; }
.remove-item:hover { background: #fff0f3; }
.remove-item svg, .icon-button svg, .actions svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.totals-fields { margin-top: 18px; padding: 17px; border-radius: 14px; background: #f9f2f4; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.money-input, .suffix-input { display: flex; border: 1px solid #ddcfd4; background: #fff; border-radius: 10px; align-items: center; overflow: hidden; }
.money-input b, .suffix-input b { padding: 0 11px; color: #88777d; font-size: 13px; }
.money-input input, .suffix-input input { border: 0 !important; box-shadow: none !important; border-radius: 0; padding-left: 0; }
.preview-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.preview-top .eyebrow { margin-bottom: 3px; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); color: #88757c; background: #fff; border-radius: 10px; }
.budget-card { --card-primary:#55162d;--card-secondary:#a84664;--card-soft:#fbf3f5;--card-accent:#c99a43; position: relative; overflow: hidden; border-radius: 6px; background: #fff; color: #2f2529; border: 1px solid #e8dfe2; box-shadow: 0 12px 30px rgba(45,21,30,.12); padding: 28px; aspect-ratio: 4 / 5; min-height: 610px; display: flex; flex-direction: column; }
.card-accent { height: 8px; background: linear-gradient(90deg, var(--card-primary), var(--card-secondary), var(--card-accent)); position: absolute; inset: 0 0 auto; }
.card-header { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-top: 7px; }
.card-header > *, .client-block > *, .card-items, .card-item > *, .item-table-head > * { min-width: 0; }
.logo-preview { width: 54px; height: 54px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--card-secondary) 38%, white); background: var(--card-soft); color: var(--card-primary); display: grid; place-items: center; overflow: hidden; font: 700 17px Georgia, serif; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.card-brand h3 { margin: 0 0 3px; overflow-wrap: anywhere; color: var(--card-primary); font: 700 18px/1.15 Georgia, serif; }
.card-brand p { margin: 1px 0; color: #7d6f74; font-size: 10px; }
.quote-label { text-align: right; align-self: start; }
.quote-label span { display: block; color: var(--card-secondary); font-size: 9px; letter-spacing: .15em; font-weight: 800; }
.quote-label strong { display: block; color: var(--card-primary); font: 600 16px Georgia, serif; margin-top: 2px; }
.card-rule { height: 1px; background: #eadfe2; margin: 16px 0; }
.client-block { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; background: var(--card-soft); border-radius: 8px; padding: 11px 13px; }
.client-block div:last-child { text-align: right; }
.client-block span, .conditions span { display: block; font-size: 8px; letter-spacing: .13em; color: var(--card-secondary); font-weight: 800; }
.client-block strong, .conditions strong { display: block; margin-top: 3px; font-size: 11px; color: #4c343d; }
.client-block small { display: block; color: #887b80; font-size: 9px; margin-top: 1px; }
.card-items { margin-top: 16px; }
.item-table-head, .card-item { display: grid; grid-template-columns: 1fr 44px 76px; gap: 7px; align-items: center; }
.item-table-head { color: #9a858c; font-size: 8px; font-weight: 800; letter-spacing: .11em; padding: 0 2px 7px; border-bottom: 1px solid #ece4e6; }
.item-table-head span:not(:first-child), .card-item > span { text-align: right; }
.card-item { min-height: 45px; border-bottom: 1px solid #f0e9eb; padding: 7px 2px; font-size: 10px; }
.card-item strong { display: block; color: #43343a; font-size: 10px; }
.card-item small { display: block; overflow-wrap: anywhere; color: #918388; font-size: 8.5px; margin-top: 2px; line-height: 1.2; }
.card-item > span { color: #55454b; font-size: 9.5px; }
.card-summary { width: 56%; margin: 12px 0 0 auto; }
.card-summary > div { display: flex; justify-content: space-between; gap: 15px; padding: 2px 0; color: #74666b; font-size: 9px; }
.card-summary strong { color: #46373d; }
.card-summary .grand-total { margin-top: 5px; padding: 7px 0; border-top: 1px solid #d9c9ce; color: var(--card-primary); font-weight: 800; }
.card-summary .grand-total strong { color: var(--card-primary); font-size: 15px; }
.card-summary .deposit { margin-top: 2px; padding: 6px 8px; background: var(--card-soft); border-radius: 5px; color: var(--card-primary); }
.card-summary .deposit strong { color: var(--card-primary); }
.conditions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; padding-top: 12px; border-top: 1px solid #eadfe2; }
.conditions div:last-child { text-align: right; }
.card-address, .card-notes { margin: 8px 0 0; color: #786a70; font-size: 8.5px; line-height: 1.35; }
.card-notes { font-style: italic; }
.budget-card footer { margin-top: 10px; padding-top: 8px; text-align: center; color: var(--card-secondary); font: italic 9px Georgia, serif; border-top: 1px solid #f0e9eb; }
.actions { display: grid; grid-template-columns: 1.25fr .75fr; gap: 10px; margin-top: 17px; }
.actions button { min-height: 48px; border-radius: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px; }
.primary-button { border: 0; background: var(--green); color: #fff; box-shadow: 0 8px 20px rgba(21,122,85,.18); }
.primary-button:hover { background: #106846; }
.download-button { border: 1px solid #d8c7cc; color: var(--wine); background: #fff; }
.share-hint { margin: 9px 6px 0; color: #897c80; font-size: 11px; text-align: center; }
.mobile-tabs { display: none; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 380px; color: #fff; background: #30252a; padding: 13px 17px; border-radius: 11px; box-shadow: 0 12px 35px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .22s ease; z-index: 50; font-size: 14px; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr 430px; }
  .editor-panel { padding: 24px; }
  .preview-panel { padding: 20px; }
  .budget-card { min-height: 575px; padding: 23px; }
  .intro-card { grid-template-columns: 1fr 210px; }
}
@media (max-width: 860px) {
  .topbar { height: 68px; padding: 0 16px; }
  .topbar-note { display: none; }
  .app-shell { padding: 16px 14px 38px; }
  .intro-card { min-height: 150px; grid-template-columns: 1fr 130px; border-radius: 18px; }
  .intro-card > div { padding: 23px; }
  .intro-card h1 { font-size: 27px; }
  .intro-card p:last-child { font-size: 14px; }
  .intro-card img { min-height: 170px; }
  .mobile-tabs { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: #eadfe2; padding: 4px; border-radius: 12px; margin-bottom: 14px; position: static; z-index: 15; }
  .mobile-tab { min-height: 44px; border: 0; background: transparent; color: #75666c; border-radius: 9px; font-weight: 800; }
  .mobile-tab.active { background: #fff; color: var(--wine); box-shadow: 0 2px 8px rgba(55,20,33,.08); }
  .workspace { width: 100%; min-width: 0; display: block; overflow: hidden; }
  .editor-panel, .preview-panel { border-radius: 17px; }
  .preview-panel { width: 100%; min-width: 0; max-width: 100%; position: static; display: none; overflow: hidden; }
  .budget-card { width: 100%; min-width: 0; max-width: 100%; min-height: 0; aspect-ratio: auto; }
  .conditions { margin-top: 18px; }
  .actions { width: 100%; min-width: 0; }
  body[data-view="preview"] .editor-panel { display: none; }
  body[data-view="preview"] .preview-panel { display: block; }
}
@media (max-width: 560px) {
  .brand { font-size: 11px; }
  .brand-mark { width: 36px; height: 36px; }
  .intro-card { display: block; position: relative; }
  .intro-card > div { position: relative; z-index: 2; padding-right: 26px; background: linear-gradient(90deg, rgba(85,22,45,.98), rgba(85,22,45,.80)); }
  .intro-card h1 { font-size: 25px; }
  .intro-card img { position: absolute; inset: 0 0 0 auto; width: 52%; opacity: .5; mask-image: none; }
  .editor-panel { padding: 20px 16px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .section-heading { align-items: flex-start; }
  .items-heading { display: grid; }
  .items-heading .secondary-button { width: 100%; }
  .item-card { grid-template-columns: 1fr 72px; }
  .item-card .product { grid-column: 1 / -1; }
  .item-card .price { grid-column: 1; }
  .item-card .remove-item { grid-column: 2; }
  .totals-fields { grid-template-columns: 1fr; }
  .palette-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .custom-colors { grid-template-columns: 1fr; }
  .preview-panel { width: 100%; padding: 12px; }
  .budget-card { width: 100%; min-width: 0; max-width: 100%; min-height: 0; aspect-ratio: auto; padding: 17px 14px 15px; }
  .card-header { grid-template-columns: auto 1fr; }
  .quote-label { display: none; }
  .client-block { gap: 8px; padding: 10px; }
  .item-table-head, .card-item { width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr) 38px minmax(68px, 76px); gap: 5px; }
  .card-summary { width: 100%; max-width: 100%; padding-left: 28%; }
  .card-summary > div { min-width: 0; }
  .card-summary strong { white-space: nowrap; }
  .actions { grid-template-columns: 1fr; }
  .toast { left: 14px; right: 14px; bottom: 14px; }
}
@media print {
  body { background: #fff; }
  .topbar, .intro-card, .editor-panel, .preview-top, .actions, .share-hint, .mobile-tabs { display: none !important; }
  .app-shell, .preview-panel { padding: 0; margin: 0; border: 0; box-shadow: none; }
  .workspace { display: block; }
  .budget-card { width: 800px; min-height: 1000px; box-shadow: none; margin: 0 auto; }
}
