:root {
  --bg: #0b1220;
  --bg-elev: #111827;
  --panel: #152033;
  --panel-border: #243247;
  --text: #e5eef7;
  --muted: #8fa3b8;
  --mint: #34d399;
  --mint-dim: #059669;
  --mint-bg: rgba(52, 211, 153, 0.12);
  --up: #34d399;
  --down: #f87171;
  --down-bg: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(52, 211, 153, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(56, 189, 248, 0.06), transparent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--panel-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #064e3b, #0f172a);
  border: 1px solid rgba(52, 211, 153, 0.35);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.15);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 18px;
  height: 2px;
  background: var(--mint);
  border-radius: 2px;
  box-shadow: 0 -6px 0 -0.5px rgba(52, 211, 153, 0.5), 0 6px 0 -0.5px rgba(52, 211, 153, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.clock {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--mint);
  font-variant-numeric: tabular-nums;
}

.updated {
  color: var(--muted);
  font-size: 0.78rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: #3b5169; background: #1a2740; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: #1e3a34;
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--mint);
}
.btn-primary:hover { background: #234840; }

.btn-mint {
  background: var(--mint-dim);
  border-color: var(--mint);
  color: #042f1e;
}
.btn-mint:hover { background: #10b981; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--mint-bg);
  color: var(--mint);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.add-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.add-form input:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.2);
}
.add-form input::placeholder {
  text-transform: none;
  letter-spacing: 0;
  color: #6b7f94;
  font-family: var(--font);
}

.hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--warn);
}

.watchlist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty {
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.watch-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(4, minmax(0, 0.9fr)) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.watch-row .sym {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.03em;
}
.watch-row .name {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.num {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.86rem;
  text-align: right;
}
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

.btn-icon {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1;
}
.btn-icon:hover { color: var(--down); background: var(--down-bg); }

.filters {
  display: flex;
  gap: 4px;
}

.chip {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: #3b5169; }
.chip.active {
  background: var(--mint-bg);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--mint);
}

.movers-meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  max-height: min(70vh, 720px);
  overflow-y: auto;
}

.movers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.movers-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a2740;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
}

.movers-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(36, 50, 71, 0.7);
  white-space: nowrap;
}

.movers-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.movers-table tbody tr:hover {
  background: rgba(52, 211, 153, 0.06);
}
.movers-table tbody tr:active {
  background: rgba(52, 211, 153, 0.12);
}

.col-rank { width: 36px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-code { font-family: var(--mono); font-weight: 700; letter-spacing: 0.02em; }
.col-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.col-num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

.loading-cell, .error-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 24px 10px !important;
  white-space: normal !important;
}
.error-cell { color: var(--down); }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  margin-top: 8px;
  color: #5c738a;
  font-size: 0.72rem;
}

@media (max-width: 720px) {
  .watch-row {
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
  }
  .watch-row .sym { grid-column: 1 / -1; }
  .watch-row .btn-remove {
    grid-column: 2;
    justify-self: end;
    grid-row: 1;
  }
  .col-name { max-width: 100px; }
  .app { padding: 12px 10px 32px; }
}

@media (max-width: 480px) {
  .header-meta { width: 100%; }
  .btn-primary { margin-left: auto; }
}


.ticker-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted rgba(110, 231, 183, 0.55);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.ticker-link:hover {
  color: #6ee7b7;
  border-bottom-color: #6ee7b7;
}
.ticker-link:focus-visible {
  outline: 2px solid #6ee7b7;
  outline-offset: 2px;
  border-radius: 2px;
}
