/* =========================================================
   Wall Painting & Decorations — Quotation Studio
   Design tokens
   ========================================================= */
:root{
  --ink:        #211d1a;
  --ink-soft:   #4b453e;
  --muted:      #837c72;
  --paper:      #faf7f2;
  --paper-alt:  #f2ede4;
  --line:       #e4dcd0;
  --line-soft:  #ece6db;

  --brand:       #1f4e45;   /* wet-paint pine teal */
  --brand-dark:  #16342e;
  --brand-tint:  #e7efec;

  --clay:        #c1603a;   /* terracotta swatch accent */
  --clay-tint:   #f7e9e1;
  --gold:        #b8975a;

  --ok:          #2f7d52;
  --err:         #b03a2e;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(33,29,26,.05), 0 8px 24px -12px rgba(33,29,26,.18);
  --shadow-2: 0 2px 6px rgba(33,29,26,.08), 0 20px 44px -20px rgba(33,29,26,.28);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family:var(--font-body);
  color:var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--brand-tint), transparent 60%),
    var(--paper-alt);
  min-height:100vh;
}
img{ max-width:100%; display:block; }
button{ font-family:inherit; cursor:pointer; }
input,select,textarea{ font-family:inherit; }
em{ font-style:normal; color:var(--clay); font-size:.78em; }

/* =========================================================
   Buttons
   ========================================================= */
.btn{
  display:inline-flex; align-items:center; gap:6px;
  padding:10px 16px; border-radius:999px; border:1px solid transparent;
  font-size:13.5px; font-weight:600; letter-spacing:.01em;
  transition:transform .12s ease, box-shadow .12s ease, background .15s ease;
  white-space:nowrap;
}
.btn:active{ transform:translateY(1px); }
.btn-primary{ background:var(--brand); color:#fff; box-shadow:var(--shadow-1); }
.btn-primary:hover{ background:var(--brand-dark); }
.btn-ghost{ background:transparent; color:var(--ink-soft); border-color:var(--line); }
.btn-ghost:hover{ background:#fff; border-color:var(--brand); color:var(--brand); }
.btn-outline{ background:#fff; color:var(--brand-dark); border-color:var(--line); }
.btn-outline:hover{ border-color:var(--brand); }
.btn-sm{ padding:7px 12px; font-size:12.5px; }
.btn-danger-text{ background:none; border:none; color:var(--err); font-size:16px; padding:4px 8px; }

/* =========================================================
   Topbar
   ========================================================= */
.topbar{
  position:sticky; top:0; z-index:40;
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 28px;
  background:rgba(250,247,242,.88);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}
.topbar-left{ display:flex; align-items:center; gap:12px; }
.brand-mark{ width:38px; height:38px; object-fit:contain; border-radius:8px; }
.brand-text{ display:flex; flex-direction:column; line-height:1.2; }
.brand-name{ font-family:var(--font-display); font-weight:600; font-size:16.5px; }
.brand-sub{ font-size:11.5px; color:var(--muted); letter-spacing:.08em; text-transform:uppercase; }
.topbar-right{ display:flex; align-items:center; gap:10px; }
.save-status{ font-size:12px; color:var(--ok); font-weight:600; display:flex; align-items:center; gap:5px; }
.save-status::before{ content:''; width:6px; height:6px; border-radius:50%; background:var(--ok); }
.save-status.saving{ color:var(--muted); }
.save-status.saving::before{ background:var(--muted); }

/* =========================================================
   Mobile tabs
   ========================================================= */
.mobile-tabs{ display:none; }
.tab-btn{
  flex:1; padding:12px; background:#fff; border:none; border-bottom:2px solid var(--line);
  font-weight:600; color:var(--muted); font-size:13.5px;
}
.tab-btn.active{ color:var(--brand-dark); border-bottom-color:var(--clay); }

/* =========================================================
   App grid
   ========================================================= */
.app-grid{
  display:grid;
  grid-template-columns: minmax(360px, 480px) 1fr;
  gap:24px;
  padding:24px 28px 80px;
  align-items:start;
}
.form-panel{ display:flex; flex-direction:column; gap:16px; }
.preview-panel{ position:sticky; top:78px; display:flex; flex-direction:column; gap:12px; }

/* =========================================================
   Cards
   ========================================================= */
.card{
  background:#fff; border:1px solid var(--line);
  border-radius:var(--radius-lg); padding:20px 20px 22px;
  box-shadow:var(--shadow-1);
}
.card-head{ display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.card-head h2{ font-family:var(--font-display); font-size:16.5px; font-weight:600; margin:0; }
.swatch{
  width:11px; height:11px; border-radius:3px; flex:none;
  background: var(--sw-color, var(--brand));
  box-shadow:0 0 0 3px var(--sw-tint, var(--brand-tint));
}
.card[data-swatch="1"] .swatch{ --sw-color:#1f4e45; --sw-tint:#e7efec; }
.card[data-swatch="2"] .swatch{ --sw-color:#c1603a; --sw-tint:#f7e9e1; }
.card[data-swatch="3"] .swatch{ --sw-color:#b8975a; --sw-tint:#f4ecdd; }
.card[data-swatch="4"] .swatch{ --sw-color:#3d6b78; --sw-tint:#e6eef0; }
.card[data-swatch="5"] .swatch{ --sw-color:#1f4e45; --sw-tint:#e7efec; }
.card[data-swatch="6"] .swatch{ --sw-color:#c1603a; --sw-tint:#f7e9e1; }
.card[data-swatch="7"] .swatch{ --sw-color:#b8975a; --sw-tint:#f4ecdd; }
.card[data-swatch="8"] .swatch{ --sw-color:#3d6b78; --sw-tint:#e6eef0; }
.card[data-swatch="9"] .swatch{ --sw-color:#1f4e45; --sw-tint:#e7efec; }
.card[data-swatch="10"] .swatch{ --sw-color:#c1603a; --sw-tint:#f7e9e1; }

.hint-text{ font-size:12px; color:var(--muted); line-height:1.55; margin:-4px 0 14px; }

.input-with-btn{ display:flex; gap:6px; }
.input-with-btn input{ flex:1; }
.btn-mini{
  flex:none; width:38px; border-radius:8px; border:1px solid var(--line);
  background:var(--paper); font-size:15px; color:var(--brand-dark);
  display:flex; align-items:center; justify-content:center;
  transition:border-color .12s ease, background .12s ease, transform .5s ease;
}
.btn-mini:hover{ border-color:var(--brand); background:#fff; }
.btn-mini:active{ transform:rotate(180deg); }

.field-grid{ display:grid; grid-template-columns:1fr 1fr; gap:14px 16px; }
.field{ display:flex; flex-direction:column; gap:6px; font-size:12.5px; font-weight:600; color:var(--ink-soft); }
.field-wide{ grid-column:1 / -1; }
.field input, .field select, .field textarea{
  font-size:14px; font-weight:400; color:var(--ink);
  padding:10px 12px; border:1px solid var(--line); border-radius:var(--radius-sm);
  background:var(--paper); outline:none; resize:vertical;
  transition:border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.field input:focus, .field select:focus, .field textarea:focus{
  border-color:var(--brand); background:#fff; box-shadow:0 0 0 3px var(--brand-tint);
}
.field input.invalid, .field textarea.invalid{ border-color:var(--err); background:#fdf2f0; }
.err{ display:none; color:var(--err); font-weight:600; font-size:11.5px; }
.err.show{ display:block; }

/* =========================================================
   Items editor table
   ========================================================= */
.table-scroll{ overflow-x:auto; margin:0 -4px 12px; }
.items-editor{ border-collapse:collapse; width:100%; min-width:760px; font-size:13px; }
.items-editor th{
  text-align:left; font-size:10.5px; letter-spacing:.06em; text-transform:uppercase;
  color:var(--muted); font-weight:700; padding:0 8px 8px; border-bottom:1px solid var(--line);
}
.items-editor td{ padding:5px 8px; vertical-align:middle; }
.items-editor tbody tr{ border-bottom:1px solid var(--line-soft); }
.items-editor input, .items-editor select{
  width:100%; padding:8px 9px; border:1px solid var(--line); border-radius:7px;
  background:var(--paper); font-size:13px; outline:none;
}
.items-editor input:focus, .items-editor select:focus{ border-color:var(--brand); background:#fff; }
.items-editor .col-qty input, .items-editor .col-price input, .items-editor .col-disc input{ text-align:right; }
.items-editor .col-drag{ width:16px; color:var(--muted); cursor:grab; text-align:center; }
.items-editor .col-total{ width:100px; text-align:right; font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap; }
.items-editor .col-del{ width:30px; }
.items-editor .col-item{ min-width:150px; } .items-editor .col-desc{ min-width:160px; }
.items-editor .col-unit{ min-width:88px; } .items-editor .col-qty{ width:64px; } .items-editor .col-price{ width:104px; } .items-editor .col-disc{ width:70px; }

/* =========================================================
   Wizard (multi-step form)
   ========================================================= */
.wizard-nav{ margin-bottom:2px; }
.wizard-steps{
  display:flex; align-items:center; gap:2px;
  background:#fff; border:1px solid var(--line); border-radius:999px;
  padding:6px; box-shadow:var(--shadow-1); overflow-x:auto;
}
.wstep{
  display:flex; align-items:center; gap:7px; background:none; border:none;
  padding:7px 12px; border-radius:999px; font-size:12.5px; font-weight:600;
  color:var(--muted); white-space:nowrap; transition:background .15s ease, color .15s ease;
}
.wstep:hover{ background:var(--paper); }
.wstep .wnum{
  width:21px; height:21px; border-radius:50%; background:var(--line-soft); color:var(--ink-soft);
  display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; flex:none;
  transition:background .15s ease, color .15s ease;
}
.wstep.active{ color:var(--brand-dark); background:var(--brand-tint); }
.wstep.active .wnum{ background:var(--brand); color:#fff; }
.wstep.done .wnum{ background:var(--clay); color:#fff; }
.wstep.done{ color:var(--ink-soft); }

.step{ display:none; flex-direction:column; gap:16px; }
.step.active{ display:flex; }

.wizard-controls{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#fff; border:1px solid var(--line); border-radius:var(--radius-md);
  padding:12px 16px; box-shadow:var(--shadow-1);
}
.wizard-controls #wizBack:disabled{ visibility:hidden; }
.wizard-progress-text{ font-size:12px; color:var(--muted); font-weight:600; }

/* =========================================================
   Editable list (Terms & Conditions)
   ========================================================= */
.editable-list{ list-style:none; margin:0 0 12px; padding:0; display:flex; flex-direction:column; gap:8px; }
.editable-list li{ display:flex; align-items:flex-start; gap:8px; }
.editable-list .term-num{ font-family:var(--font-mono); font-size:12px; color:var(--clay); font-weight:600; padding-top:10px; flex:none; width:18px; }
.editable-list textarea{
  flex:1; padding:9px 11px; border:1px solid var(--line); border-radius:var(--radius-sm);
  background:var(--paper); font-size:13.5px; resize:vertical; min-height:38px; outline:none;
}
.editable-list textarea:focus{ border-color:var(--brand); background:#fff; }

/* =========================================================
   Preview panel / toolbar
   ========================================================= */
.preview-toolbar{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  background:#fff; border:1px solid var(--line); border-radius:var(--radius-md);
  padding:12px 16px; box-shadow:var(--shadow-1); flex-wrap:wrap;
}
.preview-toolbar-left{ display:flex; flex-direction:column; line-height:1.3; }
.preview-toolbar-left strong{ font-family:var(--font-display); font-size:15px; }
.preview-toolbar-left .hint{ font-size:11.5px; color:var(--muted); }
.preview-toolbar-right{ display:flex; gap:8px; flex-wrap:wrap; }

.a4-stage{
  display:flex; justify-content:center;
  background: repeating-linear-gradient(45deg, #efe9de 0 2px, transparent 2px 14px);
  border-radius:var(--radius-lg); padding:26px; border:1px solid var(--line);
}

/* =========================================================
   A4 Document
   ========================================================= */
.a4-page{
  width:210mm; min-height:297mm;
  background:#fffdfa;
  box-shadow:var(--shadow-2);
  padding:16mm 15mm 14mm;
  font-family:var(--font-body);
  color:var(--ink);
  position:relative;
}

.doc-header{ display:flex; justify-content:space-between; align-items:flex-start; gap:16px; padding-bottom:14px; border-bottom:2px solid var(--brand); }
.doc-header-left{ display:flex; align-items:center; gap:12px; }
.doc-logo{ width:52px; height:52px; object-fit:contain; }
.doc-company{ font-family:var(--font-display); font-weight:700; font-size:21px; color:var(--brand-dark); }
.doc-tagline{ font-size:10px; color:var(--muted); margin-top:2px; letter-spacing:.02em; }
.doc-header-right{ text-align:right; }
.doc-quote-label{ font-family:var(--font-display); font-size:22px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--clay); }
.brush-underline{ width:150px; height:10px; margin:2px 0 6px auto; display:block; }
.brush-underline path{ stroke:var(--clay); stroke-width:3; opacity:.55; }
.doc-meta{ font-size:11px; display:flex; justify-content:flex-end; gap:6px; color:var(--muted); }
.doc-meta span{ min-width:70px; text-align:left; }
.doc-meta strong{ color:var(--ink); font-family:var(--font-mono); font-weight:600; }

.doc-parties{ display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:16px; }
.doc-party{ background:var(--paper); border:1px solid var(--line); border-radius:10px; padding:12px 14px; }
.doc-party-label{ font-size:10px; letter-spacing:.1em; text-transform:uppercase; font-weight:700; color:var(--brand); margin-bottom:6px; }
.doc-party-name{ font-weight:700; font-size:14px; margin-bottom:2px; }
.doc-party-line{ font-size:11.5px; color:var(--ink-soft); display:flex; gap:6px; line-height:1.6; }
.doc-party-line span{ color:var(--muted); min-width:76px; flex:none; }

.doc-project-desc{ margin-top:14px; }
.doc-section-label{ font-size:10.5px; letter-spacing:.09em; text-transform:uppercase; font-weight:700; color:var(--brand); margin-bottom:5px; }
.doc-project-desc p{ margin:0 0 6px; font-size:12px; color:var(--ink-soft); line-height:1.55; }
.doc-project-extra{ display:flex; gap:16px; font-size:11px; color:var(--muted); flex-wrap:wrap; }
.doc-project-extra b{ color:var(--ink); font-weight:600; }

table.doc-items{ width:100%; border-collapse:collapse; margin-top:16px; font-size:11.5px; }
.doc-items thead th{
  background:var(--brand-dark); color:#fff; text-align:right; padding:8px 9px;
  font-size:10px; letter-spacing:.06em; text-transform:uppercase; font-weight:600;
}
.doc-items thead th.ta-l{ text-align:left; }
.doc-items tbody td{ padding:8px 9px; border-bottom:1px solid var(--line-soft); text-align:right; vertical-align:top; break-inside:avoid; }
.doc-items tbody td.ta-l{ text-align:left; }
.doc-items tbody tr:nth-child(even){ background:#faf7f1; }
.doc-item-name{ font-weight:600; }
.doc-item-desc{ font-size:10.5px; color:var(--muted); margin-top:1px; }
.doc-items tbody td.ta-r{ text-align:right; font-weight:600; }

.doc-totals-wrap{ display:flex; justify-content:flex-end; margin-top:10px; break-inside:avoid; }
.doc-totals{ width:58%; min-width:230px; }
.tot-row{ display:flex; justify-content:space-between; padding:6px 4px; font-size:12px; color:var(--ink-soft); border-bottom:1px dashed var(--line); }
.tot-row strong{ font-variant-numeric:tabular-nums; color:var(--ink); font-weight:600; }
.tot-grand{ margin-top:6px; padding:10px 12px; background:var(--brand-dark); color:#fff; border-radius:8px; border-bottom:none; }
.tot-grand span{ font-weight:700; text-transform:uppercase; font-size:11.5px; letter-spacing:.05em; }
.tot-grand strong{ color:#fff; font-size:16px; }

.doc-words{ margin-top:10px; font-size:11.5px; background:var(--clay-tint); border-left:3px solid var(--clay); padding:8px 12px; border-radius:6px; break-inside:avoid; }
.doc-words span{ font-weight:700; color:var(--clay); margin-right:5px; }
.doc-words em{ color:var(--ink-soft); font-style:italic; }

.doc-two-col{ display:grid; grid-template-columns:1fr 1.3fr; gap:18px; margin-top:16px; break-inside:avoid; }
.doc-two-col p{ font-size:11.5px; color:var(--ink-soft); margin:0; line-height:1.6; }
.doc-two-col ol{ margin:0; padding-left:16px; font-size:10.8px; color:var(--ink-soft); line-height:1.65; }
.doc-two-col li{ margin-bottom:3px; }

.doc-notes{ margin-top:14px; padding-top:10px; border-top:1px solid var(--line); break-inside:avoid; }
.doc-notes p{ font-size:11.5px; font-style:italic; color:var(--ink-soft); margin:0; }

.doc-signatures{ display:grid; grid-template-columns:1fr 1fr; gap:40px; margin-top:34px; break-inside:avoid; }
.sig-block{ text-align:center; }
.sig-space{ height:34px; }
.sig-line{ border-top:1px solid var(--ink); margin-top:4px; }
.sig-caption{ font-size:10px; letter-spacing:.08em; text-transform:uppercase; color:var(--brand); font-weight:700; margin-top:6px; }
.sig-name{ font-size:11.5px; margin-top:10px; color:var(--ink-soft); }
.sig-date{ font-size:11.5px; margin-top:6px; color:var(--ink-soft); }

/* Premium footer band */
.doc-footer{
  position:absolute; left:15mm; right:15mm; bottom:9mm;
  border-radius:11px; overflow:hidden;
  box-shadow:0 6px 18px -8px rgba(22,52,46,.4);
}
.doc-footer-bar{ height:3px; background:linear-gradient(90deg, var(--clay), var(--gold) 55%, var(--clay)); }
.doc-footer-content{
  display:flex; align-items:center; gap:12px;
  background:var(--brand-dark); color:#fff; padding:9px 16px;
}
.doc-footer-logo{ width:24px; height:24px; object-fit:contain; border-radius:6px; background:#fff; padding:3px; flex:none; }
.doc-footer-text{ flex:1; text-align:left; line-height:1.35; }
.doc-footer-brand{ font-family:var(--font-display); font-weight:600; font-size:11.5px; color:#fff; }
.doc-footer-contact{ font-size:9px; color:#d7e3df; margin-top:1px; letter-spacing:.01em; }
.doc-footer-thanks{ font-size:9px; font-style:italic; color:var(--gold); text-align:right; line-height:1.3; flex:none; }

/* =========================================================
   Toast
   ========================================================= */
.toast{
  position:fixed; bottom:24px; left:50%; transform:translate(-50%,20px);
  background:var(--ink); color:#fff; padding:10px 18px; border-radius:999px;
  font-size:13px; font-weight:600; opacity:0; pointer-events:none;
  transition:opacity .25s ease, transform .25s ease; z-index:100; box-shadow:var(--shadow-2);
}
.toast.show{ opacity:1; transform:translate(-50%,0); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1080px){
  .app-grid{ grid-template-columns:1fr; }
  .preview-panel{ position:static; }
  .a4-stage{ overflow-x:auto; }
}
@media (max-width: 760px){
  .mobile-tabs{ display:flex; position:sticky; top:0; z-index:39; }
  .topbar{ padding:10px 16px; flex-wrap:wrap; gap:8px; }
  .brand-sub{ display:none; }
  .app-grid{ padding:14px; gap:14px; }
  .field-grid{ grid-template-columns:1fr; }
  [data-panel]{ display:none; }
  [data-panel].active-panel{ display:flex; }
  .preview-panel.active-panel{ display:flex; }
  .a4-stage{ padding:10px; overflow-x:auto; }
  .a4-page{ transform-origin:top left; }
  .card{ padding:16px 16px 18px; }

  .wstep .wlabel{ display:none; }
  .wstep{ padding:8px; }
  .wizard-steps{ justify-content:space-between; }
  .wizard-controls{ position:sticky; bottom:0; z-index:20; margin-top:2px; }
  .doc-parties, .doc-two-col{ grid-template-columns:1fr; }
  .doc-signatures{ gap:20px; }
  .preview-toolbar{ flex-direction:column; align-items:stretch; }
  .preview-toolbar-right{ justify-content:stretch; }
  .preview-toolbar-right .btn{ flex:1; justify-content:center; }
}
@media (max-width: 420px){
  .a4-page{ transform:scale(0.82); margin-bottom:-52mm; }
}

/* =========================================================
   PRINT
   ========================================================= */
@media print{
  @page{ size:A4; margin:0; }
  html,body{ background:#fff !important; height:auto; }
  .no-print, .topbar, .mobile-tabs, .preview-toolbar{ display:none !important; }
  .app-grid{ display:block !important; padding:0; margin:0; }
  .form-panel{ display:none !important; }
  .preview-panel{ position:static; display:block; }
  .a4-stage{ background:none; border:none; padding:0; display:block; }
  .a4-page{
    width:210mm; min-height:297mm; box-shadow:none; margin:0 auto;
    padding:14mm 15mm 16mm;
  }
  .doc-items{ break-inside:auto; }
  .doc-items thead{ display:table-header-group; }
  .doc-items tbody tr{ break-inside:avoid; }
  .doc-signatures{ break-inside:avoid; }
  .doc-footer{ position:fixed; bottom:6mm; left:15mm; right:15mm; }
  a{ color:inherit; text-decoration:none; }
}
