:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #151f32;
  --surface-2: #1e293b;
  --ink: #e5eefb;
  --muted: #94a3b8;
  --border: #2f3d55;
  --accent: #7c3aed;
  --green: #22c55e;
  --red: #f43f5e;
  --amber: #f59e0b;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Yu Gothic UI", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button, .file-button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}
button:hover, .file-button:hover { border-color: #60708c; }
.primary { background: #12351f; color: #bbf7d0; }
.danger { background: #3a1726; color: #fecdd3; }
.ghost { background: transparent; }
.small { padding: 7px 10px; font-size: 12px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  background: #0b1120;
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}
.brand h1 { margin: 0; font-size: 19px; }
.brand p, .eyebrow, .aside-note, .panel-head span { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
nav { display: grid; gap: 8px; }
nav a {
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 8px;
  padding: 10px 12px;
}
nav a.active, nav a:hover { background: var(--surface-2); color: white; }
.aside-note { margin-top: auto; line-height: 1.7; }

main { margin-left: 250px; padding: 22px; }
.topbar, .panel-head, .actions, .tabs { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar { margin-bottom: 16px; }
.topbar h2 { margin: 0; font-size: 26px; }
.eyebrow { color: var(--amber); font-weight: 700; }

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.metrics article, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.metrics article { padding: 13px 14px; }
.metrics span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metrics strong { display: block; margin-top: 4px; font-size: 24px; }

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 14px;
}
.bottom { margin-top: 14px; }
.panel { padding: 16px; min-width: 0; }
.wide { margin-top: 14px; }
h3 { margin: 0 0 12px; font-size: 17px; }

label { display: grid; gap: 6px; color: #cbd5e1; font-size: 12px; font-weight: 700; }
input, select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 11px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.field-row.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.actions { justify-content: flex-start; margin-top: 12px; }
.wrap { flex-wrap: wrap; }
.file-button { display: inline-flex; align-items: center; gap: 8px; }
.file-button input, .dropzone input { display: none; }

.deck-manager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 9px;
  color: #dbeafe;
  font-size: 13px;
}
.chip button {
  border: 0;
  background: transparent;
  color: #fda4af;
  padding: 0 2px;
  border-radius: 0;
}
#chartCanvas {
  width: 100%;
  height: auto;
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
.small-table table { min-width: 420px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
th { color: #cbd5e1; background: var(--surface-2); font-size: 12px; }
td { color: #dbeafe; font-size: 13px; }
td.note { text-align: left; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(124, 58, 237, 0.16); }
.win { color: #86efac; font-weight: 800; }
.loss { color: #fda4af; font-weight: 800; }

.tabs { justify-content: flex-start; margin-bottom: 10px; }
.tabs button.active { background: var(--accent); color: white; }

@media (max-width: 980px) {
  .sidebar { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  nav { grid-template-columns: repeat(4, 1fr); }
  main { margin-left: 0; padding: 14px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .field-row, .field-row.compact { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  nav { grid-template-columns: repeat(2, 1fr); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .field-row, .field-row.compact { grid-template-columns: 1fr; }
  .actions button, .file-button { flex: 1 1 auto; }
}
