:root {
  --bg: #0c0f14;
  --panel: #141922;
  --panel-2: #1b2230;
  --line: #232c3b;
  --text: #e6edf6;
  --muted: #8b97ab;
  --green: #2ecc8f;
  --red: #ff5d6c;
  --blue: #4c8dff;
  --amber: #ffb648;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Roboto, Arial, sans-serif;
}

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2ecc8f22, #ff5d6c33); border: 1px solid var(--line);
  font-size: 24px; color: var(--amber);
}
h1 { margin: 0; font-size: 18px; letter-spacing: .4px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.sub b { color: var(--text); font-weight: 600; }
.status { display: flex; align-items: center; gap: 10px; }
.chip {
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: #223046; color: var(--blue); border: 1px solid var(--line); white-space: nowrap;
}
.chip.live { background: #14331f; color: var(--green); }
.chip.scan { background: #33290f; color: var(--amber); }
.chip.err  { background: #3a1620; color: var(--red); }
.muted { color: var(--muted); font-size: 12px; }

.controls, .filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.filters { align-items: center; background: transparent; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
input, select {
  background: #0f141c; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; font-size: 13px; min-width: 110px;
}
input[type=checkbox] { min-width: auto; }
button, .btn {
  background: #0f141c; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--blue); }
button.primary { background: #14243d; border-color: #2b4a7d; color: #cfe0ff; }

.advanced { border-bottom: 1px solid var(--line); background: var(--panel-2); }
.advanced > summary {
  padding: 10px 20px; cursor: pointer; color: var(--muted); font-size: 12px; list-style: none;
  user-select: none;
}
.advanced > summary::before { content: "▸ "; color: var(--blue); }
.advanced[open] > summary::before { content: "▾ "; }
.advanced > summary:hover { color: var(--text); }
.advanced .controls { border-bottom: none; padding-top: 0; }

.stats { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; min-width: 132px;
}
.stat b { display: block; font-size: 19px; margin-top: 2px; }
.stat span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.stat small { color: var(--muted); font-size: 11px; }
.stat.note { flex: 1 1 340px; min-width: 300px; }
.stat.note p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.grade-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 0 20px 12px; font-size: 12px;
}
.chip-grade {
  padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); background: #10151e; font-size: 12px;
}
.grade {
  padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.grade.g-strong, .chip-grade.g-strong { background: #12301f; border-color: #1d4c31; color: var(--green); }
.grade.g-ok, .chip-grade.g-ok { background: #14243d; border-color: #2b4a7d; color: #9ec2ff; }
.grade.g-mid, .chip-grade.g-mid { background: #1d2634; border-color: #2a3547; color: #9fb0c9; }
.grade.g-weak, .chip-grade.g-weak { background: #2a1b20; border-color: #4a2730; color: #d08a95; }

.table-wrap { overflow-x: auto; padding: 0 12px 30px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: var(--panel-2); text-align: right; padding: 9px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; font-weight: 600;
  color: var(--muted); font-size: 12px;
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
tbody td { padding: 8px 10px; border-bottom: 1px solid #1a212c; text-align: right; white-space: nowrap; }
tbody td:first-child, tbody td:nth-child(2) { text-align: left; }
tbody tr:hover { background: #161d28; cursor: pointer; }
tbody tr.forming { background: #1d1a10; }
tbody tr.forming:hover { background: #262111; }
tbody tr.fresh td:nth-child(2) b { color: var(--amber); }
.long { color: var(--green); }
.short { color: var(--red); }
.tag {
  padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; border: 1px solid transparent;
}
.tag.long { background: #12301f; border-color: #1d4c31; color: var(--green); }
.tag.short { background: #34161d; border-color: #5a232e; color: var(--red); }
.tag.wait { background: #1d2634; color: #9fb0c9; }
.tag.form { background: #33290f; color: var(--amber); border-color: #5a4a1e; }
.tag.cont { background: #163a2a; color: var(--green); }
.tag.rev { background: #3a1620; color: var(--red); }
.tag.exp { background: #23262d; color: var(--muted); }
.fill {
  display: inline-flex; height: 9px; width: 64px; border-radius: 3px; overflow: hidden;
  background: #222b3a; vertical-align: middle; margin-right: 6px;
}
.fill i { display: block; height: 100%; }
.fill i.long { background: var(--green); }
.fill i.short { background: var(--red); }
a.ext { color: var(--blue); text-decoration: none; font-size: 12px; }
a.ext:hover { text-decoration: underline; }

.modal { position: fixed; inset: 0; background: #04060ad9; display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: min(1240px, 100%); max-height: 92vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; }
#chart { width: 100%; height: auto; background: #080b10; border: 1px solid var(--line); border-radius: 10px; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.levels .lvl { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; background: #10151e; color: var(--muted); }
.levels .lvl b { color: var(--text); }
.card-list { display: flex; flex-direction: column; gap: 6px; }
.card-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #10151e; cursor: pointer; font-size: 12px; }
.card-row:hover { border-color: var(--blue); }
.card-row.active { border-color: var(--amber); }

.foot { display: flex; justify-content: space-between; gap: 20px; padding: 14px 20px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: flex-start; }
  .controls, .filters { padding: 10px 12px; }
  label { min-width: 46%; }
}

.why { margin: 6px 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #10151e; }
.why-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; }
.why .plan { margin-top: 8px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.why-list { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--text); }
.why-list li { margin: 3px 0; }
.warn { color: var(--amber); }

.tournament { padding: 12px 20px; border-bottom: 1px solid var(--line); background: #101722; }
.t-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.t-row label.inline { gap: 8px; }
.t-row input { min-width: 90px; }
.t-note { margin-top: 8px; line-height: 1.5; max-width: 1100px; }
.t-live { color: var(--text); font-weight: 600; }

td.links { white-space: nowrap; }
td.links a.ext { margin-left: 8px; }
td.links a.ext:first-child { margin-left: 0; }
