/* ==========================================================================
   Deal Maker theme. Dark, premium, finance grade.
   Brand accents are driven by CSS variables set per deal at runtime:
     --brand-a  (secondary accent, cool)   --brand-b  (primary action, warm)
   ========================================================================== */

:root {
  --bg: #0a0b0d;
  --bg-raised: #121419;
  --bg-card: #15181e;
  --bg-input: #0e1116;
  --line: #262a33;
  --line-soft: #1c2027;
  --text: #f4f6fa;
  --text-soft: #aab2c0;
  --text-dim: #6b7480;

  --brand-a: #9ec4d8; /* Azimut cool light blue, secondary accent */
  --brand-b: #ff7a1a; /* BeFit orange, primary action and highlight */
  --brand-b-ink: #1a0e04;

  --good: #45d483;
  --warn: #ffcc55;
  --bad: #ff6b6b;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.4);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;

  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

body {
  background:
    radial-gradient(1100px 600px at 82% -8%, rgba(158, 196, 216, 0.09), transparent 60%),
    radial-gradient(900px 520px at 8% 108%, rgba(255, 122, 26, 0.08), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--brand-a); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.4em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; color: var(--text-soft); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 28px 22px 80px; }
.narrow { max-width: 720px; }

/* ---- top facilitator bar --------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 11, 13, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar .fac { display: flex; align-items: center; gap: 12px; }
.topbar .fac img, .topbar .fac svg { height: 26px; width: auto; }
.topbar .fac small { color: var(--text-dim); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; }

/* ---- co-branded lockup ----------------------------------------------- */
.lockup {
  display: flex; align-items: center; justify-content: center; gap: 26px;
  padding: 30px 24px; margin-bottom: 22px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-raised), var(--bg-card));
  box-shadow: var(--shadow-soft);
}
.lockup .brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.lockup .brand img, .lockup .brand svg { height: 40px; max-width: 220px; width: auto; object-fit: contain; }
.lockup .brand span { color: var(--text-dim); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; }
.lockup .x { color: var(--text-dim); font-size: 1.4rem; font-weight: 300; }

/* ---- cards ----------------------------------------------------------- */
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
  box-shadow: var(--shadow-soft);
}
.card h2 { display: flex; align-items: center; gap: 10px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 780px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* ---- forms ----------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 0.95rem; }
.field .help { color: var(--text-dim); font-size: 0.82rem; margin: 0 0 8px; }
.field .inputwrap { position: relative; display: flex; align-items: center; }
.field .affix {
  position: absolute; right: 14px; color: var(--text-dim);
  font-size: 0.8rem; letter-spacing: 0.06em; pointer-events: none;
}
.field .affix.left { left: 14px; right: auto; }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--line);
  color: var(--text); font-family: var(--font); font-size: 0.98rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input.has-affix-left { padding-left: 40px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-b);
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.16);
}
input.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.14); }
.field .err { color: var(--bad); font-size: 0.78rem; margin-top: 5px; display: none; }
.field.invalid .err { display: block; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: auto; }

.group-title {
  font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--brand-a); margin: 26px 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.group-title:first-of-type { margin-top: 4px; }

/* ---- buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: var(--font); font-weight: 650; font-size: 0.95rem; cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-b); color: var(--brand-b-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--brand-a); color: var(--brand-a); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---- badges and pills ------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 0.72rem; font-weight: 650;
  letter-spacing: 0.04em; border: 1px solid var(--line);
}
.badge.known { color: var(--good); border-color: rgba(69, 212, 131, 0.35); background: rgba(69, 212, 131, 0.08); }
.badge.estimate { color: var(--warn); border-color: rgba(255, 204, 85, 0.35); background: rgba(255, 204, 85, 0.08); }
.badge.recommended { color: var(--brand-b); border-color: rgba(255, 122, 26, 0.45); background: rgba(255, 122, 26, 0.1); }
.badge.await { color: var(--text-dim); }
.badge.done { color: var(--good); border-color: rgba(69, 212, 131, 0.35); }
.badge.live { color: var(--brand-a); border-color: rgba(158, 196, 216, 0.4); }

/* ---- tables ---------------------------------------------------------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 640px; }
th, td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line-soft); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--bg-raised); color: var(--text-soft); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.03em; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
td.num, th.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }
tr.rec td { background: rgba(255, 122, 26, 0.06); }

/* ---- scenario cards -------------------------------------------------- */
.scn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.scn {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  background: var(--bg-card); position: relative; display: flex; flex-direction: column; gap: 10px;
}
.scn.rec { border-color: var(--brand-b); box-shadow: 0 0 0 1px rgba(255, 122, 26, 0.25), var(--shadow-soft); }
.scn h3 { font-size: 0.98rem; min-height: 2.6em; }
.scn .metric { display: flex; justify-content: space-between; font-size: 0.85rem; }
.scn .metric b { font-family: var(--mono); }
.scn .headline { font-size: 1.5rem; font-weight: 700; font-family: var(--mono); }
.scn .best { color: var(--text-dim); font-size: 0.8rem; margin-top: auto; }

/* ---- stat blocks ----------------------------------------------------- */
.stat { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--bg-raised); }
.stat .k { color: var(--text-dim); font-size: 0.78rem; letter-spacing: 0.04em; }
.stat .v { font-size: 1.35rem; font-weight: 700; font-family: var(--mono); margin-top: 4px; }

/* ---- deal list ------------------------------------------------------- */
.deal-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-card); margin-bottom: 10px; cursor: pointer;
}
.deal-row:hover { border-color: var(--brand-a); }
.deal-row .meta { color: var(--text-dim); font-size: 0.8rem; }

/* ---- misc ------------------------------------------------------------ */
.muted { color: var(--text-dim); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.chip-copy { cursor: pointer; -webkit-user-select: all; user-select: all; word-break: break-all; }
.divider { height: 1px; background: var(--line-soft); margin: 20px 0; border: 0; }
.chart-box { position: relative; height: 320px; }
.disclaimer {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-raised); padding: 16px 18px; color: var(--text-dim);
  font-size: 0.82rem; line-height: 1.6;
}
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  z-index: 50; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { border-color: var(--bad); }

.overlay {
  position: fixed; inset: 0; background: rgba(4, 5, 7, 0.72);
  display: none; align-items: center; justify-content: center; z-index: 40; padding: 20px;
}
.overlay.show { display: flex; }
.overlay .card { max-width: 560px; width: 100%; margin: 0; max-height: 88vh; overflow: auto; }

.brand-b { color: var(--brand-b); }
.brand-a { color: var(--brand-a); }
.hidden { display: none !important; }

/* ---- print ----------------------------------------------------------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #111; }
  .no-print { display: none !important; }

  /* Branded bands stay dark so the on-black brand logos and the white C&P mark
     remain legible. The document body prints white for readability. */
  .topbar { position: static; background: #0a0b0d; border-color: #0a0b0d; }
  .topbar .fac small { color: #aab2c0 !important; }
  .lockup { background: #0a0b0d; border-color: #0a0b0d; break-inside: avoid; }
  .lockup .brand span, .lockup .x { color: #aab2c0 !important; }
  #facBottom { background: #0a0b0d; padding: 8px 16px; border-radius: 8px; }

  .card, .scn, .stat, .tablewrap, .disclaimer {
    box-shadow: none; border-color: #ccc; background: #fff; break-inside: avoid;
  }
  h1, h2, h3, td, th, .stat .v, .scn .headline, p, .muted, .small { color: #111 !important; }
  .muted, .help, .meta, #facBottomLine { color: #555 !important; }
  a { color: #111; }
  .chart-box { height: 260px; }
  .badge.known { color: #0a7d43; }
  .badge.estimate { color: #9a6a00; }
  .badge.recommended { color: #c85a00; }
}
