:root {
  --bg: #0f1720;
  --bg-elev: #18222e;
  --bg-card: #1b2734;
  --line: #2a3a4a;
  --text: #e8eef4;
  --muted: #93a4b5;
  --accent: #4ea1ff;
  --up: #4caf6a;
  --down: #ff6b6b;
  --signal: #ffb020;
  --signal-bg: rgba(255, 176, 32, 0.14);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  padding-bottom: calc(64px + var(--safe-bottom));
}

/* ---- header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 { font-size: 17px; margin: 0; font-weight: 700; }
.updated { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.icon-btn {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  width: 34px; height: 34px; font-size: 16px; cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }

/* ---- tabs ---- */
main { padding: 12px 12px 20px; max-width: 640px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--bg-elev);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 11px; padding: 8px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab-btn span { font-size: 20px; line-height: 1; }
.tab-btn.active { color: var(--accent); }

/* ---- cards / watch list ---- */
.status { color: var(--muted); font-size: 13px; padding: 6px 4px; }
.card-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.card.lit { border-color: var(--signal); background: var(--signal-bg); }

.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-name { font-weight: 700; font-size: 16px; }
.card-code { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--signal); color: #1a1300; white-space: nowrap;
}
.badge.off { background: var(--line); color: var(--muted); }

.card-price { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }
.prox { font-size: 12px; color: var(--muted); }
.prox.near { color: var(--signal); }

.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px;
  margin-top: 10px; font-size: 13px;
}
.grid .k { color: var(--muted); }
.grid .v { text-align: right; font-variant-numeric: tabular-nums; }

.hold-chip {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px; vertical-align: middle;
  background: rgba(78, 161, 255, 0.16); color: var(--accent);
}

/* ---- holdings ---- */
.holding-form { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.holding-form .row { display: flex; gap: 8px; margin-bottom: 8px; }
.holding-form .row:last-child { margin-bottom: 0; }
.holding-form input[type=text], .holding-form input[type=number] {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 14px;
}
button.primary { background: var(--accent); color: #04121f; border: none; border-radius: 10px; padding: 10px 14px; font-weight: 700; cursor: pointer; }
button.ghost, .file-label { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 13px; }
.file-label { display: inline-flex; align-items: center; }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.summary .box { background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.summary .box .label { color: var(--muted); font-size: 12px; }
.summary .box .val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.pl-pos { color: var(--up); }
.pl-neg { color: var(--down); }

.del-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 4px 8px; font-size: 12px; cursor: pointer; }

/* ---- progress ---- */
.progress-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.progress-figures { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.progress-figures .label { display: block; color: var(--muted); font-size: 12px; }
.progress-figures .big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--up)); transition: width .5s ease; }
.note { color: var(--muted); font-size: 13px; margin-top: 10px; }

.empty { color: var(--muted); text-align: center; padding: 28px 10px; }
