/* LeakFinder — animated modern UI. Mobile-first. */
:root {
  --bg: #0b1220;
  --bg-2: #0f1830;
  --surface: #141d33;
  --surface-2: #1a2540;
  --border: #243052;
  --text: #f1f5fb;
  --muted: #9aa7c2;
  --accent: #22c55e;
  --accent-2: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --info: #60a5fa;
  --violet: #a78bfa;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.5;
  background-image: radial-gradient(1200px 500px at 50% -10%, rgba(34,197,94,.08), transparent);
}
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent); color: #06230f; padding: .6rem 1rem; border-radius: 0 0 8px 0; z-index: 200; font-weight: 700; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
/* View headings demoted from h1 (one h1 per page) — keep the h1 look. */
.view-title { font-size: 1.7rem; line-height: 1.2; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 1.2rem; }
.accent { color: var(--accent-2); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--muted); margin: 0 0 .4rem; }
.section-title { margin: 1.8rem 0 .8rem; font-size: 1.05rem; }

/* ---------- header / nav ---------- */
.app-header { position: sticky; top: 0; z-index: 50; background: rgba(11,18,32,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 860px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; }
.brand-mark { color: var(--accent-2); display: inline-flex; animation: brandPulse 3.2s ease-in-out infinite; }
@keyframes brandPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.main-nav { display: flex; gap: .15rem; }
.nav-btn { background: none; border: 0; color: var(--muted); font: inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem .6rem; border-radius: 10px; cursor: pointer; font-size: .68rem; min-width: 62px; transition: color .2s, background .2s, transform .15s; }
.nav-btn svg { width: 21px; height: 21px; }
.nav-btn:hover { color: var(--text); background: var(--surface); }
.nav-btn:active { transform: scale(.94); }
.nav-btn[aria-current="page"] { color: var(--accent-2); background: rgba(34,197,94,.12); }

main { max-width: 860px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }
.view[hidden] { display: none; }

/* ---------- buttons / fields ---------- */
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: .75rem 1.2rem; cursor: pointer; transition: transform .15s, box-shadow .2s, background .2s, opacity .2s; display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
.btn:active { transform: scale(.96); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #16a34a); color: #04170b; box-shadow: 0 6px 18px rgba(34,197,94,.35); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(34,197,94,.5); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #223052; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-danger { background: rgba(248,113,113,.12); color: var(--danger); border: 1px solid rgba(248,113,113,.4); }
.btn-big { font-size: 1.05rem; padding: .9rem 1.6rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .7rem; }
.link-btn { background: none; border: 0; color: var(--accent-2); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.file-label { cursor: pointer; }

.field { display: block; margin-bottom: .85rem; }
.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }
.field input, .field select { width: 100%; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; transition: border-color .2s, box-shadow .2s; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,.18); outline: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.check-field { display: flex; align-items: center; gap: .6rem; margin: .9rem 0; cursor: pointer; font-weight: 600; }
.check-field input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .85rem; }
.form-error { color: var(--danger); background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.35); border-radius: 10px; padding: .6rem .8rem; font-size: .88rem; }
.search-row { margin-bottom: 1rem; }
.search-row input { width: 100%; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; }
.search-row input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(34,197,94,.15); }

/* ---------- wizard ---------- */
.wizard { max-width: 640px; margin: 1rem auto 0; }
.wizard-progress { margin-bottom: 1.6rem; }
.wizard-progress-bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: .9rem; }
.wizard-progress-bar::after { content: ""; display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s cubic-bezier(.22,1,.36,1); }
.wizard-steps { list-style: none; display: flex; margin: 0; padding: 0; }
.wizard-step { flex: 1; display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; font-weight: 600; }
.wizard-step .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; transition: all .3s; flex: none; }
.wizard-step.is-active { color: var(--text); }
.wizard-step.is-active .dot { background: var(--accent); border-color: var(--accent); color: #04170b; box-shadow: 0 0 0 4px rgba(34,197,94,.2); animation: dotPop .4s cubic-bezier(.34,1.56,.64,1); }
.wizard-step.is-done .dot { background: rgba(34,197,94,.2); border-color: var(--accent); color: var(--accent-2); }
@keyframes dotPop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }
.wizard-panel { animation: panelIn .45s cubic-bezier(.22,1,.36,1); }
@keyframes panelIn { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: none; } }
.wizard-panel[hidden] { display: none; }
.wizard-actions { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1.4rem; }

.quickadd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .55rem; max-height: 46vh; overflow-y: auto; padding: .2rem; }
.qa-chip { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .65rem; cursor: pointer; text-align: left; color: var(--text); font: inherit; transition: transform .15s, border-color .2s, background .2s; animation: chipIn .4s both; animation-delay: calc(var(--i, 0) * 22ms); }
@keyframes chipIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.qa-chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.qa-chip .qa-name { display: block; font-weight: 700; font-size: .88rem; }
.qa-chip .qa-price { display: block; color: var(--muted); font-size: .78rem; }
.qa-chip.is-added { border-color: var(--accent); background: rgba(34,197,94,.12); }
.qa-chip.is-added .qa-name::after { content: " ✓"; color: var(--accent-2); }

.mini-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem; animation: chipIn .35s both; }
.mini-row .n { font-weight: 700; }
.mini-row .p { color: var(--muted); font-size: .85rem; }
.mini-row button { background: none; border: 0; color: var(--danger); font-size: 1.1rem; cursor: pointer; padding: .2rem .4rem; border-radius: 8px; }
.wizard-summary { background: linear-gradient(135deg, rgba(34,197,94,.16), rgba(52,211,153,.06)); border: 1px solid rgba(34,197,94,.35); border-radius: var(--radius); padding: 1rem 1.2rem; margin-top: 1rem; }
.wizard-summary strong { font-size: 1.3rem; color: var(--accent-2); }

/* ---------- dashboard ---------- */
.dash-hero { background: linear-gradient(160deg, var(--surface), var(--bg-2)); border: 1px solid var(--border); border-radius: 20px; padding: 1.4rem; margin-bottom: 1rem; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.dash-hero::before { content: ""; position: absolute; inset: -40% -20% auto; height: 120%; background: radial-gradient(closest-side, rgba(34,197,94,.14), transparent); pointer-events: none; animation: heroGlow 6s ease-in-out infinite alternate; }
@keyframes heroGlow { to { transform: translateX(8%); opacity: .7; } }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: .4rem 0 .8rem; position: relative; }
.total-card { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.total-card.highlight { border-color: rgba(34,197,94,.5); background: rgba(34,197,94,.07); }
.total-label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.total-value { display: block; font-size: clamp(1.5rem, 6vw, 2.1rem); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.total-note { color: var(--muted); font-size: .85rem; margin: 0 0 1rem; position: relative; }
.dash-actions { display: flex; gap: .6rem; flex-wrap: wrap; position: relative; }

.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.share-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .85rem; animation: chipIn .45s both; animation-delay: calc(var(--i, 0) * 45ms); }
.share-top { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; margin-bottom: .45rem; }
.share-name { font-weight: 700; }
.share-amt { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.share-bar { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.share-fill { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--violet), var(--info)); transition: width 1s cubic-bezier(.22,1,.36,1); }
.share-pct { font-size: .75rem; color: var(--muted); margin-top: .25rem; display: block; font-variant-numeric: tabular-nums; }

/* trial rings */
.trials-row { display: flex; gap: .9rem; overflow-x: auto; padding: .3rem .1rem 1rem; }
.trial-card { flex: 0 0 auto; width: 150px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem .7rem; text-align: center; animation: chipIn .45s both; animation-delay: calc(var(--i, 0) * 60ms); }
.trial-card .tname { font-weight: 700; font-size: .85rem; display: block; margin-top: .5rem; }
.trial-card .tdays { color: var(--warn); font-size: .78rem; font-weight: 700; display: block; }
.ring-wrap { position: relative; width: 84px; height: 84px; margin: 0 auto; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-2); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--warn); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.22,1,.36,1); }
.ring-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.trial-card.urgent .ring-fg { stroke: var(--danger); }
.trial-card.urgent .tdays { color: var(--danger); }

.renew-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.renew-item { display: flex; justify-content: space-between; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .65rem .85rem; animation: chipIn .4s both; animation-delay: calc(var(--i, 0) * 40ms); }
.renew-item .d { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.insight-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.insight { background: rgba(96,165,250,.07); border: 1px solid rgba(96,165,250,.3); border-radius: 12px; padding: .8rem 1rem; font-size: .92rem; animation: chipIn .45s both; animation-delay: calc(var(--i, 0) * 60ms); }
.insight.warn { background: rgba(251,191,36,.07); border-color: rgba(251,191,36,.35); }
.insight.good { background: rgba(34,197,94,.07); border-color: rgba(34,197,94,.35); }

/* empty state */
.empty-state { text-align: center; padding: 2.5rem 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: 20px; margin-bottom: 1.2rem; }
.empty-art svg { width: 150px; height: auto; }
.es-wallet-body { fill: var(--surface-2); stroke: var(--violet); stroke-width: 3; }
.es-wallet-band { fill: rgba(167,139,250,.25); }
.es-wallet-clasp { fill: var(--accent); }
.es-shadow { fill: rgba(0,0,0,.35); }
.es-wallet { animation: walletBob 3s ease-in-out infinite; transform-origin: 80px 75px; }
@keyframes walletBob { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-6px) rotate(-2deg); } }
.es-drop { fill: var(--accent-2); opacity: 0; animation: dropFall 2.4s ease-in infinite; }
.es-drop.d2 { animation-delay: .8s; } .es-drop.d3 { animation-delay: 1.6s; }
@keyframes dropFall { 0% { opacity: 0; transform: translateY(-8px); } 25% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(46px); } }

/* ---------- triage ---------- */
.triage-hero { margin-bottom: 1.2rem; }
.triage-hero h2 { margin-bottom: .3rem; }
.savings-card { background: linear-gradient(135deg, rgba(34,197,94,.18), rgba(52,211,153,.05)); border: 1px solid rgba(34,197,94,.4); border-radius: 20px; padding: 1.2rem 1.4rem; margin-top: 1rem; box-shadow: var(--shadow); }
.savings-label { display: block; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.savings-value { display: block; font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 800; color: var(--accent-2); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.savings-per { font-size: 1rem; color: var(--muted); font-weight: 600; }
.savings-sub { color: var(--muted); font-size: .85rem; }
.triage-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.triage-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem; display: grid; gap: .6rem; animation: chipIn .45s both; animation-delay: calc(var(--i, 0) * 45ms); transition: border-color .3s, background .3s; }
.triage-item[data-status="kill"] { border-color: rgba(248,113,113,.55); background: rgba(248,113,113,.05); }
.triage-item[data-status="keep"] { border-color: rgba(34,197,94,.45); }
.triage-item[data-status="maybe"] { border-color: rgba(251,191,36,.45); }
.triage-top { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.triage-name { font-weight: 700; }
.triage-cost { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem; }
.seg button { font: inherit; font-weight: 700; font-size: .85rem; border: 1px solid var(--border); background: var(--bg-2); color: var(--muted); border-radius: 10px; padding: .55rem .2rem; cursor: pointer; transition: all .2s; }
.seg button:hover { color: var(--text); }
.seg button:active { transform: scale(.95); }
.seg button[aria-pressed="true"].seg-kill { background: rgba(248,113,113,.2); border-color: var(--danger); color: var(--danger); box-shadow: 0 0 0 3px rgba(248,113,113,.12); }
.seg button[aria-pressed="true"].seg-keep { background: rgba(34,197,94,.18); border-color: var(--accent); color: var(--accent-2); box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.seg button[aria-pressed="true"].seg-maybe { background: rgba(251,191,36,.15); border-color: var(--warn); color: var(--warn); box-shadow: 0 0 0 3px rgba(251,191,36,.12); }

/* ---------- guides ---------- */
.guides-list { display: grid; gap: .6rem; }
.guide { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; animation: chipIn .4s both; animation-delay: calc(var(--i, 0) * 30ms); }
.guide > summary { list-style: none; cursor: pointer; padding: .85rem 1rem; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.guide > summary::-webkit-details-marker { display: none; }
.guide > summary::after { content: "+"; font-size: 1.3rem; color: var(--accent-2); transition: transform .25s; flex: none; }
.guide[open] > summary::after { transform: rotate(45deg); }
.guide-body { padding: 0 1rem 1rem; }
.guide-body ol { margin: .2rem 0 .8rem; padding-left: 1.2rem; color: var(--muted); }
.guide-body li { margin-bottom: .35rem; }
.guide-body .ext { color: var(--accent-2); font-size: .88rem; }

/* ---------- settings cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card h2 { margin-top: 0; }
.fx-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; align-items: end; margin-bottom: .6rem; }
.fx-row .code { font-weight: 800; padding: .7rem 0; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,8,16,.7); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; z-index: 100; animation: fadeIn .25s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 20px 20px 0 0; padding: 1.4rem; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; animation: sheetUp .35s cubic-bezier(.22,1,.36,1); }
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.1rem; }

/* ---------- toast ---------- */
.toast-region { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 120; display: grid; gap: .5rem; width: min(92vw, 420px); }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: .8rem 1rem; font-size: .9rem; box-shadow: var(--shadow); animation: toastIn .35s cubic-bezier(.34,1.56,.64,1); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }

/* ---------- footer ---------- */
.app-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem 2rem; }

/* ---------- print ---------- */
@media print {
  .app-header, .app-footer, .dash-actions, .main-nav, .btn, .toast-region, .modal-backdrop, .search-row { display: none !important; }
  body { background: #fff; color: #111; }
  main { max-width: none; }
  .view { display: block !important; }
  #view-welcome, #view-triage, #view-guides, #view-settings { display: none !important; }
  #view-dashboard { display: block !important; }
  .dash-hero, .total-card, .share-item, .insight { break-inside: avoid; background: #fff !important; color: #111 !important; border-color: #ccc !important; box-shadow: none !important; }
  .total-value, .share-name { color: #111 !important; }
  .share-fill { background: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  h1, h2, .eyebrow, .total-note, .share-amt, .share-pct { color: #333 !important; }
  .total-card.highlight .total-value { color: #0a7a3d !important; }
}

/* ---------- responsive ---------- */
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 1rem; }
  .modal { border-radius: 20px; }
  .triage-item { grid-template-columns: 1fr auto; align-items: center; }
  .seg { min-width: 280px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .brand-mark, .dash-hero::before, .es-wallet, .es-drop { animation: none !important; }
  .es-drop { opacity: 0 !important; }
  .share-fill { transition: none !important; }
}
