:root {
    --bg: #0a1628;
    --bg-soft: #0f1f36;
    --sidebar: #111827;
    --card: #1f2937;
    --card-alt: #162131;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e5eef8;
    --muted: #93a4ba;
    --green: #22c55e;
    --yellow: #f59e0b;
    --red: #ef4444;
    --blue: #38bdf8;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    --font: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 30%),
        radial-gradient(circle at right bottom, rgba(34, 197, 94, 0.08), transparent 25%),
        var(--bg);
    color: var(--text);
}

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

button, input, select, textarea {
    font: inherit;
}

.shell {
    min-height: 100vh;
}

.mobile-topbar {
    display: none;
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #111827 0%, #0d1420 100%);
    padding: 24px;
    min-height: 100vh;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-mark small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.brand-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--green), var(--blue));
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0.14);
}

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

.nav-link {
    padding: 12px 14px;
    border-radius: 8px;
    color: #cad7e6;
    background: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.sidebar-footer {
    margin-top: 28px;
    display: grid;
    gap: 16px;
}

.operator-card {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 14px;
}

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

.operator-meta {
    color: var(--muted);
    font-size: 0.92rem;
}

.content {
    padding: 26px;
}

.topbar,
.section-heading,
.host-card-head,
.metrics-header,
.noc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.topbar {
    margin-bottom: 24px;
}

.topbar h1,
.section-heading h2,
.login-card h1,
.noc-header h1 {
    margin: 0;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.eyebrow {
    text-transform: uppercase;
    color: var(--blue);
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    margin: 0 0 8px;
}

.clock-pill {
    min-width: 150px;
    text-align: center;
    padding: 11px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
}

.stats-grid,
.panel-grid,
.chart-grid,
.form-grid {
    display: grid;
    gap: 18px;
}

.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 22px;
}

.panel-grid {
    grid-template-columns: 1.2fr 1fr;
}

.hosts-layout {
    grid-template-columns: 420px 1fr;
}

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

.stat-card,
.panel,
.host-card,
.chart-panel,
.login-card,
.noc-host-card {
    background: linear-gradient(180deg, rgba(31, 41, 55, 0.96), rgba(22, 33, 49, 0.96));
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 20px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: clamp(2rem, 4vw, 3rem);
}

.stat-online strong { color: var(--green); }
.stat-offline strong { color: var(--red); }
.stat-alert strong { color: var(--yellow); }

.panel,
.chart-panel,
.login-card {
    padding: 20px;
}

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

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

th, td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: middle;
}

th {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 11px 16px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

.button.secondary {
    background: rgba(255, 255, 255, 0.08);
}

.button.danger {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
}

.button.small {
    padding: 9px 14px;
    font-size: 0.92rem;
}

.button.wide {
    width: 100%;
}

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

.form-grid.compact {
    margin-top: 16px;
}

.full {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 8px;
    color: #dbe6f2;
}

input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 22, 40, 0.78);
    color: var(--text);
}

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

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

.flash {
    padding: 13px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
}

.flash.success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.flash.error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.status-online,
.level-info {
    color: #d8ffe6;
    background: rgba(34, 197, 94, 0.18);
}

.status-warning,
.level-warning {
    color: #fff3cf;
    background: rgba(245, 158, 11, 0.18);
}

.status-offline,
.level-critical {
    color: #ffe0e0;
    background: rgba(239, 68, 68, 0.18);
}

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

.host-card {
    padding: 18px;
}

.host-card h3,
.chart-panel h3 {
    margin: 0 0 6px;
}

.mini-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
    color: var(--muted);
}

.mini-metrics strong {
    display: block;
    color: var(--text);
    margin-top: 4px;
}

.inline-chart-box {
    position: relative;
    width: 100%;
    height: 130px;
    margin-bottom: 12px;
}

.inline-chart {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

.action-row {
    display: flex;
    gap: 12px;
}

.inline-form {
    display: inline-flex;
    gap: 10px;
}

.metrics-header {
    margin: 18px 0;
}

.chart-panel {
    position: relative;
}

.chart-box {
    position: relative;
    height: 220px;
    width: 100%;
}

.chart-panel canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(480px, 100%);
}

.auth-body {
    background:
        radial-gradient(circle at top, rgba(56, 189, 248, 0.08), transparent 30%),
        linear-gradient(180deg, #08111f 0%, #0a1628 100%);
}

.form-space {
    margin-top: 20px;
}

.login-hint {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.noc-body {
    background:
        linear-gradient(180deg, rgba(10, 22, 40, 0.98), rgba(6, 15, 29, 1)),
        var(--bg);
}

.noc-shell {
    min-height: 100vh;
    padding: 24px;
}

.noc-stats {
    margin-top: 24px;
}

.noc-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr 360px;
}

.noc-side {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.noc-alerts-panel {
    flex: 1;
}

.noc-alert-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 600px;
    overflow-y: auto;
}

.noc-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.noc-filter-select {
    width: auto;
    min-width: 180px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.noc-host-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.noc-host-info p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.noc-org-badge {
    margin-top: 6px;
    font-size: 0.75rem;
}

.noc-hosts {
    display: grid;
    gap: 10px;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 4px;
}

.noc-host-card {
    padding: 14px 16px;
    border-left: 4px solid transparent;
}

.noc-host-card.status-online  { border-left-color: var(--green); }
.noc-host-card.status-warning { border-left-color: var(--yellow); }
.noc-host-card.status-offline { border-left-color: var(--red); background: rgba(239,68,68,0.06); }

.noc-host-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--muted);
}

.noc-host-metrics strong {
    display: block;
    color: var(--text);
    font-size: 0.95rem;
    margin-top: 2px;
}

.alert-line {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-radius: 8px;
    padding: 10px 12px;
}

.alert-line > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-host {
    color: var(--muted);
    font-size: 0.88rem;
}

.alert-msg {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
    padding-left: 4px;
}

.alert-line.level-info {
    background: rgba(56, 189, 248, 0.1);
}

.alert-line.level-warning {
    background: rgba(245, 158, 11, 0.12);
}

.alert-line.level-critical {
    background: rgba(239, 68, 68, 0.12);
}

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

    .panel-grid,
    .hosts-layout,
    .chart-grid,
    .noc-grid {
        grid-template-columns: 1fr;
    }

    .noc-hosts {
        max-height: none;
    }

    .noc-header-right {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .sidebar {
        display: none;
        min-height: auto;
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        overflow-y: auto;
    }

    .sidebar.open {
        display: block;
    }

    .mobile-topbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 18px;
        background: var(--sidebar, #111827);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 500;
        width: 100%;
    }

    .brand-text {
        font-weight: 700;
        color: var(--text);
        font-size: 1.1rem;
    }

    .menu-toggle {
        background: none;
        border: none;
        color: var(--text);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 4px 10px;
    }
}

@media (min-width: 1101px) {
    .sidebar {
        display: block !important;
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }
}

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

    .form-grid,
    .mini-metrics,
    .noc-host-metrics {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-heading,
    .host-card-head,
    .metrics-header,
    .noc-header,
    .login-hint {
        flex-direction: column;
        align-items: flex-start;
    }

    .content,
    .noc-shell {
        padding: 14px;
    }

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

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

/* ── Overlay for mobile sidebar ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 999;
}

.sidebar-overlay.open {
    display: block;
}

/* ── Organizations ── */
.orgs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.org-card {
    background: linear-gradient(180deg, rgba(31,41,55,0.96), rgba(22,33,49,0.96));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow);
}

.org-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.org-name {
    margin: 0 0 4px;
    font-size: 1rem;
}

.org-desc {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.org-card-foot {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge.blue { background: rgba(56,189,248,0.18); color: #7dd3fc; }
.badge.green { background: rgba(34,197,94,0.18); color: #86efac; }
.badge.yellow { background: rgba(245,158,11,0.18); color: #fde68a; }
.badge.red { background: rgba(239,68,68,0.18); color: #fca5a5; }

.role-admin { background: rgba(168,85,247,0.18); color: #d8b4fe; }
.role-operator { background: rgba(56,189,248,0.18); color: #7dd3fc; }
.role-viewer { background: rgba(148,163,184,0.18); color: #cbd5e1; }

/* ── Nav separator ── */
.nav-separator {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* ── Nav icon ── */
.nav-icon {
    margin-right: 6px;
}

/* ── Operator role badge ── */
.operator-role {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-head h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

/* ── Avatar ── */
.avatar-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1d4ed8, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   NOC — status filter tabs
══════════════════════════════════════════════════════ */
.noc-status-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}

.noc-tab {
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.noc-tab:hover {
    background: rgba(255,255,255,0.07);
    color: var(--text);
}

.noc-tab.active {
    background: var(--card);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.noc-tab.tab-critical.active {
    background: rgba(239,68,68,0.22);
    color: #fca5a5;
}

.noc-tab.tab-alert.active {
    background: rgba(245,158,11,0.22);
    color: #fde68a;
}

/* NOC host code display */
.noc-host-code-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.noc-code {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .03em;
    color: var(--text);
}

.noc-host-name-sub {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* ══════════════════════════════════════════════════════
   Organizations redesign
══════════════════════════════════════════════════════ */
.orgs-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.orgs-page-header h2 {
    margin: 4px 0 0;
}

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

.search-input {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(10,22,40,.7);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    min-width: 200px;
    outline: none;
    transition: border-color .15s;
}

.search-input:focus {
    border-color: var(--blue);
}

/* Summary strip */
.orgs-summary-strip {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.orgs-summary-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 20px;
    flex: 1;
    min-width: 160px;
}

.orgs-summary-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.orgs-summary-label {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.orgs-summary-value {
    font-size: 1.6rem;
    font-weight: 700;
    display: block;
    line-height: 1.1;
}

/* Cards grid */
.orgs-grid2 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.org-card2 {
    background: linear-gradient(160deg, #1a2742, #101c30);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .18s, box-shadow .18s;
    display: flex;
    flex-direction: column;
}

.org-card2:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 48px rgba(0,0,0,.36);
}

.org-card2-bar {
    height: 4px;
    width: 100%;
}

.org-card2-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}

.org-card2-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.org-avatar {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -.02em;
}

.org-card2-title h3 {
    margin: 0 0 4px;
    font-size: 0.98rem;
    line-height: 1.3;
}

.org-card2-desc {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Stats row */
.org-card2-stats {
    display: flex;
    gap: 10px;
}

.org-stat-pill {
    flex: 1;
    border: 1px solid;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    background: rgba(255,255,255,.03);
}

.org-stat-num {
    display: block;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.1;
}

.org-stat-lbl {
    font-size: 0.74rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* Host bar */
.org-host-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.org-host-bar-track {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    overflow: hidden;
}

.org-host-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .4s ease;
}

.org-host-bar-label {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}

/* Footer actions */
.org-card2-foot {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.org-delete-form {
    display: inline;
}

/* ── hosts table code cell ── */
.host-code {
    font-size: 0.85rem;
    font-weight: 700;
    font-family: "Fira Code", "Consolas", monospace;
    color: var(--blue);
    letter-spacing: .04em;
}
