:root {
    color-scheme: dark;

    --bg: #0b0e14;
    --surface: #131826;
    --surface-2: #1a2030;
    --surface-hover: #171d2b;
    --border: #232a3b;
    --border-strong: #2f3850;

    --text: #eef1f8;
    --text-secondary: #98a2b8;
    --text-muted: #8f97ab;

    --accent-fill: #3a7afe;
    --accent-fill-hover: #5c92ff;
    --accent-ink: #6d9bff;
    --accent-contrast: #ffffff;
    --accent-tint: rgba(58, 122, 254, 0.12);

    --positive-ink: #2fd48a;
    --positive-tint: rgba(47, 212, 138, 0.12);
    --negative-ink: #ff5c72;
    --negative-tint: rgba(255, 92, 114, 0.12);
    --info-ink: #6d8bff;
    --info-tint: rgba(109, 139, 255, 0.12);
    --neutral-ink: #98a2b8;
    --neutral-tint: rgba(152, 162, 184, 0.10);

    --font-ui: 'Sora', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-emphasis-color: var(--text);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-color: var(--text-muted);
    --bs-border-color: var(--border);
    --bs-border-color-translucent: var(--border);
    --bs-secondary-bg: var(--surface-2);
    --bs-tertiary-bg: var(--surface);
    --bs-primary: var(--accent-fill);
    --bs-primary-rgb: 58, 122, 254;
    --bs-link-color: var(--accent-ink);
    --bs-link-color-rgb: 109, 155, 255;
    --bs-link-hover-color: var(--accent-fill-hover);
    --bs-focus-ring-color: rgba(58, 122, 254, 0.35);

    --bs-card-bg: var(--surface);
    --bs-card-color: var(--text);
    --bs-card-border-color: var(--border);
    --bs-card-cap-bg: var(--surface-2);

    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: var(--surface-hover);
    --bs-table-hover-color: var(--text);

    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-color: var(--text);
    --bs-dropdown-link-color: var(--text);
    --bs-dropdown-link-hover-bg: var(--surface-2);
    --bs-dropdown-link-hover-color: var(--text);
    --bs-dropdown-link-active-bg: var(--accent-fill);
    --bs-dropdown-link-active-color: var(--accent-contrast);
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-divider-bg: var(--border);
}

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

    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #f0f1f6;
    --surface-hover: #f7f8fc;
    --border: #e3e6ee;
    --border-strong: #cfd3e0;

    --text: #14171f;
    --text-secondary: #565c6f;
    --text-muted: #8a90a3;

    --accent-fill: #3a7afe;
    --accent-fill-hover: #2a63d8;
    --accent-ink: #1d4fbf;
    --accent-contrast: #ffffff;
    --accent-tint: rgba(29, 79, 191, 0.08);

    --positive-ink: #157a52;
    --positive-tint: rgba(21, 122, 82, 0.10);
    --negative-ink: #b3273e;
    --negative-tint: rgba(179, 39, 62, 0.10);
    --info-ink: #3554d1;
    --info-tint: rgba(53, 84, 209, 0.08);
    --neutral-ink: #565c6f;
    --neutral-tint: rgba(86, 92, 111, 0.08);

    --bs-table-striped-bg: rgba(0, 0, 0, 0.02);
}

html, body { background: var(--bg); }
body { font-family: var(--font-ui); color: var(--text); transition: background-color .15s ease, color .15s ease; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
a { color: var(--accent-ink); }
a:hover { color: var(--accent-fill-hover); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-muted, small.text-muted, .text-secondary { color: var(--text-muted) !important; }
.text-success { color: var(--positive-ink) !important; }
.text-danger { color: var(--negative-ink) !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }

.site-navbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-navbar__inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.site-navbar__left { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.site-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.site-brand__text { display: flex; flex-direction: column; line-height: 1; }
.site-brand__name { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.site-brand__tag { font-weight: 600; font-size: 9px; letter-spacing: .16em; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; }
.navlink { text-decoration: none; padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-secondary); transition: color .15s, background-color .15s; }
.navlink:hover { color: var(--accent-ink); }
.navlink.active { color: var(--accent-ink); background: var(--accent-tint); }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn .icon-moon { display: none; }
:root[data-theme="light"] .icon-btn .icon-sun { display: none; }
:root[data-theme="light"] .icon-btn .icon-moon { display: inline-flex; }
.site-user { display: flex; align-items: center; gap: 9px; padding-left: 12px; margin-left: 4px; border-left: 1px solid var(--border); text-decoration: none; color: var(--text); }
.lang-switch { display: flex; gap: 2px; }
.lang-switch a { padding: 6px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-decoration: none; }
.lang-switch a.active { color: var(--accent-ink); background: var(--accent-tint); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: none; }
.card-title { color: var(--text); font-weight: 700; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }

.btn { font-family: var(--font-ui); font-weight: 600; border-radius: 8px; }
.btn-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-contrast); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); color: var(--accent-contrast); }
.btn-secondary, .btn-outline-secondary { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-secondary:hover, .btn-outline-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-outline-primary { color: var(--accent-ink); border-color: var(--border); background: transparent; }
.btn-outline-primary:hover, .btn-outline-primary.active { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-contrast); }
.btn-danger { background: var(--negative-ink); border-color: var(--negative-ink); }
.btn-success { background: var(--positive-ink); border-color: var(--positive-ink); }
.btn-sm { font-size: 12.5px; }

.alert { border-radius: 10px; border: 1px solid transparent; font-size: 13.5px; }
.alert-success { background: var(--positive-tint); border-color: var(--positive-ink); color: var(--positive-ink); }
.alert-danger { background: var(--negative-tint); border-color: var(--negative-ink); color: var(--negative-ink); }
.alert-warning { background: var(--accent-tint); border-color: var(--accent-ink); color: var(--accent-ink); }
.alert-info { background: var(--info-tint); border-color: var(--info-ink); color: var(--info-ink); }
.alert a { color: inherit; text-decoration: underline; }
.btn-close { filter: invert(1) grayscale(100%) brightness(1.8); }
:root[data-theme="light"] .btn-close { filter: none; }

.form-control, .form-select { background-color: var(--surface); border: 1px solid var(--border); color: var(--text); font-family: var(--font-ui); font-size: 13.5px; }
.form-control:focus, .form-select:focus { background-color: var(--surface); border-color: var(--accent-ink); color: var(--text); box-shadow: 0 0 0 .2rem var(--accent-tint); }
.form-control::placeholder { color: var(--text-muted); }
.form-label { color: var(--text-secondary); font-size: 13px; font-weight: 600; }
textarea.form-control { font-family: var(--font-mono); font-size: 12.5px; }

.table { --bs-table-bg: transparent; color: var(--text); vertical-align: middle; }
.table > thead { border-bottom: 1px solid var(--border); }
.table thead th { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); border-bottom-color: var(--border) !important; white-space: nowrap; }
.table td, .table th { border-color: var(--border); }
.table-hover > tbody > tr:hover > * { background-color: var(--surface-hover); }

.data-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.data-panel .table { margin-bottom: 0; }
.data-panel .table thead th { padding: 14px 16px 10px; border-top: none; }
.data-panel .table thead tr th:first-child { padding-left: 20px; }
.data-panel .table thead tr th:last-child { padding-right: 20px; }
.data-panel .table tbody td { padding: 14px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.data-panel .table tbody tr:last-child td { border-bottom: none; }
.data-panel .table tbody td:first-child { padding-left: 20px; }
.data-panel .table tbody td:last-child { padding-right: 20px; }
.text-end-num { text-align: right; }

.badge-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 6px; letter-spacing: .02em; font-family: var(--font-ui); line-height: 1.4; }
.badge-positive { color: var(--positive-ink); background: var(--positive-tint); }
.badge-negative { color: var(--negative-ink); background: var(--negative-tint); }
.badge-accent { color: var(--accent-ink); background: var(--accent-tint); }
.badge-info { color: var(--info-ink); background: var(--info-tint); }
.badge-neutral { color: var(--neutral-ink); background: var(--neutral-tint); }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg-btn { padding: 7px 18px; border-radius: 6px; font-size: 13px; font-weight: 700; color: var(--text-secondary); background: transparent; border: none; cursor: pointer; font-family: var(--font-ui); }
.seg-btn.active { background: var(--accent-fill); color: var(--accent-contrast); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.stat-tile__label { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-muted); }
.stat-tile__value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.stat-tile__value.is-positive { color: var(--positive-ink); }
.stat-tile__value.is-negative { color: var(--negative-ink); }
.stat-tile__sub { font-size: 12px; color: var(--text-muted); }

h3.card-title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }

.hp-field { position: absolute; width: 1px; height: 1px; left: -9999px; overflow: hidden; }

.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 48px; padding: 28px 24px; }
.site-footer__inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.site-footer__links { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer__links a { color: var(--text-muted); text-decoration: none; }
.site-footer__links a:hover { color: var(--accent-ink); }

.hero { padding: 72px 24px 56px; text-align: center; }
.hero h1 { font-size: 40px; font-weight: 800; letter-spacing: -.02em; max-width: 720px; margin: 0 auto 18px; }
.hero p.lead { font-size: 16px; color: var(--text-secondary); max-width: 620px; margin: 0 auto 28px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 1000px; margin: 0 auto; }
@media (max-width: 800px) { .feature-grid { grid-template-columns: 1fr; } }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; text-align: left; }
.feature-card__icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-tint); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.feature-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 13.5px; color: var(--text-secondary); margin: 0; }

.rule-issue { border: 1px solid var(--negative-ink); background: var(--negative-tint); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.rule-issue__code { font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--negative-ink); }
.rule-issue__msg { font-size: 13.5px; color: var(--text); margin-top: 4px; }
