:root {
    --bg: #eef3f6;
    --panel: #ffffff;
    --ink: #172235;
    --muted: #627184;
    --line: #d6e0ea;
    --brand: #0b7f8c;
    --brand-dark: #123346;
    --accent: #315f87;
    --ok: #28764f;
    --warn: #a86600;
    --soft: #eaf7f8;
    --radius: 8px;
    --shadow: 0 14px 34px rgba(23, 34, 53, .08);
}

.admin-hero {
    background:
        linear-gradient(110deg, rgba(11,127,140,.08), rgba(49,95,135,.05) 42%, rgba(255,255,255,1) 70%),
        #ffffff;
}

.health-card strong {
    color: var(--ok);
}

.admin-metrics article strong {
    color: var(--brand-dark);
}

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

.pendency {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfcfd;
    padding: 12px;
}

.pendency small,
.quick-tile span {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
}

.pendency strong {
    display: block;
    margin-top: 6px;
    font-size: 30px;
}

.pendency span {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.pendency.good strong {
    color: var(--ok);
}

.pendency.warn strong {
    color: var(--warn);
}

.quick-actions {
    display: grid;
    gap: 10px;
}

.quick-actions a,
.log-actions button,
.backup-btn {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    padding: 11px;
    text-decoration: none;
    font: inherit;
    font-weight: 800;
    color: var(--ink);
}

.quick-actions a:hover,
.log-actions button:hover,
.backup-btn:hover {
    border-color: var(--brand);
    color: #075d68;
}

.log-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.log-actions button {
    background: #26894d;
    border-color: #26894d;
    color: #fff;
    cursor: pointer;
}

.backup-btn {
    width: auto;
    margin-top: 12px;
    background: var(--brand-dark);
    color: #fff;
    border-color: var(--brand-dark);
    cursor: pointer;
}

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

.admin-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
}

.command-box {
    margin-top: 16px;
    max-width: 720px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.command-box button {
    border: 0;
    border-radius: 7px;
    background: var(--brand);
    color: #fff;
    padding: 0 14px;
    font: inherit;
    font-weight: 800;
}

.health-card small {
    display: block;
    margin-top: 10px;
    color: var(--muted);
}

.future-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: stretch;
}

.command-panel,
.cockpit-panel,
.alert-panel {
    min-width: 0;
}

.shortcut-list,
.alert-list {
    display: grid;
    gap: 9px;
}

.shortcut-list a {
    display: grid;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfcfd;
    padding: 10px;
    text-decoration: none;
}

.shortcut-list a:hover {
    border-color: var(--brand);
    color: #075d68;
}

.shortcut-list span,
.cockpit span,
.cockpit small,
.automation-step small,
.alert span {
    color: var(--muted);
}

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

.cockpit div {
    min-height: 116px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfcfd;
    padding: 12px;
    display: grid;
    align-content: space-between;
}

.cockpit strong {
    display: block;
    font-size: 28px;
    margin: 8px 0;
}

.alert {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfcfd;
    padding: 10px;
    display: grid;
    gap: 3px;
}

.alert.warn {
    border-color: #e0b56e;
    background: #fff8ed;
}

.alert.good {
    border-color: #95c6aa;
    background: #f1faf4;
}

.automation-panel {
    display: grid;
    gap: 9px;
}

.automation-step {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    column-gap: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfcfd;
    padding: 10px;
}

.automation-step span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca8b5;
    margin-top: 5px;
}

.automation-step strong,
.automation-step small {
    grid-column: 2;
}

.automation-step.done span {
    background: var(--ok);
}

.automation-step.warn span {
    background: var(--warn);
}

@media (max-width: 1180px) {
    .pendency-grid,
    .menu-card-grid,
    .future-grid,
    .cockpit {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cockpit-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .pendency-grid,
    .menu-card-grid,
    .admin-layout,
    .future-grid,
    .cockpit,
    .command-box {
        grid-template-columns: 1fr;
    }

    .log-actions,
    .log-actions button,
    .backup-btn {
        width: 100%;
    }
}

/* Final layout stability overrides for the admin console pages. */
.module-head {
    display: block;
}

.module-head h2 {
    max-width: 760px;
}

.module-head p:last-child {
    max-width: 980px;
}

.module-layout.admin-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
}

.menu-card-grid.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.menu-card-grid .quick-tile {
    min-height: 132px;
    display: grid;
    align-content: start;
    gap: 6px;
    overflow-wrap: anywhere;
}

.menu-card-grid .quick-tile strong {
    font-size: 16px;
    line-height: 1.25;
}

.menu-card-grid .quick-tile small {
    line-height: 1.45;
}

.result-panel {
    min-width: 0;
}

@media (max-width: 1180px) {
    .module-layout.admin-layout {
        grid-template-columns: 1fr;
    }

    .result-panel {
        position: static;
    }
}

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

/* Advanced navigation: app rail + command search. */
body {
    padding-left: 96px;
}

.app-rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: 96px;
    background: #0e2e40;
    border-right: 1px solid rgba(255,255,255,.12);
    z-index: 40;
    display: grid;
    grid-auto-rows: min-content;
    gap: 8px;
    padding: 12px 8px;
    overflow-y: auto;
}

.rail-logo,
.rail-item {
    color: #dcebf0;
    text-decoration: none;
    border-radius: 10px;
}

.rail-logo {
    height: 48px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-weight: 900;
    margin-bottom: 6px;
}

.rail-item {
    min-height: 66px;
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 7px 4px;
    text-align: center;
    border: 1px solid transparent;
}

.rail-item span {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    font-size: 12px;
    font-weight: 900;
}

.rail-item strong {
    font-size: 11px;
    line-height: 1.1;
}

.rail-item:hover,
.rail-item.active {
    background: #ffffff;
    color: var(--brand-dark);
    border-color: rgba(255,255,255,.28);
}

.rail-item.active span,
.rail-item:hover span {
    background: var(--soft);
    color: #075d68;
}

.topbar {
    grid-template-columns: auto minmax(360px, 780px) auto;
}

.topnav {
    display: none;
}

.global-command {
    position: relative;
    min-width: 0;
}

.global-command input {
    height: 42px;
    border: 1px solid rgba(255,255,255,.28);
    background: rgba(255,255,255,.1);
    color: #fff;
    border-radius: 10px;
    padding: 0 14px;
}

.global-command input::placeholder {
    color: #cfe0e8;
}

.global-results {
    position: absolute;
    display: none;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px;
    z-index: 50;
    max-height: 360px;
    overflow: auto;
}

.global-results.open {
    display: grid;
    gap: 6px;
}

.global-results a {
    display: grid;
    gap: 2px;
    padding: 10px;
    border-radius: 7px;
    text-decoration: none;
}

.global-results a:hover,
.global-results a.active {
    background: var(--soft);
    color: #075d68;
}

.global-results span {
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 1180px) {
    body {
        padding-left: 78px;
    }

    .app-rail {
        width: 78px;
    }

    .rail-item {
        min-height: 58px;
    }

    .rail-item strong {
        display: none;
    }

    .topbar {
        grid-template-columns: auto minmax(260px, 1fr) auto;
    }
}

@media (max-width: 760px) {
    body {
        padding-left: 0;
        padding-bottom: 74px;
    }

    .app-rail {
        inset: auto 0 0 0;
        width: auto;
        height: 68px;
        grid-auto-flow: column;
        grid-auto-columns: minmax(58px, 1fr);
        padding: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-top: 1px solid rgba(255,255,255,.12);
    }

    .rail-logo {
        display: none;
    }

    .rail-item {
        min-height: 56px;
        padding: 5px 4px;
    }

    .rail-item span {
        width: 26px;
        height: 26px;
    }

    .rail-item strong {
        display: block;
        font-size: 10px;
    }

    .topbar {
        grid-template-columns: 1fr auto;
    }

    .global-command {
        grid-column: 1 / -1;
        order: 3;
    }

    .global-command input {
        height: 38px;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

a { color: inherit; }

.topbar {
    min-height: 72px;
    background: var(--brand-dark);
    color: #fff;
    border-bottom: 4px solid var(--brand);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    padding: 12px 22px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
}

.brand > span {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--brand);
    font-weight: 800;
}

.brand h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0;
}

.brand p {
    margin: 2px 0 0;
    color: #cfe0e8;
    white-space: nowrap;
}

.topnav {
    display: flex;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.nav-group {
    position: relative;
}

.nav-group > button,
.actions a,
.panel-head button,
.chat-form button {
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    color: #fff;
    padding: 9px 12px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.nav-group.active > button,
.nav-group:hover > button {
    background: #fff;
    color: var(--brand-dark);
}

.nav-panel {
    position: absolute;
    left: 0;
    top: calc(100% + 9px);
    min-width: 280px;
    display: none;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px;
}

.nav-group:hover .nav-panel,
.nav-group:focus-within .nav-panel {
    display: grid;
}

.nav-item {
    display: grid;
    gap: 2px;
    padding: 10px;
    border-radius: 7px;
    text-decoration: none;
}

.nav-item span {
    color: var(--muted);
    font-size: 12px;
}

.nav-item.active,
.nav-item:hover {
    background: var(--soft);
    color: #075d68;
}

.actions {
    display: flex;
    gap: 8px;
}

.actions a {
    text-decoration: none;
    white-space: nowrap;
}

.actions .primary {
    background: var(--brand);
    border-color: var(--brand);
}

.mobile-jump {
    display: none;
}

.page {
    width: min(1480px, calc(100% - 32px));
    margin: 18px auto 34px;
    display: grid;
    gap: 16px;
}

.dashboard-hero,
.module-head,
.panel,
.metrics article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dashboard-hero,
.module-head {
    padding: 22px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 18px;
    align-items: center;
}

.eyebrow {
    margin: 0 0 6px;
    color: #087180;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
}

h2,
h3 {
    margin: 0;
    letter-spacing: 0;
}

.dashboard-hero h2,
.module-head h2 {
    font-size: 30px;
    line-height: 1.1;
}

.dashboard-hero p:last-child,
.module-head p:last-child,
.muted {
    color: var(--muted);
}

.readiness {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: #f8fbfc;
}

.readiness strong {
    display: block;
    font-size: 32px;
}

.readiness span {
    color: var(--muted);
    font-weight: 700;
}

.bar {
    height: 8px;
    border-radius: 99px;
    background: #dce6ee;
    overflow: hidden;
    margin-top: 12px;
}

.bar i {
    display: block;
    width: 0;
    height: 100%;
    background: var(--brand);
}

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

.metrics article {
    padding: 16px;
}

.metrics span,
.dash-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 800;
}

.metrics strong {
    display: block;
    margin-top: 6px;
    font-size: 28px;
}

.metrics p,
.panel p {
    margin: 8px 0 0;
}

.workbench,
.module-layout,
.assistant-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 16px;
    align-items: start;
}

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

.panel {
    padding: 18px;
}

.wide {
    min-width: 0;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-head a,
.panel-head button {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--brand);
    padding: 8px 10px;
    text-decoration: none;
    font-weight: 800;
}

.journey {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.journey a,
.quick-tile {
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfcfd;
    padding: 12px;
    min-width: 0;
}

.journey span {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--soft);
    color: #075d68;
    font-weight: 800;
}

.journey strong,
.journey small {
    display: block;
    margin-top: 8px;
}

.journey small,
.quick-tile small {
    color: var(--muted);
}

.ready-list,
.quick-grid {
    display: grid;
    gap: 8px;
}

.ready-list button {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    padding: 9px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font: inherit;
    cursor: pointer;
}

.ready-list button.done {
    background: var(--soft);
    color: #075d68;
}

.engine-flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.engine-flow span,
.flow-chip {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px;
    background: #fbfcfd;
    font-weight: 800;
    text-align: center;
}

.module-layout {
    grid-template-columns: 300px minmax(0, 1fr) 340px;
}

.teach {
    position: sticky;
    top: 96px;
}

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

label span {
    display: block;
    font-weight: 800;
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #c5d0da;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 10px;
    font: inherit;
}

.result-panel {
    position: sticky;
    top: 96px;
}

#liveResult,
#blueprint {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fafb;
    padding: 12px;
}

#blueprintJson {
    min-height: 380px;
    margin-top: 12px;
    font-family: Consolas, monospace;
}

.assistant-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
}

.chat-window {
    height: 520px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fafb;
    padding: 14px;
    display: grid;
    align-content: start;
    gap: 10px;
}

.msg {
    max-width: 82%;
    border-radius: 12px;
    padding: 11px 12px;
    background: #fff;
    border: 1px solid var(--line);
}

.msg.user {
    justify-self: end;
    background: var(--brand);
    color: #fff;
}

.chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 12px;
}

.chat-form button {
    background: var(--brand);
    border-color: var(--brand);
}

.prompt {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 7px;
    padding: 10px;
    text-align: left;
    font: inherit;
    font-weight: 800;
    margin-top: 8px;
    cursor: pointer;
}

@media (max-width: 1180px) {
    .topbar {
        grid-template-columns: 1fr auto;
    }

    .topnav {
        grid-column: 1 / -1;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 3px;
    }

    .brand p {
        white-space: normal;
    }

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

    .module-layout {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

    .teach {
        grid-column: 1 / -1;
        position: static;
    }
}

@media (max-width: 760px) {
    body {
        background: #f6f8fa;
        font-size: 15px;
    }

    .topbar {
        min-height: 64px;
        grid-template-columns: 1fr auto;
        padding: 10px 12px;
        border-bottom-width: 3px;
    }

    .brand {
        min-width: 0;
    }

    .brand > span {
        width: 36px;
        height: 36px;
    }

    .brand h1 {
        font-size: 18px;
    }

    .brand p,
    .topnav {
        display: none;
    }

    .actions a:first-child {
        display: none;
    }

    .actions a {
        padding: 8px 9px;
        font-size: 13px;
    }

    .mobile-jump {
        position: sticky;
        top: 67px;
        z-index: 20;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        padding: 10px 12px;
        background: #fff;
        border-bottom: 1px solid var(--line);
    }

    .mobile-jump label {
        font-weight: 800;
        color: var(--muted);
        font-size: 12px;
        text-transform: uppercase;
    }

    .page {
        width: 100%;
        margin: 0;
        padding: 12px;
        gap: 12px;
    }

    .dashboard-hero,
    .module-head {
        grid-template-columns: 1fr;
        padding: 16px;
        border-radius: 8px;
    }

    .dashboard-hero h2,
    .module-head h2 {
        font-size: 24px;
    }

    .readiness {
        padding: 12px;
    }

    .readiness strong {
        font-size: 26px;
    }

    .metrics,
    .workbench,
    .workbench.bottom,
    .module-layout,
    .assistant-grid,
    .form-panel form,
    .engine-flow {
        grid-template-columns: 1fr;
    }

    .metrics {
        gap: 10px;
    }

    .metrics article,
    .panel {
        border-radius: 8px;
        padding: 14px;
    }

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

    .journey a {
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr);
        column-gap: 10px;
        align-items: center;
    }

    .journey small {
        grid-column: 2;
        margin-top: 2px;
    }

    .result-panel {
        position: static;
    }

    .chat-window {
        height: calc(100vh - 260px);
        min-height: 360px;
    }

    .msg {
        max-width: 94%;
    }

    .chat-form {
        grid-template-columns: 1fr;
    }
}

/* True final layout stability overrides for admin console pages. */
.module-head {
    display: block;
}

.module-head h2 {
    max-width: 760px;
}

.module-head p:last-child {
    max-width: 980px;
}

.module-layout.admin-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
}

.menu-card-grid.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.menu-card-grid .quick-tile {
    min-height: 132px;
    display: grid;
    align-content: start;
    gap: 6px;
    overflow-wrap: anywhere;
}

.menu-card-grid .quick-tile strong {
    font-size: 16px;
    line-height: 1.25;
}

.menu-card-grid .quick-tile small {
    line-height: 1.45;
}

.result-panel {
    min-width: 0;
}

@media (max-width: 1180px) {
    .module-layout.admin-layout {
        grid-template-columns: 1fr;
    }

    .result-panel {
        position: static;
    }
}

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