:root {
    color-scheme: light dark;
    font-family: system-ui, -apple-system, sans-serif;
    background: #f4f5f7;
    color: #15171a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(12px, 3vw, 24px);
}

main {
    width: min(100%, 960px);
    padding: clamp(20px, 4vw, 36px);
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(20, 24, 32, 0.1);
}

.eyebrow {
    margin: 0 0 8px;
    color: #59616d;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

h1 {
    margin: 0;
    font-size: clamp(38px, 10vw, 64px);
    letter-spacing: -0.05em;
}

.lead {
    margin: 12px 0 28px;
    color: #59616d;
    font-size: 18px;
    line-height: 1.6;
}

.status {
    min-height: 58px;
    display: flex;
    align-items: center;
    padding: 16px;
    border-radius: 14px;
    background: #eceff3;
    font-size: 17px;
    font-weight: 700;
}

.status.ok {
    background: #e2f5e9;
    color: #14532d;
}

.status.error {
    background: #fde8e8;
    color: #7f1d1d;
}

.actions {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

button {
    min-height: 52px;
    padding: 0 20px;
    border: 0;
    border-radius: 14px;
    background: #15171a;
    color: #ffffff;
    font: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid #6b8afd;
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

.tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 24px;
    padding: 6px;
    overflow-x: auto;
    border-radius: 16px;
    background: #eceff3;
    scrollbar-width: thin;
}

.tabs button {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 0 18px;
    white-space: nowrap;
    background: transparent;
    color: #59616d;
}

.tabs button[aria-selected="true"] {
    background: #ffffff;
    color: #15171a;
    box-shadow: 0 4px 14px rgba(20, 24, 32, 0.08);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-heading h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.badge {
    flex: none;
    padding: 8px 12px;
    border-radius: 999px;
    background: #eceff3;
    color: #59616d;
    font-size: 14px;
    font-weight: 700;
}

.badge.ok {
    background: #e2f5e9;
    color: #14532d;
}

.badge.error {
    background: #fde8e8;
    color: #7f1d1d;
}

.badge.neutral {
    background: #e8edf7;
    color: #334155;
}

.meta {
    display: grid;
    gap: 12px;
    margin: 18px 0;
}

.meta div {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #f6f7f9;
}

.meta dt {
    color: #59616d;
    font-weight: 700;
}

.meta dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.actions.compact {
    display: flex;
    flex-wrap: wrap;
    margin-top: 0;
}

.actions.compact button {
    flex: 1 1 140px;
}

button.secondary {
    background: #e8ebef;
    color: #15171a;
}

button.danger {
    background: #8f2525;
    color: #ffffff;
}

.heading-button {
    min-height: 44px;
    padding: 0 16px;
    font-size: 15px;
}

.feature-panel {
    margin-top: 30px;
    padding-top: 26px;
    border-top: 1px solid #e2e5ea;
}

.feature-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.feature-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border: 1px solid #e2e5ea;
    border-radius: 14px;
    cursor: pointer;
}

.feature-toggle > span {
    display: grid;
    gap: 4px;
}

.feature-toggle strong {
    font-size: 16px;
}

.feature-toggle small {
    color: #59616d;
    font-weight: 400;
    line-height: 1.4;
}

.feature-toggle input {
    position: relative;
    flex: none;
    width: 50px;
    height: 30px;
    margin: 0;
    appearance: none;
    border-radius: 999px;
    background: #c8ced8;
    cursor: pointer;
    transition: background 160ms ease;
}

.feature-toggle input::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 160ms ease;
}

.feature-toggle input:checked {
    background: #15171a;
}

.feature-toggle input:checked::after {
    transform: translateX(20px);
}

.feature-toggle input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.rule-counts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.rule-counts div {
    padding: 16px;
    border-radius: 14px;
    background: #f6f7f9;
}

.rule-counts dt {
    color: #59616d;
    font-weight: 700;
}

.rule-counts dd {
    margin: 6px 0 0;
    font-size: 26px;
    font-weight: 800;
}

.import-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-top: 20px;
}

.field {
    display: grid;
    gap: 8px;
    color: #59616d;
    font-weight: 700;
}

.field input {
    width: 100%;
    min-height: 52px;
    padding: 0 14px;
    border: 1px solid #d5dae2;
    border-radius: 14px;
    background: #ffffff;
    color: #15171a;
    font: inherit;
    font-weight: 400;
}

.field input:disabled {
    opacity: 0.6;
}

.search-field {
    margin-top: 20px;
}

.rule-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rule-list li {
    display: grid;
    gap: 5px;
    padding: 15px 16px;
    border: 1px solid #e2e5ea;
    border-radius: 14px;
}

.rule-list strong {
    font-size: 16px;
}

.rule-list span {
    color: #59616d;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.rule-raw {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.empty {
    margin: 16px 0 0;
    padding: 18px;
    border: 1px dashed #c8ced8;
    border-radius: 14px;
    color: #59616d;
    text-align: center;
    line-height: 1.5;
}

.rule-list .empty {
    margin: 0;
}

.logs-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 18px 0;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    font-weight: 700;
    cursor: pointer;
}

.checkbox-label input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: #15171a;
}

.table-wrap {
    margin-top: 16px;
    overflow-x: auto;
    border: 1px solid #e2e5ea;
    border-radius: 14px;
}

table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    font-size: 14px;
}

caption {
    padding: 14px 16px;
    background: #f6f7f9;
    color: #59616d;
    font-weight: 700;
    text-align: left;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e5ea;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

th {
    background: #f6f7f9;
    color: #59616d;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 20px 0 0;
}

.metrics-grid div {
    min-width: 0;
    padding: 18px;
    border-radius: 16px;
    background: #f6f7f9;
}

.metrics-grid dt {
    color: #59616d;
    font-weight: 700;
}

.metrics-grid dd {
    margin: 8px 0 0;
    font-size: clamp(22px, 4vw, 30px);
    font-weight: 800;
    letter-spacing: -0.03em;
    overflow-wrap: anywhere;
}

.note {
    margin: 16px 0 0;
    color: #59616d;
    font-size: 14px;
    line-height: 1.6;
}

@media (max-width: 600px) {
    .section-heading {
        align-items: flex-start;
    }

    .import-controls {
        grid-template-columns: 1fr;
    }

    .import-controls button {
        width: 100%;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .meta div {
        grid-template-columns: 88px minmax(0, 1fr);
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        background: #111317;
        color: #f5f7fa;
    }

    main {
        background: #1b1e24;
    }

    .eyebrow,
    .lead,
    .meta dt,
    .rule-list span,
    .feature-toggle small,
    .rule-counts dt,
    .field,
    .metrics-grid dt,
    caption,
    th,
    .empty,
    .note {
        color: #b6bdc8;
    }

    .status {
        background: #2a2f38;
    }

    .status.ok {
        background: #173c28;
        color: #b9f4ce;
    }

    .status.error {
        background: #482222;
        color: #ffd0d0;
    }

    .tabs,
    .meta,
    .badge {
        background: #2a2f38;
        color: #b6bdc8;
    }

    .tabs button[aria-selected="true"] {
        background: #f5f7fa;
        color: #15171a;
    }

    .badge.ok {
        background: #173c28;
        color: #b9f4ce;
    }

    .badge.error {
        background: #482222;
        color: #ffd0d0;
    }

    .badge.neutral {
        background: #273449;
        color: #cbd5e1;
    }

    .feature-panel {
        border-top-color: #343a44;
    }

    .feature-toggle,
    .rule-list li,
    .table-wrap,
    th,
    td,
    .empty {
        border-color: #343a44;
    }

    .field input {
        border-color: #343a44;
        background: #252a32;
        color: #f5f7fa;
    }

    .feature-toggle input {
        background: #4b5563;
    }

    .feature-toggle input:checked {
        background: #f5f7fa;
    }

    .feature-toggle input:checked::after {
        background: #15171a;
    }

    .rule-counts div,
    .metrics-grid div,
    caption,
    th {
        background: #252a32;
    }

    .checkbox-label input {
        accent-color: #f5f7fa;
    }

    button.secondary {
        background: #343a44;
        color: #f5f7fa;
    }

    button.danger {
        background: #6f2424;
        color: #ffffff;
    }

    button {
        background: #f5f7fa;
        color: #15171a;
    }
}
