:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1b2733;
  --ink-2: #4a5866;
  --ink-3: #7a8794;
  --line: #e1e6eb;
  --brand: #0f4c5c;
  --brand-2: #1f7a8c;
  --accent: #e07a2f;
  --good: #2e7d4f;
  --warn: #b7791f;
  --bad: #c0392b;
  --good-bg: #e8f5ee;
  --warn-bg: #fdf4e3;
  --bad-bg: #fbeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: #fff; padding: 10px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); font-weight: 700; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; }
.brand-text small { font-size: 11px; opacity: .75; }
.topbar-right { font-size: 13px; opacity: .9; }
.topbar-right a { color: #fff; }
.proto-banner {
  background: var(--warn-bg); color: #7a5410; font-size: 12px; text-align: center; padding: 6px 16px;
  border-bottom: 1px solid #f1dfb8;
}

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.loading { color: var(--ink-3); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-body { padding: 14px 20px 18px; }
.stack > * + * { margin-top: 16px; }

/* association list */
.list-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.assoc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.assoc-card { display: block; padding: 16px 18px; color: inherit; transition: border-color .15s, transform .15s; }
.assoc-card:hover { text-decoration: none; border-color: var(--brand-2); transform: translateY(-1px); }
.assoc-card h3 { font-size: 15px; margin-bottom: 4px; }
.assoc-card .meta { color: var(--ink-3); font-size: 12px; }
.assoc-card .stats { display: flex; gap: 18px; margin-top: 12px; }
.assoc-card .stats div { display: flex; flex-direction: column; }
.assoc-card .stats b { font-size: 15px; font-variant-numeric: tabular-nums; }
.assoc-card .stats span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.search { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; min-width: 240px; background: #fff; }

/* association header + tabs */
.assoc-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.assoc-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumb { font-size: 12px; margin-bottom: 6px; display: inline-block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-3); font-weight: 600; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi .delta { font-size: 12px; margin-top: 4px; font-weight: 500; }
.delta.up { color: var(--bad); } .delta.down { color: var(--good); } .delta.flat { color: var(--ink-3); }
.delta.better { color: var(--good); } .delta.worse { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 320px; }
.chart-box.short { height: 240px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-3); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
tbody tr:hover { background: #f8fafb; }
tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
tr.neg td.end { color: var(--bad); font-weight: 600; }
tr.low td.end { color: var(--warn); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable td:first-child { white-space: nowrap; }
tr.detail td { background: #fafbfc; padding: 0; }
tr.detail ul { margin: 0; padding: 8px 20px 10px 34px; columns: 2; column-gap: 32px; }
tr.detail li { font-size: 12px; padding: 2px 0; break-inside: avoid; }
.caret { display: inline-block; width: 12px; color: var(--ink-3); }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #eef2f5; color: var(--ink-2); white-space: nowrap; }
.tag.loan { background: #e7f0fb; color: #1d5fa8; }
.tag.edit { background: var(--warn-bg); color: #8a5a12; }
.tag.off { background: var(--bad-bg); color: var(--bad); }

.upcoming li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.upcoming ul { list-style: none; margin: 0; padding: 0; }
.upcoming .yr { font-weight: 600; color: var(--brand); width: 44px; flex: none; }
.upcoming .nm { flex: 1; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
select, input[type=number], input[type=text] {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}
input[type=number] { width: 110px; text-align: right; }
input.narrow { width: 80px; }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* buttons */
.btn {
  font: inherit; font-weight: 500; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 7px; cursor: pointer;
}
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.link { border: none; background: none; color: var(--brand-2); padding: 4px 6px; }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* modeler */
.model { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.model > *, .grid-2 > *, .stack > * { min-width: 0; }
.controls { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
@media (max-width: 1060px) {
  .model { grid-template-columns: 1fr; }
  .controls { position: static; max-height: none; }
}
.ctrl-section { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ctrl-section:last-child { border-bottom: none; }
.ctrl-section h3 { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; }
.field > span { color: var(--ink-2); }
.field .hint { display: block; font-size: 11px; color: var(--ink-3); }
.input-unit { display: inline-flex; align-items: center; gap: 4px; }
.input-unit em { font-style: normal; color: var(--ink-3); font-size: 12px; }
.byyear { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; margin-top: 8px; }
.byyear label { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 12px; color: var(--ink-2); }
.byyear input { width: 62px; padding: 4px 6px; }
.assess-row { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: center; margin: 6px 0; }
.assess-row input[type=number] { width: 100%; }
.assess-row .per { grid-column: 2 / 4; font-size: 11px; color: var(--ink-3); margin-top: -4px; }
.comp-edit { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.comp-edit table td, .comp-edit table th { padding: 5px 8px; font-size: 12px; }
.comp-edit input[type=number] { width: 66px; padding: 3px 5px; font-size: 12px; }
.comp-edit tr.edited { background: #fffaf0; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.alert.bad { background: var(--bad-bg); color: #8e2a20; border: 1px solid #f2c9c4; }
.alert.warn { background: var(--warn-bg); color: #7a5410; border: 1px solid #f1dfb8; }
.alert.good { background: var(--good-bg); color: #1f5c39; border: 1px solid #c6e6d3; }

details.about { font-size: 13px; color: var(--ink-2); }
details.about summary { cursor: pointer; font-weight: 500; color: var(--ink); }
details.about p { margin: 8px 0 0; }

/* topbar user */
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-right .sep { opacity: .5; }
.topbar-right .who { opacity: .8; }

/* sign in */
.signin { max-width: 440px; margin: 40px auto; padding: 28px 28px 24px; }
.signin h1 { margin-bottom: 8px; }
.signin p { margin: 0 0 14px; }
.signin .alert { margin-bottom: 14px; }
.lbl { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.lbl input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.signin .btn.primary { width: 100%; padding: 10px; }

/* saved scenarios */
.saved { background: #fafbfc; border-radius: var(--radius) var(--radius) 0 0; }
.saved-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.saved-item {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 1px; width: 100%;
  font: inherit; background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; cursor: pointer;
}
.saved-item:hover { border-color: var(--brand-2); }
.saved-item.on { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.saved-item small { color: var(--ink-3); font-size: 11px; }
.sv-form { display: flex; gap: 6px; margin-top: 10px; }
.sv-form input { flex: 1; min-width: 0; }

/* admin */
.ac-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.ac-form input[type=email] { min-width: 220px; flex: 1; }
code { font-size: 12px; background: #eef2f5; padding: 1px 5px; border-radius: 4px; }

.check-table td.ok { color: var(--good); font-weight: 600; }
.check-table td.bad { color: var(--bad); font-weight: 600; }

@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; }
  tr.detail ul { columns: 1; }
  .search { min-width: 0; width: 100%; }
}
