:root {
  --bg: #0a0e17;
  --bg-2: #0d1220;
  --panel: #101626;
  --panel-2: #161f33;
  --border: #1f2a40;
  --border-soft: #182238;
  --text: #e8eef7;
  --muted: #8695ad;
  --muted-2: #5d6b83;
  --up: #26d07c;
  --up-bg: rgba(38, 208, 124, 0.12);
  --down: #f6465d;
  --down-bg: rgba(246, 70, 93, 0.12);
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --mono: "SF Mono", "JetBrains Mono", "Consolas", "Roboto Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html { scrollbar-color: var(--border) transparent; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(76, 141, 255, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 24px;
  background: rgba(13, 18, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { font-size: 20px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand-accent { color: var(--accent); margin-left: 3px; }

.search { position: relative; flex: 1; min-width: 240px; }
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); pointer-events: none;
}
.search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--muted-2); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-results {
  list-style: none; margin: 8px 0 0; padding: 5px;
  position: absolute; left: 0; right: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 340px; overflow-y: auto; z-index: 50;
  box-shadow: var(--shadow);
}
.search-results li {
  padding: 10px 11px; border-radius: 7px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.search-results li:hover { background: var(--panel); }
.search-results .sym { font-weight: 600; font-family: var(--mono); font-size: 13px; }
.search-results .desc { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.search-results .msg { color: var(--muted); cursor: default; }
.search-results .msg:hover { background: transparent; }

.status { display: flex; align-items: center; gap: 14px; color: var(--muted); white-space: nowrap; }
.market-status { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.market-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.market-status.open .dot { background: var(--up); box-shadow: 0 0 8px var(--up); }
.market-status.closed .dot { background: var(--down); }
.last-updated { font-size: 12px; color: var(--muted-2); }

#refresh-btn {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 10px; width: 38px; height: 38px; cursor: pointer;
  display: grid; place-items: center; transition: color 0.15s, border-color 0.15s;
}
#refresh-btn:hover { color: var(--text); border-color: var(--accent); }
#refresh-btn.spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 372px;
  gap: 18px;
  padding: 20px 24px;
  align-items: start;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Prices / groups ---------- */
.prices { display: flex; flex-direction: column; gap: 20px; }

.group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.group-title { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.group-title .tag { color: var(--accent); }
.group-count { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 9px 18px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted-2); font-weight: 600;
  border-bottom: 1px solid var(--border-soft);
}
th.num, td.num { text-align: right; }

tbody tr {
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer; transition: background 0.12s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }

td { padding: 13px 18px; }
.sym-cell { display: flex; align-items: center; gap: 11px; }
.sym-badge {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  overflow: hidden;
}
.sym-badge img { width: 100%; height: 100%; object-fit: contain; }
.sym-text b { font-weight: 600; font-family: var(--mono); font-size: 13.5px; }
.sym-text small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; margin-top: 1px; }

.price-cell { font-size: 14px; font-weight: 600; }
.pct-badge {
  display: inline-block; min-width: 74px; text-align: right;
  padding: 4px 9px; border-radius: 7px; font-size: 13px; font-weight: 600;
  font-family: var(--mono);
}
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.pct-badge.up { background: var(--up-bg); }
.pct-badge.down { background: var(--down-bg); }
.pct-badge.flat { background: rgba(134,149,173,0.1); }

.remove-btn {
  background: transparent; border: none; color: var(--muted-2);
  cursor: pointer; font-size: 14px; padding: 4px 7px; border-radius: 6px; line-height: 1;
  opacity: 0; transition: opacity 0.12s, color 0.12s, background 0.12s;
}
tbody tr:hover .remove-btn { opacity: 1; }
.remove-btn:hover { color: var(--down); background: var(--down-bg); }

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

/* ---------- News ---------- */
.news {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  position: sticky; top: 82px;
  overflow: hidden;
}
.news-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.news-header h2 { font-size: 14px; margin: 0; font-weight: 700; }
.news-live {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--up);
  background: var(--up-bg); padding: 3px 8px; border-radius: 20px;
}
.news-list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 190px); overflow-y: auto; }
.news-list li { border-bottom: 1px solid var(--border-soft); }
.news-list li:last-child { border-bottom: none; }
.news-list a { display: block; padding: 13px 18px; color: var(--text); text-decoration: none; transition: background 0.12s; }
.news-list a:hover { background: var(--panel-2); }
.news-list .headline { font-size: 13px; line-height: 1.45; margin-bottom: 6px; }
.news-list .meta { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }
.news-empty { padding: 22px 18px; color: var(--muted); }

/* ---------- Footer ---------- */
footer {
  padding: 14px 24px; color: var(--muted-2); font-size: 12px;
  border-top: 1px solid var(--border); text-align: center;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 14, 0.72);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  position: relative;
  width: min(560px, 100%);
  max-height: 88vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow);
  animation: pop 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.modal-close:hover { color: var(--text); border-color: var(--accent); }

.modal-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; padding-right: 40px; }
.modal-logo {
  width: 54px; height: 54px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-weight: 700; font-size: 15px;
}
.modal-logo img { width: 100%; height: 100%; object-fit: contain; }
.modal-title { flex: 1; min-width: 0; }
.modal-title h2 { margin: 0; font-size: 22px; font-family: var(--mono); letter-spacing: -0.01em; }
.modal-name { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.modal-price-block { text-align: right; }
.modal-price { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.modal-change { font-size: 13px; font-weight: 600; font-family: var(--mono); margin-top: 3px; }

.modal-description { color: var(--text); font-size: 13.5px; line-height: 1.6; margin: 0 0 20px; opacity: 0.92; }

.modal-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px;
}
.stat {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 11px 13px;
}
.stat .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-2); margin-bottom: 5px; }
.stat .value { font-size: 14px; font-weight: 600; font-family: var(--mono); }

.modal-news-section h3 { font-size: 13px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.modal-news { list-style: none; margin: 0 0 18px; padding: 0; }
.modal-news li { border-bottom: 1px solid var(--border-soft); }
.modal-news li:last-child { border-bottom: none; }
.modal-news a { display: block; padding: 10px 0; color: var(--text); text-decoration: none; }
.modal-news a:hover .mn-headline { color: var(--accent); }
.mn-headline { font-size: 13px; line-height: 1.45; margin-bottom: 4px; }
.mn-meta { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }

.modal-link {
  display: inline-block; color: var(--accent); text-decoration: none;
  font-size: 13px; font-weight: 600;
}
.modal-link:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .news { position: static; }
  th.hide-sm, td.hide-sm { display: none; }
  .topbar { gap: 14px; }
}
@media (max-width: 560px) {
  .modal-stats { grid-template-columns: repeat(2, 1fr); }
  td, th { padding-left: 12px; padding-right: 12px; }
}
