/* ============================================================================
 * Advisor app styles — professional white-label design system.
 * Accent color is themeable via --accent (set from Brand Settings).
 * ==========================================================================*/
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #16202e;          /* deep navy — headers, primary text */
  --ink-2: #2c3a4d;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --accent: #8a6d3b;       /* themeable brand color */
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --green: #15803d;
  --green-soft: #f0faf3;
  --red: #b23b2e;
  --bg: #f6f8fa;
  --card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(22, 32, 46, .06);
  --shadow-md: 0 4px 16px rgba(22, 32, 46, .10);
  --shadow-lg: 0 12px 32px rgba(22, 32, 46, .16);
  --radius: 12px;
}

html { scroll-behavior: smooth; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------- header -------------------------------- */
header {
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #fff; padding: 26px 36px 22px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
#brand-logo { max-height: 46px; max-width: 160px; border-radius: 6px; display: none; }
#brand-logo.show { display: block; }
.header-text { flex: 1; min-width: 260px; }
header h1 { font-weight: 300; font-size: 25px; letter-spacing: 0.2px; }
header h1 .brand-name { font-weight: 600; }
header .tagline { color: #9fb0c2; font-size: 13px; margin-top: 3px; }
#brand-settings-btn {
  background: rgba(255,255,255,.08); color: #cbd5e1; border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer; transition: all .15s;
}
#brand-settings-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ------------------------------- tab bar ------------------------------- */
.tab-bar {
  background: var(--ink); padding: 0 36px; display: flex; gap: 4px;
  position: sticky; top: 0; z-index: 40; box-shadow: var(--shadow-md);
}
.tab-btn {
  background: transparent; color: #94a3b8; border: none; padding: 14px 24px 15px;
  font-size: 14.5px; cursor: pointer; border-bottom: 3px solid transparent;
  transition: color .15s; font-family: inherit;
}
.tab-btn:hover { color: #fff; }
.tab-btn.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1220px; margin: 0 auto; padding: 30px 24px 90px; }

/* -------------------------------- panels ------------------------------- */
section.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 32px; margin-bottom: 26px; box-shadow: var(--shadow-sm);
}
section.panel > h2 { font-weight: 550; font-size: 19px; margin-bottom: 4px; letter-spacing: -0.2px; }
section.panel > .hint { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; max-width: 900px; }

/* ---------------------- section head + suggestions ---------------------- */
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 10px; flex-shrink: 0; padding-top: 4px; }
.suggest-box {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, white);
  border-radius: var(--radius); padding: 18px 22px; margin: 14px 0 20px;
}
.suggest-box h3 { font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); margin-bottom: 8px; }
.suggest-box .hint { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.suggest-box ul { margin: 0 0 12px 20px; font-size: 13.5px; }
.suggest-box li { margin-bottom: 6px; }

/* --------------------------------- form -------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px 22px; align-items: end; }
.field label {
  display: block; font-size: 11px; font-weight: 650; color: var(--muted);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; line-height: 1.35;
}
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px;
  font-size: 15px; font-family: inherit; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .param input:focus, .param select:focus,
#library-search:focus, .scenario-box input.label-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.field.check { display: inline-flex; align-items: center; gap: 9px; }
.field.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.field.check label { margin: 0; text-transform: none; font-size: 13.5px; letter-spacing: 0; font-weight: 500; color: var(--ink-2); }
.check-row { display: flex; gap: 32px; flex-wrap: wrap; margin-top: 16px; }
.form-group { border-top: 1px solid var(--line-soft); padding: 18px 0 8px; margin-top: 12px; }
.form-group:first-of-type { border-top: none; margin-top: 0; padding-top: 4px; }
.group-title {
  font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--accent); margin-bottom: 14px;
}

/* --------------------------- strategy library --------------------------- */
#library-search {
  width: 100%; padding: 13px 18px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; margin-bottom: 22px; font-family: inherit; background: #fff;
}
.lib-category { margin-bottom: 26px; }
.lib-cat-title {
  font-size: 12.5px; font-weight: 750; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--accent); margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.lib-cat-title .count, .pick-category .count { color: var(--muted); font-weight: 450; }
.lib-cat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.strategy-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: box-shadow .18s, transform .18s, border-color .18s; background: #fff;
  display: flex; flex-direction: column;
}
.strategy-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.strategy-card h4 { margin: 10px 0 6px; font-size: 15.5px; font-weight: 650; letter-spacing: -0.1px; }
.strategy-card p { font-size: 13px; color: var(--muted); flex: 1; }
.category-badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.7px;
  padding: 3px 10px; border-radius: 20px;
}
.advisory-badge {
  display: inline-block; background: #eef2f7; color: #51677f; font-size: 10px; font-weight: 750;
  text-transform: uppercase; letter-spacing: 0.6px; padding: 2px 9px; border-radius: 20px; margin-left: 6px;
}
.card-actions { display: flex; gap: 18px; align-items: baseline; margin-top: 12px; }
.strategy-card .link { font-size: 13px; color: var(--accent); font-weight: 650; }
.card-actions .card-pdf { color: #4a6a8a; }
.card-actions .link:hover { text-decoration: underline; }

/* --------------------------- scenario builders -------------------------- */
.scenarios { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 880px) { .scenarios { grid-template-columns: 1fr; } }
.scenario-box { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 20px; background: #fcfdfe; }
.scenario-box input.label-input {
  width: 100%; font-size: 16px; font-weight: 650; border: none; border-bottom: 2px solid var(--accent);
  padding: 4px 2px 6px; margin-bottom: 14px; background: transparent; font-family: inherit;
}
.pick-category { border-top: 1px solid var(--line-soft); padding: 2px 0; }
.pick-category summary {
  cursor: pointer; padding: 10px 0; text-transform: uppercase; letter-spacing: 0.8px;
  font-size: 12px; font-weight: 750; color: var(--ink-2); list-style-position: inside; transition: color .15s;
}
.pick-category summary:hover { color: var(--accent); }
.strategy-pick { border-top: 1px dashed var(--line-soft); padding: 9px 0 9px 8px; }
.pick-label { font-size: 14px; font-weight: 550; cursor: pointer; display: flex; gap: 9px; align-items: center; }
.pick-label input { width: 16px; height: 16px; accent-color: var(--accent); }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 12px 0 4px 27px; }
.param label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.param input, .param select {
  width: 100%; padding: 7px 9px; border: 1.5px solid var(--line); border-radius: 6px;
  font-size: 14px; font-family: inherit;
}

/* ------------------------------- buttons -------------------------------- */
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 8px 0 0; }
button.primary {
  background: var(--ink); color: #fff; border: none; border-radius: 10px; padding: 14px 32px;
  font-size: 15.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  box-shadow: var(--shadow-sm); transition: all .15s;
}
button.primary:hover { background: var(--ink-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
button.secondary {
  background: #fff; color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 22px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .15s;
}
button.secondary:hover { border-color: var(--accent); color: var(--accent); }
.fee-group { display: flex; gap: 12px; align-items: flex-end; margin-left: auto; padding-left: 16px; border-left: 1px solid var(--line); }
.fee-field label { display: block; font-size: 10.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.fee-field input { width: 130px; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 14px; text-align: right; }

/* ------------------------------- results -------------------------------- */
.results-context { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin: 2px 0 16px; }
.results-context .rc-client { font-size: 21px; font-weight: 650; letter-spacing: -0.3px; }
.results-context .rc-meta { font-size: 13px; color: var(--muted); }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 6px 0 26px; }
@media (max-width: 920px) { .kpi-row { grid-template-columns: 1fr 1fr; } }
.kpi {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  background: #fff; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi .kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin-bottom: 6px; }
.kpi .kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi.bad .kpi-value { color: var(--red); }
/* savings cards are the hero: stronger treatment, bigger numbers */
.kpi.good {
  background: linear-gradient(135deg, var(--green-soft), #e6f7ec);
  border-color: #bfe8cd;
}
.kpi.good .kpi-value { color: var(--green); font-size: 31px; font-weight: 750; }
.kpi.good::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--green), #5dd08a);
}
.kpi .kpi-chip {
  display: inline-block; margin-top: 7px; background: var(--green); color: #fff;
  font-size: 11.5px; font-weight: 750; padding: 2px 10px; border-radius: 20px;
}

.bar-chart { margin: 6px 0 28px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 170px; gap: 12px; align-items: center; margin-bottom: 9px; }
.bar-row .bar-label { font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: right; }
.bar-track { background: var(--line-soft); border-radius: 6px; height: 26px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--ink-2), var(--ink)); width: 0; transition: width .9s cubic-bezier(.22,.9,.35,1); }
.bar-row.scenario .bar-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 80%, white), var(--accent)); }
.bar-row .bar-value { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row .bar-delta {
  display: inline-block; margin-left: 8px; background: var(--green-soft); color: var(--green);
  border: 1px solid #bfe8cd; font-size: 11.5px; font-weight: 750; padding: 1px 8px; border-radius: 20px;
}

.results-table { width: 100%; border-collapse: collapse; margin: 10px 0 28px; font-size: 14px; }
.results-table th, .results-table td { padding: 9px 13px; text-align: right; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.results-table th:first-child, .results-table td:first-child { text-align: left; }
.results-table thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted);
  border-bottom: 2px solid var(--ink); font-weight: 700;
}
.results-table tbody tr:hover td { background: #fafcfe; }
.results-table .total-row td { border-top: 2px solid var(--ink); font-weight: 700; background: #fafbfc; }
.results-table .savings-row td { color: var(--green); font-weight: 700; background: var(--green-soft); }
.results-table .due-row td { color: var(--red); font-weight: 700; border-top: 1px solid var(--line); }
.results-table .sav { color: var(--green); }
#results h3 { font-weight: 600; font-size: 16px; margin: 26px 0 8px; letter-spacing: -0.1px; }
ul.notes { margin: 8px 0 8px 20px; font-size: 13.5px; color: var(--muted); }
ul.notes li { margin-bottom: 6px; }
.fine-print { font-size: 12px; color: var(--muted); margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }

/* -------------------------------- modals -------------------------------- */
#detail-modal, #brand-modal, #pdf-review-modal { display: none; position: fixed; inset: 0; background: rgba(16,24,34,.58); z-index: 50; padding: 4vh 4vw; backdrop-filter: blur(2px); }
#detail-modal.open, #brand-modal.open, #pdf-review-modal.open { display: flex; justify-content: center; align-items: flex-start; }
.modal-card {
  background: #fff; border-radius: 14px; max-width: 920px; width: 100%; max-height: 92vh;
  overflow-y: auto; padding: 32px 38px; position: relative; box-shadow: var(--shadow-lg);
}
.modal-card.narrow { max-width: 480px; }
.modal-close {
  position: sticky; top: 0; float: right; background: var(--ink); color: #fff; border: none;
  border-radius: 8px; padding: 7px 15px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.advisor-detail h2 { font-weight: 500; margin: 10px 0 18px; font-size: 24px; }
.advisor-detail section { margin-bottom: 22px; }
.advisor-detail h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: 8px; font-weight: 750; }
.advisor-detail ul { margin-left: 20px; font-size: 14px; }
.advisor-detail li { margin-bottom: 6px; }
.advisor-detail p { font-size: 14.5px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 700px) { .cols-2 { grid-template-columns: 1fr; } }
.authority-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.authority-table th, .authority-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.authority-table thead th { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; }
.auth-type { white-space: nowrap; color: var(--accent); font-weight: 750; }
.auth-cite { font-weight: 650; min-width: 180px; }

/* brand settings modal fields */
.brand-field { margin-bottom: 18px; }
.brand-field label { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 6px; }
.brand-field input[type="text"] { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 15px; font-family: inherit; }
.brand-field input[type="color"] { width: 64px; height: 38px; border: 1.5px solid var(--line); border-radius: 8px; cursor: pointer; padding: 2px; background: #fff; }
.brand-swatches { display: flex; gap: 8px; margin-top: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); transition: transform .1s; }
.swatch:hover { transform: scale(1.15); }
#brand-logo-preview { max-height: 50px; max-width: 180px; margin-top: 8px; display: none; border-radius: 6px; }
#brand-logo-preview.show { display: block; }
.brand-actions { display: flex; gap: 10px; margin-top: 22px; }
