/* Renovalora — Milestone 1.
   Palette is the logo's family (shared with Acrevalia): deep forest
   green grounds, gold accent, ivory text. Fleur's glass rule:
   layered translucent glass over an ambient scene, reveal-on-scroll,
   prefers-reduced-motion honoured. */

:root {
  --green-950: #0a1f13;
  --green-900: #0e2417;
  --green-800: #14331f;
  --green-700: #1a4229;
  --gold: #c49e54;
  --gold-bright: #e3c078;
  --ivory: #f4eedd;
  --ivory-dim: rgba(244, 238, 221, 0.72);
  --ivory-faint: rgba(244, 238, 221, 0.5);
  --glass: rgba(244, 238, 221, 0.055);
  --glass-strong: rgba(244, 238, 221, 0.09);
  --glass-border: rgba(196, 158, 84, 0.28);
  --danger: #e08a7a;
  --radius: 18px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ivory);
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(196, 158, 84, 0.13), transparent 60%),
    radial-gradient(900px 600px at -10% 30%, rgba(38, 96, 58, 0.35), transparent 60%),
    linear-gradient(165deg, var(--green-800) 0%, var(--green-900) 45%, var(--green-950) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}

.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.glow {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5;
  animation: drift 26s ease-in-out infinite alternate;
}
.glow-a { width: 420px; height: 420px; top: -120px; right: -80px; background: rgba(196, 158, 84, 0.20); }
.glow-b { width: 520px; height: 520px; bottom: -200px; left: -140px; background: rgba(30, 84, 50, 0.55); animation-delay: -12s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-40px, 30px) scale(1.08); }
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(244, 238, 221, 0.08);
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 10px; z-index: 20;
  margin: 10px auto 0; max-width: 1120px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-radius: 999px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ivory); }
.brand-mark { height: 34px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; letter-spacing: 0.04em; }
.brand-byline { font-size: 0.66rem; color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { font-size: 0.85rem; color: var(--ivory-dim); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: 0.92rem; cursor: pointer;
  border-radius: 999px; padding: 9px 18px; border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn-gold {
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  color: #221a08; font-weight: 600;
  box-shadow: 0 6px 18px rgba(196, 158, 84, 0.35);
}
.btn-gold:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ivory-dim); border-color: rgba(244, 238, 221, 0.25); }
.btn-ghost:hover { color: var(--ivory); border-color: rgba(244, 238, 221, 0.5); }
.btn-big { font-size: 1.02rem; padding: 13px 28px; }
.btn-small { font-size: 0.8rem; padding: 5px 12px; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(224, 138, 122, 0.4); }

/* ---------- layout ---------- */
main { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 26px 16px 10px; }

.hero { padding: 40px 28px 34px; text-align: center; }
.hero-logo { width: min(430px, 86%); height: auto; display: block; margin: 0 auto; }
.hero-tagline {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--gold); letter-spacing: 0.14em; font-size: 1.02rem; margin: 14px 0 6px;
}
.hero-lede { max-width: 560px; margin: 8px auto 22px; color: var(--ivory-dim); }
.signin-note { color: var(--gold-bright); margin: 14px auto 0; max-width: 480px; }

.card-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.card { padding: 22px; }
.card h3 { margin: 0 0 8px; font-family: Georgia, serif; font-weight: 600; color: var(--ivory); }
.card p { margin: 0; color: var(--ivory-dim); font-size: 0.94rem; }

/* ---------- dashboard ---------- */
.dash-head h2 { font-family: Georgia, serif; font-weight: 600; margin: 6px 0 2px; }
.dash-biz { color: var(--gold); margin: 0 0 6px; min-height: 1.2em; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.panel { padding: 22px; }
.panel h3 { margin: 0 0 6px; font-family: Georgia, serif; font-weight: 600; }
.panel-sub { color: var(--ivory-faint); font-size: 0.88rem; margin: 0 0 12px; }
.soon p { color: var(--ivory-dim); font-size: 0.94rem; }
.soon-badge {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: #221a08; background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  border-radius: 999px; padding: 3px 10px; vertical-align: middle; margin-left: 8px; white-space: nowrap;
}
.legal-inline { color: var(--gold-bright) !important; font-size: 0.85rem !important; }

/* ---------- forms & lists ---------- */
.form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.form h4 { margin: 6px 0 0; font-size: 0.95rem; color: var(--gold); }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ivory-dim); }
.form .opt { color: var(--ivory-faint); font-size: 0.78rem; }
.form input, .form select, .form textarea {
  font: inherit; font-size: 0.95rem; color: var(--ivory);
  background: rgba(10, 31, 19, 0.55); border: 1px solid rgba(244, 238, 221, 0.18);
  border-radius: 10px; padding: 9px 12px; width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid rgba(196, 158, 84, 0.65); outline-offset: 1px; border-color: transparent;
}
.form-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.save-state { font-size: 0.85rem; color: var(--gold-bright); min-height: 1.2em; }
.save-state.error { color: var(--danger); }

.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item-list li {
  background: var(--glass-strong); border: 1px solid rgba(244, 238, 221, 0.10);
  border-radius: 12px; padding: 10px 12px;
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
}
.item-main { min-width: 0; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-sub { color: var(--ivory-faint); font-size: 0.83rem; overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 6px; flex-shrink: 1; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.empty-note { color: var(--ivory-faint); font-size: 0.9rem; }

/* ---------- service catalog ---------- */
.panel-wide { grid-column: 1 / -1; }
.catalog-tools { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.catalog-search { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ivory-dim); flex: 1 1 220px; }
.catalog-search input {
  font: inherit; font-size: 0.95rem; color: var(--ivory);
  background: rgba(10, 31, 19, 0.55); border: 1px solid rgba(244, 238, 221, 0.18);
  border-radius: 10px; padding: 9px 12px; width: 100%;
}
.catalog-search input:focus { outline: 2px solid rgba(196, 158, 84, 0.65); outline-offset: 1px; border-color: transparent; }
.catalog-list { display: flex; flex-direction: column; gap: 8px; }
.cat-block { border: 1px solid rgba(244, 238, 221, 0.10); border-radius: 12px; background: rgba(10, 31, 19, 0.28); overflow: hidden; }
.cat-head {
  font: inherit; width: 100%; cursor: pointer; text-align: left;
  display: flex; align-items: baseline; gap: 10px;
  background: transparent; border: 0; color: var(--ivory);
  padding: 11px 14px;
}
.cat-head-main { font-weight: 600; font-family: Georgia, serif; font-size: 1rem; }
.cat-head-meta { color: var(--ivory-faint); font-size: 0.8rem; flex: 1; }
.cat-chev { color: var(--gold); }
.cat-items { padding: 0 10px 10px; }
.cat-actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.item-inactive { opacity: 0.55; }
.item-actions .btn:disabled { opacity: 0.35; cursor: default; }
.packages-block { margin-top: 26px; border-top: 1px solid rgba(196, 158, 84, 0.18); padding-top: 18px; }
.packages-title { margin: 0 0 4px; font-family: Georgia, serif; font-weight: 600; font-size: 1.05rem; }
.package-lines { display: flex; flex-direction: column; gap: 8px; }
.package-line { display: flex; gap: 8px; align-items: center; }
.package-line select { flex: 1 1 auto; min-width: 0; }
.package-line input { flex: 0 0 84px; width: 84px; }

/* ---------- estimates & calculators (M3) ---------- */
.builder-h { margin: 20px 0 8px; font-family: Georgia, serif; font-weight: 600; font-size: 1rem; color: var(--gold-bright); }
.builder-head { margin-top: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.builder-add { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.builder-add label, .catalog-tools > label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ivory-dim); }
.builder-add select, .catalog-tools select, .est-line input, .calc-fields input {
  font: inherit; font-size: 0.95rem; color: var(--ivory);
  background: rgba(10, 31, 19, 0.55); border: 1px solid rgba(244, 238, 221, 0.18);
  border-radius: 10px; padding: 9px 12px;
}
.builder-add select:focus, .catalog-tools select:focus, .est-line input:focus, .calc-fields input:focus {
  outline: 2px solid rgba(196, 158, 84, 0.65); outline-offset: 1px; border-color: transparent;
}
.est-line {
  background: var(--glass-strong); border: 1px solid rgba(244, 238, 221, 0.10);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
}
.est-line-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.est-line .el-name { flex: 1 1 170px; min-width: 0; }
.est-line .el-qty { flex: 0 0 78px; width: 78px; }
.est-line .el-unit { flex: 0 0 78px; width: 78px; }
.est-line .el-mat, .est-line .el-lab { flex: 0 0 118px; width: 118px; }
.est-line .el-sub { flex: 0 0 auto; min-width: 76px; text-align: right; font-weight: 600; color: var(--gold-bright); }
.est-line .el-note { width: 100%; margin-top: 8px; }
.totals-rail { margin: 16px 0 4px auto; max-width: 430px; border-top: 1px solid rgba(196, 158, 84, 0.25); padding-top: 10px; }
.totals-row { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; color: var(--ivory-dim); font-size: 0.94rem; }
.totals-grand {
  color: var(--ivory); font-weight: 700; font-size: 1.06rem;
  border-top: 1px solid rgba(196, 158, 84, 0.35); border-bottom: 1px solid rgba(196, 158, 84, 0.35);
  padding: 6px 0; margin: 6px 0;
}
.totals-note { color: var(--ivory-faint); font-size: 0.82rem; margin: 8px 0 0; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.calc-card { background: rgba(10, 31, 19, 0.28); border: 1px solid rgba(244, 238, 221, 0.10); border-radius: 12px; padding: 14px; }
.calc-card h4 { margin: 0 0 10px; font-family: Georgia, serif; font-weight: 600; color: var(--gold-bright); }
.calc-fields { display: flex; flex-direction: column; gap: 8px; }
.calc-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 0.83rem; color: var(--ivory-dim); }
.calc-fields input { width: 100%; }
.calc-result { color: var(--ivory); font-weight: 600; min-height: 1.4em; margin: 10px 0 8px; font-size: 0.94rem; }
.calc-adds { display: flex; gap: 6px; flex-wrap: wrap; }
.calc-adds .btn:disabled { opacity: 0.35; cursor: default; }

@media (max-width: 860px) {
  .totals-rail { margin-left: 0; }
  .est-line .el-mat, .est-line .el-lab { flex: 1 1 118px; }
}

/* ---------- documents + approval links (M4) ---------- */
.status-badge {
  display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
  border: 1px solid rgba(244, 238, 221, 0.35); color: var(--ivory-dim);
}
.status-badge.st-sent { border-color: var(--gold); color: var(--gold-bright); }
.status-badge.st-approved { border-color: #7fb069; color: #a7d491; }
.status-badge.st-changes_requested { border-color: #e0a458; color: #eec27f; }
.status-badge.st-declined { border-color: var(--danger); color: var(--danger); }
.item-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.share-panel {
  margin-top: 14px; border: 1px solid rgba(196, 158, 84, 0.30); border-radius: 12px;
  background: rgba(10, 31, 19, 0.30); padding: 14px;
}
.share-panel h4 { margin: 0 0 4px; font-family: Georgia, serif; font-weight: 600; color: var(--gold-bright); }
.share-link-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.share-link-row input {
  flex: 1 1 260px; min-width: 0; font: inherit; font-size: 0.85rem; color: var(--ivory);
  background: rgba(10, 31, 19, 0.55); border: 1px solid rgba(244, 238, 221, 0.18);
  border-radius: 10px; padding: 8px 10px;
}
.share-link-meta { font-size: 0.8rem; color: var(--ivory-faint); }
.share-link-meta .revoked { color: var(--danger); }
.response-item, .history-item { font-size: 0.88rem; color: var(--ivory-dim); padding: 6px 0; border-top: 1px solid rgba(244, 238, 221, 0.08); }
.response-item strong, .history-item strong { color: var(--ivory); }
.share-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
@media (max-width: 860px) { .share-cols { grid-template-columns: 1fr; } }

/* The document face — paper on the green ground, shared by the
   contractor print view and the public customer page. */
.doc {
  background: #fffdf4; color: #21301f; border-radius: 14px;
  padding: 34px 36px; margin: 18px auto; max-width: 860px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  border-top: 6px solid var(--gold);
}
.doc-head { border-bottom: 2px solid #14331f; padding-bottom: 14px; }
.doc-biz { font-family: Georgia, "Times New Roman", serif; font-size: 1.7rem; font-weight: 700; color: #14331f; }
.doc-tagline { color: #8a6d2f; letter-spacing: 0.06em; font-size: 0.9rem; margin-top: 2px; }
.doc-contact { color: #4c5a48; font-size: 0.88rem; margin-top: 2px; }
.doc-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin: 18px 0 6px; }
.doc-title { font-family: Georgia, serif; font-size: 1.35rem; margin: 0; color: #14331f; }
.doc-sub { color: #5c6b56; font-size: 0.88rem; margin-top: 3px; }
.doc .status-badge { border-color: #14331f; color: #14331f; }
.doc .status-badge.st-approved { border-color: #4c7a3f; color: #4c7a3f; }
.doc .status-badge.st-declined { border-color: #b0503c; color: #b0503c; }
.doc .status-badge.st-changes_requested { border-color: #a8742c; color: #a8742c; }
.doc-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.94rem; }
.doc-table th { text-align: left; font-size: 0.75rem; letter-spacing: 0.07em; text-transform: uppercase; color: #5c6b56; border-bottom: 1.5px solid #14331f; padding: 6px 8px; }
.doc-table td { padding: 8px; border-bottom: 1px solid #e4dfc8; vertical-align: top; }
.doc-table .num, .doc-trow .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-line-name { font-weight: 600; }
.doc-line-note { color: #5c6b56; font-size: 0.83rem; margin-top: 2px; }
.doc-totals { margin: 16px 0 0 auto; max-width: 380px; }
.doc-trow { display: flex; justify-content: space-between; gap: 18px; padding: 3px 0; color: #3c4a38; }
.doc-grand { font-weight: 700; font-size: 1.12rem; color: #14331f; border-top: 1.5px solid #14331f; border-bottom: 1.5px solid #14331f; padding: 7px 0; margin: 7px 0; }
.doc-notes { margin-top: 24px; border-top: 1px solid #e4dfc8; padding-top: 14px; }
.doc-notes h2 { font-family: Georgia, serif; font-size: 1rem; color: #14331f; margin: 0 0 6px; }
.doc-notes p { white-space: pre-wrap; color: #3c4a38; margin: 0; font-size: 0.92rem; }
.doc-foot { margin-top: 26px; color: #7a8774; font-size: 0.78rem; border-top: 1px solid #e4dfc8; padding-top: 10px; }
.doc-toolbar { display: flex; gap: 10px; align-items: center; max-width: 860px; margin: 18px auto 0; flex-wrap: wrap; }
.doc-internal-note { color: #8a6d2f; font-size: 0.8rem; }

.respond-card { max-width: 860px; margin: 16px auto; }
.respond-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.respond-latest { color: var(--gold-bright); font-size: 0.92rem; }
.respond-done { color: #a7d491; font-weight: 600; margin: 12px 0 0; }

/* Print: only the document, on white. */
@media print {
  body { background: #fff !important; }
  .ambient, .nav, .footer, .doc-toolbar, #dashboard, #landing, .respond-card, #pubState { display: none !important; }
  main { padding: 0; max-width: none; margin: 0; }
  .doc { box-shadow: none; border: none; border-top: 6px solid #c49e54; border-radius: 0; margin: 0; max-width: none; padding: 12px 4px; }
}

/* ---------- footer ---------- */
.footer {
  position: relative; z-index: 1; max-width: 1120px; margin: 26px auto 0;
  padding: 20px 16px 34px; color: var(--ivory-faint); font-size: 0.83rem;
  border-top: 1px solid rgba(196, 158, 84, 0.18);
}
.footer-brand { color: var(--ivory-dim); font-size: 0.9rem; }
.footer a { color: var(--gold); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---------- legal pages ---------- */
.legal-card { padding: 30px 28px; max-width: 760px; margin: 0 auto; }
.legal-card h1 { font-family: Georgia, serif; font-weight: 600; margin: 0 0 10px; }
.legal-card h2 { font-family: Georgia, serif; font-weight: 600; font-size: 1.08rem; color: var(--gold-bright); margin: 22px 0 6px; }
.legal-card p { color: var(--ivory-dim); margin: 0 0 10px; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 860px) {
  .card-row { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .nav { border-radius: var(--radius); }
  .user-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .glow { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn { transition: none; }
}

/* ---------- invoicing + profit (M5) ---------- */
.status-badge.st-paid { border-color: #7fb069; color: #a7d491; }
.status-badge.st-partially_paid { border-color: #e0a458; color: #eec27f; }
.status-badge.st-overdue { border-color: var(--danger); color: var(--danger); }
.doc .status-badge.st-paid { border-color: #4c7a3f; color: #4c7a3f; }
.doc .status-badge.st-partially_paid { border-color: #a8742c; color: #a8742c; }
.doc .status-badge.st-overdue { border-color: #b0503c; color: #b0503c; }

/* The invoice's frozen lines, inside the dark dashboard panel —
   the same table shape as the paper document, recoloured. */
.inv-lines { color: var(--ivory); }
#invoiceLines { overflow-x: auto; }
.panel { min-width: 0; }
.inv-lines th { color: var(--ivory-dim); border-bottom-color: rgba(196, 158, 84, 0.4); }
.inv-lines td { border-bottom-color: rgba(244, 238, 221, 0.12); }
.inv-lines .doc-line-note { color: var(--ivory-faint); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.stat-card {
  background: rgba(10, 31, 19, 0.28); border: 1px solid rgba(244, 238, 221, 0.10);
  border-radius: 12px; padding: 12px 14px;
}
.stat-value { font-size: 1.25rem; font-weight: 700; color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ivory-dim); margin-top: 2px; }
.job-rail { margin-left: 0; max-width: 520px; }
