:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
  --base: #191724;
  --surface: #1f1d2e;
  --overlay: #26233a;
  --muted: #6e6a86;
  --subtle: #908caa;
  --text: #e0def4;
  --love: #eb6f92;
  --gold: #f6c177;
  --rose: #ebbcba;
  --pine: #31748f;
  --foam: #9ccfd8;
  --iris: #c4a7e7;
  --line: rgba(224, 222, 244, .08);
  --nav-height: 63px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; background: var(--base); }

body {
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--iris); outline-offset: 2px; }
[hidden] { display: none !important; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon,
.server-icon svg,
.nav-icon svg,
.row-chevron {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app {
  width: 100%;
  max-width: 600px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(var(--nav-height) + 24px + env(safe-area-inset-bottom));
}

.page { animation: page-in .18s ease-out; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 { margin: 3px 0 0; letter-spacing: -.045em; }

.eyebrow {
  margin: 0;
  color: var(--subtle);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .14em;
  line-height: 1.2;
}

.dashboard-section { margin-bottom: 14px; }
.dashboard-section:last-child { margin-bottom: 0; }
.section-heading { margin: 0 2px 7px; }
.section-heading h2 { margin: 0; font-size: 16px; letter-spacing: -.025em; }

.quiet-status {
  color: var(--subtle);
  font-size: 10px;
  font-weight: 650;
}
.quiet-status.is-stale { color: var(--gold); }
.quiet-status.is-error { color: var(--love); }

.host-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.host-card,
.metric-card,
.ai-card,
.empty-state,
.automation-row,
.access-card,
.settings-list {
  border: 1px solid var(--line);
  background: var(--surface);
}

.host-card {
  --host-accent: var(--subtle);
  --host-tint: rgba(144, 140, 170, .07);
  --host-border: rgba(144, 140, 170, .18);
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 9px 10px 10px;
  border-radius: 14px;
  border-color: var(--host-border);
  background: linear-gradient(115deg, var(--host-tint), var(--surface) 58%);
}
.host-card::before { content: ""; position: absolute; inset: 10px auto 10px 0; width: 2px; border-radius: 0 2px 2px 0; background: var(--host-accent); opacity: .65; }
.host-card--orange { --host-accent: var(--love); --host-tint: rgba(235, 111, 146, .07); --host-border: rgba(235, 111, 146, .18); }
.host-card--pi { --host-accent: var(--foam); --host-tint: rgba(156, 207, 216, .07); --host-border: rgba(156, 207, 216, .18); }
.host-card-header { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 6px; }
.host-identity { display: flex; min-width: 0; align-items: center; gap: 7px; padding-top: 4px; }
.server-icon { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: 8px; background: var(--host-tint); color: var(--host-accent); }
.server-icon svg { width: 18px; height: 18px; }
.host-identity h3 { overflow: hidden; margin: 0; font-size: 12px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.host-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.host-metrics > div { display: flex; min-width: 0; flex-direction: column; }
.host-metrics span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 7px; font-weight: 750; line-height: 9px; letter-spacing: .08em; }
.host-metrics > div > div { display: flex; min-height: 16px; align-items: baseline; gap: 3px; }
.host-metrics strong { display: block; min-height: 16px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 16px; letter-spacing: -.03em; white-space: nowrap; }
.host-metrics small { color: var(--subtle); font-size: 8px; line-height: 1; }
.host-metrics small[hidden] { display: none; }
.health-placeholder { display: grid; width: 42px; height: 51px; flex: 0 0 42px; grid-template-rows: 40px 11px; place-items: center; color: var(--subtle); }
.health-placeholder svg { grid-area: 1 / 1; width: 40px; height: 40px; transform: rotate(-90deg); fill: none; }
.health-placeholder circle { fill: none; stroke-width: 2.5; }
.health-placeholder .ring-base { stroke: var(--overlay); }
.health-placeholder .ring-accent { stroke: currentColor; stroke-dasharray: 2 5; opacity: .7; }
.health-placeholder > span { grid-area: 1 / 1; font-size: 10px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.health-placeholder small { grid-area: 2 / 1; align-self: end; color: var(--muted); font-size: 7px; line-height: 1; letter-spacing: .06em; text-transform: uppercase; }
.health-placeholder[data-status="online"] { color: var(--host-accent); }
.health-placeholder[data-status="online"] .ring-accent { stroke-dasharray: none; opacity: .8; }
.health-placeholder[data-status="offline"] { color: var(--love); }
.health-placeholder[data-status="offline"] .ring-accent { stroke-dasharray: 5 4; opacity: .9; }

.freshness { min-height: 12px; margin: 6px 3px 0; color: var(--muted); font-size: 9px; line-height: 1.35; }
.freshness.is-stale, .freshness.is-error { color: var(--gold); }
.freshness.is-error { color: var(--love); }

.metric-grid { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 8px; }
.metric-card { min-width: 0; min-height: 78px; padding: 11px; border-radius: 14px; }
.metric-card--primary { background: linear-gradient(145deg, rgba(49, 116, 143, .28), var(--surface) 78%); }
.metric-label { display: flex; align-items: center; gap: 5px; color: var(--subtle); font-size: 9px; font-weight: 650; }
.metric-card strong { display: block; margin-top: 9px; font-size: 25px; line-height: 1; letter-spacing: -.045em; }
.metric-mark { width: 5px; height: 5px; border-radius: 50%; }
.metric-mark.important { background: var(--gold); }
.metric-mark.urgent { background: var(--love); }

.ai-card { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(92px, .85fr); min-height: 92px; border-radius: 14px; }
.ai-model { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 12px; }
.ai-model > div { min-width: 0; }
.card-icon { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 10px; background: rgba(196, 167, 231, .1); color: var(--iris); }
.card-icon .ui-icon { width: 19px; height: 19px; }
.ai-model strong { display: block; overflow: hidden; margin-top: 6px; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.ai-model small, .credit-value small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.credit-value { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: 12px; border-left: 1px solid var(--line); }
.credit-value strong { margin-top: 6px; color: var(--foam); font-size: 19px; letter-spacing: -.035em; }

.page-header { margin: 5px 2px 14px; }
.page-header h1 { font-size: clamp(29px, 8vw, 36px); line-height: 1.05; }
.metric-grid--large .metric-card { min-height: 91px; padding: 13px; }
.metric-grid--large .metric-card strong { margin-top: 13px; font-size: 29px; }

.empty-state { border-radius: 16px; }
.compact-empty { display: flex; gap: 13px; margin-top: 24px; padding: 16px; }
.empty-icon { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border-radius: 12px; background: rgba(49, 116, 143, .14); color: var(--foam); }
.empty-icon .ui-icon { width: 21px; height: 21px; }
.empty-state h2, .access-card h2 { margin: 7px 0 4px; font-size: 15px; letter-spacing: -.02em; }
.empty-state p, .access-card p { margin: 0; color: var(--subtle); font-size: 10px; line-height: 1.5; }
.state-badge { color: var(--iris); font-size: 8px; font-weight: 800; letter-spacing: .1em; }

.mail-list { display: grid; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.mail-row { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.mail-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mail-sender { min-width: 0; overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.mail-time { flex-shrink: 0; color: var(--subtle); font-size: 9px; font-variant-numeric: tabular-nums; }
.mail-subject { margin: 6px 0 4px; font-size: 12px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.mail-snippet { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; margin: 0; color: var(--subtle); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.mail-class { display: inline-block; margin-top: 7px; padding: 3px 6px; border-radius: 5px; font-size: 8px; font-weight: 650; }
.mail-class.urgent { color: var(--love); background: rgba(235, 111, 146, .1); }
.mail-class.important { color: var(--gold); background: rgba(246, 193, 119, .1); }
.mail-class.normal { color: var(--foam); background: rgba(156, 207, 216, .08); }
.mail-class.low { color: var(--subtle); background: var(--overlay); }

.locked-state { margin-top: 34px; padding: 22px 18px 18px; text-align: center; }
.lock-visual { display: grid; width: 64px; height: 64px; margin: 0 auto 15px; place-items: center; border: 1px solid rgba(196, 167, 231, .15); border-radius: 21px; background: linear-gradient(145deg, rgba(196, 167, 231, .12), rgba(235, 111, 146, .06)); color: var(--iris); }
.lock-visual .ui-icon { width: 28px; height: 28px; }
.locked-state h2 { margin-top: 9px; font-size: 19px; }
.locked-state > p { max-width: 360px; margin: 0 auto; }
.requirements { margin: 20px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); text-align: left; }
.requirements li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; min-height: 43px; gap: 8px; border-bottom: 1px solid var(--line); color: var(--subtle); font-size: 10px; }
.requirements li:last-child { border-bottom: 0; }
.requirements b { color: var(--gold); font-size: 9px; font-weight: 650; }
.requirement-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

.automation-list { display: grid; gap: 8px; }
.automation-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; min-height: 66px; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; }
.automation-icon, .access-icon, .settings-icon { display: grid; place-items: center; }
.automation-icon { width: 38px; height: 38px; border-radius: 11px; }
.automation-icon .ui-icon { width: 19px; height: 19px; }
.automation-icon.love { color: var(--love); background: rgba(235, 111, 146, .11); }
.automation-icon.foam { color: var(--foam); background: rgba(156, 207, 216, .11); }
.automation-icon.iris { color: var(--iris); background: rgba(196, 167, 231, .11); }
.automation-icon.gold { color: var(--gold); background: rgba(246, 193, 119, .11); }
.automation-row h2 { margin: 0; font-size: 12px; }
.automation-row p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.pill { padding: 5px 7px; border-radius: 7px; font-size: 8px; font-weight: 800; white-space: nowrap; }
.pill.capability-active { border: 1px solid rgba(156, 207, 216, .16); background: transparent; color: var(--foam); }
.pill.planned { background: rgba(246, 193, 119, .08); color: var(--gold); }

.access-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; }
.access-icon { width: 38px; height: 38px; border-radius: 11px; background: rgba(196, 167, 231, .1); color: var(--iris); }
.access-icon .ui-icon { width: 20px; height: 20px; }
.access-card h2 { margin: 0; font-size: 12px; }
.access-card p { margin-top: 3px; font-size: 9px; }
.settings-list { overflow: hidden; margin-top: 10px; border-radius: 14px; }
.settings-list button { display: grid; width: 100%; min-height: 57px; grid-template-columns: 32px 1fr auto; align-items: center; gap: 9px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; opacity: 1; }
.settings-list button:last-child { border-bottom: 0; }
.settings-list button > span:nth-child(2) { font-size: 11px; font-weight: 650; }
.settings-list small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 400; }
.settings-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--overlay); color: var(--subtle); }
.settings-icon .ui-icon { width: 16px; height: 16px; }
.row-chevron { width: 15px; height: 15px; color: var(--muted); }

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  max-width: 600px;
  min-height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 6px 5px max(5px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(25, 23, 36, .96);
  backdrop-filter: blur(16px);
}

.nav-tab { display: flex; min-width: 0; min-height: 49px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 2px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; }
.nav-tab > span:last-child { overflow: hidden; max-width: 100%; font-size: 8px; font-weight: 650; text-overflow: ellipsis; }
.nav-icon { display: grid; width: 36px; height: 29px; place-items: center; border-radius: 9px; }
.nav-icon svg { width: 22px; height: 22px; stroke-width: 1.8; }
.nav-tab.is-active { color: var(--love); }
.nav-tab.is-active .nav-icon { background: rgba(235, 111, 146, .1); }

@media (min-width: 520px) {
  .app { padding-right: 22px; padding-left: 22px; }
  .host-card, .metric-card, .ai-card, .automation-row, .access-card { border-radius: 16px; }
}

@media (max-width: 350px) {
  .app { padding-right: 10px; padding-left: 10px; }
  .metric-grid { gap: 6px; }
  .metric-card { padding: 9px; }
  .metric-card strong { font-size: 22px; }
  .ai-card { grid-template-columns: minmax(0, 1.45fr) minmax(86px, .8fr); }
  .card-icon { display: none; }
  .pill { padding-right: 5px; padding-left: 5px; }
  .access-card { grid-template-columns: 34px minmax(0, 1fr); }
  .access-card > .pill { grid-column: 2; justify-self: start; }
  .host-card { padding-right: 8px; padding-left: 8px; }
  .host-card-header { gap: 4px; }
  .host-identity { gap: 5px; }
  .server-icon { width: 24px; height: 24px; flex-basis: 24px; }
  .server-icon svg { width: 16px; height: 16px; }
  .host-identity h3 { font-size: 10.5px; }
  .health-placeholder { width: 38px; flex-basis: 38px; }
  .health-placeholder svg { width: 38px; height: 38px; }
  .host-metrics { gap: 6px; }
  .host-metrics strong { font-size: 12px; }
}

@media (max-width: 300px) {
  .host-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Private portfolio */
.portfolio-account-list { display: grid; gap: 14px; margin-top: 14px; }
.portfolio-account { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(196, 167, 231, .09) 0, transparent 180px), var(--surface); }
.portfolio-account-head { display: grid; gap: 9px; padding: 16px 14px 13px; }
.portfolio-account-label { margin: 0 0 7px; color: var(--iris); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.portfolio-total { display: block; font-size: clamp(25px, 7vw, 32px); line-height: 1.1; letter-spacing: -.045em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.portfolio-day { justify-self: start; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--overlay); font-size: 10px; line-height: 1.4; font-weight: 650; font-variant-numeric: tabular-nums; }
.portfolio-day.positive { color: var(--foam); }
.portfolio-day.negative { color: var(--love); }

.portfolio-type-share { --asset-accent: var(--iris); }
.portfolio-type-bond { --asset-accent: var(--gold); }
.portfolio-type-etf { --asset-accent: var(--foam); }
.portfolio-type-currency { --asset-accent: var(--rose); }
.portfolio-type-other { --asset-accent: var(--subtle); }
.portfolio-assets { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 14px; }
.portfolio-asset { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 8px; max-width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--base); }
.portfolio-asset span { color: var(--asset-accent); font-size: 9px; }
.portfolio-asset strong { font-size: 10px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.portfolio-asset-share {
  color: var(--subtle) !important;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}
.portfolio-contribution { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; margin: 0 14px 14px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--overlay); }
.portfolio-contribution-item { min-width: 0; }
.portfolio-contribution-item:last-child { text-align: right; }
.portfolio-contribution-label { display: block; color: var(--subtle); font-size: 8px; line-height: 1.2; }
.portfolio-contribution-value { display: block; margin-top: 4px; color: var(--text); font-size: 10px; font-weight: 650; font-variant-numeric: tabular-nums; }

.portfolio-holdings-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 14px 4px; padding-top: 8px; }
.portfolio-holdings-head h3 { margin: 0; font-size: 11px; font-weight: 650; }
.portfolio-holdings-head > span { color: var(--subtle); font-size: 9px; }
.portfolio-positions { margin: 0; padding: 0 14px 10px; list-style: none; }
.portfolio-position { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px 12px; padding: 10px 0 5px; }
.portfolio-position-main { min-width: 0; }
.portfolio-position-main strong { display: block; overflow: hidden; margin-top: 4px; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-position-main > span:not(.portfolio-type-badge) { display: block; overflow: hidden; margin-top: 3px; color: var(--subtle); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-type-badge { display: inline-block; padding: 2px 5px; border-radius: 4px; background: var(--overlay); color: var(--asset-accent); font-size: 8px; line-height: 1.2; }
.portfolio-position-values { text-align: right; font-variant-numeric: tabular-nums; }
.portfolio-position-values strong { display: block; font-size: 12px; font-weight: 700; }
.portfolio-position-values span { display: block; margin-top: 4px; color: var(--subtle); font-size: 10px; }
.portfolio-weight { grid-column: 1 / -1; height: 3px; overflow: hidden; border-radius: 3px; background: var(--overlay); }
.portfolio-weight span { display: block; height: 100%; border-radius: inherit; background: var(--asset-accent); opacity: .7; }
.portfolio-more { border-top: 1px solid var(--line); }
.portfolio-more summary { min-height: 44px; padding: 14px; color: var(--iris); font-size: 10px; cursor: pointer; }
.portfolio-more summary:focus-visible { outline: 2px solid var(--iris); outline-offset: -3px; }
.portfolio-empty { margin: 10px 14px 16px; color: var(--subtle); font-size: 11px; }

/* Private strategies: separate from broker account totals. */
.strategies-section { margin-top: 20px; }
.strategies-section .compact-empty { margin-top: 0; }
.strategies-list { display: grid; gap: 12px; }
.strategy-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow-wrap: anywhere; }
.strategy-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.strategy-head h3 { margin: 0; color: var(--iris); font-size: 14px; }
.strategy-mode { flex-shrink: 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--subtle); font-size: 8px; font-weight: 700; }
.strategy-total { display: block; margin: 9px 0 12px; font-size: 25px; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.strategy-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 12px; margin: 0; }
.strategy-facts > div { min-width: 0; }
.strategy-facts dt { color: var(--subtle); font-size: 9px; line-height: 1.4; }
.strategy-facts dd { margin: 3px 0 0; font-size: 11px; line-height: 1.4; font-weight: 650; font-variant-numeric: tabular-nums; }
.strategy-structure, .strategy-note { margin: 10px 0 0; color: var(--subtle); font-size: 10px; line-height: 1.5; }
.strategy-structure.is-mismatch { color: var(--gold); }
.strategy-positions { margin: 12px 0 0; padding: 0; list-style: none; }
.strategy-position { padding: 10px 0; border-top: 1px solid var(--line); }
.strategy-position h4 { margin: 0 0 8px; font-size: 12px; }
.strategy-execution { margin-top: 8px; border-top: 1px solid var(--line); }
.strategy-execution summary { min-height: 44px; padding: 14px 0; color: var(--subtle); font-size: 11px; cursor: pointer; }
.strategy-execution summary:focus-visible { outline: 2px solid var(--iris); outline-offset: 2px; }
