:root {
    --admin-bg: #f3f7f6;
    --admin-surface: #ffffff;
    --admin-border: #d8e3e1;
    --admin-text: #173132;
    --admin-muted: #5d7577;
    --admin-primary: #1a7f72;
    --admin-danger: #c84545;
    --admin-warning: #b7791f;
    --admin-success: #287a52;
    --admin-shadow: 0 18px 44px rgba(15, 49, 45, 0.08);
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
}

body {
    min-height: 100vh;
}

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

a:hover {
    text-decoration: underline;
}

.admin-app {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: #102426;
    color: #f4fbfa;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 12px 18px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.admin-brand__mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2aa88f, #165d52);
    font-weight: 800;
}

.admin-brand__title {
    font-weight: 800;
}

.admin-brand__subtitle {
    color: rgba(244, 251, 250, 0.7);
    font-size: 0.92rem;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    padding-bottom: 12px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.admin-nav::-webkit-scrollbar {
    width: 8px;
}

.admin-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
}

.admin-nav__item {
    padding: 10px 14px;
    border-radius: 10px;
    color: rgba(244, 251, 250, 0.86);
    font-weight: 600;
    border: 1px solid transparent;
    flex-shrink: 0;
}

.admin-nav__item.active,
.admin-nav__item:hover {
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.admin-main {
    min-width: 0;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px 28px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--admin-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-topbar__leading {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.admin-menu-btn {
    display: none;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--admin-border);
    background: #fff;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

.admin-menu-btn__bars,
.admin-menu-btn__bars::before,
.admin-menu-btn__bars::after {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--admin-text);
    border-radius: 2px;
    position: relative;
}

.admin-menu-btn__bars::before,
.admin-menu-btn__bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.admin-menu-btn__bars::before { top: -6px; }
.admin-menu-btn__bars::after { top: 6px; }

.admin-sidebar__close {
    display: none;
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.admin-nav-backdrop {
    display: none;
}

.login-password-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.login-password-row .form-control {
    flex: 1 1 auto;
}

.login-password-toggle {
    flex: 0 0 auto;
    white-space: nowrap;
}

.admin-topbar__eyebrow,
.admin-page__eyebrow {
    color: var(--admin-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.admin-topbar__title {
    font-size: 1.1rem;
    font-weight: 700;
}

.admin-topbar__user {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-topbar__user-copy {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.admin-topbar__user-copy span {
    color: var(--admin-muted);
    font-size: 0.92rem;
}

.admin-role-stack,
.admin-chip-wrap,
.admin-action-stack {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-content {
    padding: 28px;
}

.admin-page {
    display: grid;
    gap: 20px;
}

.admin-page__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    flex-wrap: wrap;
}

.admin-page__header h1,
.admin-empty h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
}

.admin-page__header p,
.admin-empty p {
    margin: 8px 0 0;
    color: var(--admin-muted);
    max-width: 760px;
}

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

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

.admin-kpi {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-kpi span {
    color: var(--admin-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.admin-kpi strong {
    font-size: 1.9rem;
    line-height: 1.05;
}

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

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

.admin-grid-2--wide-left {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
}

.admin-card {
    padding: 20px;
}

.admin-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-card__header h2,
.admin-empty--inline h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
}

.admin-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 220px;
    gap: 12px;
    margin-bottom: 16px;
}

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

.admin-table {
    margin: 0;
}

.admin-table thead th {
    color: var(--admin-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.admin-table tbody td {
    vertical-align: middle;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.admin-badge--neutral {
    background: #edf4f3;
    color: #335355;
}

.admin-badge--success {
    background: #e8f7ef;
    color: var(--admin-success);
}

.admin-badge--warning {
    background: #fff5e6;
    color: var(--admin-warning);
}

.admin-badge--danger {
    background: #fff0f0;
    color: var(--admin-danger);
}

.admin-list {
    display: grid;
    gap: 10px;
}

.admin-list__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #eef3f2;
}

.admin-list__row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.admin-list__row:first-child {
    padding-top: 0;
}

.admin-list__row strong,
.admin-list__row span,
.admin-list__row small {
    display: block;
}

.admin-list__row span,
.admin-list__row small {
    color: var(--admin-muted);
}

.admin-pagination {
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-empty {
    min-height: 50vh;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 32px;
}

.admin-empty--inline {
    min-height: 360px;
}

.admin-textarea {
    min-height: 110px;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(26, 127, 114, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(16, 36, 38, 0.16), transparent 32%),
        var(--admin-bg);
}

.login-panel {
    width: min(100%, 460px);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--admin-border);
    border-radius: 22px;
    padding: 32px;
    box-shadow: var(--admin-shadow);
}

.login-brand {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--admin-primary);
    font-weight: 800;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.login-panel h1 {
    margin: 0 0 10px;
    font-size: 2rem;
    font-weight: 800;
}

.login-panel p {
    color: var(--admin-muted);
    margin-bottom: 24px;
}

#blazor-error-ui {
    background: #fff4d8;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

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

    .admin-grid-2,
    .admin-grid-2--wide-left {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .admin-app {
        grid-template-columns: 1fr;
    }

    .admin-menu-btn {
        display: inline-flex;
    }

    .admin-sidebar__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .admin-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 40;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(300px, 88vw);
        height: 100vh;
        max-height: 100vh;
        z-index: 50;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: none;
        overflow: hidden;
        pointer-events: none;
        visibility: hidden;
    }

    .admin-sidebar--open {
        transform: translateX(0);
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 24px 0 48px rgba(0, 0, 0, 0.28);
        pointer-events: auto;
        visibility: visible;
    }

    .admin-nav {
        overflow-y: auto;
        flex: 1 1 auto;
        min-height: 0;
    }

    .admin-topbar {
        padding: 16px 20px;
    }

    .admin-content {
        padding: 20px;
    }

    .admin-toolbar,
    .admin-toolbar--wide {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .admin-kpi-grid {
        grid-template-columns: 1fr;
    }

    .admin-page__header h1,
    .admin-empty h1,
    .login-panel h1 {
        font-size: 1.55rem;
    }
}

/* Exploitation / Operations */
.admin-nav__section {
    margin: 1rem 0.75rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--admin-muted);
}

.ops-env-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    background: #fff;
    margin-bottom: 1rem;
}

.ops-env-bar--development { border-left: 4px solid #64748b; }
.ops-env-bar--preproduction { border-left: 4px solid #ea580c; background: #fff7ed; }
.ops-env-bar--production { border-left: 4px solid #dc2626; background: #fef2f2; }

.ops-env-chip {
    border: 1px solid var(--admin-border);
    background: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.ops-env-chip.active {
    background: var(--admin-primary);
    color: #fff;
    border-color: var(--admin-primary);
}

.ops-prod-banner { font-weight: 600; }

.ops-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.ops-card {
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    padding: 1rem;
}

.ops-card--healthy { border-top: 3px solid var(--admin-success); }
.ops-card--degraded { border-top: 3px solid var(--admin-warning); }
.ops-card--unhealthy { border-top: 3px solid var(--admin-danger); }
.ops-card--unknown { border-top: 3px solid #94a3b8; }

.ops-card__title { font-weight: 700; }
.ops-card__status { font-size: 0.9rem; margin: 0.35rem 0; }
.ops-card__meta { color: var(--admin-muted); font-size: 0.8rem; }

.ops-timeline { padding-left: 1.2rem; }
.ops-wiki-md {
    background: #fff;
    color: var(--admin-text, #1f2937);
    padding: 1rem 1.25rem;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    max-height: 70vh;
    overflow: auto;
    line-height: 1.6;
}
.ops-wiki-md h1, .ops-wiki-md h2, .ops-wiki-md h3,
.ops-wiki-md h4, .ops-wiki-md h5, .ops-wiki-md h6 { margin-top: 1.25rem; }
.ops-wiki-md .ops-wiki-code {
    white-space: pre-wrap;
    background: #0f172a;
    color: #e2e8f0;
    padding: 0.75rem;
    border-radius: 6px;
    overflow: auto;
}
.ops-wiki-toc { background: #f8fafc; }
.ops-wiki-toc ul { list-style: none; padding-left: 0.5rem; }
.ops-dryrun-banner { font-weight: 600; }

.ops-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
