:root {
  color-scheme: light;

  --bg: #f3f6fb;
  --panel: #ffffff;
  --card: #fbfcff;
  --sidebar: #0f1d2d;
  --header: #16324f;

  --text: #1f2937;
  --muted: #64748b;

  --border: #e5e7eb;
  --border-soft: #eef2f7;

  --accent: #0f8f5f;
  --accent-secondary: #2b6cb0;

  --chart-bg: linear-gradient(135deg, #f8fbff 0%, #f0f5ff 100%);
  --chart-surface: rgba(255, 255, 255, 0.88);

  --shadow: 0 10px 30px rgba(15, 29, 45, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #111827;
  --panel: #1f2937;
  --card: #273548;
  --sidebar: #0b1220;
  --header: #0b1220;

  --text: #f3f4f6;
  --muted: #9ca3af;

  --border: #374151;
  --border-soft: #4b5563;

  --accent: #34d399;
  --accent-secondary: #60a5fa;

  --chart-bg: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  --chart-surface: rgba(17, 24, 39, 0.85);

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
  line-height: 1.5;
}

header,
footer {
  background: var(--header);
  color: white;
  padding: 1rem 2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

nav a,
.sidebar-nav a,
.text-link {
  color: inherit;
  text-decoration: none;
}

nav a {
  color: white;
  margin-right: 0.75rem;
}

nav a:hover,
.sidebar-nav a:hover,
.text-link:hover {
  text-decoration: underline;
}

.page-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: calc(100vh - 180px);
}

.sidebar {
  background: var(--sidebar);
  color: white;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-block {
  padding: 0.8rem;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
}

.sidebar-block.small p {
  margin-bottom: 0;
}

.sidebar-nav {
  display: grid;
  gap: 0.45rem;
}

.sidebar-nav a {
  color: white;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.08);
}

.content-area {
  padding: 1.5rem;
  /* max-width: 1200px; */
  width: 100%;
}

.panel {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.hero {
  background: linear-gradient(
    120deg,
    var(--panel) 0%,
    rgba(64, 128, 255, 0.08) 100%
  );
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  text-decoration: none;
}

.button.secondary {
  background: var(--accent-secondary);
  margin-left: 0.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.card-grid.two-up {
  grid-template-columns: 2fr 1fr;
}

.card-grid .chart-card {
  grid-column: 1 / -1;
  min-height: 430px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  text-align: center;
  border-radius: 12px;
  padding: 1rem;
}

.highlight-card {
  background: linear-gradient(
    120deg,
    #16324f 0%,
    #2d5c86 100%
  );
  color: white;
}

.metric {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.3rem 0;
}

.metric.small {
  font-size: 1.5rem;
}

.feature-list {
  display: grid;
  gap: 0.5rem;
  padding-left: 1.2rem;
}

.mini-list {
  display: grid;
  gap: 0.6rem;
}

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(15, 143, 95, 0.12);
  border: 1px solid rgba(15, 143, 95, 0.28);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.stats-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.stats-panel h4,
.stats-group h5 {
  margin-top: 0;
}

.stats-list {
  display: grid;
  gap: 0.85rem;
}

.stats-group {
  border-top: 1px solid var(--border-soft);
  padding-top: 0.75rem;
}

.stats-group:first-of-type {
  border-top: none;
  padding-top: 0;
}

.muted {
  color: var(--muted);
}

.note {
  color: var(--muted);
}

.flash {
  background: #fff7d6;
  color: #111827;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
}

form {
  background: var(--panel);
  padding: 1rem;
  border-radius: 10px;
  display: grid;
  gap: 0.75rem;
  max-width: 480px;
}

input[type="file"] {
  padding: 0.4rem;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  cursor: pointer;
}

.table-stack {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

.table-stack th,
.table-stack td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}


.table-stack a {
  color: var(--accent-secondary);
  text-decoration: none;
}

.table-stack a:hover {
  text-decoration: underline;
}

.category-table {
    width: 100%;
    border-collapse: collapse;
}

.category-table th,
.category-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.category-table th:last-child,
.category-table td:last-child {
    text-align: right;
}

.category-bars-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.category-bar-header {
  flex: 1;
}

.category-value-header {
  width: 5rem;
  text-align: right;
}

.category-value {
  width: 5rem;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.category-bars {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 1rem;
}

.category-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-color: var(--muted);
    border-style: dashed solid;
    border-width: 0 0 1px 0;
}

.category-label {
    width: 5rem;
    flex-shrink: 0;
}

.category-bar {
    flex: 1;
    height: 1rem;
    background: var(--border-soft);
    border-radius: 4px;
    overflow: hidden;
}

.category-bar-fill {
    height: 100%;
    background: var(--accent);
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.chart-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.chart-badge {
  background: var(--header);
  color: white;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.rating-chart {
  width: 100%;
  height: 320px;
  background: var(--chart-bg);
  border-radius: 12px;
}

.chart-surface {
  fill: var(--chart-surface);
  stroke: var(--border);
  stroke-width: 1;
}

.axis {
  stroke: var(--border-soft);
}

.grid {
  stroke: var(--border-soft);
  stroke-dasharray: 4 4;
}

.baseline {
  stroke: #ef4444;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.trend {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.point {
  fill: var(--header);
  stroke: white;
  stroke-width: 2;
}

.current-point {
  fill: #ef4444;
  stroke: white;
  stroke-width: 2;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.chart-current {
  font-weight: 700;
  color: var(--text);
}

/* Floating language / theme controls */

#floating-controls {
  position: fixed;
  bottom: 22px;
  right: 22px;

  display: flex;
  gap: 10px;

  z-index: 9999;
}

#floating-controls button {
  width: 54px;
  height: 54px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  border: 1px solid var(--border);

  background: var(--panel);
  color: var(--text);

  font-size: 1rem;
  font-weight: 700;
  line-height: 1;

  box-shadow: var(--shadow);

  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

#floating-controls button:hover {
  transform: translateY(-2px);
}

#floating-controls button:active {
  transform: translateY(0);
}

@media (max-width: 900px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .card-grid.two-up {
    grid-template-columns: 1fr;
  }
}

.centered-header {
  justify-content: center;
  text-align: center;
}

.record-name {
  text-align: left;
}

.record-win {
  background-color: #34d399; /* var(--accent) */ /* rgba(34, 197, 94, 0.15);*/
}

.record-even {
  background-color: rgba(234, 179, 8, 0.15);
}

.record-loss {
  background-color: rgba(255, 0, 0, 0.5);
}

[data-theme="dark"] .record-win {
  background-color: rgba(50, 255, 0, 0.35); /*var(--accent)*/
}

[data-theme="dark"] .record-even {
  background-color: rgba(0, 255, 255, 0.35);
}

[data-theme="dark"] .record-loss {
  background-color: rgba(255, 75, 75, 0.35);
}

.filter-form {
    margin: 0 auto 1rem auto;
    max-width: 900px;
}

.filter-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.filter-row input {
    min-width: 180px;
}

.filter-item {
    width: 100%;
    display: flex;
    justify-content: center;
}

.filter-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.slider-container {
    min-width: 350px;
    padding: 0.5rem;
}

#rating-slider {
    margin-top: 0.75rem;
}

#rating-range-display {
    font-weight: bold;
    color: var(--accent);
}
.formula-box {
        background-color: var(--border-soft);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 1.5rem;
        margin-bottom: 2rem;
        font-size: 1.25rem;
        transition: background-color 0.3s, border-color 0.3s;
    }

.variables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.variable-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 6px;
    transition: background-color 0.3s, border-color 0.3s;
}

.variable-name {
    font-weight: bold;
    color: var(--muted);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.variable-value {
    font-size: 1.5rem;
    color: var(--accent-secondary);
    font-weight: 700;
    transition: color 0.3s;
}