:root {
  --bg: #0b0a09; --bg2: #13110f; --card: #1a1714; --line: #2c2722; --text: #f3ede4; --muted: #a39a8e;
  --gold: #d4a64a; --gold2: #f0cf85; --green: #3fb27f; --red: #e0645a; --blue: #5aa3e0; --amber: #e0a33f;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --serif: 'Playfair Display', Georgia, serif; --sans: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold2); text-decoration: none; }
img, video { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0 0 .5em; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #2a251f; color: var(--muted); white-space: nowrap; }
.pill.draft { background: #2a2a2a; color: #cfcfcf; } .pill.sent { background: #1c2c3d; color: var(--blue); }
.pill.lead { background: #3a2c14; color: var(--amber); } .pill.sale { background: #15301f; color: var(--green); }
.pill.new { background: #3a1616; color: #ff9b91; } .pill.void { background: #222; color: #777; text-decoration: line-through; }

/* buttons & inputs */
.btn { appearance: none; border: 1px solid var(--line); background: #221e1a; color: var(--text); padding: 10px 16px; border-radius: 10px; font: 600 14px var(--sans); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: linear-gradient(135deg, var(--gold), #b8872c); color: #1a1205; border: 0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wa { background: #1fa855; color: #fff; border: 0; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
input, select, textarea { width: 100%; background: #100e0c; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 15px var(--sans); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 12px; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* toast & modal */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2b241b; border: 1px solid var(--gold); color: var(--text); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 1000; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 900; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; width: min(860px, 100%); padding: 20px; box-shadow: var(--shadow); position: relative; }
.modal .x { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; }

/* ---------- invoice document (always light, prints well) ---------- */
.doc { background: #fff; color: #1d1a16; font: 13px/1.5 var(--sans); padding: 36px; border-radius: 6px; width: 794px; max-width: 100%; margin: 0 auto; }
.doc h1 { font-family: var(--serif); font-size: 30px; margin: 0; color: #111; letter-spacing: .02em; }
.doc .head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid #c79a3b; padding-bottom: 16px; margin-bottom: 18px; }
.doc .tag { color: #8b6a26; font-size: 12px; }
.doc .title { font-family: var(--serif); font-size: 26px; color: #c79a3b; text-align: right; letter-spacing: .1em; }
.doc .meta td { padding: 2px 0 2px 12px; } .doc .meta td:first-child { color: #777; padding-left: 0; }
.doc .boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.doc .box { background: #faf6ee; border-radius: 8px; padding: 12px 14px; }
.doc .box b { display: block; font-size: 11px; color: #8b6a26; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.doc table.items { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.doc table.items th { background: #1d1a16; color: #f0cf85; text-align: left; padding: 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.doc table.items td { padding: 9px 10px; border-bottom: 1px solid #eee; }
.doc .totals { margin-left: auto; width: 300px; }
.doc .totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.doc .totals .grand { border-top: 2px solid #1d1a16; margin-top: 4px; padding-top: 8px; font-weight: 700; font-size: 16px; }
.doc .policies { font-size: 11px; color: #555; margin-top: 18px; } .doc .policies ol { padding-left: 18px; margin: 6px 0; }
.doc .stamp { display: inline-block; border: 3px solid #2e8b57; color: #2e8b57; font-weight: 800; padding: 6px 14px; border-radius: 8px; transform: rotate(-6deg); letter-spacing: .1em; font-size: 18px; }
.doc .foot { text-align: center; font-size: 11px; color: #888; margin-top: 22px; border-top: 1px solid #eee; padding-top: 10px; }

@media (max-width: 640px) {
  .doc { padding: 18px; } .doc .boxes { grid-template-columns: 1fr; } .doc .totals { width: 100%; }
  .doc .head { flex-direction: column; } .doc .title { text-align: left; }
}
@media print {
  body { background: #fff; } .no-print { display: none !important; } .doc { width: 100%; padding: 0; }
}

/* phone: tables become stacked cards */
@media (max-width: 640px) {
  .table.cards thead { display: none; }
  .table.cards tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
  .table.cards td { display: block; border: 0; padding: 2px 0; text-align: left; }
  .table.cards td.num::before { content: attr(data-l) ' '; color: var(--muted); font-size: 12px; }
}
