:root {
    --bg: #0b0f14;
    --surface: #121820;
    --surface-2: #18212b;
    --border: #24303d;
    --text: #e6edf3;
    --muted: #8b98a5;
    --accent: #4f8cff;
    --accent-strong: #2f6fe4;
    --danger: #e55353;
    --ok: #3fb950;
    --warn: #d29922;
    --radius: 0.75rem;
    --shadow: 0 1.25rem 3rem rgba(0, 0, 0, 0.45);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
}

body {
    font-size: 0.95rem;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

code {
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.85em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    padding: 0.1rem 0.35rem;
    word-break: break-all;
}

h1 {
    font-size: 1.55rem;
    margin: 0;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.05rem;
    margin: 0 0 1rem;
}

.muted {
    color: var(--muted);
    margin: 0.25rem 0 0;
}

/* Layout */

.container {
    width: min(72rem, calc(100% - 2rem));
    margin: 2rem auto 4rem;
}

.container.narrow {
    width: min(42rem, calc(100% - 2rem));
}

.breadcrumb {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin: 0;
}

/* Topbar */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.85rem 1.5rem;
    background: rgba(18, 24, 32, 0.92);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
}

.brand {
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.brand:hover {
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 0.35rem;
    flex: 1;
}

.nav-link {
    color: var(--muted);
    padding: 0.4rem 0.7rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

.nav-link.is-active {
    color: var(--text);
    background: var(--surface-2);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-name {
    color: var(--muted);
    font-size: 0.85rem;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
    color: var(--text);
    background: var(--surface-2);
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
    filter: brightness(1.1);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #04101f;
    font-weight: 600;
}

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

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--muted);
}

.btn-danger {
    background: transparent;
    border-color: rgba(229, 83, 83, 0.45);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(229, 83, 83, 0.12);
}

.btn-sm {
    padding: 0.3rem 0.55rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* Forms */

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
    border: 0;
    padding: 0;
    margin: 0;
}

.field legend {
    margin-bottom: 0.35rem;
}

input,
select,
textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font: inherit;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

input:disabled {
    opacity: 0.6;
}

.check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text);
    font-size: 0.9rem;
}

.check input {
    width: auto;
    accent-color: var(--accent);
}

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin: 0;
    min-height: 1.1rem;
}

/* Tables */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.015);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem 0.5rem;
}

.row-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.value-cell {
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

/* Badges */

.badge {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
}

.badge-ok {
    color: var(--ok);
    border-color: rgba(63, 185, 80, 0.35);
    background: rgba(63, 185, 80, 0.08);
}

.badge-off {
    color: var(--danger);
    border-color: rgba(229, 83, 83, 0.35);
    background: rgba(229, 83, 83, 0.08);
}

/* Details */

.details {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: 0.6rem 1rem;
    margin: 0;
    font-size: 0.9rem;
}

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

.details dd {
    margin: 0;
    min-width: 0;
}

/* Modals */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 10, 0.72);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-overlay.is-open {
    display: flex;
}

.modal {
    width: min(30rem, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.4rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.25rem;
}

.secret-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.7rem;
    margin-top: 0.75rem;
}

.secret-box code {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

/* Toast */

.toast {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 1rem;
    border-radius: 0.55rem;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(0.5rem);
    transition: opacity 150ms ease, transform 150ms ease;
    pointer-events: none;
    z-index: 80;
    max-width: min(24rem, calc(100vw - 2.5rem));
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-color: rgba(63, 185, 80, 0.45);
}

.toast-error {
    border-color: rgba(229, 83, 83, 0.5);
}

/* Auth */

.auth-layout {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 2rem;
    background:
        radial-gradient(circle at 20% 20%, rgba(79, 140, 255, 0.12), transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(79, 140, 255, 0.08), transparent 40%),
        var(--bg);
}

.auth-container {
    width: min(22rem, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.auth-brand {
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
    margin-bottom: 1.25rem;
}

.auth-container h1 {
    margin-bottom: 0.25rem;
}

.auth-container .stack {
    margin-top: 1.5rem;
}

/* Responsive */

@media (max-width: 720px) {
    .topbar {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .nav {
        order: 3;
        width: 100%;
    }

    .topbar-right {
        margin-left: auto;
    }

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

    .details {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: stretch;
    }
}
