/* The app. Builds on site.css: same tokens, same type, same buttons and cards. */
:root { --good: #17663a; --bad: #a12a1c; --tabs: 0px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body.app { background: var(--ivory); overflow-x: hidden; }
.app h1 { font-size: clamp(32px, 3.4vw, 56px); line-height: 1.04; letter-spacing: -0.04em; font-weight: 570; margin-top: 0; text-shadow: none; max-width: none; text-wrap: balance; }
.app h3 { font-size: 17px; }
.app .lede { margin-top: 12px; max-width: 64ch; }
.app-main { padding: calc(68px + var(--tabs) + clamp(28px, 4vw, 56px)) 0 clamp(56px, 7vw, 110px); min-height: 78svh; }
.mono { font-family: "Geist Mono", ui-monospace, monospace; font-size: .92em; }
.wrap-any { overflow-wrap: anywhere; }
.muted { color: var(--mute); }
.loading { color: var(--mute); font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; padding: 60px 0; }
.empty-note { color: var(--mute); background: var(--paper); border: 1px dashed var(--line); border-radius: 14px; padding: 16px 18px; font-size: 15px; }

/* Nav */
.app .nav-links a.on { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; text-decoration-color: var(--gold); opacity: 1; }
.nav-side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.test-sel { width: auto; max-width: 300px; min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 0 12px; font-size: 13.5px; font-family: "Geist Mono", ui-monospace, monospace; }
#connect { font-variant-numeric: tabular-nums; }

/* Page head */
.page-head { margin-bottom: clamp(22px, 2.6vw, 40px); }
.page-head .kicker { margin-bottom: 12px; }
.back { display: inline-flex; align-items: center; min-height: 40px; font-size: 14.5px; color: var(--mute); text-decoration: none; margin-bottom: 4px; }
.back::before { content: ""; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: 8px; }
.back:hover { color: var(--ink); }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.addr-line { color: var(--mute); margin-top: 10px; font-size: 13px; }
.sym { font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; letter-spacing: .06em; color: var(--mute); }
.title-row .sym { border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; background: #fff; }

/* Panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: clamp(20px, 2.1vw, 34px); min-width: 0; }
.panel > .kicker { margin-bottom: 8px; }
.app .panel-h { font-size: clamp(22px, 1.9vw, 30px); letter-spacing: -0.03em; line-height: 1.1; font-weight: 580; max-width: none; margin-bottom: 20px; }
.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(12px, 1.2vw, 20px); align-items: start; }
.span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; } .span-12 { grid-column: span 12; }
.gap { margin-top: 28px; }
.panel h3 { margin-bottom: 12px; }

/* Status tags */
.tag { display: inline-flex; align-items: center; gap: 7px; font-family: "Geist Mono", ui-monospace, monospace; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--paper); color: var(--ink); white-space: nowrap; line-height: 1.4; }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mute); flex: none; }
.tag-good::before { background: var(--good); }
.tag-warn::before, .tag-gold::before { background: var(--gold); }
.tag-bad { color: var(--bad); border-color: #e3c2bc; } .tag-bad::before { background: var(--bad); }
.tag-ink::before { background: var(--ink); }
.tag-mute { color: var(--mute); }
.you { font-family: "Geist Mono", ui-monospace, monospace; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; background: var(--gold); color: var(--ink); border-radius: 6px; padding: 2px 6px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px clamp(16px, 2vw, 36px); }
.stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; }
.stat { border-top: 2px solid var(--ink); padding-top: 12px; min-width: 0; }
.stat-l { font-size: 13px; color: var(--mute); }
.stat-v { font-size: clamp(19px, 1.5vw, 25px); letter-spacing: -0.025em; font-weight: 570; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-s { font-family: "Geist Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--mute); margin-top: 4px; }
.big-num { font-size: clamp(40px, 4.4vw, 72px); letter-spacing: -0.045em; line-height: 1; font-weight: 570; font-variant-numeric: tabular-nums; }
.mark-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }

/* Label and value rows */
.kvs { margin: 0; }
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 6px 18px; padding: 11px 0; border-top: 1px solid var(--mist); font-size: 15px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.evi { display: flex; flex-direction: column; gap: 2px; }
.hash { color: var(--mute); font-size: 12.5px; }

/* Asset list */
.asset-list { display: grid; gap: clamp(12px, 1.2vw, 20px); }
.asset-card { display: block; text-decoration: none; transition: border-color .15s ease, transform .15s ease; }
.asset-card:hover { border-color: var(--ink); transform: translateY(-1px); }
.asset-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.app .asset-name { font-size: clamp(24px, 2.2vw, 36px); letter-spacing: -0.035em; line-height: 1.08; font-weight: 580; max-width: none; }
.asset-top .sym { margin-top: 6px; }
.asset-go { display: inline-flex; align-items: center; min-height: 40px; margin-top: 18px; font-weight: 550; font-size: 14.5px; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--gold); text-decoration-thickness: 2px; }

/* Waterfall */
.wf-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(22px, 3vw, 56px); }
.wf-col { min-width: 0; }
.tier-chart .bar { margin: 6px 0 8px; height: 44px; }
.tiers .sum-row th, .tiers .sum-row td { border-top: 2px solid var(--ink); font-weight: 600; }
.whatif-out { margin-top: 14px; }
.whatif-out .muted { font-size: 14px; }

/* Forms */
.af { margin: 0; }
.af-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 16px; }
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { margin-bottom: 6px; font-size: 13.5px; }
.field input, .pre-wrap { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); min-height: 46px; padding: 0 14px; font-size: 16px; font-weight: 400; }
.field input[type=datetime-local] { font-family: inherit; }
.pre-wrap { display: flex; align-items: center; gap: 6px; }
.pre-wrap input { border: 0; background: none; padding: 0; min-height: 44px; outline-offset: 6px; font-family: "Geist Mono", ui-monospace, monospace; }
.field input:disabled { opacity: .55; }
.pre { color: var(--mute); }
.hint { font-size: 12.5px; color: var(--mute); margin-top: 6px; }
.af > .hint { margin-top: 12px; }
.sum { font-size: 14px; color: var(--mute); margin-top: 12px; background: var(--paper); border: 1px solid var(--mist); border-radius: 12px; padding: 10px 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn-sm { min-height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn-line { background: #fff; color: var(--ink); border-color: var(--ink); }
.btn-line:hover { background: var(--paper); }
.is-busy .app-main .btn { opacity: .55; }
.gate-btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.order-forms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(12px, 1.2vw, 20px); margin-top: 22px; }
.order-forms.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 0; }
.sub-card { border: 1px solid var(--line); border-radius: 18px; padding: clamp(16px, 1.5vw, 24px); background: #fff; min-width: 0; }
.sub-card + .sub-card.chal { margin-top: 14px; }
.callout { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; border: 1px solid var(--gold); background: #fff8e6; border-radius: 16px; padding: 14px 18px; margin: 20px 0 0; font-size: 15px; }
.callout p { flex: 1 1 320px; }
.callout.owed { margin: 0 0 clamp(16px, 2vw, 28px); background: #fff; }
.callout-text { border: 1px solid var(--gold); background: #fff8e6; border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; font-size: 15px; }

/* Folds */
.app details.fold { border-top: 1px solid var(--line); border-bottom: 0; }
.app details.fold:last-of-type { border-bottom: 0; }
.app .fold summary { padding: 15px 40px 15px 0; font-size: 16.5px; min-height: 44px; }
.app .fold summary::after { font-size: 22px; }
.fold-body { padding: 2px 0 22px; }
.fold-body > .muted { margin-bottom: 14px; font-size: 15px; max-width: 70ch; padding: 0; }
.app .fold-body p { padding: 0; max-width: none; }
.app .fold-body p.sum { padding: 10px 14px; }
.panel > details.fold:first-of-type { margin-top: 20px; }
.manage-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 14.5px; margin-top: -8px; }
.manage-meta a, .kv a { text-underline-offset: 4px; }

/* Tables */
.tbl-wrap { margin-top: 22px; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.tbl caption { text-align: left; font-weight: 600; font-size: 17px; letter-spacing: -0.015em; padding-bottom: 8px; }
.tbl th, .tbl td { text-align: left; padding: 11px 14px 11px 0; border-top: 1px solid var(--mist); vertical-align: middle; }
.tbl thead th { font-size: 12.5px; color: var(--mute); font-weight: 500; border-top: 0; white-space: nowrap; }
.tbl .num { text-align: right; font-family: "Geist Mono", ui-monospace, monospace; font-size: 13.5px; }
.tbl thead .num { font-family: inherit; font-size: 12.5px; }
.tbl .act { text-align: right; padding-right: 0; }
.tbl .act .btn { min-height: 40px; }

/* Not deployed */
.gate { display: grid; place-items: center; min-height: 52svh; }
.gate-card { max-width: 760px; padding: clamp(26px, 4vw, 56px); }

/* Toasts */
.toasts { position: fixed; right: var(--edge); bottom: 20px; z-index: 40; display: flex; flex-direction: column; gap: 10px; width: min(400px, calc(100vw - 2 * var(--edge))); }
.toast { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 14px; padding: 12px 14px 12px 16px; box-shadow: 0 10px 30px rgba(14, 15, 12, .12); font-size: 14.5px; }
.toast[data-state=ok] { border-left-color: var(--good); }
.toast[data-state=bad] { border-left-color: var(--bad); }
.toast[data-state=info] { border-left-color: var(--ink); }
.toast-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.toast-title { font-weight: 600; padding-top: 8px; }
.toast-msg { color: var(--mute); overflow-wrap: anywhere; }
.toast[data-state=bad] .toast-msg { color: var(--bad); }
.toast-link { font-family: "Geist Mono", ui-monospace, monospace; font-size: 12.5px; margin-top: 4px; }
.toast-link:empty { display: none; }
.toast-x { flex: none; width: 40px; height: 40px; margin: -4px -6px 0 0; border: 0; background: none; font: inherit; font-size: 22px; line-height: 1; color: var(--mute); cursor: pointer; border-radius: 10px; }
.toast-x:hover { background: var(--mist); color: var(--ink); }

@media (max-width: 1100px) {
  .span-5, .span-7 { grid-column: span 12; }
  .order-forms.three { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --tabs: 48px; }
  .app .nav-links { display: flex; position: fixed; left: 0; right: 0; top: 68px; transform: none; height: 48px; align-items: center; gap: 26px; padding: 0 var(--edge); background: rgba(255, 253, 248, .96); border-bottom: 1px solid var(--line); color: var(--ink); }
  .wf-grid, .order-forms { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  /* Tables become stacked rows so nothing scrolls sideways. */
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl, .tbl tbody, .tbl tr, .tbl td, .tbl caption { display: block; width: 100%; }
  .tbl tr { border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; margin-top: 10px; }
  .tbl td, .tbl .num, .tbl .act { display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: right; padding: 8px 0; border-top: 1px solid var(--mist); }
  .tbl td:first-child { border-top: 0; }
  .tbl td::before { content: attr(data-l); color: var(--mute); font-family: Geist, system-ui, sans-serif; font-size: 13px; text-align: left; flex: none; }
  .tbl .act:empty { display: none; }
  .tbl .act::before { content: none; }
  .tbl .act .btn { width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .toasts { left: var(--edge); right: var(--edge); width: auto; bottom: 12px; }
}
@media (max-width: 520px) {
  .nav.has-test .brand-word { display: none; }
  .tiers { font-size: 13.5px; }
  .tiers td { font-size: 12px; padding-left: 8px; letter-spacing: -0.02em; }
  .tiers .sw { margin-right: 6px; }
  .test-sel { max-width: 150px; }
  .stats.two { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .btn-row .btn { flex: 1 1 auto; }
  .app .nav-cta { padding: 0 14px; }
}
@media (prefers-reduced-motion: reduce) { .asset-card { transition: none; } }
