:root {
  color-scheme: light;
  --page: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-solid: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(29, 29, 31, 0.08);
  --blue: #0071e3;
  --blue-soft: #e8f2ff;
  --green: #16875b;
  --green-soft: #e9f7ef;
  --red: #d84a3a;
  --red-soft: #fff0ee;
  --amber: #b96f16;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.07);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(0, 113, 227, .28); outline-offset: 3px; }

.ambient { position: fixed; width: 340px; height: 340px; border-radius: 50%; filter: blur(80px); opacity: .32; pointer-events: none; }
.ambient-one { background: #bfe0ff; top: -160px; right: -140px; }
.ambient-two { background: #d8f2e4; left: -200px; top: 420px; }
.app-shell { width: min(100%, 760px); margin: 0 auto; padding: 0 20px calc(108px + var(--safe-bottom)); position: relative; }

.topbar { height: 86px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
.topbar::before { content: ""; position: absolute; inset: 0 -20px; background: rgba(245,245,247,.78); z-index: -1; border-bottom: 1px solid rgba(255,255,255,.7); }
.brand-mark { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #fff; background: var(--ink); font-size: 14px; font-weight: 750; letter-spacing: -.03em; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-copy span { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand-copy small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.avatar-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: linear-gradient(145deg, #e1edff, #cfe3ff); color: #0d5da7; font-weight: 700; cursor: pointer; }

.view { display: none; animation: viewIn .35s ease both; }
.view.active { display: block; }
.hero-copy { padding: 44px 4px 30px; }
.eyebrow, .card-kicker { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 720; letter-spacing: .09em; }
h1, h2, h3, p { letter-spacing: -.025em; }
.hero-copy h1 { font-size: clamp(44px, 12vw, 72px); line-height: .98; margin: 0; font-weight: 760; }
.hero-copy h1 span { color: #8b8b90; }
.hero-subtitle { max-width: 100%; color: var(--muted); font-size: 19px; line-height: 1.45; margin: 22px 0 0; }

.signal-card { min-height: 224px; border-radius: var(--radius-xl); padding: 30px; color: #fff; background: radial-gradient(circle at 92% 10%, rgba(65,155,255,.72), transparent 34%), linear-gradient(145deg, #15171a, #292d34); box-shadow: var(--shadow); display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; overflow: hidden; position: relative; }
.signal-card::after { content: ""; position: absolute; width: 170px; height: 170px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; right: -40px; top: -55px; }
.signal-card .card-kicker { color: rgba(255,255,255,.62); }
.signal-card h2 { margin: 0 0 8px; font-size: clamp(32px, 9vw, 48px); line-height: 1; max-width: 520px; }
.signal-card p:last-child { margin: 0; color: rgba(255,255,255,.7); font-size: 15px; }
.round-arrow { width: 52px; height: 52px; flex: 0 0 52px; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 26px; cursor: pointer; backdrop-filter: blur(12px); }

.section-heading { display: flex; justify-content: space-between; align-items: baseline; margin: 38px 4px 18px; gap: 12px; min-width: 0; }
.section-heading h2 { margin: 0; font-size: 26px; }
.section-heading span { color: var(--muted); font-size: 13px; text-align: right; min-width: 0; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.module-card { min-height: 150px; padding: 20px; border: 1px solid rgba(255,255,255,.8); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 10px 34px rgba(0,0,0,.045); text-align: left; color: var(--ink); display: flex; flex-direction: column; cursor: pointer; }
.module-card:disabled { opacity: .56; cursor: default; }
.module-card.market { background: linear-gradient(145deg, #f1f7ff, #fff); }
.module-card.purchases { background: linear-gradient(145deg, #eef9f3, #fff); }
.module-card.finance { background: linear-gradient(145deg, #fff8ea, #fff); }
.module-card.workspace { background: linear-gradient(145deg, #f7f2ff, #fff); }
.module-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: #efeff1; color: var(--ink); font-size: 20px; margin-bottom: auto; }
.module-card.market .module-icon { background: var(--blue); color: white; }
.module-card.purchases .module-icon { background: var(--green); color: white; }
.module-card.finance .module-icon { background: #b66a10; color: white; }
.module-card.workspace .module-icon { background: #7153b6; color: white; }
.module-card strong { font-size: 18px; margin-top: 18px; }
.module-card small { color: var(--muted); font-size: 12px; margin-top: 4px; }

.market-header { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 12px; padding: 30px 0 18px; }
.market-header > div { min-width: 0; }
.market-header h1 { margin: 0; font-size: clamp(38px, 10vw, 56px); }
.market-header .eyebrow { margin-bottom: 4px; }
.back-button, .refresh-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255,255,255,.78); color: var(--ink); box-shadow: 0 6px 24px rgba(0,0,0,.055); cursor: pointer; font-size: 28px; display: grid; place-items: center; }
.refresh-button { font-size: 20px; }
.refresh-button.loading { animation: spin .8s linear infinite; }
.period-pill { width: max-content; max-width: 100%; padding: 10px 14px; border-radius: 999px; background: rgba(255,255,255,.75); color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.rate-strip { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.rate-card { border-radius: 20px; padding: 17px 14px; min-height: 106px; min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid rgba(255,255,255,.8); box-shadow: 0 8px 28px rgba(0,0,0,.04); }
.rate-card small { display: block; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; min-height: 24px; }
.rate-card strong { display: block; font-size: clamp(20px, 5.5vw, 28px); margin: 5px 0; white-space: nowrap; }
.delta { color: var(--muted); font-size: 11px; }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }

.product-list { display: grid; gap: 14px; }
.product-card { padding: 24px; border-radius: var(--radius-lg); background: var(--surface-solid); box-shadow: 0 12px 38px rgba(0,0,0,.055); border: 1px solid var(--line); }
.product-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.product-top h3 { font-size: 24px; margin: 0; }
.verdict { padding: 8px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; text-align: right; white-space: nowrap; }
.verdict.good { color: var(--green); background: var(--green-soft); }
.verdict.bad { color: var(--red); background: var(--red-soft); }
.verdict.missing { color: var(--amber); background: #fff5e9; }
.price-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
.price-cell { min-width: 0; }
.price-cell small { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; min-height: 24px; }
.price-cell strong { display: block; font-size: clamp(18px, 5vw, 25px); margin: 5px 0; white-space: nowrap; }

.chart-card { margin-top: 36px; border-radius: var(--radius-xl); padding: 26px; background: #17191d; color: #fff; box-shadow: var(--shadow); }
.chart-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.chart-heading .card-kicker { color: rgba(255,255,255,.55); }
.chart-heading h3 { font-size: 36px; margin: 0; }
.chart-heading > span { color: rgba(255,255,255,.65); font-size: 13px; }
#rateChart { width: 100%; height: 180px; margin-top: 20px; overflow: visible; }
.chart-line { fill: none; stroke: #53a9ff; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#areaGradient); }
.chart-dot { fill: #17191d; stroke: #7dc0ff; stroke-width: 4; }
.chart-axis { display: flex; justify-content: space-between; color: rgba(255,255,255,.42); font-size: 11px; }
.source-note { color: var(--muted); font-size: 12px; line-height: 1.5; padding: 20px 4px 0; }

.purchase-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 4px 0 18px; }
.summary-tile { min-width: 0; min-height: 112px; padding: 18px 15px; border-radius: 20px; background: var(--surface); border: 1px solid rgba(255,255,255,.85); box-shadow: 0 8px 28px rgba(0,0,0,.04); }
.summary-tile small { display: block; color: var(--muted); font-size: 10px; font-weight: 720; text-transform: uppercase; letter-spacing: .04em; min-height: 25px; }
.summary-tile strong { display: block; margin-top: 9px; font-size: clamp(21px, 5.2vw, 29px); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-tile span { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.section-tabs { display: flex; gap: 7px; overflow-x: auto; padding: 5px 1px 12px; scrollbar-width: none; }
.section-tabs::-webkit-scrollbar { display: none; }
.section-tab { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 10px 15px; background: rgba(255,255,255,.74); color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.section-tab.active { background: var(--ink); color: #fff; }
.purchase-panel { display: none; }
.purchase-panel.active { display: block; animation: viewIn .25s ease both; }
.purchase-list { display: grid; gap: 11px; }
.purchase-row { padding: 19px; border-radius: 21px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: 0 9px 30px rgba(0,0,0,.045); }
.purchase-row-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.purchase-row h3 { margin: 0; font-size: 18px; line-height: 1.15; }
.status-pill { flex: 0 0 auto; border-radius: 999px; padding: 6px 9px; background: #f0f0f2; color: var(--muted); font-size: 10px; font-weight: 700; }
.status-pill.urgent, .status-pill.risk { color: var(--red); background: var(--red-soft); }
.status-pill.good { color: var(--green); background: var(--green-soft); }
.purchase-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 18px; }
.purchase-metric { min-width: 0; }
.purchase-metric small { display: block; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; min-height: 22px; }
.purchase-metric strong { display: block; margin-top: 3px; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.purchase-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.coverage-hero, .risk-hero { padding: 24px; border-radius: 25px; margin-bottom: 13px; background: #17191d; color: #fff; }
.coverage-hero small, .risk-hero small { color: rgba(255,255,255,.55); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.coverage-hero strong, .risk-hero strong { display: block; margin: 10px 0 7px; font-size: clamp(31px, 8vw, 45px); line-height: 1; }
.coverage-hero span, .risk-hero span { color: rgba(255,255,255,.67); font-size: 12px; }
.risk-timeline { display: grid; gap: 7px; }
.risk-day { display: grid; grid-template-columns: 55px 1fr auto; align-items: center; gap: 10px; padding: 14px 15px; background: rgba(255,255,255,.76); border-radius: 16px; border: 1px solid rgba(255,255,255,.85); font-size: 12px; }
.risk-day strong { font-size: 13px; }
.risk-day .negative { color: var(--red); }
.empty-card { padding: 28px 22px; border-radius: 22px; background: var(--surface); color: var(--muted); font-size: 13px; line-height: 1.5; }
.tool-directory { display: grid; gap: 12px; margin-top: 12px; }
.directory-card { display: grid; grid-template-columns: 48px minmax(0,1fr); align-items: center; gap: 15px; padding: 19px; border-radius: 22px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: 0 9px 30px rgba(0,0,0,.04); }
.directory-card > span { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: #efeff1; font-size: 21px; }
.directory-card div { min-width: 0; }
.directory-card strong { display: block; font-size: 17px; }
.directory-card small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 4px; }
.migration-note { margin: 19px 4px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.tabbar { position: fixed; left: 50%; bottom: calc(14px + var(--safe-bottom)); transform: translateX(-50%); width: min(calc(100% - 28px), 640px); height: 72px; padding: 8px 12px; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid rgba(255,255,255,.75); border-radius: 24px; background: rgba(252,252,253,.82); box-shadow: 0 18px 50px rgba(0,0,0,.12); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); z-index: 20; }
.tab { border: 0; background: transparent; color: #8b8b90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; border-radius: 16px; }
.tab span { font-size: 20px; line-height: 1; }
.tab small { font-size: 10px; font-weight: 600; }
.tab.active { color: var(--blue); background: rgba(0,113,227,.075); }
.tab:disabled { opacity: .38; }
.toast { position: fixed; left: 50%; bottom: calc(102px + var(--safe-bottom)); transform: translate(-50%, 20px); padding: 12px 16px; border-radius: 14px; background: rgba(25,25,27,.92); color: white; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 30; max-width: calc(100% - 40px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.reveal { animation: rise .55s cubic-bezier(.22,.8,.28,1) both; }
.delay-1 { animation-delay: .08s; }
.delay-2 { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .app-shell { padding-inline: 16px; }
  .signal-card { min-height: 210px; padding: 24px; }
  .signal-card h2 { font-size: 34px; }
  .hero-subtitle { font-size: 17px; }
  .section-heading span { max-width: 45%; }
  .market-header h1 { font-size: 42px; }
  .rate-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-card:last-child { grid-column: 1 / -1; min-height: 92px; }
  .product-top { flex-direction: column; }
  .verdict { white-space: normal; max-width: 100%; text-align: left; }
  .price-grid { grid-template-columns: 1fr 1fr; }
  .price-cell:first-child { grid-column: 1 / -1; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .product-card { padding: 20px; }
  .verdict { white-space: normal; max-width: 130px; }
  .purchase-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-tile:first-child { grid-column: 1 / -1; }
  .purchase-metrics { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
