/* Themes: light, dark and "old" (the original eestats look). The theme is set with data-theme on <html>
   (see theme.js); everything below the variables uses them, and the "old" block adds a few structural rules. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #65708a; --line: #dfe3ec;
  --accent: #2456d6; --accent-text: #ffffff; --head: #eef1f7; --hover: #f2f5fc;
  --dead: #c0392b; --prot: #1f9d62; --up: #1f9d62; --down: #c0392b; --kill: #c0392b;
  --c1: #2456d6; --c2: #d98a00; --c3: #1f9d62; --c4: #c0392b; --c5: #8e44ad; --c6: #0e9aa7; --c7: #a0522d; --c8: #6b7280;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f131a; --panel: #171c26; --text: #e4e8f1; --muted: #8e99b3; --line: #2a3140;
  --accent: #6c97ff; --accent-text: #0b1020; --head: #1d2330; --hover: #1c2330;
  --dead: #ff7b6b; --prot: #52d69a; --up: #52d69a; --down: #ff7b6b; --kill: #ff7b6b;
  --c1: #6c97ff; --c2: #f0b040; --c3: #52d69a; --c4: #ff7b6b; --c5: #c39bd3; --c6: #4fd1dd; --c7: #d9a066; --c8: #a0a8b8;
}
:root[data-theme="old"], :root:not([data-theme]) {
  /* the old eestats palette: black page, dark red headers and buttons, cream text and borders */
  color-scheme: dark;
  --bg: #000000; --panel: #0c0c0c; --text: #ffffff; --muted: #bbaa88; --line: #3a3030;
  --cream: #ffeecc; --edge: #ddccaa; --red: #400000; --cell: #202020; --cell-dark: #151515; --cell-darker: #0c0c0c;
  --accent: #ffeecc; --accent-text: #000000; --head: #400000; --hover: #2c2c2c; --bar: #5c1414;
  --input: #404040; --focus: #558dd9;
  --dead: #ff7b6b; --prot: #6fd08a; --up: #6fd08a; --down: #ff7b6b; --kill: #ff7b6b;
  --c1: #ffeecc; --c2: #e0533f; --c3: #6fbf73; --c4: #5aa7e0; --c5: #b58ae0; --c6: #4ec5c0; --c7: #e08ab5; --c8: #a89c85;
}
* { box-sizing: border-box; }
html { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 1.2rem 0 .8rem; }
h1 small { font-size: .9rem; font-weight: 400; color: var(--muted); margin-left: .5rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }
footer { max-width: 1180px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: .85rem; }

.top { display: flex; align-items: center; gap: 1.2rem; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--text); }
.servers { display: flex; gap: .3rem; flex-wrap: wrap; }
.servers a, .sections a { padding: 4px 10px; border-radius: 6px; color: var(--text); }
.servers a:hover, .sections a:hover { background: var(--hover); text-decoration: none; }
.servers a.active, .sections a.active { background: var(--accent); color: var(--accent-text); }
.sections { display: flex; gap: .3rem; padding: 6px 16px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); background: var(--panel); }
.sections .sep { margin: 0 .3rem 0 1rem; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

.lead { color: var(--muted); }
.servers-list { display: flex; gap: .6rem; flex-wrap: wrap; padding: 0; list-style: none; }
.servers-list a { display: block; padding: 8px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.note { color: var(--muted); }
.pager a { margin-right: 1rem; }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.table-wrap.narrow { max-width: 760px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { background: var(--head); text-align: center; position: sticky; top: 0; }
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th.asc::after { content: " \25B2"; font-size: .7em; }
table.sortable thead th.desc::after { content: " \25BC"; font-size: .7em; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
td.c { text-align: center; } td.r { text-align: right; }
.dead { color: var(--dead); } .prot { color: var(--prot); }
.kill { color: var(--kill); font-weight: 600; }
.up { color: var(--up); } .down { color: var(--down); }
table.plain { border: 0; }
table.stats tr.dark td { background: var(--head); } table.stats tr.darker td { background: var(--head); font-weight: 600; }
table.plain.stats td:nth-child(odd) { color: var(--muted); }

.filterbar { display: flex; gap: .8rem; align-items: center; padding: 8px 10px; }
.filterbar input { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); min-width: 220px; }
.filterbar .count { color: var(--muted); font-size: .9rem; }

.cards { margin: 0 0 1rem; }
dl.card { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0; }
dl.card > div { padding: 10px 14px; box-shadow: 0 0 0 .5px var(--line); }
dl.card dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
dl.card dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 600; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 14px 0; }
.panel > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.panel > h2 { margin-top: .2rem; }
.panel .table-wrap { border: 0; margin-top: 8px; }
.chart-box { position: relative; height: 320px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 8px; }

.warselect { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 20px; }
.warselect .side { display: flex; flex-direction: column; flex: 1 1 180px; }
.warselect label { font-weight: 600; margin-bottom: 4px; }
.warselect select { width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.warselect .mid { display: flex; flex-direction: column; gap: 6px; }
.warselect .submit { flex: 1 0 100%; text-align: center; }
button { padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); cursor: pointer; font: inherit; }
button:hover { background: var(--hover); }
.warselect .submit button { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

@media (max-width: 600px) {
  html { font-size: 14px; }
  th, td { padding: 5px 7px; }
}

.tabs, .goods { display: flex; gap: .3rem; flex-wrap: wrap; margin: 6px 0 10px; }
.tabs button, .goods a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.goods a:hover { background: var(--hover); text-decoration: none; }
.tabs button.active, .goods a.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
tr.sub th { background: var(--head); text-align: left; }
.topgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.topten table { table-layout: auto; }
td.bar { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 22%, transparent) var(--pct, 0%), transparent var(--pct, 0%)); }
.chartgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.chartgrid .panel { margin: 0; }
tr.total td { font-weight: 600; background: var(--head); }
@media (max-width: 600px) { .chartgrid { grid-template-columns: 1fr; } }
.topten th { white-space: normal; }
.topten td:first-child { white-space: normal; }
.tools { margin-left: auto; display: flex; gap: .3rem; flex-wrap: wrap; font-size: .9rem; }
.tools a { padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.tools a:hover { background: var(--hover); text-decoration: none; }
.tools a.active { background: var(--accent); color: var(--accent-text); }
textarea.paste { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: inherit; margin: 6px 0 4px; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.calc-controls { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.calc input, .calc select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font: inherit; max-width: 130px; }
.calc td input { max-width: 110px; text-align: right; }
.calc .table-wrap { margin-bottom: 14px; }
table.stats-table td.r, table.stats-table th { text-align: right; }
table.stats-table th:first-child, table.stats-table td:first-child { text-align: left; }

thead tr.filters th { position: static; padding: 3px 4px; background: var(--head); }
input.colfilter { width: 100%; min-width: 60px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; }
.filterbar { flex-wrap: wrap; }
.filterhelp { color: var(--muted); font-size: .8rem; }



.theme { margin-left: .5rem; font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.theme select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; font: inherit; }

/* dropdown menus (hover, keyboard focus, or a tap on touch screens) */
.navbar { display: flex; gap: 3px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.nav { position: relative; }
.nav > a { display: block; min-width: 110px; text-align: center; padding: 4px 14px; font-size: 1.05rem; color: var(--text); border-radius: 6px; }
.nav > a:hover, .nav:hover > a, .nav:focus-within > a, .nav.open > a { background: var(--hover); text-decoration: none; }
.nav.active > a { background: var(--accent); color: var(--accent-text); }
.nav ul { display: none; position: absolute; top: 100%; left: 0; min-width: 100%; z-index: 50; margin: 0; padding: 4px 0;
  list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.nav:hover > ul, .nav:focus-within > ul, .nav.open > ul { display: block; }
.nav li a { display: block; padding: 3px 14px; white-space: nowrap; text-align: center; color: var(--text); }
.nav li a:hover { background: var(--hover); text-decoration: none; }
.nav li a[aria-current] { font-weight: bold; color: var(--accent); }
.nav li.label { text-align: center; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; padding: 6px 14px 2px; }

/* ---- the "old" theme: black, dark red and cream, as the original eestats ---- */
:root[data-theme="old"] { font: 14px/1.45 Arial, Helvetica, sans-serif; }
:root[data-theme="old"] h1,
:root[data-theme="old"] h2,
:root[data-theme="old"] h3,
:root[data-theme="old"] .brand { color: var(--cream); }
:root[data-theme="old"] h1,
:root[data-theme="old"] h2 { text-align: center; }
:root[data-theme="old"] h1 small { display: block; font-size: .75rem; margin: 2px 0 0; color: var(--muted); }
:root[data-theme="old"] a { color: var(--cream); }
:root[data-theme="old"] .lead,
:root[data-theme="old"] .note { text-align: center; }
:root[data-theme="old"] .pager { text-align: center; }
:root[data-theme="old"] .top { background: var(--bg); border-bottom: 0; justify-content: center; gap: 1rem; padding: 14px 16px 6px; }
:root[data-theme="old"] .brand { font-size: 1.5rem; letter-spacing: .02em; }
:root[data-theme="old"] .servers { gap: 3px; }
:root[data-theme="old"] .servers a,
:root[data-theme="old"] .tools a { color: var(--cream); background: var(--red); border: 1px solid var(--edge); border-radius: 0; padding: 4px 14px; }
:root[data-theme="old"] .servers a { font-size: 1.1rem; }
:root[data-theme="old"] .servers a:hover,
:root[data-theme="old"] .tools a:hover { background: #000; text-decoration: none; }
:root[data-theme="old"] .servers a.active,
:root[data-theme="old"] .tools a.active,
:root[data-theme="old"] .goods a.active,
:root[data-theme="old"] .tabs button.active { background: #000; color: var(--cream); border-color: var(--edge); }
:root[data-theme="old"] .tools { margin-left: 0; gap: 3px; font-size: .85rem; }
:root[data-theme="old"] .tools a { padding: 3px 9px; }
:root[data-theme="old"] .sections { background: var(--bg); border-bottom: 1px solid var(--red); justify-content: center; padding: 6px 16px 10px; }
:root[data-theme="old"] .sections a { color: var(--cream); border-radius: 0; padding: 3px 10px; font-weight: bold; }
:root[data-theme="old"] .sections a:hover { background: var(--red); }
:root[data-theme="old"] .sections a.active { background: var(--red); color: var(--cream); outline: 1px solid var(--edge); }
:root[data-theme="old"] .sections .sep { color: var(--muted); }
:root[data-theme="old"] footer { text-align: center; color: var(--muted); }
:root[data-theme="old"] .table-wrap { background: transparent; border: 0; border-radius: 0; }
:root[data-theme="old"] table { border-collapse: separate; border-spacing: 2px; font-size: .92rem; margin: 5px auto; }
:root[data-theme="old"] th,
:root[data-theme="old"] td { border: 0; padding: 4px 8px; }
:root[data-theme="old"] th { background: var(--red); color: var(--cream); }
:root[data-theme="old"] td { background: var(--cell); }
:root[data-theme="old"] thead th { background: var(--red); }
:root[data-theme="old"] tbody tr:hover td { background: var(--hover); }
:root[data-theme="old"] table.sortable thead th.asc::after,
:root[data-theme="old"] table.sortable thead th.desc::after { color: var(--cream); }
:root[data-theme="old"] table.stats tr.dark td { background: var(--cell-dark); }
:root[data-theme="old"] table.stats tr.darker td { background: var(--cell-darker); font-weight: 600; }
:root[data-theme="old"] table.plain td,
:root[data-theme="old"] table.plain th { background: transparent; }
:root[data-theme="old"] table.plain.stats td:nth-child(odd) { color: var(--muted); }
:root[data-theme="old"] tr.sub th { background: var(--red); text-align: center; }
:root[data-theme="old"] tr.total td { background: var(--cell-darker); font-weight: bold; }
:root[data-theme="old"] thead tr.filters th { background: #2a0000; }
:root[data-theme="old"] td.bar { background: linear-gradient(90deg, var(--bar) var(--pct, 0%), var(--cell) var(--pct, 0%)); }
:root[data-theme="old"] input,
:root[data-theme="old"] select,
:root[data-theme="old"] textarea { color-scheme: dark; }
:root[data-theme="old"] .filterbar input,
:root[data-theme="old"] input.colfilter,
:root[data-theme="old"] .calc input,
:root[data-theme="old"] .calc select,
:root[data-theme="old"] textarea.paste,
:root[data-theme="old"] .warselect select {
  background: var(--input); color: #fff; border: 1px solid #ccc; border-top-color: #ccc; border-left-color: #999; border-radius: 0; }
:root[data-theme="old"] input.colfilter:focus,
:root[data-theme="old"] .filterbar input:focus,
:root[data-theme="old"] .calc input:focus,
:root[data-theme="old"] textarea.paste:focus { outline: 0; border-color: var(--focus); }
:root[data-theme="old"] select:hover { background: #000; }
:root[data-theme="old"] button,
:root[data-theme="old"] .button { padding: 3px 12px; background: var(--red); color: var(--cream); font-weight: bold; border: 1px solid var(--edge); border-radius: 0; }
:root[data-theme="old"] button:hover,
:root[data-theme="old"] .button:hover { background: #000; }
:root[data-theme="old"] .warselect .submit button { background: var(--red); color: var(--cream); border-color: var(--edge); }
:root[data-theme="old"] .tabs button,
:root[data-theme="old"] .goods a { background: var(--red); border: 1px solid var(--edge); border-radius: 0; color: var(--cream); font-weight: bold; }
:root[data-theme="old"] .goods a:hover { background: #000; }
:root[data-theme="old"] dl.card { gap: 2px; background: #000; border: 0; border-radius: 0; box-shadow: none; }
:root[data-theme="old"] dl.card > div { background: var(--cell); box-shadow: none; }
:root[data-theme="old"] dl.card dt { color: var(--muted); }
:root[data-theme="old"] dl.card dd { color: var(--cream); }
:root[data-theme="old"] .panel { background: var(--panel); border: 1px solid var(--red); border-radius: 0; }
:root[data-theme="old"] .panel > summary { color: var(--cream); }
:root[data-theme="old"] .servers-list a { background: var(--red); border: 1px solid var(--edge); border-radius: 0; font-size: 1.2rem; padding: 8px 18px; }
:root[data-theme="old"] .servers-list a:hover { background: #000; text-decoration: none; }
:root[data-theme="old"] .servers-list { justify-content: center; }

:root[data-theme="old"] .theme select { background: var(--input); border: 1px solid #ccc; border-radius: 0; }

:root[data-theme="old"] .nav > a { background: var(--red); border: 1px solid var(--edge); border-radius: 0; color: var(--cream); font-size: 1.3rem; padding: 3px 14px; }
:root[data-theme="old"] .nav > a:hover, :root[data-theme="old"] .nav:hover > a, :root[data-theme="old"] .nav.open > a,
:root[data-theme="old"] .nav:focus-within > a, :root[data-theme="old"] .nav.active > a { background: #000; color: var(--cream); }
:root[data-theme="old"] .nav ul { background: var(--red); border: 0; border-radius: 0; outline: 1px solid var(--edge); margin-top: 1px; padding: 0; box-shadow: none; }
:root[data-theme="old"] .nav li a { color: var(--cream); font-weight: bold; font-size: .85rem; padding: 2px 10px; }
:root[data-theme="old"] .nav li a:hover { background: #000; }
:root[data-theme="old"] .nav li a[aria-current] { color: #fff; }
:root[data-theme="old"] .nav li.label { color: var(--muted); text-transform: none; letter-spacing: 0; font-size: .85rem; padding: 4px 10px 2px; }
:root[data-theme="old"] .nav li.label::before, :root[data-theme="old"] .nav li.label::after { content: " - "; }
.top { align-items: flex-start; }
.top .brand, .top .theme { margin-top: 6px; }
