:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #1d2433;
    --muted: #677085;
    --line: #dde3ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --warning: #b7791f;
    --danger: #c2410c;
    --shadow: 0 10px 28px rgba(20, 31, 53, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: "Manrope", "Segoe UI", sans-serif;
    font-size: 15px;
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 14px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 700;
    font-size: 20px;
}

.nav {
    display: flex;
    gap: 18px;
    color: var(--muted);
    flex: 1;
}

.nav a:hover {
    color: var(--text);
}

.logout {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.logout button,
.button,
.form-panel button,
.login-panel button {
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.logout button {
    padding: 8px 12px;
    background: #f0f3f8;
    color: var(--text);
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

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

.page-head.compact {
    margin-bottom: 14px;
}

.page-head h1 {
    margin: 0;
    font-size: 30px;
}

.page-head p,
.panel-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.toolbar,
.panel,
.table-panel,
.form-panel,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    gap: 10px;
    padding: 14px;
    margin-bottom: 18px;
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
}

.panel-head {
    margin-bottom: 18px;
}

.panel-head.inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 0;
    margin-bottom: 12px;
}

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

.cabinet-info {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.cabinet-info h2 {
    margin: 7px 0 8px;
    font-size: 20px;
}

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

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.cabinet-url {
    display: block;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.stat {
    min-height: 112px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.stat span {
    display: block;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
}

.stat strong {
    display: block;
    margin-top: 10px;
    font-size: 30px;
}

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

.stat.good strong,
.balance.ok {
    color: var(--success);
}

.stat.warn strong,
.balance.warning {
    color: var(--warning);
}

.stat.bad strong,
.balance.error {
    color: var(--danger);
}

.table-panel {
    overflow: hidden;
}

.table-panel.spaced {
    margin-bottom: 18px;
}

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

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

th {
    background: #f0f3f8;
    color: #3a4458;
    font-size: 12px;
    text-transform: uppercase;
}

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

code {
    padding: 3px 6px;
    border-radius: 6px;
    background: #eef2f7;
}

.right {
    text-align: right;
}

.muted,
.cell-note,
.empty {
    color: var(--muted);
}

.cell-title {
    font-weight: 700;
}

.cell-note {
    margin-top: 4px;
    font-size: 13px;
}

.balance {
    font-weight: 800;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge.ok {
    color: #0f5132;
    background: #dcfce7;
}

.badge.warning {
    color: #7c4a03;
    background: #fef3c7;
}

.badge.error {
    color: #7c2d12;
    background: #ffedd5;
}

.badge.admin {
    color: #3730a3;
    background: #e0e7ff;
}

.tag {
    display: inline-flex;
    padding: 4px 8px;
    margin: 2px 3px 2px 0;
    border-radius: 999px;
    color: #344054;
    background: #eef2f7;
    font-size: 12px;
    font-weight: 700;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
}

.button.primary {
    color: #ffffff;
    background: var(--primary);
}

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

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

.button.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

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

.alert {
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-info {
    background: #eff6ff;
    color: #1e3a8a;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
}

.alert-error {
    background: #fff1f2;
    color: #9f1239;
}

.narrow {
    max-width: 760px;
}

.form-panel {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.form-panel label,
.login-panel label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid #cfd7e6;
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    font: inherit;
}

input:focus {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    border-color: var(--primary);
}

.checkline {
    display: flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px !important;
}

.checkline input {
    width: auto;
    min-height: auto;
}

.field-group {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.field-group-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.field-preview {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.field-preview span {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
}

.field-preview code {
    width: fit-content;
    font-size: 20px;
}

.login-shell {
    min-height: calc(100vh - 96px);
    display: grid;
    place-items: center;
}

.login-panel {
    width: min(420px, 100%);
    display: grid;
    gap: 18px;
    padding: 28px;
}

.login-panel h1 {
    margin: 0;
    font-size: 34px;
}

.login-panel p {
    margin: 6px 0 0;
    color: var(--muted);
}

.login-panel button,
.form-panel button {
    min-height: 42px;
    color: #ffffff;
    background: var(--primary);
}

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

    .logout {
        justify-content: space-between;
    }

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

    .cabinet-info {
        flex-direction: column;
    }

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

    th,
    td {
        white-space: nowrap;
    }
}

@media (max-width: 520px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }
}
