/* Shared tool-page components (analyzer, loan calculator, surveys).
   Tokens, buttons, and the page shell come from styles.css. */

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.text-link { color: var(--accent-ink); font-weight: 500; font-size: .92rem; }
.app-section { padding-top: 40px; padding-bottom: 56px; }

/* ---------- Cards & panels ---------- */
.panel, .decision-form, .chart-card, .kpi, .insight, .scenario-block, .verdict {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ---------- Upload ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 48px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 18px;
  background:
    radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%),
    var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); box-shadow: var(--ring); }
.dropzone:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.dropzone-icon {
  width: 52px; height: 52px; padding: 13px; margin-bottom: 8px;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  fill: none; stroke: var(--accent-ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.dropzone-title { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.dropzone-hint { color: var(--muted); font-size: .88rem; }
.link-like { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.upload-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.status { min-height: 1.6em; margin: 12px 0 0; color: var(--muted); font-size: .92rem; }
.error {
  margin: 8px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--status-bad) 45%, var(--border));
  color: var(--text-bad);
  background: color-mix(in srgb, var(--status-bad) 7%, var(--surface));
  font-size: .92rem;
}

/* ---------- Results header ---------- */
.results-head { margin-bottom: 24px; }
.results-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: .2em; overflow-wrap: anywhere; }
.chips { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline;
  padding: 4px 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.chip-key { color: var(--text); font-weight: 600; }

/* ---------- Stat tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 28px; }
.kpi { border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.kpi-label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; overflow-wrap: anywhere; }
.kpi-value { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.03em; margin-top: 6px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.kpi-delta.is-good { color: var(--text-good); }
.kpi-delta.is-bad { color: var(--text-bad); }

/* ---------- Insights ---------- */
.insights-block { margin-bottom: 36px; }
.insights-block h3 { font-size: 1.2rem; }
.insights { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.insight {
  position: relative;
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 18px;
  border-radius: 12px;
  overflow: hidden;
}
.insight::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone, var(--status-info)); }
.insight strong { display: block; line-height: 1.35; letter-spacing: -0.01em; }
.insight p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.tone-label { display: block; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 2px; }
.tone-good { --tone: var(--status-good); }
.tone-warn { --tone: var(--status-warn); }
.tone-bad { --tone: var(--status-bad); }
.tone-info { --tone: var(--status-info); }
.tone-icon {
  flex: none;
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--tone, var(--status-info));
  color: #fff;
  font-size: .72rem; font-weight: 700;
  margin-top: 1px;
}
.tone-warn .tone-icon, .tone-warn > .tone-icon { color: #3a2a00; }
.tone-icon-lg { width: 44px; height: 44px; font-size: 1.2rem; margin-top: 0; border-radius: 12px; }

/* ---------- Charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.chart-card { margin: 0; border-radius: 16px; padding: 20px 20px 14px; min-width: 0; }
.chart-card-wide { grid-column: 1 / -1; }
.chart-card figcaption h3, .chart-card > h3 { font-size: 1rem; margin-bottom: 2px; }
.chart-card figcaption p { color: var(--muted); font-size: .85rem; margin-bottom: 14px; }
.chart-box { position: relative; height: 280px; }
.chart-card-wide .chart-box { height: 340px; }
.chart-table { margin-top: 10px; font-size: .85rem; border-top: 1px solid var(--border); padding-top: 8px; }
.chart-table summary, .data-preview summary { cursor: pointer; color: var(--accent-ink); font-weight: 500; padding: 4px 0; font-size: .88rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.num-table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.num-table th, .num-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.num-table th:first-child { text-align: left; }
.num-table thead th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; background: var(--bg-alt); position: sticky; top: 0; }
.num-table tbody th { font-weight: 500; }
.num-table tbody tr:hover { background: var(--surface-2); }
.num-table .is-bad { color: var(--text-bad); }
.data-preview { margin-top: 8px; }
.data-preview .table-wrap { max-height: 420px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 12px; }

/* ---------- Forms ---------- */
.decision-section .app-section { padding-top: 80px; padding-bottom: 80px; }
.decision-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px 22px;
  border-radius: 18px;
  padding: 28px;
}
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-wide, .form-actions { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .88rem; color: var(--text-2); }
.field small { color: var(--faint); font-size: .78rem; }
.optional { font-weight: 400; color: var(--faint); }
.field input {
  font: inherit; font-size: .95rem;
  width: 100%; min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:hover { border-color: var(--faint); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.field input::placeholder { color: var(--faint); }

/* One bordered control containing a $ / % / unit affix. */
.input-affix {
  display: flex; align-items: stretch;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input-affix:hover { border-color: var(--faint); }
.input-affix:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.input-affix span { display: grid; place-items: center; padding: 0 0 0 14px; color: var(--faint); font-size: .92rem; font-weight: 500; }
.input-affix-end span { padding: 0 14px 0 0; }
.field .input-affix input {
  height: 100%; border: 0; border-radius: 10px; background: transparent; box-shadow: none;
  padding: 0 14px 0 6px; font-variant-numeric: tabular-nums;
}
.field .input-affix-end input { padding: 0 6px 0 14px; }
.field .input-affix input:focus { box-shadow: none; }
.form-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.form-actions .muted { font-size: .84rem; }

/* ---------- Decision result ---------- */
.decision-result { margin-top: 28px; }
.verdict {
  position: relative;
  border-radius: 18px;
  padding: 24px 26px;
  margin-bottom: 20px;
  overflow: hidden;
}
.verdict::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--tone); }
.verdict-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.verdict-head h3 { font-size: 1.55rem; margin: 0; letter-spacing: -0.025em; }
.verdict-kicker { display: block; color: var(--muted); font-size: .82rem; font-weight: 500; overflow-wrap: anywhere; }
.reasons { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tone-neutral { --tone: var(--accent); }
.facts { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); }
.facts li::marker { color: var(--accent); }
.facts-note { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); color: var(--faint); font-size: .85rem; }
.reasons li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); }
.decision-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.scenario-block { border-radius: 16px; padding: 20px; }
.scenario-block h3 { font-size: 1rem; }
.scenario-block p { margin: 12px 0 0; }

/* ---------- Get a quote ---------- */
.quote-card {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.quote-main, .quote-side { padding: 32px; }
.quote-side { background: var(--bg-alt); border-left: 1px solid var(--border); display: flex; flex-direction: column; align-items: flex-start; }
.quote-card h2 { font-size: 1.25rem; margin-bottom: 14px; }
.quote-main .checklist { margin-bottom: 16px; }
.quote-btn { margin: 8px 0 18px; }
.quote-copy { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.quote-address { font-weight: 600; overflow-wrap: anywhere; }
.quote-note { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--border); }
@media (max-width: 860px) {
  .quote-card { grid-template-columns: minmax(0, 1fr); }
  .quote-side { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .quote-main, .quote-side { padding: 22px 18px; }
  .quote-btn { width: 100%; }
}

/* ---------- Guided decision tools ---------- */
.decision-types { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.decision-type {
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.decision-type:hover { border-color: var(--border-strong); }
.decision-type.is-selected { border-color: var(--accent); box-shadow: var(--ring); }
.decision-type strong { font-size: .95rem; letter-spacing: -0.01em; }
.decision-type .muted { font-size: .8rem; line-height: 1.45; }
.decision-type-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); margin-bottom: 4px; }
.decision-type-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--accent-ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.decision-type.is-selected .decision-type-icon { background: var(--accent); }
.decision-type.is-selected .decision-type-icon svg { stroke: #fff; }

.context-note {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--muted); font-size: .88rem;
}
.context-note.has-data {
  border-style: solid;
  border-color: color-mix(in srgb, var(--status-good) 40%, var(--border));
  background: color-mix(in srgb, var(--status-good) 6%, var(--surface));
  color: var(--text-2);
}
.data-badge, .prefill-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 600;
  color: var(--text-good);
  background: color-mix(in srgb, var(--status-good) 12%, transparent);
  border-radius: 999px; padding: 2px 9px;
  white-space: nowrap;
}
.prefill-badge { align-self: flex-start; }
.prefill-badge::before { content: "✓"; }
.form-section { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); }
.form-section h3 { font-size: .95rem; margin: 0; }

.tipping-card {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--ink); color: #fff;
  border-radius: 20px;
  padding: 28px 32px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}
.tipping-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 140% at 100% 0%, rgba(84, 110, 255, .45), transparent 70%),
    linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px) 0 0 / 40px 40px;
}
.tipping-card p { margin: 0; }
.tipping-kicker { font-size: .72rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #9fb0ff; margin-bottom: 10px !important; }
.tipping-label { color: #c3cbe0; font-size: 1.02rem; }
.tipping-value { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; margin: 4px 0 8px !important; font-variant-numeric: tabular-nums; }
.tipping-text { color: #98a3bd; max-width: 46em; }
.tone-info { --tone: var(--status-info); }

.decision-grid.no-side { grid-template-columns: minmax(0, 1fr); }
.assumptions { margin-top: 20px; }
.assumptions h3 { font-size: .95rem; margin-bottom: 8px; }
.decision-notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: .85rem; display: grid; gap: 4px; }

@media (max-width: 1000px) {
  .decision-types { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .decision-types { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .decision-type { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 12px; padding: 12px 14px; }
  .decision-type .muted { flex-basis: 100%; }
  .decision-type-icon { margin: 0; }
  .tipping-card { padding: 22px 20px; }
}

/* ---------- Confirmation dialog ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(7, 11, 22, .55); backdrop-filter: blur(2px); }
.dialog h2 { font-size: 1.25rem; margin: 14px 0 10px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.dialog p { color: var(--muted); font-size: .93rem; margin: 0 0 10px; }
.dialog-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--status-bad) 12%, transparent);
  color: var(--text-bad); font-weight: 700; font-size: 1.1rem;
}
.dialog-label { display: block; margin-top: 16px; font-size: .88rem; color: var(--text-2); }
.dialog-input {
  display: block; width: 100%; margin-top: 8px;
  height: 44px; padding: 0 14px;
  font: inherit; letter-spacing: .08em;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
.dialog-input:focus { outline: none; border-color: var(--status-bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-bad) 22%, transparent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.danger-zone { border-color: color-mix(in srgb, var(--status-bad) 30%, var(--border)); }
.danger-zone p { margin-bottom: 14px !important; }

/* ---------- Accounts ---------- */
.account-bar {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 12px 16px; margin: 0 0 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--muted); font-size: .9rem;
}
.account-bar .btn { margin-left: auto; }
.account-bar.is-saved {
  border-style: solid;
  border-color: color-mix(in srgb, var(--status-good) 40%, var(--border));
  background: color-mix(in srgb, var(--status-good) 6%, var(--surface));
  color: var(--text-2);
}
.account-bar a { color: var(--accent-ink); font-weight: 500; }

.auth-page {
  position: relative;
  display: grid; place-items: center;
  min-height: calc(100vh - 64px - 220px);
  padding: 64px 16px;
  background:
    radial-gradient(50% 60% at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--bg-alt);
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.auth-card h1 { font-size: 1.6rem; letter-spacing: -0.03em; }
.auth-card .muted { margin-bottom: 24px; }
.google-button { min-height: 44px; display: flex; justify-content: flex-start; min-width: 0; overflow: hidden; }
.auth-card { min-width: 0; }
.auth-fine-print { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--border); color: var(--faint); font-size: .8rem; }
.auth-card .field { margin-bottom: 16px; }
.auth-submit { width: 100%; margin-top: 4px; }

.dash-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.dash-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.dash-side { display: grid; gap: 16px; }
.dash-panel { border-radius: 16px; padding: 22px; }
.dash-panel h2 { font-size: 1.05rem; margin-bottom: 10px; }
.dash-panel p { margin: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.plan-name { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 6px !important; }
.dash-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }

.survey-rows { list-style: none; padding: 0; margin: 0; }
.survey-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 12px; margin: 0 -12px;
  border-top: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text); text-decoration: none;
  transition: background .15s;
}
.survey-rows li:first-child .survey-row { border-top-color: transparent; }
.survey-row:hover { background: var(--bg-alt); }
.survey-row:hover .arrow { transform: translateX(3px); }
.survey-row-main { display: flex; flex-direction: column; min-width: 0; }
.survey-row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.01em; }
.survey-row-meta { display: flex; align-items: center; gap: 16px; flex: none; }
.survey-row .arrow { color: var(--faint); transition: transform .15s; }
.status-pill { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--muted); }
.status-pill.is-open { color: var(--text-good); border-color: color-mix(in srgb, var(--status-good) 40%, transparent); background: color-mix(in srgb, var(--status-good) 8%, transparent); }
.response-count strong { font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 32px 16px; }
.empty-state p { max-width: 30em; margin: 6px auto 16px; }

@media (max-width: 860px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .survey-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .survey-row-main strong { white-space: normal; }
  .account-bar .btn { margin-left: 0; }
}

.disclaimer { color: var(--faint); font-size: .8rem; padding-top: 8px; padding-bottom: 40px; max-width: 1200px; }

@media (max-width: 860px) {
  .chart-grid, .decision-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .app-section { padding-top: 28px; }
  .decision-form { padding: 18px; border-radius: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 1.3rem; }
  .insights { grid-template-columns: minmax(0, 1fr); }
  .chart-box, .chart-card-wide .chart-box { height: 240px; }
  .decision-section .app-section { padding-top: 56px; padding-bottom: 56px; }
  .dropzone { padding: 36px 18px; }
}
