@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,600;1,400&family=Jost:wght@400;500;600&display=swap');

:root {
  --ink: #0a0a0a;
  --gold: #c9a96e;
  --gold-deep: #a9834a;
  --sage: #4f6339;
  --white: #ffffff;
  --gray-50: #faf9f7;
  --gray-200: #e6e2db;
  --gray-500: #8a8478;
  --danger: #a13a3a;
  --radius: 4px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Jost', sans-serif;
  color: var(--ink);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

a { color: var(--ink); }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  background: var(--ink);
  color: var(--white);
  padding: 14px 0;
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; }
.topbar a { color: var(--white); text-decoration: none; }
.topbar .brand { font-family: 'EB Garamond', serif; font-size: 1.3rem; letter-spacing: 0.03em; }
.topbar nav a { margin-left: 18px; font-size: 0.9rem; color: var(--gray-200); }

.page { padding: 32px 0 80px; }

/* ---------- app shell (sidebar layout) ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex: none;
  background: var(--ink);
  color: #cfc9ba;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .brand-plate { display: block; margin-bottom: 26px; }
.sidebar .brand-plate img { width: 150px; height: auto; display: block; }
.sidebar a {
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 9px 10px;
  border-radius: var(--radius);
  margin-bottom: 2px;
}
.sidebar a:hover { background: rgba(255,255,255,0.06); }
.sidebar a.active { background: var(--gold); color: var(--ink); font-weight: 500; }
.sidebar .sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 0.8rem; }
.sidebar .sidebar-foot a { display: block; color: #cfc9ba; }
.main-content { flex: 1; min-width: 0; max-width: 1100px; padding: 32px 32px 80px; }
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 14px 16px; }
  .sidebar .brand-plate { margin-bottom: 0; margin-right: 16px; }
  .sidebar .brand-plate img { width: 110px; }
  .sidebar .sidebar-foot { margin-top: 0; padding-top: 0; border-top: none; margin-left: auto; }
  .main-content { padding: 20px 16px 60px; }
}

/* ---------- snapshot / stat tiles ---------- */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat { flex: 1; min-width: 110px; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-family: 'EB Garamond', serif; font-size: 1.7rem; line-height: 1.1; }
.stat .lbl { font-size: 0.78rem; color: var(--gray-500); margin-top: 4px; }
.stat.hi { background: var(--ink); border-color: var(--ink); }
.stat.hi .num, .stat.hi .lbl { color: #fff; }
.stat.hi .lbl { opacity: 0.7; }

.snapshot-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 980px) { .snapshot-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .snapshot-row { grid-template-columns: 1fr; } }
.snapshot-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 18px 20px; }
.snapshot-card h3 { margin: 0 0 12px; font-size: 1rem; }
.snapshot-card .empty { color: var(--gray-500); font-size: 0.88rem; }
.activity-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--gray-200); font-size: 0.88rem; }
.activity-row:last-child { border-bottom: none; }
.activity-row .name { font-weight: 500; }
.activity-row .sub { color: var(--gray-500); font-size: 0.8rem; margin-top: 1px; }
.activity-row .amt { font-family: 'EB Garamond', serif; white-space: nowrap; }

.card {
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 0.82rem; color: var(--gray-500); margin-bottom: 4px; margin-top: 14px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: 'Jost', sans-serif;
  font-size: 0.95rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
}
textarea { resize: vertical; min-height: 80px; }

/* ---------- banner header (proposal/invoice detail) ---------- */
.banner {
  position: relative;
  min-height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: flex-end;
  padding: 16px 22px;
  margin-bottom: 20px;
  overflow: hidden;
  background-color: #fbfaf6;
  background-image: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.35));
}
.banner .btag { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.banner h1 { font-size: 1.6rem; margin: 2px 0 0; }
.banner .spray {
  position: absolute;
  top: 50%;
  right: 30px;
  transform: translateY(-50%);
  width: 190px;
  height: 90px;
  -webkit-mask-image: url('/images/floral-spray.webp');
  mask-image: url('/images/floral-spray.webp');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  pointer-events: none;
}
.banner.gold .spray { background-color: var(--gold-deep); opacity: 0.8; }
.banner.green .spray { background-color: var(--sage); opacity: 0.75; }
@media (max-width: 600px) {
  .banner .spray { width: 120px; height: 60px; right: 14px; }
}

.item-icon { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; margin-right: 8px; flex: none; }

/* ---------- snapshot charts ---------- */
.chart-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
@media (max-width: 860px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 18px 20px 12px; margin-bottom: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-title { font-family: 'Jost', sans-serif; font-size: 0.9rem; font-weight: 500; color: var(--ink); }
.chart-sub { font-size: 0.75rem; color: var(--gray-500); }
.chart-wrap { position: relative; }
.chart-svg, .bar-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .gridline { stroke: var(--gray-200); stroke-width: 1; }
.chart-svg .axis-label, .chart-svg .month-label, .bar-svg .bar-val, .bar-svg .bar-label {
  fill: var(--gray-500); font-size: 10px; font-family: 'Jost', sans-serif;
}
.chart-svg .month-label { text-anchor: middle; }
.chart-svg .chart-line { fill: none; stroke: var(--gold-deep); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-svg .chart-dot { fill: var(--white); stroke: var(--gold-deep); stroke-width: 2; }
.chart-svg .chart-dot.end { fill: var(--gold-deep); }
.chart-svg .hoverline { stroke: var(--gray-500); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart-tip {
  position: absolute; top: 0; left: 0; background: var(--ink); color: #fff; font-size: 0.72rem; line-height: 1.35;
  padding: 7px 10px; border-radius: 7px; pointer-events: none; opacity: 0;
  transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; transition: opacity .12s ease;
}
.chart-tip .tip-amt { font-family: 'EB Garamond', serif; font-size: 0.85rem; display: block; }
.bar-svg .bar-val { font-size: 12px; font-weight: 500; fill: var(--ink); text-anchor: middle; }
.bar-svg .bar-label { font-size: 10.5px; text-anchor: middle; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--white);
  font-family: 'Jost', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.btn.secondary { background: var(--white); color: var(--ink); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.danger { background: var(--white); color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 0.8rem; }

.delete-form { display: inline-block; margin-left: 32px; }
.btn-text-delete {
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'Jost', sans-serif;
  font-size: 0.9rem;
  color: var(--gray-500);
  padding: 0;
}
.btn-text-delete:hover { color: var(--danger); text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--gray-200);
}
.badge.draft { background: var(--gray-200); }
.badge.sent, .badge.viewed { background: #eadcc4; }
.badge.approved { background: #cfe3cf; }
.badge.changes_requested { background: #f0dcb8; }
.badge.declined, .badge.expired, .badge.canceled { background: #ecd3d3; }
.badge.paid { background: #cfe3cf; }
.badge.partially_paid { background: #f0dcb8; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--gray-200); font-size: 0.9rem; }
th { font-weight: 500; color: var(--gray-500); font-size: 0.78rem; text-transform: uppercase; }

.section-block { border: 1px solid var(--ink); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; background: var(--white); }
.section-block img { max-width: 100%; border-radius: var(--radius); margin-top: 8px; }
.section-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.totals { text-align: right; }
.totals .line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.95rem; }
.totals .grand { font-family: 'EB Garamond', serif; font-size: 1.4rem; border-top: 1px solid var(--gray-200); margin-top: 8px; padding-top: 10px; }

.notice { padding: 12px 16px; border-radius: var(--radius); background: #fbeee0; border: 1px solid var(--gold); margin-bottom: 16px; font-size: 0.9rem; }
.notice.error { background: #f6e2e2; border-color: var(--danger); }

.client-view { background: var(--white); }
.client-hero { padding: 64px 0 24px; text-align: center; }
.client-hero-logo { width: 260px; max-width: 70%; height: auto; margin-bottom: 18px; }
.client-hero h1 { font-size: 2rem; margin-bottom: 6px; }
.client-hero .investment { font-family: 'EB Garamond', serif; font-size: 2.4rem; color: var(--gold); margin: 20px 0; }

/* ---------- client-facing luxury treatment (proposals/invoices) ---------- */
.client-view .doc-label {
  display: block;
  font-family: 'Jost', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 16px;
}
.client-view .client-hero h1 {
  font-family: 'EB Garamond', serif;
  font-weight: 400;
  font-size: 2.6rem;
  margin-bottom: 0;
}
/* Scoped off the photo variant (below) -- ::after generates as the LAST
   child of whatever it's attached to, and on .client-hero-photo that put
   this rule's margin+line *after* .client-hero-scrim's box, directly on
   the raw, undarkened photo. That gap was the real cause of the lighter
   band at the bottom -- not the scrim's opacity, which never covered that
   strip in the first place no matter what it was set to. */
.client-view .client-hero:not(.client-hero-photo)::after {
  content: '';
  display: block;
  width: 44px;
  height: 2px;
  background: var(--gold);
  margin: 26px auto 0;
}
.client-view .client-hero-photo .client-hero-scrim::after {
  content: '';
  display: block;
  width: 44px;
  height: 2px;
  background: var(--gold);
  margin: 26px auto 0;
}

/* Full-bleed cover photo hero, used when a proposal has one uploaded.
   Falls back to the plain typographic hero above when it hasn't. */
.client-view .client-hero-photo {
  padding: 0;
  background-size: cover;
  background-position: center;
}
.client-view .client-hero-photo .client-hero-scrim {
  /* Flat, uniform darkening over the whole photo -- a top-to-bottom
     gradient left a visible lighter band whatever opacity it ended on,
     since it was fading through the exact spot the eye catches the seam
     against .doc-meta-strip below. One flat value has no fade to go
     wrong. */
  background: rgba(10,10,10,0.55);
  padding: 90px 0 56px;
}
/* logo-on-photo.webp is a separate asset built once from the real logo:
   background keyed out to true transparency, with a soft white glow baked
   into the pixels themselves (not a CSS filter) so it stays legible over
   whatever photo sits behind it. Baked-in means it renders identically in
   the browser and in the PDF (html2canvas doesn't reliably apply CSS
   `filter`, which is what the white-box and invert bugs came from). */
.client-view .client-hero-photo h1,
.client-view .client-hero-photo .doc-label {
  color: var(--white);
}
.client-view .client-hero-photo .doc-label { color: var(--gold); }

.doc-meta-strip {
  background: var(--ink);
  color: var(--gray-200);
  text-align: center;
  font-family: 'Jost', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  padding: 12px 0;
  margin-bottom: 40px;
}

/* Print-friendly mode: toggled on #doc-content right before generating the
   "ink-saving" PDF. Swaps solid dark fills (the meta strip, the cover
   photo's dark scrim) for light ones with a thin rule instead -- a real
   uploaded photo is left alone, since photos print fine and aren't what
   drains a home printer's ink; flat dark panels are. */
.print-light .doc-meta-strip {
  background: var(--white);
  color: var(--ink);
  border-top: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
}
.print-light .client-hero-photo {
  background-image: none !important;
}
.print-light .client-hero-photo .client-hero-scrim {
  background: none !important;
  padding: 64px 0 24px !important;
}
.print-light .client-hero-photo .client-hero-logo {
  filter: none !important;
}
.print-light .client-hero-photo h1,
.print-light .client-hero-photo .doc-label {
  color: var(--ink) !important;
}
.print-light .client-hero-photo .doc-label {
  color: var(--gold-deep) !important;
}

.client-view .card,
.client-view .section-block {
  border: none;
  border-top: 1px solid var(--gray-200);
  border-radius: 0;
  padding: 28px 0;
  margin-bottom: 0;
  background: transparent;
}
.client-view .card h3,
.client-view .section-block h3 {
  font-family: 'Jost', sans-serif;
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 10px;
}
.client-view h2 {
  font-family: 'EB Garamond', serif !important;
  font-weight: 400;
  font-size: 1.25rem !important;
  letter-spacing: 0.01em;
  color: var(--ink);
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-top: 48px !important;
  margin-bottom: 4px !important;
}

.client-view .totals {
  background: var(--gray-50);
  border: none !important;
  border-top: none;
  border-radius: var(--radius);
  padding: 24px 30px;
  margin: 30px 0;
}
.client-view .totals .line { font-family: 'Jost', sans-serif; }
.client-view .totals .grand { border-top: 1px solid var(--gray-200); }
.client-view .totals .grand span:last-child { color: var(--gold-deep); }

@media (max-width: 600px) {
  .page { padding: 20px 0 60px; }
  .card { padding: 16px; }
  .client-hero { padding: 36px 0 20px; }
  .client-hero-logo { width: 190px; }
  .client-view .client-hero h1 { font-size: 1.8rem; }
}

/* Login page: full-bleed brand photo with a dark scrim so the white card
   and form text stay fully legible regardless of what the photo looks
   like underneath. The card itself never sits directly on the image. */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.login-bg {
  position: fixed;
  inset: 0;
  /* anchor to the bottom so the flowers along the bottom edge of the photo
     stay in frame on every screen — cover crops the sides on narrow/tall
     viewports (phones) rather than the top or bottom, which is what we want
     here since the subject is at the bottom, not the center. */
  background: url('/images/login-bg.jpg') bottom center / cover no-repeat;
  z-index: -2;
}
.login-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  /* lighter scrim up top (moody background photo is already dark there),
     easing up toward the bottom so the flowers stay visible while the
     card — vertically centered — still sits on enough of a scrim to read */
  background: linear-gradient(180deg, rgba(10,10,10,0.45) 0%, rgba(10,10,10,0.25) 55%, rgba(10,10,10,0.15) 100%);
}
.login-wrap {
  width: 100%;
  padding: 40px 0;
}
.login-page .card {
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.print-bar { text-align: center; margin: 0 0 24px; }

/* ---------- flower library ---------- */
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 20px; }
.library-card { display: block; text-decoration: none; color: var(--ink); background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.library-thumb { position: relative; aspect-ratio: 1 / 1; background: var(--gray-50); display: flex; align-items: center; justify-content: center; }
.library-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 10px; box-sizing: border-box; }
.library-ai-badge { position: absolute; top: 6px; right: 6px; background: var(--ink); color: var(--white); font-size: 0.65rem; font-weight: 600; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 3px; }
.library-name { font-size: 0.85rem; font-weight: 500; padding: 8px 10px 2px; }
.library-meta { font-size: 0.75rem; color: var(--gray-500); padding: 0 10px 10px; }

@media print {
  @page { margin: 0.6in; }
  .no-print, .topbar, .sidebar { display: none !important; }
  body { background: var(--white) !important; }
  .client-hero { padding: 0 0 20px; }
  .card, .section-block {
    box-shadow: none !important;
    border-color: #000 !important;
    break-inside: avoid;
  }
  /* The browser's own Print/Save-as-PDF has no "print-light" button to
     press first, and most people print with background graphics off
     anyway -- so default straight to the ink-saving treatment here,
     same as .print-light above. A real cover photo still prints. */
  .doc-meta-strip {
    background: var(--white) !important;
    color: var(--ink) !important;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
  }
  .client-hero-photo .client-hero-scrim {
    background: none !important;
  }
  .client-hero-photo .client-hero-logo { filter: none !important; }
  .client-hero-photo h1,
  .client-hero-photo .doc-label { color: var(--ink) !important; }
  .client-hero-photo .doc-label { color: var(--gold-deep) !important; }
}
