/* ===== App shell ===== */
.app { min-height: 100vh; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); padding: 1.25rem 0.9rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav .brand { padding: 0.25rem 0.5rem 1.25rem; }
.nav a.tab { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.75rem; border-radius: 12px; text-decoration: none; color: var(--muted); font-weight: 500; transition: background 0.15s, color 0.15s; }
.nav a.tab svg { width: 20px; height: 20px; flex: none; }
.nav a.tab:hover { background: var(--bg); color: var(--ink); }
.nav a.tab[aria-current="page"] { background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.nav .back { margin-top: auto; font-size: 0.85rem; color: var(--muted); text-decoration: none; padding: 0.5rem 0.75rem; }
.main { min-width: 0; }
.app-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1rem 2rem; background: rgba(246, 247, 249, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.app-top h1 { font-size: 1.5rem; letter-spacing: -0.02em; line-height: 1.2; }
.app-top .brand { display: none; }
.view { padding: 0.5rem 2rem 3rem; max-width: 70rem; animation: viewIn 0.35s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around; padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -6px 20px -12px rgba(11, 31, 58, 0.25); }
  .nav .brand, .nav .back { display: none; }
  .nav a.tab { flex: 1 1 0; flex-direction: column; gap: 0.2rem; padding: 0.45rem 0.25rem; font-size: 0.7rem; text-align: center; }
  .nav a.tab[aria-current="page"] { background: transparent; }
  .app-top { padding: 0.8rem 1rem; }
  .app-top .brand { display: inline-flex; font-size: 1rem; }
  .app-top .brand .brand-mark { width: 26px; height: 26px; }
  .app-top h1 { display: none; }
  .view { padding: 0.25rem 1rem 6.5rem; }
  .view-title { display: block !important; }
}
.view-title { display: none; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0.25rem 0 1rem; }

/* ===== Cards & common ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 1.25rem; }
.card-title { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.9rem; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; }
.stack > * + * { margin-top: 1rem; }
.grid-2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); } }

/* ===== Dashboard ===== */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi .label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 0.15rem; }
.kpi.hero-kpi { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.hero-kpi .label { color: #b9c5d8; }
.kpi.hero-kpi .value { font-size: 1.9rem; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; } .kpi { padding: 0.9rem; } .kpi.hero-kpi { grid-column: 1 / -1; } .kpi .label { font-size: 0.72rem; line-height: 1.3; } .kpi .value { font-size: 1.15rem; } }

.donut-wrap { display: flex; align-items: center; gap: 1.25rem; }
.donut { width: 140px; height: 140px; flex: none; }
.donut circle.seg { fill: none; stroke-width: 18; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dasharray 1s cubic-bezier(0.2, 0.8, 0.2, 1); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; font-size: 0.88rem; min-width: 0; }
.legend li { display: flex; align-items: center; gap: 0.5rem; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .pct { margin-left: auto; font-weight: 600; padding-left: 0.5rem; }

.filters { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; margin-bottom: 0.75rem; }
.filters::-webkit-scrollbar { display: none; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0.4rem 0.8rem; font-size: 0.82rem; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; transition: all 0.15s; }
.chip-btn[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 0.75rem 0.6rem; }
.table td { padding: 0.8rem 0.75rem; border-top: 1px solid var(--line); vertical-align: middle; }
.table .right { text-align: right; }
.fund-cell { display: flex; align-items: center; gap: 0.65rem; }
.fund-dot { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 0.7rem; font-weight: 700; flex: none; }
.row-in { animation: rise 0.4s ease-out both; }

/* Position cards on phones */
.pos-list { display: none; }
@media (max-width: 700px) {
  .table.positions { display: none; }
  .pos-list { display: grid; gap: 0.6rem; }
  .pos { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 0.15rem 0.7rem; align-items: center; padding: 0.75rem 0; border-top: 1px solid var(--line); }
  .pos .fund-dot { grid-row: span 2; }
  .pos .t { font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
  .pos .v { font-weight: 700; text-align: right; }
  .pos .m { font-size: 0.78rem; color: var(--muted); }
  .pos .w { text-align: right; }
}

/* ===== Buy flow ===== */
.steps { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; }
.steps .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.steps .bar span { display: block; height: 100%; width: 0; background: var(--teal-2); border-radius: 999px; transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.steps .count { font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.fund-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.fund-opt { text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 1rem; cursor: pointer; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0.2rem 0.75rem; align-items: center; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.fund-opt:hover { border-color: #c9d1dd; }
.fund-opt:active { transform: scale(0.99); }
.fund-opt[aria-pressed="true"] { border-color: var(--teal-2); box-shadow: 0 0 0 3px var(--teal-soft); }
.fund-opt .fund-dot { grid-row: span 2; width: 36px; height: 36px; }
.fund-opt .t { font-weight: 600; line-height: 1.25; }
.fund-opt .m { font-size: 0.8rem; color: var(--muted); }
.fund-opt .facts { grid-column: 1 / -1; display: flex; gap: 1rem; margin-top: 0.6rem; font-size: 0.8rem; color: var(--muted); }
.fund-opt .facts b { color: var(--ink); font-weight: 600; }
@media (max-width: 700px) { .fund-pick { grid-template-columns: minmax(0, 1fr); } }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
.input, .select { width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: 0.75rem 0.9rem; }
.input:focus, .select:focus { outline: none; border-color: var(--teal-2); box-shadow: 0 0 0 3px var(--teal-soft); }
.amount { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; padding: 0.6rem 0.9rem; }
.quick { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }
.prefill { font-size: 0.72rem; font-weight: 600; color: var(--teal); margin-left: 0.35rem; }
@media (max-width: 700px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.check { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 1rem; border-radius: 12px; background: var(--bg); margin-top: 1rem; font-size: 0.92rem; font-weight: 500; transition: background 0.3s; }
.check .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check.loading .ic { border: 3px solid var(--line); border-top-color: var(--teal-2); animation: spin 0.8s linear infinite; }
.check.ok { background: var(--teal-soft); }
.check.ok .ic { background: var(--teal-2); animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; justify-content: space-between; gap: 0.75rem; margin-top: 1.5rem; }
.actions .btn-primary, .actions .btn-teal { min-width: 9rem; }
@media (max-width: 700px) { .actions { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); padding-top: 1rem; margin-top: 1rem; } .actions .btn { flex: 1; } }

.review { display: grid; gap: 0; }
.review div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.75rem 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.review div:first-child { border-top: 0; }
.review dt { color: var(--muted); }
.review dd { margin: 0; font-weight: 600; text-align: right; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: spin 0.8s linear infinite; }

.timeline { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0.9rem; padding-bottom: 1.5rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 15px; top: 32px; width: 2px; height: 0; background: var(--teal-2); transition: height 0.6s ease-out; }
.timeline li.done::after { height: calc(100% - 32px); }
.timeline li:last-child::after { display: none; }
.timeline .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); color: transparent; transition: all 0.35s; z-index: 1; }
.timeline li.done .dot { background: var(--teal-2); border-color: var(--teal-2); color: #fff; animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.timeline li.active .dot { border-color: var(--teal-2); }
.timeline li.active .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--teal-2); animation: pulseDot 1.2s ease-in-out infinite; }
@keyframes pulseDot { 50% { transform: scale(0.6); opacity: 0.5; } }
.timeline .t { font-weight: 600; padding-top: 0.25rem; }
.timeline .d { font-size: 0.85rem; color: var(--muted); }
.success-head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.5rem; }
.success-head .big { width: 48px; height: 48px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex: none; animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3); }

/* ===== Redemptions ===== */
.countdown { background: var(--navy); color: #fff; border-color: var(--navy); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.countdown .label { font-size: 0.8rem; color: #b9c5d8; }
.countdown .fund { font-weight: 600; }
.clock { display: flex; gap: 0.4rem; }
.clock div { background: rgba(255, 255, 255, 0.08); border-radius: 10px; padding: 0.45rem 0.6rem; text-align: center; min-width: 3.3rem; }
.clock b { display: block; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.clock span { font-size: 0.66rem; color: #b9c5d8; text-transform: uppercase; letter-spacing: 0.06em; }
.req-list { display: grid; gap: 0.85rem; }
.req-top { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.req-top .t { font-weight: 600; line-height: 1.25; }
.req-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 0.9rem 0 0.6rem; }
.req-nums .l { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.req-nums .v { font-weight: 700; font-size: 1.05rem; }
.req-nums .v.paid { color: var(--teal); }
.req-nums .v.pend { color: var(--amber); }
.prog { height: 10px; border-radius: 999px; background: var(--amber-soft); overflow: hidden; }
.prog span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--teal-2); transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1); }
.req-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-top: 0.9rem; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 0.6rem; background: none; border: 0; padding: 0.2rem 0; cursor: pointer; font-size: 0.88rem; font-weight: 600; }
.switch .knob { position: relative; width: 44px; height: 26px; border-radius: 999px; background: #cfd6e0; transition: background 0.2s; flex: none; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1.2); }
.switch[aria-checked="true"] .knob { background: var(--teal-2); }
.switch[aria-checked="true"] .knob::after { transform: translateX(18px); }
.toast { position: fixed; left: 50%; bottom: 2rem; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 0.75rem 1.1rem; border-radius: 12px; font-size: 0.9rem; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 50; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 900px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ===== Calendar ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.cal-head .m { font-weight: 700; font-size: 1.1rem; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.25rem; text-align: center; }
.cal .dow { font-size: 0.7rem; font-weight: 600; color: var(--muted); padding-bottom: 0.3rem; }
.day { position: relative; aspect-ratio: 1; border: 0; background: none; border-radius: 10px; font-size: 0.88rem; font-weight: 500; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.day:hover { background: var(--bg); }
.day.empty { cursor: default; }
.day.today { color: var(--teal); font-weight: 700; }
.day.today::before { content: ""; position: absolute; inset: 3px; border: 1.5px solid var(--teal-2); border-radius: 9px; }
.day[aria-pressed="true"] { background: var(--navy); color: #fff; }
.day .dots { display: flex; gap: 3px; height: 6px; }
.day .dots i { width: 6px; height: 6px; border-radius: 50%; }
.dot-sub { background: var(--navy); }
.dot-red { background: #f59e0b; }
.day[aria-pressed="true"] .dot-sub { background: #fff; }
.cal-legend { display: flex; gap: 1rem; margin-top: 0.9rem; font-size: 0.8rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.cal-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.events { display: grid; gap: 0.6rem; }
.event { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 0.85rem; align-items: center; padding: 0.75rem; border-radius: 12px; background: var(--bg); transition: background 0.2s, box-shadow 0.2s; }
.event.hl { background: var(--teal-soft); box-shadow: inset 0 0 0 1.5px var(--teal-2); }
.event .date { text-align: center; background: var(--surface); border-radius: 10px; padding: 0.3rem 0; border: 1px solid var(--line); }
.event .date b { display: block; font-size: 1.15rem; line-height: 1.1; }
.event .date span { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.event .t { font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
