* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f6fa;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e5e7eb;
    --text: #172033;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #15803d;
    --shadow: 0 8px 28px rgba(15, 23, 42, .06);
    --radius: 14px;
}

html {
    color-scheme: light;
}

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

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #111827;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.topbar-inner {
    max-width: 1240px;
    min-height: 64px;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand {
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: -.2px;
}

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

.topnav a {
    color: #dbeafe;
    text-decoration: none;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 14px;
}

.topnav a:hover {
    background: rgba(255,255,255,.09);
    color: #fff;
}

.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 22px 48px;
}

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

.page-title h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 30px);
    letter-spacing: -.6px;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 22px;
}

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

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

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

.stat {
    padding: 19px;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
}

.stat-note {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    text-decoration: none;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    transition: .15s ease;
}

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

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

.btn-secondary {
    background: #eef2f7;
    color: #1f2937;
    border-color: #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-warning {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fed7aa;
}

.btn-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.btn-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.btn-sm {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

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

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

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

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

th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

td {
    font-size: 14px;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
}

.badge.active {
    background: #dcfce7;
    color: #166534;
}

.badge.suspended {
    background: #fef3c7;
    color: #92400e;
}

.badge.disabled {
    background: #fee2e2;
    color: #991b1b;
}

.empty {
    padding: 54px 24px;
    text-align: center;
    color: var(--muted);
}

.empty strong {
    display: block;
    color: var(--text);
    font-size: 17px;
    margin-bottom: 6px;
}

.notice {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

.notice-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.notice-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.form-card {
    max-width: 760px;
}

.form-group {
    margin-bottom: 17px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
    font-size: 14px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
    font-size: 14px;
}

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

textarea {
    min-height: 110px;
    resize: vertical;
}

.help {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.form-actions {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    padding-top: 5px;
}

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

code {
    background: #f1f5f9;
    border-radius: 5px;
    padding: 3px 6px;
    font-size: 12px;
}

@media (max-width: 900px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .topbar-inner {
        min-height: auto;
        padding: 12px 15px;
        align-items: flex-start;
        flex-direction: column;
    }

    .topnav {
        width: 100%;
    }

    .page {
        padding: 20px 15px 35px;
    }

    .page-header {
        flex-direction: column;
    }

    .grid-4,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .card-body {
        padding: 17px;
    }
}

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

.badge.primary {
    margin-left: 6px;
    background: #dbeafe;
    color: #1e40af;
}

.badge.nat {
    background: #ede9fe;
    color: #6d28d9;
}

.badge.routed {
    background: #e0f2fe;
    color: #075985;
}

.notice-info {
    background: #eff6ff;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
}

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

.radio-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.choice-card,
.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    cursor: pointer;
    margin: 0;
}

.choice-card:has(input:checked),
.checkbox-row:has(input:checked) {
    border-color: #93c5fd;
    background: #eff6ff;
}

.choice-card input,
.checkbox-row input {
    width: auto;
    margin-top: 3px;
}

.choice-card span,
.checkbox-row span {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.choice-card small,
.checkbox-row small {
    color: var(--muted);
    font-weight: 400;
    line-height: 1.4;
}

.nat-box {
    margin-bottom: 17px;
    padding: 16px;
    border: 1px dashed #93c5fd;
    border-radius: 11px;
    background: #f8fbff;
}

.inline-form {
    margin: 0;
}

@media (max-width: 760px) {
    .form-grid-2,
    .radio-grid {
        grid-template-columns: 1fr;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}


.notice-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.notice-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 16px;
}

.checkbox input {
    width: auto;
}

.code-area {
    min-height: 300px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
}

.key-cell {
    white-space: nowrap;
}
