:root {
  color-scheme: dark;
  --bg: #080809;
  --panel: #111114;
  --panel-2: #18181c;
  --border: #29292f;
  --text: #f8f8fa;
  --muted: #a1a1aa;
  --red: #d10d25;
  --red-dark: #8e0717;
  --red-soft: rgba(209, 13, 37, .14);
  --green: #34d17b;
  --amber: #f5ae2e;
  --shadow: 0 12px 36px rgba(0, 0, 0, .3);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 85% -10%, rgba(209,13,37,.17), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100dvh; padding-bottom: 84px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(8,8,9,.98) 75%, transparent);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid #ff4057; border-radius: 12px;
  background: linear-gradient(145deg, #e20f29, #650411);
  box-shadow: 0 0 24px rgba(209,13,37,.28);
  font-weight: 900; letter-spacing: -.06em;
}
.brand h1 { margin: 1px 0 0; font-size: 1.08rem; letter-spacing: -.03em; }
.eyebrow { margin: 0; font-size: .62rem; font-weight: 800; letter-spacing: .16em; color: #ff5b6e; }
main { width: min(100%, 1120px); margin: 0 auto; padding: 6px 16px 28px; }
.page-head { margin: 10px 0 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head h2 { margin: 2px 0 0; font-size: clamp(1.65rem, 6vw, 2.35rem); letter-spacing: -.055em; }
.page-head p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 26px 0 12px; }
.section-title h3 { margin: 0; font-size: .9rem; text-transform: uppercase; letter-spacing: .1em; }
.section-title span { color: var(--muted); font-size: .78rem; }
.grid { display: grid; gap: 12px; }
.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  position: relative;
  background: linear-gradient(150deg, rgba(27,27,31,.96), rgba(14,14,16,.98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: transparent; }
.card.risk::before { background: var(--red); }
.card.good::before { background: var(--green); }
.metric-card { min-height: 126px; }
.metric-card.featured {
  grid-column: 1 / -1;
  min-height: 160px;
  background: linear-gradient(135deg, rgba(94,3,17,.94), rgba(18,15,18,.98) 65%);
  border-color: #5e1520;
}
.metric-label { color: var(--muted); font-size: .75rem; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.metric-value { margin-top: 10px; font-weight: 850; font-size: clamp(1.45rem, 7vw, 2.45rem); letter-spacing: -.06em; line-height: 1; }
.metric-card.featured .metric-value { font-size: clamp(2.7rem, 13vw, 5rem); }
.metric-sub { margin-top: 10px; color: var(--muted); font-size: .77rem; line-height: 1.35; }
.negative, .risk-text { color: #ff3e55; }
.positive { color: var(--green); }
.warning { color: var(--amber); }
.mini-trend { font-size: .75rem; font-weight: 700; }
.account-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--border); }
.account-row:last-child { border: 0; padding-bottom: 0; }
.account-row:first-child { padding-top: 0; }
.account-name { font-weight: 750; }
.account-meta { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.account-value { font-weight: 800; text-align: right; }
.progress { height: 7px; margin-top: 12px; background: #2b2b31; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--red-dark), var(--red)); }
.progress.green > span { background: var(--green); }
.progress.amber > span { background: var(--amber); }
.status {
  display: inline-flex; padding: 5px 8px; border-radius: 99px;
  font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: #ff8e9b; background: var(--red-soft); border: 1px solid rgba(209,13,37,.22);
}
.status.green { color: var(--green); background: rgba(52,209,123,.1); border-color: rgba(52,209,123,.2); }
.status.amber { color: var(--amber); background: rgba(245,174,46,.1); border-color: rgba(245,174,46,.2); }
.insight-list { display: grid; gap: 9px; }
.insight { display: flex; gap: 12px; padding: 13px; border-radius: 13px; background: #151518; border: 1px solid #242429; color: #d6d6dc; font-size: .86rem; line-height: 1.45; }
.insight b { color: var(--red); }
.timeline-card { margin-bottom: 12px; }
.timeline-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.timeline-top h3 { margin: 0; font-size: 1.05rem; }
.timeline-top strong { font-size: 1.15rem; }
.data-points { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 15px; }
.data-point small { display: block; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.data-point span { display: block; margin-top: 4px; font-weight: 700; font-size: .88rem; }
.btn {
  border: 0; border-radius: 12px; padding: 12px 15px; font-weight: 800;
  color: white; background: linear-gradient(135deg, #df112b, #a4071a);
  box-shadow: 0 7px 20px rgba(209,13,37,.18);
}
.btn.secondary { background: #242429; box-shadow: none; color: #eee; border: 1px solid #34343a; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); border: 1px solid var(--border); }
.btn.danger { background: #5f0714; }
.btn.small { padding: 8px 10px; font-size: .75rem; border-radius: 9px; }
.icon-btn { color: white; border: 1px solid #4e1720; background: #26070c; border-radius: 10px; padding: 8px 10px; font-size: .75rem; font-weight: 800; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.form-grid { display: grid; gap: 13px; }
label { display: grid; gap: 7px; color: #d1d1d6; font-size: .78rem; font-weight: 700; }
input, select, textarea {
  width: 100%; color: white; background: #0c0c0e; border: 1px solid #34343a;
  border-radius: 11px; padding: 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(209,13,37,.13); }
textarea { min-height: 84px; resize: vertical; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; background: #0e0e10; border: 1px solid var(--border); border-radius: 13px; padding: 4px; }
.segmented button { border: 0; border-radius: 9px; background: transparent; color: var(--muted); padding: 10px 5px; font-weight: 750; font-size: .75rem; }
.segmented button.active { background: #2d0c12; color: white; box-shadow: inset 0 0 0 1px #5f1722; }
.result-hero { text-align: center; padding: 22px 12px; background: linear-gradient(145deg, #29070d, #111114); border-radius: 15px; margin-top: 15px; }
.result-hero strong { display: block; margin: 7px 0; font-size: 2.1rem; letter-spacing: -.05em; }
.allocation { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.allocation div { padding: 12px 6px; background: #0d0d0f; border-radius: 11px; text-align: center; }
.allocation small { display: block; color: var(--muted); font-size: .63rem; text-transform: uppercase; }
.allocation b { display: block; margin-top: 5px; font-size: .9rem; }
.strategy-order { counter-reset: order; display: grid; gap: 8px; margin-top: 12px; }
.strategy-order div { display: flex; align-items: center; gap: 10px; padding: 10px; background: #101012; border-radius: 10px; }
.strategy-order div::before { counter-increment: order; content: counter(order); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #5d0916; color: white; font-size: .7rem; font-weight: 900; }
.chart { display: flex; align-items: end; gap: 8px; height: 150px; margin-top: 18px; padding-top: 14px; border-bottom: 1px solid #38383e; }
.chart-bar { flex: 1; min-width: 16px; max-width: 54px; position: relative; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #ef2941, #7c0716); }
.chart-bar.positive-bar { background: linear-gradient(180deg, #49de8b, #12673b); }
.chart-bar span { position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: .6rem; white-space: nowrap; }
.notice { padding: 12px 13px; color: #c8c8ce; font-size: .78rem; line-height: 1.45; background: #141416; border-left: 3px solid var(--amber); border-radius: 4px 10px 10px 4px; }
.settings-group { margin-bottom: 13px; }
.settings-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border: 0; }
.settings-row p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; }
.toggle { appearance: none; width: 46px; height: 26px; border-radius: 99px; background: #34343a; padding: 0; position: relative; flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .2s; }
.toggle:checked { background: var(--red); }
.toggle:checked::after { transform: translateX(20px); }
.bottom-nav {
  position: fixed; z-index: 30; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 6px 5px max(7px, env(safe-area-inset-bottom));
  border-top: 1px solid #27272c; background: rgba(12,12,14,.96); backdrop-filter: blur(18px);
}
.nav-item { border: 0; background: none; color: #777780; display: grid; justify-items: center; gap: 3px; padding: 5px 1px; }
.nav-item span { font-size: 1.05rem; font-weight: 850; }
.nav-item small { font-size: .58rem; font-weight: 750; }
.nav-item.active { color: #ff344c; }
dialog { width: min(calc(100% - 24px), 560px); max-height: 90dvh; padding: 0; border: 1px solid #38383e; border-radius: 20px; color: white; background: #111114; box-shadow: 0 30px 80px black; }
dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(4px); }
.modal-card { padding: 19px; overflow-y: auto; max-height: 88dvh; }
.modal-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 1.35rem; }
.close-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 1px solid #3b3b41; background: #202024; color: white; }
#toast { visibility: hidden; opacity: 0; position: fixed; z-index: 100; left: 50%; bottom: 92px; transform: translate(-50%, 10px); background: #f5f5f7; color: #111; padding: 11px 15px; border-radius: 10px; font-size: .8rem; font-weight: 750; transition: .2s; white-space: nowrap; box-shadow: 0 8px 28px black; }
#toast.show { visibility: visible; opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; padding: 34px 15px; color: var(--muted); }
.muted { color: var(--muted); }

@media (min-width: 720px) {
  main { padding-inline: 24px; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-card.featured { grid-column: span 2; grid-row: span 2; }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-points { grid-template-columns: repeat(4, 1fr); }
  .bottom-nav { left: 50%; right: auto; width: min(650px, calc(100% - 30px)); transform: translateX(-50%); bottom: 12px; border: 1px solid #303036; border-radius: 17px; padding: 7px; }
  .app-shell { padding-bottom: 105px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
