:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #5f6b7a;
    --line: #d8dee9;
    --primary: #1f6feb;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    font-size: 14px;
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 58px;
    padding: 0 24px;
    background: #0f1b2d;
    color: #fff;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 232px;
    padding: 24px 16px;
    overflow-y: auto;
    background: #0f1b2d;
    color: #fff;
}

.brand {
    display: block;
    color: #fff;
    font-weight: 700;
    font-size: 20px;
}

.sidebar .brand {
    padding: 4px 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.nav {
    display: flex;
    gap: 14px;
    flex: 1;
    flex-wrap: wrap;
}

.sidebar .nav {
    flex: 1;
    flex-direction: column;
    gap: 6px;
    flex-wrap: nowrap;
}

.sidebar .nav a {
    border-radius: 6px;
    padding: 10px 12px;
    color: #e8edf7;
    font-weight: 600;
}

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

.nav a,
.logout {
    color: #e8edf7;
}

.logout {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: auto;
}

.sidebar .logout {
    display: grid;
    gap: 10px;
    margin-left: 0;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .logout span {
    color: #fff;
    font-weight: 700;
}

.sidebar .logout button {
    width: 100%;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 12px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
}

.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.secondary {
    background: #eef2f7;
}

.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.has-sidebar .page {
    max-width: none;
    margin-left: 232px;
    padding: 32px;
}

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

.network-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 320px));
    gap: 16px;
}

.network-card {
    display: grid;
    gap: 8px;
    min-height: 120px;
    align-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    background: #fff;
    color: var(--text);
}

.network-card strong {
    font-size: 22px;
}

.network-card span {
    color: var(--muted);
}

.network-card:hover {
    border-color: var(--primary);
}

h1 {
    margin: 0 0 6px;
    font-size: 26px;
}

h2 {
    margin-top: 0;
}

p {
    color: var(--muted);
}

.panel,
.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.auth-card {
    max-width: 420px;
    margin: 60px auto;
}

label {
    display: block;
    margin-bottom: 14px;
    font-weight: 600;
}

input,
select {
    width: 100%;
    max-width: 440px;
    margin-top: 5px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
}

.filter {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.filter input {
    max-width: 420px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    align-items: end;
}

.filter-grid label {
    margin-bottom: 0;
}

.filter-grid input,
.filter-grid select {
    max-width: none;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.table-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

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

.table th {
    background: #edf2f7;
    font-weight: 700;
}

.table.compact th,
.table.compact td {
    padding: 7px 8px;
}

.small-input {
    max-width: 82px;
}

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

.messages {
    margin-bottom: 16px;
}

.message {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    background: #eef2f7;
}

.message.success {
    background: #e6f4ea;
}

.message.error {
    background: #fde8e7;
    color: var(--danger);
}

.message.info {
    background: #e8f1ff;
}

.danger-panel {
    border-color: #f0b8b4;
}

.danger-text {
    color: var(--danger);
    font-weight: 700;
    font-size: 18px;
}

.pagination,
.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.sticky-action {
    position: sticky;
    bottom: 16px;
    margin-top: 16px;
}

.journal {
    display: grid;
    gap: 8px;
}

.journal-interval {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #edf2f7;
}

.journal-row {
    display: flex;
    gap: 6px;
    align-items: baseline;
    flex-wrap: wrap;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}

.journal-number {
    min-width: 42px;
    font-weight: 700;
}

.journal-row code {
    overflow-wrap: anywhere;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
}

.busy-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 27, 45, 0.55);
    display: grid;
    place-items: center;
    z-index: 1000;
}

.busy-overlay[hidden] {
    display: none;
}

.busy-box {
    display: grid;
    gap: 8px;
    width: min(460px, calc(100vw - 32px));
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    text-align: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

@media (max-width: 780px) {
    .page-head,
    .filter {
        flex-direction: column;
        align-items: stretch;
    }

    .sidebar {
        position: static;
        width: 100%;
        padding: 16px;
    }

    .sidebar .brand {
        padding: 0 0 14px;
    }

    .sidebar .nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .sidebar .nav a {
        white-space: nowrap;
    }

    .has-sidebar .page {
        margin-left: 0;
        padding: 16px;
    }

    .logout {
        margin-left: 0;
    }

    .table {
        display: block;
        overflow-x: auto;
    }
}
