:root {
    --font-body: "Sora", "Share", sans-serif;
    --font-display: "Sora", "Share", sans-serif;
    --radius: 14px;
    --radius-sm: 10px;
    --space: 16px;
    --bg: #f2f4f7;
    --bg-2: #e9edf3;
    --bg-3: #f7f8fb;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --text: #1f2937;
    --muted: #5b6470;
    --border: #d7dbe2;
    --shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    --link: #1f2937;
    --link-hover: #111827;
    --table-row: #eef2f7;
    --table-row-alt: #f6f8fb;
    --table-text: #1f2937;
    --accent: #c8a24a;
    --accent-2: #7c5c1e;
    --accent-soft: rgba(200, 162, 74, 0.18);
    --chart-1: #c8a24a;
    --chart-2: #4b7bbd;
    --chart-3: #5f9b7a;
    --chart-4: #d97f4a;
    --chart-5: #7f6fd1;
    --chart-6: #e3b34d;
    --chart-bg-1: rgba(200, 162, 74, 0.08);
    --chart-bg-2: rgba(15, 23, 42, 0.04);
    --tint-1: rgba(200, 162, 74, 0.12);
    --tint-2: rgba(79, 123, 189, 0.08);
}

html[data-theme="dark"] {
    --bg: #1a2030;
    --bg-2: #1e2638;
    --bg-3: #222c40;
    --surface: #232d41;
    --surface-2: #1f283b;
    --text: #eef2f7;
    --muted: #c0c9d6;
    --border: #3a4860;
    --shadow: 0 18px 36px rgba(12, 16, 24, 0.42);
    --link: #edf1f6;
    --link-hover: #ffffff;
    --table-row: #202a3c;
    --table-row-alt: #1f2736;
    --table-text: #eef2f7;
    --chart-bg-1: rgba(200, 162, 74, 0.18);
    --chart-bg-2: rgba(26, 32, 48, 0.28);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --bg: #1a2030;
        --bg-2: #1e2638;
        --bg-3: #222c40;
        --surface: #232d41;
        --surface-2: #1f283b;
        --text: #eef2f7;
        --muted: #c0c9d6;
        --border: #334055;
        --shadow: 0 18px 36px rgba(12, 16, 24, 0.42);
        --link: #edf1f6;
        --link-hover: #ffffff;
        --chart-bg-1: rgba(200, 162, 74, 0.18);
        --chart-bg-2: rgba(26, 32, 48, 0.28);
    }
}

html[data-palette="ink-brass"] {
    --accent: #c8a24a;
    --accent-2: #7c5c1e;
    --accent-soft: rgba(200, 162, 74, 0.18);
    --chart-1: #c8a24a;
    --chart-2: #4b7bbd;
    --chart-3: #5f9b7a;
    --chart-4: #d97f4a;
    --chart-5: #7f6fd1;
    --chart-6: #e3b34d;
    --tint-1: rgba(200, 162, 74, 0.14);
    --tint-2: rgba(79, 123, 189, 0.10);
}
html[data-palette="forest-copper"] {
    --accent: #b86a3a;
    --accent-2: #0f6b4e;
    --accent-soft: rgba(184, 106, 58, 0.18);
    --chart-1: #b86a3a;
    --chart-2: #0f6b4e;
    --chart-3: #7c9b6e;
    --chart-4: #d69b55;
    --chart-5: #6a7bb7;
    --chart-6: #c06a5f;
    --tint-1: rgba(184, 106, 58, 0.14);
    --tint-2: rgba(15, 107, 78, 0.12);
}
html[data-palette="blue-slate"] {
    --accent: #e04e39;
    --accent-2: #2f5aa6;
    --accent-soft: rgba(224, 78, 57, 0.18);
    --chart-1: #e04e39;
    --chart-2: #2f5aa6;
    --chart-3: #5f8fcf;
    --chart-4: #f0a54f;
    --chart-5: #6c8b6e;
    --chart-6: #b86bd6;
    --tint-1: rgba(224, 78, 57, 0.12);
    --tint-2: rgba(47, 90, 166, 0.14);
}
html[data-theme="light"][data-palette="ink-brass"],
html[data-theme="auto"][data-palette="ink-brass"] {
    --bg: #f6f3ee;
    --bg-2: #efe8de;
    --bg-3: #faf7f1;
    --surface: #ffffff;
    --surface-2: #f6f0e6;
    --text: #1f2937;
    --muted: #5b6470;
    --border: #d5ccbe;
    --table-row: #f7f1e7;
    --table-row-alt: #fffaf3;
    --table-text: #1f2937;
}
html[data-theme="light"][data-palette="forest-copper"],
html[data-theme="auto"][data-palette="forest-copper"] {
    --bg: #f2f1ec;
    --bg-2: #e9e5dd;
    --bg-3: #f7f4ee;
    --surface: #fffaf5;
    --surface-2: #f4efe7;
    --text: #1f2723;
    --muted: #5d6a63;
    --border: #d2c9bb;
    --table-row: #f7f0e8;
    --table-row-alt: #fff9f3;
    --table-text: #1f2723;
}
html[data-theme="light"][data-palette="blue-slate"],
html[data-theme="auto"][data-palette="blue-slate"] {
    --bg: #eef2f8;
    --bg-2: #e4eaf4;
    --bg-3: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #edf1f7;
    --text: #1c2430;
    --muted: #566274;
    --border: #c9d3e2;
    --table-row: #eef3fb;
    --table-row-alt: #f9fbff;
    --table-text: #1c2430;
}
html[data-theme="dark"][data-palette="ink-brass"] {
    --bg: #1b2231;
    --bg-2: #1f2838;
    --bg-3: #232d40;
    --surface: #232e41;
    --surface-2: #1f283a;
    --border: #3b4a62;
}
html[data-theme="dark"][data-palette="forest-copper"] {
    --bg: #192220;
    --bg-2: #1c2825;
    --bg-3: #20302c;
    --surface: #22322d;
    --surface-2: #1c2a27;
    --border: #3a514a;
}
html[data-theme="dark"][data-palette="blue-slate"] {
    --bg: #1a2130;
    --bg-2: #1d2638;
    --bg-3: #212d41;
    --surface: #233045;
    --surface-2: #1d283c;
    --border: #3a4c66;
}
html[data-theme="dark"][data-palette="ink-brass"] {
    --tint-1: rgba(200, 162, 74, 0.18);
    --tint-2: rgba(79, 123, 189, 0.14);
}
html[data-theme="dark"][data-palette="forest-copper"] {
    --tint-1: rgba(184, 106, 58, 0.18);
    --tint-2: rgba(15, 107, 78, 0.16);
}
html[data-theme="dark"][data-palette="blue-slate"] {
    --tint-1: rgba(224, 78, 57, 0.16);
    --tint-2: rgba(47, 90, 166, 0.18);
}

* { box-sizing: border-box; }
img, td, th { border: 0; }

html {
    background:
        radial-gradient(1100px 640px at 8% -12%, var(--tint-1), transparent 65%),
        radial-gradient(900px 520px at 100% 0%, var(--tint-2), transparent 60%),
        linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 60%, var(--bg-3) 100%);
}
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: transparent;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover, a:active { color: var(--accent); text-decoration: none; }

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-family: var(--font-display);
    letter-spacing: 0.2px;
}

img#logo { padding: 0; height: 48px; width: auto; }

div#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 8px;
    margin: 24px auto 16px;
    width: min(1100px, 100% - 32px);
}
div#menu { margin: 0; padding: 0; }
div#menu {
    background: linear-gradient(90deg, var(--surface-2), var(--bg-3));
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
div#menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
div#menu li { margin: 0; padding: 0; }
div#menu a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text);
    font-size: 16px;
    background: var(--surface-2);
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
div#menu a:hover { color: var(--text); background: var(--accent-soft); border-color: var(--accent); }
div#menu a.active { color: var(--accent); border-color: var(--accent); }

div#main {
    width: min(1100px, 100% - 32px);
    margin: 0 auto 24px;
    padding: 22px 24px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 120%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 520px;
    box-shadow: var(--shadow);
    position: relative;
}
div#main::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}


div#footer {
    font-size: 12px;
    color: var(--muted);
    padding: 10px 14px 20px;
    margin: 0 auto 32px;
    width: min(1100px, 100% - 32px);
    border-top: 1px solid var(--border);
}
div#footer a, div#footer a:visited { color: var(--muted); font-weight: 600; text-decoration: none; }
div#footer a:hover, div#footer a:active { color: var(--text); text-decoration: underline; }
div#footer table { width: 100%; }
div#footer table tr td { width: 33%; }
div#footer table tr td { vertical-align: top; padding: 6px 8px; }
div#selectlocale { margin-top: 2px; }
div#selectlocale form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--surface-2), var(--bg-3));
    border: 1px solid var(--border);
}
div#theme_controls {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--surface-2), var(--bg-3));
    border: 2px solid var(--border);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    max-width: 640px;
}
div#theme_controls label {
    min-width: 56px;
}
div#theme_controls .mm-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
div#theme_controls .mm-row + .mm-row {
    margin-top: 6px;
}
div#theme_controls .mm-pair {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
div#theme_controls .mm-pair select {
    min-width: 160px;
}
div#theme_controls label {
    font-weight: 600;
    color: var(--muted);
}
div#theme_controls select {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
    background: var(--surface-2);
    color: var(--text);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}
.stat-card h3 {
    margin: 0 0 6px 0;
    font-size: 14px;
}
.stat-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}
.stat-row .label {
    font-weight: 600;
    color: var(--muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}
.card-header {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: linear-gradient(180deg, var(--surface-2), var(--bg-3));
    border-bottom: 1px solid var(--border);
}
.card-body {
    padding: 12px;
}

div#errorbox {
    text-align: center;
    width: min(520px, 100%);
    margin: 0 auto;
    padding-top: 160px;
}
div#loading { display: none; margin-top: 6px; }

div.halfleft { width: 49%; float: left; }
div.halfright { width: 49%; float: right; }
div.choser { text-align: right; margin-bottom: 10px; }

div.motd {
    border: 1px solid var(--border);
    background: var(--surface-2);
    margin: 15px 5px 0 5px;
    padding: 10px 12px;
    height: 300px;
    overflow: auto;
    border-radius: var(--radius-sm);
}
div.motd pre { font-family: "IBM Plex Mono", "Share", monospace; }
div.topic {
    border: 1px dashed var(--border);
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-family: "IBM Plex Mono", "Share", monospace;
}
span.val { color: var(--accent-2); font-weight: 600; }
div.clear { clear: both; }
table.details th { text-align: left; vertical-align: top; color: var(--muted); width: 170px; }
table.details td { color: var(--text); }
table.details {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    margin-bottom: 16px;
    border-collapse: separate;
    border-spacing: 0;
}
table.details th,
table.details td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
table.details tr:last-child th,
table.details tr:last-child td {
    border-bottom: 0;
}
table.details h3 {
    margin: 0;
    font-size: 14px;
    color: var(--text);
}

table { border-collapse: collapse; }

input, select, textarea, button {
    font-family: var(--font-body);
    font-size: 14px;
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Tabs (jQuery UI replaced) */
.mm-tabs { margin-bottom: 16px; }
.mm-tab-list {
    list-style: none;
    margin: 0 0 12px 0;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--surface-2), var(--bg-3));
    border: 1px solid var(--border);
}
.mm-tab-list li a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    color: var(--muted);
    background: transparent;
}
.mm-tab-list li.mm-tab-active a {
    color: var(--text);
    background: var(--accent-soft);
    border-color: var(--accent);
}
.mm-tab-list li.mm-tab-disabled a {
    opacity: 0.4;
    pointer-events: none;
}
.mm-tab-panel { display: none; }

/* Channel menu */
.mm-menu {
    list-style: none;
    margin: 0;
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}
.mm-menu li {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.mm-menu li:hover {
    background: var(--accent-soft);
}
.mm-menu a { color: var(--text); }

.chanbutton {
    height: 20px;
    width: 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.chanbutton-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid var(--muted);
}

/* Radio/checkbox pills */
.choser input[type="radio"],
.choser input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.choser label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    margin-left: 6px;
}
.choser input:checked + label {
    color: var(--text);
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* Tables (DataTables replaced) */
.mm-table-wrap { margin-bottom: 14px; overflow-x: auto; }
.mm-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--surface-2), var(--bg-3));
    margin-bottom: 6px;
}
.mm-table-left, .mm-table-right { display: flex; align-items: center; gap: 8px; }
.mm-table-length-select,
.mm-table-search-input {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    background: var(--surface);
    color: var(--text);
}
.mm-table-info {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
.mm-table-pagination {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.mm-page-btn {
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: 4px 10px;
    cursor: pointer;
}
.mm-page-btn.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
}

table.mm-table {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
table.mm-table thead th {
    background: linear-gradient(180deg, var(--surface-2), var(--bg-3));
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
}
table.mm-table tbody tr img { vertical-align: middle; }
table.mm-table tbody tr,
table.mm-table tbody tr.odd,
table.mm-table tbody tr.even {
    background: var(--table-row);
    color: var(--table-text);
}
table.mm-table tbody td,
table.mm-table tbody th {
    background: var(--table-row);
    color: var(--table-text);
    padding: 10px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
}
table.mm-table tbody tr:hover td {
    background: var(--accent-soft);
}

div[id^="chart_"],
div[id*="chart-"] {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-2), var(--bg-3));
}

@media (max-width: 980px) {
    div#header {
        flex-direction: column;
        align-items: flex-start;
    }
    div#menu ul { width: 100%; }
}

@media (max-width: 760px) {
    div#main { padding: 16px; }
    div.halfleft, div.halfright { width: 100%; float: none; }
    div#footer table tr td { width: 100%; display: block; margin-bottom: 8px; }
    div#theme_controls { row-gap: 6px; }
    div#theme_controls { max-width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .stats-grid { grid-template-columns: 1fr; }
}
