/* Navigation, tables and chart patterns adapted from lucianLabs UX/UI Prompt. */
:root {
  color-scheme: light;
  --ink: #182a42;
  --muted: #52647b;
  --teal: #1858a4;
  --line: #d9e1eb;
  --bg: #eff3f8;
  --paper: #fff;
  --subtle: #f2f6fb;
  --hover: #eaf2fc;
  --green-bg: #e5f1ed;
  --green-ink: #155d48;
  --green-border: #c4ddd4;
  --button: #1858a4;
  --button-hover: #124680;
  --button-ink: #fff;
  --warn-bg: #fff5de;
  --warn-ink: #795517;
  --warn-border: #ecdbb5;
  --danger: #a73735;
  --focus: #2766ba;
  --bar: #6d9bd0;
  --bar-active: #b16b18;
  --shadow: 0 2px 5px #1026400a;
  --shell: #11243c;
  --shell-line: #354961;
  --shell-text: #edf4ff;
  --shell-muted: #b4c6dd;
  --gold: #f6bf65;
  --gutter: clamp(18px, 3.2vw, 54px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eaf0f9;
  --muted: #a8bad1;
  --teal: #9ac8ff;
  --line: #34465e;
  --bg: #111b2a;
  --paper: #1a283b;
  --subtle: #213248;
  --hover: #273e57;
  --green-bg: #203c38;
  --green-ink: #a0dcc2;
  --green-border: #3b6055;
  --button: #8cbcff;
  --button-hover: #afd2ff;
  --button-ink: #112541;
  --warn-bg: #3e3223;
  --warn-ink: #f3d395;
  --warn-border: #655036;
  --danger: #ffaaa3;
  --focus: #aad0ff;
  --bar: #658cbd;
  --bar-active: #f6bf65;
  --shadow: 0 2px 5px #070b082e;
  --shell: #0c1829;
  --shell-line: #30445e;
}

[hidden] { display: none !important; }
body { font: 14px/1.5 "Segoe UI", system-ui, sans-serif; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; }
h1 { font-size: clamp(31px, 4.1vw, 52px); letter-spacing: -.047em; margin: 8px 0; }
h2 { letter-spacing: -.025em; }
button, .download-template {
  background: var(--paper); color: var(--ink); border-color: var(--line);
  border-radius: 10px; min-height: 40px; padding: 8px 13px; line-height: 1.4;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
button:hover, .download-template:hover { color: var(--teal); background: var(--hover); border-color: var(--green-border); }
button.primary { background: var(--button); border-color: var(--button); color: var(--button-ink); }
button.primary:not(:disabled):hover { background: var(--button-hover); border-color: var(--button-hover); }
button.danger, .negative, .fee-mismatch, .fee-gap { color: var(--danger); }
button:disabled { opacity: .53; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .tablewrap:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 3px;
}
.ui-icon { width: 18px; height: 18px; flex: none; vertical-align: middle; }
button.has-icon, .download-template.has-icon { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button.has-icon .ui-icon, .download-template .ui-icon { width: 17px; height: 17px; }
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; transform: translateY(-200%); background: var(--paper); color: var(--teal); padding: 10px; border-radius: 8px; }
.skip-link:focus { transform: none; }
#backToTop {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  background: var(--button); color: var(--button-ink); border-color: var(--button);
  box-shadow: 0 3px 12px #10264040;
}
#backToTop:hover { background: var(--button-hover); border-color: var(--button-hover); }
#backToTop .ui-icon { width: 20px; height: 20px; }
#content { outline: none; }

.app-shell {
  height: auto; display: block; background: var(--shell); color: var(--shell-text);
  border: 0; border-bottom: 1px solid var(--shell-line);
}
.app-masthead {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 68px; padding: 0 var(--gutter); border-bottom: 1px solid var(--shell-line);
}
.brand { padding: 0; align-items: center; color: var(--shell-text); font-size: 22px; letter-spacing: -.035em; line-height: 1.12; }
.brand small { color: var(--shell-muted); font-size: 9px; letter-spacing: .115em; margin-top: 5px; }
.brandlight { color: var(--gold); font-weight: 700; }
.logo { width: 41px; height: 41px; border-radius: 10px; background: var(--gold); color: #38250c; flex: none; }
.logo .ui-icon { width: 23px; height: 23px; }
.header-actions, .profile { display: flex; align-items: center; gap: 11px; }
.profile { font-weight: 650; }
.avatar { margin: 0; background: #2c4460; color: var(--shell-text); }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 7px; min-height: 35px; border-radius: 8px;
  font-size: 12px; padding: 6px 10px; background: #233953; border-color: #465c76; color: var(--shell-text);
}
.theme-toggle:hover { background: #314b69; border-color: #6b829d; color: white; }
.theme-toggle .ui-icon { width: 16px; height: 16px; color: var(--gold); }
.app-nav {
  display: flex; gap: 15px; overflow-x: auto; margin: 0;
  padding: 0 var(--gutter); scrollbar-width: thin; scrollbar-color: #55708b var(--shell);
}
.app-nav button {
  flex: none; justify-content: center; width: auto; min-height: 46px; margin: 0;
  padding: 0 4px; border-radius: 0; border-bottom: 3px solid transparent;
  color: var(--shell-muted); font-size: 13px; white-space: nowrap;
}
.app-nav button:hover { background: transparent; color: white; }
.app-nav button.active { background: transparent; color: white; border-bottom-color: var(--gold); }
.app-nav button.active .ui-icon { color: var(--gold); }
.app-shell :focus-visible { outline-offset: -3px; outline-color: var(--gold); }
.dot { width: 7px; height: 7px; margin-right: 4px; background: var(--teal); }
.app-shell .dot { background: var(--gold); }

main { margin: 0; padding: 0 var(--gutter) 32px; min-width: 0; }
.pagehead { display: block; margin: 0 0 14px; padding: 22px 0 16px; border-bottom: 1px solid var(--line); }
.page-heading { display: grid; grid-template-columns: 1fr auto; align-items: end; column-gap: 16px; }
.page-heading > :not(.heading-actions) { grid-column: 1; }
.heading-actions { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-wrap: wrap; gap: 8px; }
.pagehead h1 { font-size: clamp(31px, 3.2vw, 44px); margin: 4px 0; }
.pagehead p { font-size: 14px; margin: 3px 0 0; }
.eyebrow { display: flex; align-items: center; gap: 6px; color: var(--teal); font-size: 10px; letter-spacing: .14em; }
#overviewBalance:empty { display: none; }
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 35%); align-items: center; gap: 24px;
  margin-top: 22px; padding: 24px; border-radius: 18px; border: 1px solid #314b69;
  background: radial-gradient(ellipse at 90% 0%, #2c4d72, transparent 55%), #132a44;
  color: var(--shell-text);
}
.pagehead:has(.balance-feature) .page-heading { min-width: 0; }
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) .page-heading { display: block; }
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) .page-heading h1 {
  color: var(--shell-text); font-size: clamp(36px, 4vw, 56px); margin: 5px 0;
}
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) .page-heading p { color: var(--shell-muted); }
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) .eyebrow { color: var(--gold); }
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) .eyebrow .dot { background: var(--gold); }
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) .heading-actions { margin-top: 18px; }
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) #importTop {
  background: var(--gold); border-color: var(--gold); color: #30210d;
}
.pagehead:has(#overviewBalance:not([hidden]):not(:empty)) #importTop:hover { background: #ffd28c; }
#overviewCalc { background: #284460; border-color: #526b88; color: var(--shell-text); }
#overviewCalc:hover { background: #395675; }
.balance-feature {
  width: 100%; display: block; text-align: left; padding: 16px 19px; border: 1px solid #566e8b;
  border-radius: 12px; color: var(--shell-text); background: #263f5d;
}
.balance-feature:hover { border-color: var(--gold); background: #304d6d; color: var(--shell-text); }
.balance-feature:focus-visible { outline-color: var(--gold); }
.balance-top { display: flex; justify-content: space-between; align-items: center; color: var(--gold); }
.balance-top .icon-tile { background: #3c5470; color: var(--gold); }
.balance-label, .balance-note { display: block; color: var(--shell-muted); font-size: 11px; }
.balance-label { letter-spacing: .1em; margin-top: 7px; }
.balance-feature strong { display: block; color: white; font-size: clamp(26px, 3.2vw, 46px); letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.balance-feature strong small { font-size: .48em; color: var(--gold); }
.balance-note { margin-top: 4px; }

.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.card, .panel, .metric { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); min-width: 0; }
.card { padding: 16px; }
.card strong { font-size: clamp(19px, 2.1vw, 28px); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.card.accent { background: var(--green-bg); border-color: var(--green-border); }
.card.accent strong, .money, .fee-match { color: var(--teal); }
.card small, .small, .code, .fee-source, label { color: var(--muted); }
.panelhead { padding: 17px 18px; gap: 12px; }
.controls { padding: 16px 18px; gap: 12px; }
.panelhead > *, .controls > *, .toolbar > *, .trackingfilters > * { min-width: 0; }
input, select { border-color: var(--line); color: var(--ink); background: var(--paper); border-radius: 9px; max-width: 100%; }
input::placeholder { color: var(--muted); }
input[type="file"]::file-selector-button {
  background: var(--subtle); color: var(--ink); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 8px; margin-right: 8px; cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--button); }
.hint, #notice:not(:empty) { background: var(--green-bg); border-color: var(--green-border); color: var(--green-ink); border-radius: 10px; }
.hint + .hint { margin-top: 10px; }
.warning { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-ink); }
.tablewrap { scrollbar-color: var(--line) var(--paper); }
table { font-size: 13px; }
th { background: var(--subtle); color: var(--muted); }
.panel:has(#debtTable) > .panelhead h2 {
  font-size: 22px;
  font-weight: 750;
}
#debtTable thead th,
body:has(#debtTable) .pinned-table-header th {
  font-size: 13px;
  font-weight: 750;
  color: var(--ink);
  letter-spacing: .15px;
}
td { border-color: var(--line); }
tbody tr:nth-child(even) { background: var(--subtle); }
tbody tr:hover { background: var(--hover); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px;
  border-radius: 99px; background: var(--green-bg); color: var(--green-ink); font-weight: 650;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.amountlink, .billlink { min-height: 30px; color: var(--teal); }
.amountlink:hover, .billlink:hover { background: var(--hover); }
.pinned-table-header { background: var(--subtle); box-shadow: 0 2px 6px #172c312b; }
.pagination button { min-width: 32px; min-height: 32px; }
dialog { color: var(--ink); background: var(--paper); border-radius: 20px; border-color: var(--line); box-shadow: 0 24px 85px #080e0a48; }
dialog::backdrop { background: #12211883; }
.modalhead { gap: 10px; background: var(--subtle); padding: 15px 20px; }
.modalhead h2 { margin: 0; overflow-wrap: anywhere; }
#closeModal { border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; min-height: 38px; padding: 0; flex: none; }
#modalBody { padding: 18px; }
.upload { background: var(--subtle); border-color: var(--green-border); }
.upload input { background: var(--paper); }
.sectionbody, .trackingfilters { overflow-wrap: anywhere; }

.summary-cards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: 13px;
  margin: 0 0 14px; overflow: hidden;
}
.metric {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 14px 17px; text-align: left; border: 0; border-radius: 0; box-shadow: none;
}
.metric + .metric { border-left: 1px solid var(--line); }
.metric:focus-visible { outline-offset: -3px; }
.metric > .ui-icon, .step > .ui-icon { width: 16px; height: 16px; color: var(--teal); }
.icon-tile {
  display: inline-grid; place-items: center; flex: none; width: 35px; height: 35px;
  border-radius: 9px; background: var(--subtle); color: var(--teal);
}
.metric-label, .metric-note { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; color: var(--ink); font-size: clamp(19px, 2.1vw, 28px); line-height: 1.13; letter-spacing: -.035em; margin: 3px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-note { font-size: 11px; font-weight: 400; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.95fr) minmax(265px, 1fr); gap: 14px; }
.overview-grid .panel { margin: 0; }
.segments { display: flex; flex-wrap: wrap; padding: 3px; border-radius: 99px; background: var(--subtle); border: 1px solid var(--line); gap: 2px; }
.segments button { min-height: 30px; border: 0; border-radius: 99px; padding: 4px 9px; background: transparent; color: var(--muted); font-size: 12px; }
.segments button[aria-pressed="true"] { background: var(--button); color: var(--button-ink); }
.chart-empty { min-height: 206px; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; padding: 15px; }
#overviewPlot { padding: 10px 14px 12px; }
.chart-readout { color: var(--teal); font-weight: 650; min-height: 26px; margin: 0 4px 5px; }
.chart-scroll { overflow-x: auto; }
.chart-columns { display: grid; grid-template-columns: repeat(var(--columns), minmax(27px, 1fr)); gap: 2px; padding: 3px; }
.chart-column { padding: 0 2px; border-color: transparent; border-radius: 7px; background: transparent; font-weight: 500; }
.chart-column:hover, .chart-column:focus-visible { background: var(--hover); }
.bar-track { display: block; position: relative; height: 120px; background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), var(--line) calc(25% - 1px) 25%); border-bottom: 1px solid var(--line); }
.bar-track::before { content: ""; position: absolute; inset-inline: -4px; top: var(--zero); border-top: 1px solid var(--line); }
.bar { position: absolute; top: var(--start); height: var(--height); inset-inline: 14%; border-radius: 5px 5px 2px 2px; background: var(--bar); }
.bar-negative { background: var(--danger); border-radius: 2px 2px 5px 5px; }
.chart-column.is-highlighted .bar:not(.bar-negative) { background: var(--bar-active); }
.bar-date { display: block; padding: 5px 0; font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart-foot { font-size: 11px; margin: 5px 4px 0; }
.step-list { display: grid; padding: 6px 12px 10px; }
.step { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; text-align: left; border-color: transparent; background: transparent; padding: 8px 6px; }
.step + .step { border-top: 1px solid var(--line); }
.step strong, .step span span { display: block; }
.step-index { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; font: 700 14px/1 ui-monospace, monospace; color: var(--teal); background: var(--subtle); }
.step strong { font-size: 13px; margin: 1px 0; }
.step span span { font-size: 11px; color: var(--muted); font-weight: 400; }
.recent-panel { margin-top: 14px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { padding: 9px 17px; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.recent-list li + li { border-top: 1px solid var(--line); }
.recent-list .icon-tile { width: 30px; height: 30px; }
.recent-name { font-weight: 600; overflow-wrap: anywhere; }
.recent-date { font-size: 11px; color: var(--muted); }

@media (max-width: 900px) {
  .app-nav { gap: 12px; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .metric { padding-inline: 10px; gap: 8px; }
}
@media (max-width: 640px) {
  .app-masthead { min-height: 58px; }
  .profile > span { display: none; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-heading { display: block; }
  .heading-actions { margin-top: 12px; }
  .pagehead:has(#overviewBalance:not([hidden]):not(:empty)) { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 12px; }
  .summary-cards { grid-template-columns: minmax(0, 1fr); }
  .metric + .metric { border-left: 0; border-top: 1px solid var(--line); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  button, .download-template { transition: none; }
}
