:root {
  color-scheme: dark;
  --background: #0b0d12;
  --card: #131824;
  --card-raised: #191f2c;
  --line: #292f3e;
  --text: #f2f4fb;
  --muted: #a4afc5;
  --accent: #9ab1ff;
  --gain: #66e4ab;
  --loss: #ffa1ae;
  background: var(--background);
  color: var(--text);
  font: 100%/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 1.65rem; letter-spacing: -.035em; line-height: 1.15; }
h2 { font-size: 1.15rem; letter-spacing: -.018em; }
h3 { font-size: 1rem; }
button, input { font: inherit; }
button, summary { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:disabled { cursor: default; opacity: .65; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.muted { color: var(--muted); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.right { text-align: right; }
.status { min-height: 1.4em; font-size: .875rem; }
.shell {
  max-width: 760px;
  margin-inline: auto;
  padding: calc(20px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.gate {
  max-width: 360px;
  min-height: min(660px, calc(100dvh - 60px));
  margin: auto;
  display: grid;
  align-content: center;
  gap: 14px;
}
.brand-icon { border-radius: 17px; }
.gate h1 { font-size: 2rem; }
.gate form { display: grid; gap: 10px; margin-top: 8px; }
label { color: var(--muted); font-size: .875rem; }
input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e121b;
  color: var(--text);
  font-size: 1rem;
}
.primary, .secondary, .icon-button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-weight: 650;
}
.primary { padding: 10px 14px; background: var(--accent); color: #0c142e; border-color: transparent; }
.secondary, .icon-button { background: var(--card); }
.secondary { padding: 10px 14px; }
.icon-button { display: grid; place-items: center; width: 44px; padding: 0; }
.icon-button svg { width: 21px; height: 21px; }
.danger { color: var(--loss); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 20px; }
.topbar .status { margin-top: 3px; }
.top-actions { display: flex; gap: 8px; flex: none; }
.spinning svg { animation: spin 850ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinning svg { animation: none; } }
.warning {
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid #554426;
  border-radius: 12px;
  color: #f7cf8e;
  background: #211b13;
  font-size: .875rem;
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; min-width: 0; }
.hero {
  background: radial-gradient(ellipse at 92% 0, #263456, transparent 70%), linear-gradient(155deg, #1a2235, var(--card));
  padding: 20px;
}
.hero-label { font-weight: 650; color: var(--muted); }
.hero-value {
  font-size: clamp(2rem, 9.7vw, 3.8rem);
  font-weight: 730;
  line-height: 1.13;
  letter-spacing: -.05em;
  margin: 6px 0 12px;
  overflow-wrap: anywhere;
}
.summary-pnl, .hero-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  column-gap: 9px;
  font-size: .875rem;
}
.summary-pnl > span, .hero-foot > span { color: var(--muted); }
.hero-foot { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.tile { padding: 12px; }
.tile dt { font-size: .875rem; color: var(--muted); }
.tile dd { font-size: 1.12rem; font-weight: 690; margin-top: 2px; overflow-wrap: anywhere; }
.tile .tile-note { font-size: .75rem; font-weight: 450; color: var(--muted); margin-top: 4px; }

.section { margin-top: 25px; }
.section h2 { margin: 0 0 9px 2px; }
.allocation-layout {
  display: grid;
  grid-template-columns: minmax(90px, .75fr) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 15px;
}
.donut { width: 100%; max-width: 195px; justify-self: center; }
.legend { list-style: none; padding: 0; margin: 0; font-size: .875rem; }
.legend li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 7px; align-items: center; }
.legend li + li { margin-top: 4px; }
.legend li > span:nth-child(2) { overflow-wrap: anywhere; }
.swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--swatch); }
.empty { padding: 14px; color: var(--muted); font-size: .875rem; }
.rows > * + * { border-top: 1px solid var(--line); }
.holding-row {
  list-style: none;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(min-content, auto) 8px;
  align-items: center;
  min-height: 68px;
  gap: 9px;
  padding: 10px 11px;
}
.holding-row::-webkit-details-marker { display: none; }
.holding-row:focus-visible { outline-offset: -3px; border-radius: 12px; }
.coin-icon {
  display: grid;
  place-items: center;
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #222b3c;
  color: var(--coin);
  font-size: .75rem;
  font-weight: 750;
  overflow: hidden;
}
.coin-icon img { position: absolute; inset: 0; object-fit: cover; background: #222b3c; }
.holding-name, .holding-value { display: flex; flex-direction: column; min-width: 0; }
.holding-name { overflow-wrap: anywhere; }
.holding-value { text-align: right; }
.holding-name small, .holding-value small { font-size: .75rem; }
.holding-name small { color: var(--muted); }
.chevron { width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); }
details[open] .chevron { transform: rotate(225deg); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.detail-grid dt { color: var(--muted); font-size: .8125rem; }
.detail-grid dd { font-size: .875rem; font-weight: 650; overflow-wrap: anywhere; }
details .detail-grid { margin: 0 11px 11px; padding: 10px; border-radius: 10px; background: #0f141f; }
.row { padding: 12px; }
.row-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.row-head h3, .row-head strong { overflow-wrap: anywhere; }
.row-head p { font-size: .8125rem; }
.row .detail-grid { margin-top: 10px; }
.side { color: var(--muted); font-size: .8125rem; font-weight: 500; text-transform: capitalize; }
.total { padding-block: 13px; }

dialog {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 540px);
  max-width: none;
  max-height: 86dvh;
  margin: 0 auto;
  padding: 14px max(16px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border: 1px solid var(--line);
  border-radius: 21px 21px 0 0;
  background: var(--card-raised);
  color: var(--text);
  overflow: auto;
  overscroll-behavior: contain;
}
dialog::backdrop { background: #06080ac7; }
body:has(dialog[open]) { overflow: hidden; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-header button { font-size: 1.4rem; }
fieldset { margin: 0 0 12px; padding: 10px; min-width: 0; border-radius: 12px; border: 1px solid var(--line); }
legend { padding: 0 4px; font-size: .9rem; font-weight: 650; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-grid input { margin-top: 4px; }
.field-grid label:has(input[type="date"]) { grid-column: 1 / -1; }
.sheet-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.sheet-actions .primary { grid-column: 1 / -1; }
#settings-status { margin-top: 7px; }
#settings-status:empty { display: none; }

@media (min-width: 550px) {
  .shell { padding-inline: max(24px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-right)); }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .allocation-layout { grid-template-columns: 200px minmax(0, 1fr); gap: 24px; }
  .holding-row { padding-inline: 16px; }
}
