:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg2: #f2f2f7;
  --fg: #000000;
  --fg2: #6e6e73;
  --line: #e5e5ea;
  --up: #34c759;
  --down: #ff3b30;
  --chip-fg: #ffffff;
  --accent: #0a84ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg2: #1c1c1e;
    --fg: #ffffff;
    --fg2: #8e8e93;
    --line: #2c2c2e;
    --up: #30d158;
    --down: #ff453a;
    --accent: #0a84ff;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
.num { font-variant-numeric: tabular-nums; }

/* header */
.top {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.date { font-size: 22px; font-weight: 700; letter-spacing: -0.2px; }
.market { font-size: 13px; color: var(--fg2); margin-top: 2px; font-weight: 600; }
.market.open  { color: var(--up); }
.market.closed { color: var(--down); }
.top-right { display: flex; gap: 8px; align-items: center; }
.add, .bell {
  width: 36px; height: 36px; border-radius: 18px; border: 0;
  background: var(--bg2); color: var(--accent);
  font-size: 26px; line-height: 36px; font-weight: 400; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.bell { color: var(--fg2); }
.bell.on { color: var(--up); }

/* list */
.list { flex: 1; padding: 0 16px; }
.empty { color: var(--fg2); text-align: center; padding: 60px 20px; font-size: 15px; line-height: 1.5; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 72px 86px;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.sym { font-size: 17px; font-weight: 700; }
.name { font-size: 12px; color: var(--fg2); margin-top: 3px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.name.err { color: var(--down); }
.alerts { font-size: 11px; color: var(--fg2); margin-top: 3px; white-space: nowrap; }
.alerts .fired { text-decoration: line-through; opacity: .6; }
.spark { width: 72px; height: 40px; display: block; }
.spark .line { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .base { stroke: var(--fg2); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; }
.up   .line { stroke: var(--up); }
.down .line { stroke: var(--down); }
.quote { text-align: right; }
.price { font-size: 17px; font-weight: 600; }
.chg {
  display: inline-block; margin-top: 4px; min-width: 62px;
  padding: 3px 6px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--chip-fg); text-align: center;
}
.chg.up { background: var(--up); }
.chg.down { background: var(--down); }
.chg.flat { background: var(--fg2); }
.pos { text-align: right; font-size: 13px; line-height: 1.45; }
.pos .shares { color: var(--fg); }
.pos .cost { color: var(--fg2); }
.pos .pl { font-weight: 700; }
.pl.up { color: var(--up); }
.pl.down { color: var(--down); }
.stale { opacity: .5; }

/* footer */
.bottom {
  position: sticky; bottom: 0; z-index: 2;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
}
.periods { display: flex; gap: 6px; background: var(--bg2); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.periods button {
  flex: 1; border: 0; background: transparent; color: var(--fg2);
  font-size: 14px; font-weight: 600; padding: 7px 0; border-radius: 8px;
}
.periods button.on { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.totals { display: flex; justify-content: space-between; align-items: flex-end; }
.tot { text-align: center; flex: 1; }
.tot:first-child { text-align: left; }
.tot:last-child { text-align: right; }
.tot-v { font-size: 16px; font-weight: 700; }
.tot-v.up { color: var(--up); }
.tot-v.down { color: var(--down); }
.tot-l { font-size: 11px; color: var(--fg2); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--bg2);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex; flex-direction: column; gap: 12px;
}
.sheet-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.sheet label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--fg2); font-weight: 600; }
.sheet input {
  font: inherit; font-size: 17px; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.sheet input:focus { border-color: var(--accent); }
.sheet-err { color: var(--down); font-size: 13px; }
.sheet .two { display: flex; gap: 10px; }
.sheet .two label { flex: 1 1 0; min-width: 0; }
.sheet .two input { width: 100%; min-width: 0; }
.sheet .hint { font-size: 12px; color: var(--fg2); }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.btn { flex: 1; border: 0; border-radius: 10px; padding: 12px; font-size: 16px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--fg); }
.btn-danger { background: var(--down); color: #fff; }
