:root {
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-strong: #f7fafc;
    --text: #172033;
    --muted: #697489;
    --line: #dfe6ef;
    --primary: #d71920;
    --primary-dark: #a80f16;
    --accent: #087f8c;
    --success: #138a4a;
    --warning: #a66100;
    --shadow: 0 18px 50px rgba(23, 32, 51, 0.14);
    --radius: 8px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

code,
pre {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.auth-page {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 14px;
    padding: 32px;
    background:
        linear-gradient(135deg, rgba(247, 250, 252, 0.94), rgba(238, 243, 248, 0.98)),
        var(--bg);
}

.auth-shell {
    width: min(1040px, 100%);
    min-height: 620px;
    display: grid;
    grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.96fr);
    overflow: hidden;
    border: 1px solid rgba(223, 230, 239, 0.95);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-visual {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 44px;
    overflow: hidden;
    color: #ffffff;
    background:
        linear-gradient(135deg, rgba(22, 32, 50, 0.98), rgba(17, 94, 103, 0.94)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='700' viewBox='0 0 900 700'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.18'%3E%3Cpath d='M72 164h160v96H72zM286 112h260v148H286zM604 84h188v176H604zM90 330h292v184H90zM446 330h344v184H446z'/%3E%3Cpath d='M122 212h78M330 162h172M648 136h100M134 380h198M492 384h240M134 430h128M492 434h164'/%3E%3C/g%3E%3Ccircle cx='730' cy='575' r='68' fill='%23d71920' fill-opacity='.62'/%3E%3Crect x='580' y='548' width='94' height='94' rx='16' fill='%23087f8c' fill-opacity='.7'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: center;
}

.auth-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, transparent 0%, rgba(12, 18, 32, 0.42) 100%);
}

.brand-mark,
.sidebar-brand span {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
}

.auth-copy {
    max-width: 560px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.auth-visual .eyebrow {
    color: #b7f2f8;
}

.auth-copy h1,
.topbar h1 {
    margin: 0;
    letter-spacing: 0;
}

.auth-copy h1 {
    max-width: 640px;
    font-size: clamp(2.5rem, 5vw, 4.8rem);
    line-height: 0.95;
}

.auth-copy p {
    max-width: 520px;
    margin: 22px 0 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.04rem;
    line-height: 1.65;
}

.signal-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    width: min(430px, 100%);
}

.signal-grid span {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.24);
}

.signal-grid span:nth-child(3n) {
    background: rgba(215, 25, 32, 0.9);
}

.signal-grid span:nth-child(4n) {
    background: rgba(96, 220, 230, 0.72);
}

.auth-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    background:
        linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.auth-card-header h2,
.panel h2 {
    margin: 0;
    font-size: 1.65rem;
    letter-spacing: 0;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin: 28px 0 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.tab-button {
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-weight: 750;
}

.tab-button.is-active {
    color: var(--text);
    background: #ffffff;
    box-shadow: 0 8px 18px rgba(23, 32, 51, 0.08);
}

.login-form {
    display: none;
}

.login-form.is-active {
    display: grid;
    gap: 18px;
}

.unified-login-form {
    margin-top: 28px;
}

.login-alert[hidden] {
    display: none;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    min-height: 52px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.captcha-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.captcha-image {
    flex: 0 0 auto;
    width: 168px;
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.captcha-refresh {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    cursor: pointer;
    font-weight: 800;
}

.captcha-refresh:hover {
    border-color: var(--accent);
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(8, 127, 140, 0.12);
}

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.primary-button {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 12px 22px rgba(215, 25, 32, 0.18);
}

.primary-button:hover {
    background: var(--primary-dark);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.78;
}

.login-submit {
    position: relative;
    min-height: 52px;
    margin-top: 6px;
}

.button-loader {
    width: 18px;
    height: 18px;
    display: none;
    margin-left: 10px;
    border: 2px solid rgba(255, 255, 255, 0.42);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.login-submit.is-loading .button-loader {
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.secondary-button {
    border: 1px solid var(--line);
    color: var(--text);
    background: #ffffff;
}

.form-note,
.panel-copy,
.empty-state {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.6;
}

.alert {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
    line-height: 1.5;
}

.alert-error {
    border: 1px solid rgba(215, 25, 32, 0.24);
    color: #8e1218;
    background: rgba(215, 25, 32, 0.08);
}

.alert-info {
    border: 1px solid rgba(8, 127, 140, 0.24);
    color: #075d66;
    background: rgba(8, 127, 140, 0.08);
}

.site-footer {
    margin-top: 22px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 750;
    text-align: center;
}

.auth-footer {
    margin-top: 0;
}

.modal-open {
    overflow: hidden;
}

.welcome-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(16, 24, 39, 0.56);
}

.welcome-modal-panel {
    width: min(420px, 100%);
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
    text-align: center;
}

.welcome-modal-panel h2 {
    margin: 0;
    font-size: 1.65rem;
}

.welcome-modal-panel p {
    margin: 12px 0 20px;
    color: var(--muted);
    line-height: 1.6;
}

.dashboard-page {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    background: var(--bg);
}

.sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    padding: 24px;
    border-right: 1px solid var(--line);
    background: #101827;
    color: #ffffff;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 34px;
}

.sidebar-brand span {
    width: 44px;
    height: 44px;
    font-size: 0.82rem;
}

.sidebar-brand strong {
    font-size: 1.1rem;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.72);
    font-weight: 750;
}

.sidebar-nav a.is-active,
.sidebar-nav a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.dashboard-main {
    min-width: 0;
    padding: 34px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.topbar h1 {
    font-size: 2rem;
}

.user-chip {
    min-width: 180px;
    display: grid;
    gap: 4px;
    justify-items: end;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.user-chip span {
    font-weight: 800;
}

.user-chip small {
    color: var(--muted);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.metric-card,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 26px rgba(23, 32, 51, 0.07);
}

.metric-card {
    min-height: 138px;
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 22px;
}

.metric-card span,
.metric-card small {
    color: var(--muted);
    line-height: 1.45;
}

.metric-card strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 1.35rem;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 18px;
}

.panel {
    padding: 22px;
}

.panel.is-loading {
    opacity: 0.72;
    pointer-events: none;
}

.wide-panel {
    margin-top: 18px;
}

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

.timeline {
    display: grid;
    gap: 12px;
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.7;
}

.timeline code,
.checklist code,
.panel-copy code {
    color: var(--primary-dark);
    background: rgba(215, 25, 32, 0.08);
    padding: 2px 5px;
    border-radius: 5px;
}

.checklist {
    display: grid;
    gap: 12px;
}

.checklist label {
    grid-template-columns: 18px 1fr;
    align-items: start;
    color: var(--text);
    font-weight: 650;
    line-height: 1.55;
}

.cookie-table {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.cookie-row {
    display: grid;
    grid-template-columns: minmax(130px, 0.6fr) minmax(0, 1fr);
    gap: 14px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    align-items: center;
}

.cookie-row:first-child {
    border-top: 0;
}

.cookie-head {
    color: var(--muted);
    background: var(--surface-strong);
    font-weight: 800;
}

.cookie-row code {
    min-width: 0;
    overflow-wrap: anywhere;
}

.code-block {
    max-height: 180px;
    overflow: auto;
    margin: 14px 0 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #dce7f7;
    background: #111827;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.data-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.data-table {
    width: 100%;
    min-width: 1260px;
    border-collapse: collapse;
    background: #ffffff;
}

.data-table th,
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    background: var(--surface-strong);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.data-table td strong,
.data-table td small {
    display: block;
}

.data-table td small {
    max-width: 260px;
    margin-top: 4px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.log-table {
    min-width: 980px;
}

.log-table code {
    display: block;
    max-width: 280px;
    color: #273449;
    white-space: normal;
    overflow-wrap: anywhere;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.status-pill.is-active {
    color: #0c6b3a;
    background: rgba(19, 138, 74, 0.12);
}

.status-pill.is-blocked {
    color: #8e1218;
    background: rgba(215, 25, 32, 0.12);
}

.status-pill.is-muted {
    color: #556174;
    background: rgba(105, 116, 137, 0.14);
}

.status-pill.is-pending {
    color: #76520a;
    background: rgba(166, 97, 0, 0.14);
}

.status-pill.is-read {
    color: #0c6b3a;
    background: rgba(19, 138, 74, 0.12);
}

.status-pill.is-skipped {
    color: #075d66;
    background: rgba(8, 127, 140, 0.12);
}

.status-pill.is-failed {
    color: #8e1218;
    background: rgba(215, 25, 32, 0.12);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.limit-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.limit-input {
    width: 88px;
    min-height: 34px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.table-button {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    background: #ffffff;
    cursor: pointer;
    font-weight: 800;
}

.table-button:hover {
    border-color: var(--accent);
}

.table-button.danger {
    color: #8e1218;
    border-color: rgba(215, 25, 32, 0.28);
    background: rgba(215, 25, 32, 0.06);
}

.filter-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-form input {
    min-width: 220px;
}

.logs-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    color: var(--muted);
    font-weight: 800;
}

.secondary-button.is-disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.news-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.news-status-grid > div {
    min-height: 116px;
    display: grid;
    align-content: center;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.news-status-grid span,
.news-status-grid small {
    color: var(--muted);
    line-height: 1.45;
}

.news-status-grid strong {
    font-size: 1.75rem;
}

.read-result {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.read-live-alert[hidden] {
    display: none;
}

.result-table {
    min-width: 920px;
}

.result-table td:nth-child(1),
.result-table th:nth-child(1) {
    width: 58px;
}

.compact-header {
    margin-bottom: 12px;
}

.compact-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.read-result h4 {
    margin: 18px 0 10px;
    font-size: 0.96rem;
}

.result-list {
    display: grid;
    gap: 8px;
}

.result-row {
    display: grid;
    gap: 4px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.result-row span {
    font-weight: 800;
    overflow-wrap: anywhere;
}

.result-row small {
    color: var(--muted);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

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

    .auth-shell {
        min-height: auto;
    }

    .auth-visual {
        min-height: 360px;
    }

    .sidebar {
        position: static;
        min-height: auto;
    }

    .metric-grid,
    .content-grid,
    .news-status-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .auth-page,
    .dashboard-main {
        padding: 18px;
    }

    .auth-visual,
    .auth-card {
        padding: 26px;
    }

    .auth-copy h1 {
        font-size: 2.4rem;
    }

    .topbar,
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .user-chip {
        justify-items: start;
    }

    .cookie-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
