:root {
    --blue: #2962ff;
    --blue-dark: #1749c9;
    --text: #172033;
    --muted: #65708a;
    --line: #e7eaf0;
    --bg: #ffffff;
    --soft: #f7f9fc;
    --danger: #c62828;
    --success: #0d7a42;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--blue);
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: var(--blue);
    border-bottom: 1px solid var(--blue);
    display: flex;
    gap: 18px;
    min-height: 64px;
    padding: 0 28px 0 12px;
}

.brand {
    align-items: center;
    background: #fff;
    display: flex;
    flex: 0 0 226px;
    height: 64px;
    justify-content: center;
    overflow: hidden;
    width: 226px;
}

.brand img {
    display: block;
    height: 43px;
    width: 226px;
}

.nav {
    display: flex;
    flex: 1;
    gap: 8px;
}

.nav a {
    border-radius: 6px;
    color: #eaf0ff;
    padding: 8px 12px;
}

.nav a.active,
.nav a:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.nav .nav-admin {
    border: 1px solid #ffb3b3;
    color:red;
    margin-left: auto;
    background-color: whitesmoke;
}

.nav .nav-admin.active,
.nav .nav-admin:hover {
    background: white;
    border-color: red;
    color:#c62828;
}

.userbar {
    align-items: center;
    color: #fff;
    display: flex;
    gap: 12px;
    margin-left: 0;
}

.page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 34px 28px 56px;
}

.login-page {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: calc(100vh - 64px);
    padding: 28px;
}

.auth-body .login-page {
    min-height: 100vh;
}

.login-panel,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.login-panel {
    max-width: 420px;
    padding: 30px;
    width: 100%;
}

.login-logo {
    display: block;
    height: auto;
    margin: 0 auto 24px;
    max-width: 226px;
    width: 100%;
}

.panel {
    margin-top: 22px;
    padding: 22px;
}

.page-heading h1,
.login-panel h1,
.panel h2 {
    letter-spacing: 0;
    line-height: 1.2;
    margin: 0;
}

.page-heading h1,
.login-panel h1 {
    font-size: 28px;
}

.panel h2 {
    font-size: 18px;
    margin-bottom: 18px;
}

.page-heading p {
    color: var(--muted);
    margin: 8px 0 0;
}

.subnav {
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 8px;
    margin-top: 22px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.subnav a {
    border-radius: 6px;
    color: var(--muted);
    padding: 8px 12px;
    white-space: nowrap;
}

.subnav a.active,
.subnav a:hover {
    background: #eef3ff;
    color: var(--blue);
}

.grid {
    display: grid;
    gap: 22px;
}

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

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

.form {
    display: grid;
    gap: 15px;
}

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

.import-form {
    grid-template-columns: minmax(260px, 1fr) auto;
}

.flow-filter {
    align-items: end;
    grid-template-columns: minmax(200px, 1fr) minmax(140px, 180px) minmax(220px, 1fr) auto auto;
}

.domain-filter {
    align-items: end;
    grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) auto minmax(300px, 1fr);
}

.compare-filter {
    align-items: end;
    grid-template-columns: repeat(4, minmax(140px, 1fr)) auto minmax(260px, 1fr);
}

.backtrack-filter {
    align-items: end;
    display: grid;
    gap: 15px;
    grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.35fr) minmax(150px, 190px) minmax(150px, 190px) auto;
}

.form-actions {
    align-self: end;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    gap: 6px;
}

input,
select {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 9px 11px;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--blue);
    outline: 3px solid #e7efff;
}

.button,
button {
    background: var(--blue);
    border: 1px solid var(--blue);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 40px;
    padding: 8px 14px;
}

.button:hover,
button:hover {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
}

.button-light {
    background: #fff;
    color: var(--blue);
}

.button-light:hover {
    background: #eef3ff;
    border-color: var(--blue);
}

.button-light.active {
    background: #eef3ff;
    border-color: var(--blue);
}

.button-danger {
    background: #fff;
    border-color: #f0b7b7;
    color: var(--danger);
}

.button-danger:hover {
    background: #fff1f1;
    border-color: var(--danger);
    color: var(--danger);
}

.topbar .button-light {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.38);
    color: #fff;
}

.topbar .button-light:hover {
    background: #fff;
    border-color: #fff;
    color: var(--blue);
}

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

.panel-heading h2 {
    margin-bottom: 0;
}

.stats-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 22px;
}

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

.stat {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.meta-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.mini-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.mini-panel h3 {
    background: var(--soft);
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    margin: 0;
    padding: 12px 14px;
}

.meta-grid span,
.stat span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
}

.meta-grid strong {
    color: var(--text);
    display: block;
    font-size: 16px;
}

.stat strong {
    color: var(--blue);
    display: block;
    font-size: 28px;
    line-height: 1.1;
}

.stat strong.long-value {
    color: var(--text);
    font-size: 16px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.flow-metric {
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 180px;
    padding: 10px 14px;
}

.flow-metric span,
.muted {
    color: var(--muted);
}

.flow-metric span {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
}

.flow-metric strong {
    color: var(--blue);
    display: block;
    font-size: 22px;
    line-height: 1.2;
}

.chart {
    height: 560px;
    min-height: 420px;
    overflow: hidden;
    width: 100%;
}

.link-button {
    background: transparent;
    border: 0;
    color: var(--blue);
    min-height: 0;
    padding: 0;
}

.link-button:hover {
    background: transparent;
    color: var(--blue-dark);
}

.link-button.danger {
    color: var(--danger);
}

.inline-form {
    display: inline;
}

.row-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-filters {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.domain-tag {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-weight: 700;
    padding: 7px 12px;
}

.domain-tag.active {
    background: #eefaf3;
    border-color: #88d3aa;
    color: var(--success);
}

.domain-tag.inactive {
    background: #fff;
    color: var(--muted);
    text-decoration: line-through;
}

.notice {
    border-radius: 6px;
    margin: 0 0 18px;
    padding: 12px 14px;
}

.notice-error {
    background: #fff1f1;
    color: var(--danger);
}

.notice-success {
    background: #eefaf3;
    color: var(--success);
}

.notice-info {
    background: #eef3ff;
    border: 1px solid #c9d8ff;
    color: var(--text);
}

.table-wrap {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.number {
    text-align: right;
}

.delta-positive {
    color: var(--success);
    font-weight: 700;
}

.delta-negative {
    color: var(--danger);
    font-weight: 700;
}

.delta-neutral {
    color: var(--muted);
}

.empty {
    color: var(--muted);
    text-align: center;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .userbar {
        margin-left: 0;
        width: 100%;
    }

    .nav {
        width: 100%;
    }

    .page {
        padding: 24px 16px 44px;
    }

    .grid.two,
    .grid.three {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .backtrack-filter,
    .compare-filter,
    .domain-filter,
    .import-form,
    .flow-filter,
    .meta-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
