/* =========================================================
   ALPINE ENERGY INTELLIGENCE — HOMEOWNER SAVINGS REPORT
   LIGHT THEME · warm white + Alpine orange + Alpine navy
   ========================================================= */

:root {
  /* Surfaces — warm white (Alpine light base) */
  --ink-900: #f7f5f1;
  --ink-850: #f2efe9;
  --ink-800: #ffffff;
  --ink-700: #faf8f4;
  --panel:   rgba(255, 255, 255, 0.86);
  --panel-2: rgba(250, 248, 244, 0.7);
  --line:    rgba(226, 118, 30, 0.26);
  --line-2:  rgba(27, 42, 75, 0.12);

  /* Accent — Alpine orange */
  --amber:   #e2761e;   /* Alpine orange */
  --ember:   #c25e12;   /* deeper orange */
  --copper:  #a4500e;   /* darkest orange (print) */
  --gold-lt: #f08a2e;   /* bright highlight orange */

  /* The "savings" cool accent — Alpine navy */
  --teal:    #1b2a4b;
  --teal-lt: #2c3f6b;

  /* Type — dark navy ink over warm white */
  --cream:   #1b2336;
  --sand:    #41506b;
  --muted:   #76829a;

  --shadow:  0 30px 70px -20px rgba(27, 42, 75, 0.18);
  --shadow-sm: 0 12px 30px -12px rgba(27, 42, 75, 0.14);
  --radius:  22px;

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans:  "Sora", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--cream);
  background:
    radial-gradient(ellipse 70% 50% at 15% -8%, rgba(226, 118, 30, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 45% at 92% 4%, rgba(27, 42, 75, 0.06), transparent 55%),
    linear-gradient(168deg, #f7f5f1 0%, #f2efe9 55%, #efece6 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Film grain overlay */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4, p { margin: 0; }

.display { font-family: var(--serif); font-weight: 600; letter-spacing: -0.015em; }

.app-shell {
  position: relative; z-index: 1;
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 120px;
}

.eyebrow {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.28em; color: var(--amber);
}
.kicker {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.22em; color: var(--muted);
}
.ink { color: var(--amber); }

/* ---------------- MASTHEAD ---------------- */
.masthead {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 20px; margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  height: 48px; flex: none;
  display: inline-flex; align-items: center; padding: 6px 13px; border-radius: 13px;
  background: linear-gradient(145deg, #1f3052, #13203b);
  box-shadow: 0 8px 22px rgba(27, 42, 75, 0.30); border: 1px solid rgba(27, 42, 75, 0.25);
}
.brand-mark img { height: 100%; width: auto; display: block; }
.brand-mark svg { width: 70%; height: 70%; }
.brand-mark.sm { height: 36px; padding: 5px 10px; border-radius: 10px; }
.brand-text h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(20px, 2vw, 26px); letter-spacing: -0.02em; line-height: 1; margin-top: 2px;
}
.masthead-actions { display: flex; align-items: center; gap: 12px; }
.doc-ref { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

/* ---------------- BUTTONS ---------------- */
.solid-btn, .ghost-btn {
  border-radius: 999px; padding: 11px 18px; font-size: 13px; font-weight: 600;
  letter-spacing: 0.01em; transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.solid-btn {
  color: var(--ink-900);
  background: linear-gradient(135deg, var(--gold-lt), var(--ember));
  box-shadow: 0 14px 34px -10px rgba(226, 118, 30, 0.6);
}
.solid-btn:hover { transform: translateY(-1px); box-shadow: 0 18px 40px -10px rgba(226, 118, 30, 0.7); }
.ghost-btn {
  color: var(--cream); background: rgba(255, 248, 238, 0.05);
  border: 1px solid var(--line-2);
}
.ghost-btn:hover { background: rgba(255, 248, 238, 0.1); }
.ghost-btn.subtle { color: var(--muted); }

/* ---------------- OVERTURE ---------------- */
.overture {
  display: grid; grid-template-columns: 1.55fr 0.85fr; gap: 30px; align-items: stretch;
  margin-bottom: 18px;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.overture-copy { display: flex; flex-direction: column; }
.overture h2.display {
  font-size: clamp(34px, 5.2vw, 62px); line-height: 0.98; letter-spacing: -0.03em;
  margin: 16px 0 18px; max-width: 16ch;
}
.lede {
  color: var(--sand); font-size: clamp(15px, 1.5vw, 18px); line-height: 1.65;
  max-width: 56ch; font-weight: 300;
}
.overture-meta {
  margin-top: auto; padding-top: 24px; display: flex; align-items: center; gap: 22px;
}
.meta-cell span {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--muted); margin-bottom: 4px;
}
.meta-cell strong { font-family: var(--serif); font-size: 19px; font-weight: 500; }
.meta-divider { width: 1px; height: 38px; background: var(--line); }

.headline-figure {
  position: relative; border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background:
    linear-gradient(150deg, rgba(226, 118, 30,0.22), rgba(250, 248, 244, 0.6) 55%),
    var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden;
  backdrop-filter: blur(14px);
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s both;
}
.headline-figure::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 75% 18%, rgba(255,158,77,0.25), transparent 50%);
  pointer-events: none;
}
.live-dot {
  position: absolute; top: 22px; right: 22px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--teal); box-shadow: 0 0 0 0 rgba(27, 42, 75,0.6); animation: pulse 2.4s infinite;
}
.hf-label { position: relative; font-size: 12px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--sand); }
.hf-value { position: relative; font-size: clamp(40px, 5.5vw, 60px); line-height: 1; margin: 10px 0 12px; color: var(--gold-lt); }
.hf-foot { position: relative; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ---------------- SNAPSHOT ---------------- */
.snapshot {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 22px 0;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.18s both;
}
.stat {
  border-radius: 18px; padding: 22px; background: var(--panel);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-sm); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 8px;
}
.stat.is-feature {
  background: linear-gradient(150deg, rgba(226, 118, 30,0.16), var(--panel));
  border-color: var(--line);
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.stat-value { font-family: var(--serif); font-size: clamp(30px, 3.6vw, 44px); font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.stat.is-feature .stat-value { color: var(--gold-lt); }
.stat small { font-size: 12px; color: var(--muted); }

/* ---------------- REPORT CARDS ---------------- */
.report-card {
  border-radius: var(--radius); padding: 26px; background: var(--panel);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px); margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.card-head h3 { font-size: clamp(20px, 2.4vw, 28px); margin-top: 6px; }
.seal {
  flex: none; border: 1px solid var(--line); color: var(--amber);
  border-radius: 999px; padding: 7px 13px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; white-space: nowrap;
}

/* ---------------- WORKSPACE ---------------- */
.workspace { display: grid; grid-template-columns: 1.25fr 0.95fr; gap: 16px; align-items: stretch; }
.workspace .report-card { margin-bottom: 0; }

.story { display: flex; flex-direction: column; }
.story-figures { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fig {
  background: rgba(27, 42, 75, 0.034); border: 1px solid var(--line-2);
  border-radius: 16px; padding: 16px 18px;
}
.fig.is-accent { background: rgba(226, 118, 30,0.09); border-color: var(--line); }
.fig p { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.fig strong { display: block; font-family: var(--serif); font-size: clamp(22px, 2.6vw, 32px); font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.fig.is-accent strong { color: var(--gold-lt); }

.prose {
  margin-top: 16px; border-radius: 16px; padding: 20px;
  background: linear-gradient(150deg, rgba(27, 42, 75,0.07), rgba(27, 42, 75, 0.022));
  border: 1px solid rgba(27, 42, 75,0.16); flex: 1;
  display: flex; flex-direction: column; justify-content: center;
}
.prose h4 { font-family: var(--serif); font-size: 19px; font-weight: 600; margin-bottom: 8px; }
.prose p { color: var(--sand); font-size: 14px; line-height: 1.7; font-weight: 300; }

/* ---------------- INPUTS ---------------- */
.inputs { display: flex; flex-direction: column; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; }
.field-grid label:first-child { grid-column: 1 / -1; }
label {
  display: grid; gap: 7px; font-size: 12px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
input {
  width: 100%; background: rgba(27, 42, 75, 0.041); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 11px 13px; font-size: 14px; font-weight: 400;
  text-transform: none; letter-spacing: 0; color: var(--cream); outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus { border-color: rgba(226, 118, 30,0.55); box-shadow: 0 0 0 3px rgba(226, 118, 30,0.12); }
input::placeholder { color: rgba(169,150,124,0.5); }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------------- FORECAST CHART ---------------- */
.chart-legend { display: flex; gap: 16px; align-items: center; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--sand); font-weight: 500; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.dot-utility { background: var(--ember); }
.dot-solar { background: var(--teal); }
.chart-frame {
  border-radius: 16px; padding: 6px; background: rgba(27, 42, 75, 0.036);
  border: 1px solid var(--line-2); overflow: hidden;
}
#savingsChart { width: 100%; height: clamp(220px, 30vw, 320px); display: block; }
.caption {
  margin-top: 14px; font-family: var(--serif); font-style: italic;
  font-size: 15px; color: var(--sand); line-height: 1.6; max-width: 70ch; font-weight: 400;
}

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
.total-cell {
  border-radius: 16px; padding: 16px 18px; background: rgba(27, 42, 75, 0.031);
  border: 1px solid var(--line-2);
}
.total-cell.is-accent { background: rgba(226, 118, 30,0.1); border-color: var(--line); }
.total-cell span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 6px; }
.total-cell strong { font-family: var(--serif); font-size: clamp(20px, 2.4vw, 30px); font-weight: 600; letter-spacing: -0.02em; }
.total-cell.is-accent strong { color: var(--gold-lt); }

/* ---------------- LEDGER ---------------- */
.table-frame { border-radius: 14px; overflow: hidden; border: 1px solid var(--line-2); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: right; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
  color: var(--amber); background: rgba(27, 42, 75, 0.041); border-bottom: 1px solid var(--line);
}
tbody td { font-size: 13.5px; color: var(--cream); border-bottom: 1px solid var(--line-2); }
tbody tr:nth-child(even) { background: rgba(236,240,245,0.022); }
tbody tr:hover { background: rgba(226, 118, 30,0.06); }
tbody td:first-child { color: var(--muted); font-weight: 600; }
tbody td:last-child { color: var(--teal-lt); font-weight: 500; }
tfoot td {
  font-family: var(--serif); font-size: 14px; font-weight: 600; color: var(--gold-lt);
  background: rgba(226, 118, 30,0.1); border-top: 1px solid var(--line);
}
.fine-print { margin-top: 14px; font-size: 11px; color: var(--muted); line-height: 1.6; max-width: 80ch; }

/* ---------------- FOOTER ---------------- */
.report-footer {
  margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
}
.report-footer p { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ---------------- NAV RAIL ---------------- */
.rail {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 30;
  width: min(540px, calc(100% - 32px));
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  padding: 6px; border-radius: 999px;
  background: rgba(18, 14, 10, 0.82); border: 1px solid var(--line);
  box-shadow: var(--shadow); backdrop-filter: blur(20px);
}
.rail button {
  border-radius: 999px; padding: 11px 6px; font-size: 12px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.02em; transition: color 0.15s, background 0.2s;
}
.rail button.active { color: var(--ink-900); background: linear-gradient(135deg, var(--gold-lt), var(--ember)); }

/* ---------------- ANIMATIONS ---------------- */
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(27, 42, 75,0.5); }
  70% { box-shadow: 0 0 0 10px rgba(27, 42, 75,0); }
  100% { box-shadow: 0 0 0 0 rgba(27, 42, 75,0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 900px) {
  .overture, .workspace { grid-template-columns: 1fr; }
  .headline-figure { min-height: 180px; }
}
@media (max-width: 600px) {
  .app-shell { width: calc(100% - 24px); padding: 18px 0 110px; }
  .snapshot { grid-template-columns: 1fr; }
  .story-figures { grid-template-columns: 1fr 1fr; }
  .totals { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .overture h2.display { font-size: clamp(28px, 9vw, 40px); }
  .table-frame { overflow-x: auto; }
  table { min-width: 580px; }
  .doc-ref { display: none; }
  .card-actions .ghost-btn.subtle { display: none; }
}

/* ============================================================
   PRINT — clean, paginated PDF on a warm parchment
   ============================================================ */
@media print {
  @page { size: A4 portrait; margin: 14mm 12mm; }

  :root { --cream: #16181c; --sand: #3a4047; --muted: #6a727b; }

  body {
    background: #fbfaf8 !important; color: #16181c !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .grain, .rail, .live-dot, #installBtn, .card-actions, .masthead-actions { display: none !important; }

  .app-shell { width: 100%; padding: 0; }

  .masthead { border-bottom: 2px solid var(--ember); padding-bottom: 14px; margin-bottom: 18px; }

  .report-card, .headline-figure, .stat {
    background: #ffffff !important; border: 1px solid #e7e2da !important;
    box-shadow: none !important; backdrop-filter: none !important;
    break-inside: avoid; page-break-inside: avoid;
  }
  .total-cell, .fig {
    background: #ffffff !important; border: 1px solid #e7e2da !important;
  }
  .stat.is-feature, .total-cell.is-accent, .fig.is-accent {
    background: #fff4ea !important; border-color: #f3cba6 !important;
  }
  .headline-figure::before, .headline-figure { background: #fff4ea !important; }
  .hf-value, .stat.is-feature .stat-value, .fig.is-accent strong,
  .total-cell.is-accent strong, .eyebrow, .ink, tfoot td { color: var(--copper) !important; }

  .prose { background: #f2f6fa !important; border-color: #d3e0ec !important; }

  .overture { break-after: avoid; }
  .forecast, .ledger { break-before: page; }
  .workspace { break-inside: avoid; }

  thead th { color: var(--copper) !important; background: #f6efe7 !important; }
  tbody tr:nth-child(even) { background: #f7f5f1 !important; }
  tbody td:last-child { color: #3a6b94 !important; }
  tfoot td { background: #fff4ea !important; }

  .caption { color: #41474e !important; }
  .chart-frame { background: #ffffff !important; border-color: #e6ddcd !important; }

  /* Inputs print as clean read-only values */
  input {
    background: #ffffff !important; color: #16181c !important;
    border: 1px solid #e7e2da !important; box-shadow: none !important;
  }
  input::placeholder { color: #a7aeb6 !important; }
  label { color: #6a727b !important; }

  /* Pagination: keep cards intact, allow inputs to flow with story */
  .workspace { display: grid !important; grid-template-columns: 1.25fr 0.95fr !important; }
  .report-card, .stat, .headline-figure { break-inside: avoid; }
  .forecast { break-before: page; }
  .ledger { break-before: page; }
  .report-footer { break-inside: avoid; }
}
