/* =====================================================
   AquaLabs CEO Room shell — green platform theme
   Tokens: assets/brand/ceo/ceo-brand-tokens.txt
   primary #48C070 · accent #205890
   Loaded after style.css; does not affect Room 0.
   ===================================================== */

/* CEO room distinction — full dark green desk over light corporate system */
html[data-shell="ceo"],
body.shell-ceo {
    --ceo-primary: #48c070;
    --ceo-primary-soft: rgba(72, 192, 112, 0.14);
    --ceo-primary-hover: rgba(72, 192, 112, 0.24);
    --ceo-primary-outline: rgba(72, 192, 112, 0.45);
    --ceo-primary-glow: rgba(72, 192, 112, 0.2);
    --ceo-accent: #206098;
    --ceo-accent-soft: rgba(32, 96, 152, 0.28);
    --ceo-accent-deep: #143a5c;

    /* Brand aliases stay green on CEO desk */
    --primary: #48c070;
    --primary-soft: rgba(72, 192, 112, 0.14);
    --primary-hover: rgba(72, 192, 112, 0.24);
    --primary-outline: rgba(72, 192, 112, 0.45);
    --secondary: #206098;
    --secondary-soft: rgba(32, 96, 152, 0.2);
    --secondary-hover: rgba(32, 96, 152, 0.28);
    --secondary-outline: rgba(32, 96, 152, 0.4);

    /* Full dark surface stack (overrides light :root) */
    --canvas: #020a08;
    --card: rgba(10, 31, 24, 0.92);
    --ice-blue: #0a1f18;
    --slate-navy: #020a08;
    --corp-bg: #0a1f18;
    --corp-surface: rgba(10, 31, 24, 0.85);
    --corp-surface-raised: rgba(16, 40, 32, 0.92);
    --glass-bg: rgba(6, 20, 16, 0.55);
    --glass-bg-strong: rgba(8, 28, 22, 0.75);
    --glass-bg-hover: rgba(72, 192, 112, 0.12);
    --glass-edge-top: rgba(72, 192, 112, 0.2);
    --glass-edge-left: rgba(72, 192, 112, 0.12);
    --glass-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
    --accent-ring: rgba(72, 192, 112, 0.25);

    /* Remap corp tokens so shared panels inherit green desk chrome */
    --aquakleen-blue: var(--ceo-primary);
    --aquakleen-blue-soft: var(--ceo-primary-soft);
    --aquakleen-blue-hover: var(--ceo-primary-hover);
    --aquakleen-blue-outline: var(--ceo-primary-outline);
    --corp-border: rgba(72, 192, 112, 0.28);
    --corp-border-subtle: rgba(72, 192, 112, 0.08);
    --glass-border: var(--corp-border);
    --accent: #9ae6b4;
    --accent-bright: #c6f6d5;
    --accent-soft: rgba(72, 192, 112, 0.2);
    --text-primary: #eef8f1;
    --text-secondary: #c5e0d0;
    --text-muted: #7a9a88;
}

body.shell-ceo {
    background: var(--slate-navy);
    color: var(--text-primary);
}

/* Green matrix backdrop (CEO command center) */
body.shell-ceo .matrix-bg {
    background:
        radial-gradient(
            ellipse 140% 115% at 50% 32%,
            #143a2a 0%,
            #0a1f18 38%,
            #061410 72%,
            #020a08 100%
        );
}

body.shell-ceo .matrix-bg::before {
    display: block;
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(
            180deg,
            rgba(72, 192, 112, 0.06) 0%,
            transparent 40%,
            rgba(32, 88, 144, 0.08) 100%
        );
    pointer-events: none;
}

/* Header — AquaLabs platform desk (dark green over light system base) */
body.shell-ceo .corp-header,
body.shell-ceo .corp-header.top-clear {
    background: linear-gradient(180deg, #0a1f18 0%, #061410 100%) !important;
    border-bottom-color: rgba(72, 192, 112, 0.22) !important;
    border-bottom: 1px solid rgba(72, 192, 112, 0.22) !important;
}

body.shell-ceo .header-title {
    letter-spacing: 0.06em;
    color: var(--text-primary);
}

body.shell-ceo .header-title .title-sep {
    color: var(--ceo-primary);
    opacity: 0.85;
}

body.shell-ceo .header-logo-brand,
body.shell-ceo .header-logo-ceo {
    max-height: 48px;
    width: auto;
    object-fit: contain;
}

body.shell-ceo .auth-signout-btn:hover,
body.shell-ceo .auth-signout-btn:focus {
    border-color: var(--ceo-primary-outline);
    color: var(--ceo-primary);
}

/* Secondary nav — section switcher (not tenant modules) */
body.shell-ceo .nav-secondary {
    border-bottom-color: rgba(72, 192, 112, 0.16);
}

body.shell-ceo .nav-secondary .module-tab.active,
body.shell-ceo .ceo-sub-btn.active {
    border-color: var(--ceo-primary-outline);
    color: var(--text-primary);
    box-shadow: 0 0 12px var(--ceo-primary-glow);
    background: var(--ceo-primary-soft);
}

body.shell-ceo .nav-secondary .module-tab:hover,
body.shell-ceo .nav-secondary .module-tab:focus,
body.shell-ceo .page-btn:hover {
    border-color: var(--ceo-primary-outline);
}

/* —— P-SHELL-3c: locked 100vh shell; single scrollport = #ceo-main —— */
body.shell-ceo .crt {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

body.shell-ceo .header,
body.shell-ceo .nav-secondary,
body.shell-ceo #ceo-status,
body.shell-ceo #ceo-denied {
    flex-shrink: 0;
}

/* CEO content always mounted on this shell */
body.shell-ceo #ceo-room-view {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden; /* clip; scroll lives on #ceo-main only */
}

body.shell-ceo #ceo-room-view[hidden] {
    display: flex !important;
}

/* Table / handoff accents → green */
body.shell-ceo .ceo-rooms-table th,
body.shell-ceo .ceo-rooms-table td {
    border-bottom-color: rgba(72, 192, 112, 0.12);
}

body.shell-ceo .ceo-row-zero {
    background: rgba(72, 192, 112, 0.08);
}

body.shell-ceo .ceo-handoffs-side-header {
    border-bottom-color: rgba(72, 192, 112, 0.14);
}

body.shell-ceo .ceo-handoff-item {
    border-color: rgba(72, 192, 112, 0.14);
    background: rgba(6, 20, 16, 0.45);
}

body.shell-ceo .ceo-handoff-item:hover,
body.shell-ceo .ceo-handoff-item.is-selected {
    border-color: rgba(72, 192, 112, 0.45);
    background: rgba(72, 192, 112, 0.12);
}

body.shell-ceo .ceo-handoff-preview {
    border-color: rgba(72, 192, 112, 0.16);
    background: rgba(2, 12, 10, 0.55);
}

body.shell-ceo .status.corp-status {
    border-color: rgba(72, 192, 112, 0.22);
}

body.shell-ceo .status.corp-status.error {
    border-color: rgba(196, 92, 92, 0.5);
    color: #fca5a5;
}

/* Shell actions: enter Room 0 */
.ceo-shell-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

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

.ceo-denied-meta code {
    font-size: 0.85em;
    word-break: break-all;
}

.ceo-enter-room-btn {
    border-color: rgba(32, 88, 144, 0.55) !important;
    color: #b8d4f0 !important;
}

.ceo-enter-room-btn:hover {
    border-color: var(--ceo-primary-outline) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 0 12px var(--ceo-primary-glow);
}

.ceo-platform-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ceo-primary);
    border: 1px solid var(--ceo-primary-outline);
    background: var(--ceo-primary-soft);
    vertical-align: middle;
}

/* Operator-only door on Room 0 (index) — not a module tab */
.platform-desk-link {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin-right: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-decoration: none;
    text-transform: uppercase;
    color: #9ae6b4;
    border: 1px solid rgba(72, 192, 112, 0.35);
    border-radius: 6px;
    background: rgba(72, 192, 112, 0.08);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.platform-desk-link:hover,
.platform-desk-link:focus {
    border-color: rgba(72, 192, 112, 0.65);
    background: rgba(72, 192, 112, 0.16);
    color: #c6f6d5;
}

.platform-desk-link.is-visible {
    display: inline-flex;
}

/* —— P-SHELL-3 / 3b / 3c Module unlock + scrollport —— */

/* Exclusive sections: never stack handoffs form above unlock */
body.shell-ceo .ceo-section[hidden],
body.shell-ceo #ceo-section-rooms[hidden],
body.shell-ceo #ceo-section-handoffs[hidden],
body.shell-ceo #ceo-section-modules[hidden] {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    flex: 0 0 0 !important;
    border: none !important;
    pointer-events: none !important;
}

/*
 * THE scrollport — flex-basis 0 so height is bounded by .crt chain;
 * overflow-y auto then actually engages (3b broke this with flex-basis auto).
 */
body.shell-ceo #ceo-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Active section fills scrollport without inventing a second page scroll */
body.shell-ceo #ceo-main > .ceo-section:not([hidden]) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

body.shell-ceo #ceo-section-modules:not([hidden]) {
    display: flex;
    flex-direction: column;
    scroll-margin-top: 8px;
}

/* Rooms table: own overflow so small windows reach last rows */
body.shell-ceo #ceo-section-rooms .corp-table-wrap,
body.shell-ceo #ceo-section-rooms .table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(58vh, calc(100vh - 200px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.shell-ceo #ceo-section-rooms .table-scroll {
    flex: 1 1 auto;
    min-height: 120px;
    max-height: min(55vh, calc(100vh - 220px));
    height: auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

body.shell-ceo #ceo-section-rooms .ceo-footnote {
    flex-shrink: 0;
    margin-top: 8px;
    padding-bottom: 12px;
}

/* Handoffs layout constrained inside scrollport */
body.shell-ceo #ceo-section-handoffs .ceo-handoffs-layout {
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(70vh, calc(100vh - 180px));
    overflow: auto;
}

body.shell-ceo .ceo-modules-panel {
    margin: 12px 16px 24px;
    padding: 16px 18px 20px;
}

body.shell-ceo .ceo-modules-title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--ceo-primary);
    outline: none;
}

body.shell-ceo .ceo-modules-title:focus-visible {
    box-shadow: 0 0 0 2px rgba(72, 192, 112, 0.45);
    border-radius: 4px;
}

body.shell-ceo .ceo-modules-grid {
    margin-top: 12px;
}

body.shell-ceo .ceo-mod-readonly {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(72, 192, 112, 0.25);
    background: rgba(0, 0, 0, 0.25);
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    color: #c6f6d5;
}

body.shell-ceo .ceo-mod-chips,
body.shell-ceo .ceo-mod-catalog {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 2rem;
}

body.shell-ceo .ceo-mod-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}

body.shell-ceo .ceo-mod-chip-live {
    color: #9ae6b4;
    border-color: rgba(72, 192, 112, 0.45);
    background: rgba(72, 192, 112, 0.12);
}

body.shell-ceo .ceo-mod-chip-locked {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.35);
}

body.shell-ceo .ceo-mod-chip-empty {
    color: #64748b;
    border-color: rgba(100, 116, 139, 0.3);
    background: transparent;
}

body.shell-ceo .ceo-mod-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

body.shell-ceo .ceo-mod-actions select {
    min-width: 200px;
}

/*
 * SELECT-CONTRAST-1 / CEO-DESK-SELECT-1
 * Module Unlock native selects: dark surface + light text.
 * Fixes white-on-white from shared light .form-field select rules.
 */
body.shell-ceo #ceo-mod-tenant,
body.shell-ceo #ceo-mod-key {
    background-color: #0a1f18;
    background-image: none;
    color: #eef8f1;
    border: 1px solid rgba(72, 192, 112, 0.4);
    border-top-color: rgba(72, 192, 112, 0.28);
    border-left-color: rgba(72, 192, 112, 0.28);
    border-radius: 6px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    color-scheme: dark;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    accent-color: #48c070;
}

body.shell-ceo #ceo-mod-tenant:focus,
body.shell-ceo #ceo-mod-tenant:focus-visible,
body.shell-ceo #ceo-mod-key:focus,
body.shell-ceo #ceo-mod-key:focus-visible {
    background-color: #0f281f;
    color: #eef8f1;
    border-color: rgba(72, 192, 112, 0.65);
    box-shadow: 0 0 0 3px rgba(72, 192, 112, 0.22);
}

body.shell-ceo #ceo-mod-tenant option,
body.shell-ceo #ceo-mod-key option {
    background-color: #0a1f18;
    color: #eef8f1;
}

body.shell-ceo #ceo-mod-tenant option:checked,
body.shell-ceo #ceo-mod-key option:checked,
body.shell-ceo #ceo-mod-tenant option:hover,
body.shell-ceo #ceo-mod-key option:hover {
    background-color: #143a2a;
    color: #c6f6d5;
}

body.shell-ceo .ceo-mod-key-label {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--text-muted, #94a3b8);
}

body.shell-ceo .ceo-mod-status {
    margin-top: 12px;
}
