/* ==========================================================================
   FLARES CLOUD — the developer console's own design system.

   Loaded ONLY by layouts/cloud.php. Nothing here reaches School, Admin,
   Finance, Drive or Docs: every rule is scoped under .cl-shell or the
   cloud-only [data-cl-theme] root attribute, and no shared token from
   flares.css is redefined.

   The identity: Flares' monochrome structure and Cabinet Grotesk kept, plus
   a "flare" signature — a warm amber→coral gradient used sparingly (active
   navigation, the Cloud lockup, charts, focus) — and true light/dark themes.
   Firebase, Appwrite and AWS were studied for UX shape (project-first nav,
   density, operational seriousness), not copied for pixels.
   ========================================================================== */

:root {
    /* --- The flare. The one splash of colour Flares Cloud owns. --- */
    --cl-flare-a: #ffb224;
    --cl-flare-b: #ff6a3d;
    --cl-flare: linear-gradient(135deg, var(--cl-flare-a), var(--cl-flare-b));
    --cl-accent: #e8590c;
    --cl-accent-soft: rgba(232, 89, 12, 0.1);

    /* --- Light theme (default) --- */
    --cl-bg: #f7f6f4;
    --cl-surface: #ffffff;
    --cl-surface-2: #fbfaf9;
    --cl-surface-3: #f2f1ef;
    --cl-code-bg: #16181d;
    --cl-code-fg: #e8eaf0;
    --cl-border: #e4e2de;
    --cl-border-strong: #cfccc6;
    --cl-text: #17181c;
    --cl-text-mute: #6b6d76;
    --cl-text-faint: #999ca6;
    --cl-primary-btn-bg: #17181c;
    --cl-primary-btn-fg: #ffffff;
    --cl-nav-active-bg: #ffffff;
    --cl-shadow: 0 1px 2px rgba(23, 24, 28, 0.05), 0 4px 14px rgba(23, 24, 28, 0.05);
    --cl-shadow-pop: 0 12px 40px rgba(23, 24, 28, 0.16);
    --cl-ok: #1e8e3e;
    --cl-ok-bg: rgba(30, 142, 62, 0.1);
    --cl-warn: #b26a00;
    --cl-warn-bg: rgba(178, 106, 0, 0.12);
    --cl-bad: #d43e2a;
    --cl-bad-bg: rgba(212, 62, 42, 0.1);
    --cl-info: #2b5fd9;
    --cl-info-bg: rgba(43, 95, 217, 0.1);
    --cl-paused: #6b6d76;
    --cl-paused-bg: rgba(107, 109, 118, 0.12);

    --cl-mono: ui-monospace, 'Cascadia Code', 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
    --cl-radius: 10px;
    --cl-radius-sm: 7px;
    --cl-topbar-h: 52px;
    --cl-sidebar-w: 232px;
    --cl-ease: cubic-bezier(0.2, 0, 0, 1);
}

[data-cl-theme="dark"] {
    --cl-accent: #ffa94d;
    --cl-accent-soft: rgba(255, 169, 77, 0.13);

    --cl-bg: #0e0f13;
    --cl-surface: #16181d;
    --cl-surface-2: #1b1e24;
    --cl-surface-3: #23262e;
    --cl-code-bg: #0b0c10;
    --cl-code-fg: #dde1ea;
    --cl-border: #262932;
    --cl-border-strong: #363a45;
    --cl-text: #e9eaef;
    --cl-text-mute: #9a9da8;
    --cl-text-faint: #666a76;
    --cl-primary-btn-bg: #e9eaef;
    --cl-primary-btn-fg: #101116;
    --cl-nav-active-bg: #1e2128;
    --cl-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
    --cl-shadow-pop: 0 16px 48px rgba(0, 0, 0, 0.55);
    --cl-ok: #4cc26b;
    --cl-ok-bg: rgba(76, 194, 107, 0.13);
    --cl-warn: #e2b93b;
    --cl-warn-bg: rgba(226, 185, 59, 0.13);
    --cl-bad: #ff7a68;
    --cl-bad-bg: rgba(255, 122, 104, 0.13);
    --cl-info: #7aa5ff;
    --cl-info-bg: rgba(122, 165, 255, 0.13);
    --cl-paused: #9a9da8;
    --cl-paused-bg: rgba(154, 157, 168, 0.14);
}

/* ------------------------------------------------------------------ Shell */

body.cl-body {
    background: var(--cl-bg);
    color: var(--cl-text);
}

.cl-shell {
    display: grid;
    grid-template-rows: var(--cl-topbar-h) 1fr;
    min-height: 100vh;
}

.cl-frame {
    display: grid;
    grid-template-columns: var(--cl-sidebar-w) minmax(0, 1fr);
}

.cl-main {
    padding: 26px 30px 60px;
    min-width: 0;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

.cl-main.is-home {
    max-width: 1080px;
    padding-top: 40px;
}

/* ----------------------------------------------------------------- Topbar */

.cl-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    background: var(--cl-surface);
    border-bottom: 1px solid var(--cl-border);
    position: sticky;
    top: 0;
    z-index: 60;
}

.cl-lockup {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: var(--cl-text);
    flex-shrink: 0;
}

.cl-lockup svg { display: block; }
.cl-lockup .cl-lockup-flares { font-weight: 800; letter-spacing: 0.04em; font-size: 0.92rem; }

.cl-lockup .cl-lockup-cloud {
    font-weight: 700;
    font-size: 0.92rem;
    background: var(--cl-flare);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cl-topbar-divider {
    width: 1px;
    height: 22px;
    background: var(--cl-border);
    flex-shrink: 0;
}

/* The project selector: a first-class control, not a breadcrumb. */
.cl-project-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius-sm);
    background: var(--cl-surface-2);
    color: var(--cl-text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    max-width: 320px;
    transition: border-color 0.15s var(--cl-ease), background 0.15s var(--cl-ease);
}

.cl-project-switch:hover { border-color: var(--cl-border-strong); }
.cl-project-switch .cl-env { margin-left: 2px; }

.cl-project-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 340px;
    max-height: 420px;
    overflow: auto;
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    box-shadow: var(--cl-shadow-pop);
    padding: 8px;
    z-index: 80;
}

.cl-project-menu input[type="search"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius-sm);
    background: var(--cl-surface-2);
    color: var(--cl-text);
    font: inherit;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.cl-project-menu a.cl-project-row,
.cl-project-menu .cl-project-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border-radius: var(--cl-radius-sm);
    text-decoration: none;
    color: var(--cl-text);
}

.cl-project-row:hover, .cl-project-row:focus-visible { background: var(--cl-surface-3); }
.cl-project-row .cl-project-row-name { font-weight: 600; font-size: 0.86rem; display: block; }
.cl-project-row .cl-project-row-id { font-family: var(--cl-mono); font-size: 0.7rem; color: var(--cl-text-faint); }
.cl-project-row[aria-current="true"] { background: var(--cl-accent-soft); }

.cl-topbar-spacer { flex: 1; }

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

.cl-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--cl-radius-sm);
    background: transparent;
    color: var(--cl-text-mute);
    cursor: pointer;
    transition: background 0.15s var(--cl-ease), color 0.15s var(--cl-ease);
}

.cl-icon-btn:hover { background: var(--cl-surface-3); color: var(--cl-text); }

.cl-kbd {
    font-family: var(--cl-mono);
    font-size: 0.68rem;
    padding: 2px 6px;
    border: 1px solid var(--cl-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    color: var(--cl-text-mute);
    background: var(--cl-surface-2);
}

.cl-account { display: flex; align-items: center; }

.cl-account .cl-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--cl-flare);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

/* ---------------------------------------------------------------- Sidebar */

.cl-sidebar {
    position: sticky;
    top: var(--cl-topbar-h);
    height: calc(100vh - var(--cl-topbar-h));
    overflow-y: auto;
    background: var(--cl-surface);
    border-right: 1px solid var(--cl-border);
    padding: 16px 10px 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cl-nav-heading {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--cl-text-faint);
    padding: 14px 10px 5px;
}

.cl-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--cl-radius-sm);
    text-decoration: none;
    color: var(--cl-text-mute);
    font-size: 0.87rem;
    font-weight: 600;
    position: relative;
    transition: background 0.14s var(--cl-ease), color 0.14s var(--cl-ease);
}

.cl-nav-item:hover { background: var(--cl-surface-3); color: var(--cl-text); }

.cl-nav-item[aria-current="page"] {
    background: var(--cl-nav-active-bg);
    color: var(--cl-text);
    box-shadow: inset 0 0 0 1px var(--cl-border);
}

.cl-nav-item[aria-current="page"]::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 3px;
    background: var(--cl-flare);
}

.cl-nav-item .cl-nav-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--cl-text-faint);
    font-family: var(--cl-mono);
}

.cl-sidebar-foot {
    margin-top: auto;
    padding: 12px 10px 0;
    border-top: 1px solid var(--cl-border);
    font-size: 0.72rem;
    color: var(--cl-text-faint);
    line-height: 1.5;
}

/* ------------------------------------------------------------ Page header */

.cl-page-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.cl-page-head h1 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.cl-page-head .cl-page-sub {
    color: var(--cl-text-mute);
    font-size: 0.87rem;
    margin-top: 3px;
}

.cl-page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.cl-service-head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 18px 20px;
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    background:
        radial-gradient(680px 130px at 12% -30%, var(--cl-accent-soft), transparent 70%),
        var(--cl-surface);
    margin-bottom: 20px;
}

.cl-service-glyph {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--cl-flare);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cl-service-head h1 { font-size: 1.25rem; font-weight: 800; line-height: 1.15; }
.cl-service-head .cl-service-sub { font-size: 0.8rem; color: var(--cl-text-mute); margin-top: 2px; }
.cl-service-head .cl-service-meta { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Buttons */

.cl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: var(--cl-radius-sm);
    border: 1px solid var(--cl-border-strong);
    background: var(--cl-surface);
    color: var(--cl-text);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s var(--cl-ease), border-color 0.15s var(--cl-ease), transform 0.1s var(--cl-ease);
    white-space: nowrap;
}

.cl-btn:hover { background: var(--cl-surface-3); }
.cl-btn:active { transform: translateY(1px); }

.cl-btn.primary {
    background: var(--cl-primary-btn-bg);
    color: var(--cl-primary-btn-fg);
    border-color: var(--cl-primary-btn-bg);
}

.cl-btn.primary:hover { opacity: 0.88; background: var(--cl-primary-btn-bg); }

.cl-btn.danger { color: var(--cl-bad); border-color: var(--cl-bad); background: transparent; }
.cl-btn.danger:hover { background: var(--cl-bad-bg); }
.cl-btn.sm { padding: 4px 10px; font-size: 0.78rem; }
.cl-btn.ghost { border-color: transparent; background: transparent; color: var(--cl-text-mute); }
.cl-btn.ghost:hover { background: var(--cl-surface-3); color: var(--cl-text); }
.cl-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* data-busy spinner support (flares.js toggles .is-busy on submit) */
.cl-btn .spinner {
    display: none;
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: cl-spin 0.7s linear infinite;
}

form.is-busy .cl-btn[type="submit"] .spinner { display: inline-block; }
@keyframes cl-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ Cards */

.cl-card {
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    box-shadow: var(--cl-shadow);
}

.cl-card-pad { padding: 18px 20px; }

.cl-card h2, .cl-section-title {
    font-size: 0.95rem;
    font-weight: 750;
    letter-spacing: -0.005em;
}

.cl-card .cl-card-sub { font-size: 0.82rem; color: var(--cl-text-mute); margin-top: 2px; }

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

/* ---------------------------------------------------------- Metric cards */

.cl-metric {
    padding: 14px 16px;
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    background: var(--cl-surface);
    min-width: 0;
}

.cl-metric .cl-metric-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cl-text-faint);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cl-metric .cl-metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.cl-metric .cl-metric-meta { font-size: 0.75rem; color: var(--cl-text-mute); margin-top: 2px; }

/* ------------------------------------------------------------ Status pills
   One vocabulary: healthy, provisioning, degraded, unavailable, paused. */

.cl-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px 2px 7px;
    border-radius: 999px;
    font-size: 0.73rem;
    font-weight: 700;
}

.cl-status .cl-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.cl-status.ok { color: var(--cl-ok); background: var(--cl-ok-bg); }
.cl-status.warn { color: var(--cl-warn); background: var(--cl-warn-bg); }
.cl-status.bad { color: var(--cl-bad); background: var(--cl-bad-bg); }
.cl-status.info { color: var(--cl-info); background: var(--cl-info-bg); }
.cl-status.paused { color: var(--cl-paused); background: var(--cl-paused-bg); }
.cl-status.warn .cl-dot { animation: cl-pulse 1.6s ease-in-out infinite; }

@keyframes cl-pulse { 50% { opacity: 0.35; } }

.cl-env {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    border: 1px solid var(--cl-border-strong);
    color: var(--cl-text-mute);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.cl-env.production { border-color: var(--cl-accent); color: var(--cl-accent); }

/* ------------------------------------------------------------------ Tables */

.cl-table-wrap { overflow-x: auto; border-radius: var(--cl-radius); }

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

.cl-table thead th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cl-text-faint);
    padding: 9px 12px;
    border-bottom: 1px solid var(--cl-border);
    background: var(--cl-surface-2);
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.cl-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--cl-border);
    vertical-align: middle;
}

.cl-table tbody tr:last-child td { border-bottom: none; }
.cl-table tbody tr { transition: background 0.1s var(--cl-ease); }
.cl-table tbody tr:hover { background: var(--cl-surface-2); }
.cl-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cl-table td.cl-mono, .cl-mono { font-family: var(--cl-mono); font-size: 0.78rem; }
.cl-table .cl-cell-actions { text-align: right; white-space: nowrap; }
.cl-table a { color: inherit; font-weight: 650; text-decoration: none; }
.cl-table a:hover { text-decoration: underline; }

tr.cl-row-link { cursor: pointer; }

.cl-muted { color: var(--cl-text-mute); }
.cl-faint { color: var(--cl-text-faint); }
.cl-small { font-size: 0.78rem; }

/* Field-type chips in schema views: quiet, informative. */
.cl-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--cl-mono);
    font-size: 0.7rem;
    padding: 1px 7px;
    border-radius: 5px;
    background: var(--cl-surface-3);
    color: var(--cl-text-mute);
    border: 1px solid var(--cl-border);
}

/* ------------------------------------------------------------- Code block */

.cl-code {
    background: var(--cl-code-bg);
    color: var(--cl-code-fg);
    border-radius: var(--cl-radius);
    border: 1px solid var(--cl-border);
    overflow: hidden;
}

.cl-code-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px 6px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    color: rgba(232, 234, 240, 0.55);
}

.cl-code-bar .cl-code-lang {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
}

.cl-code-bar .cl-code-lang[aria-selected="true"] { color: #fff; background: rgba(255, 255, 255, 0.1); }
.cl-code-bar .cl-code-copy { margin-left: auto; color: inherit; background: none; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font: inherit; padding: 4px 8px; border-radius: 5px; }
.cl-code-bar .cl-code-copy:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.cl-code pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    font-family: var(--cl-mono);
    font-size: 0.8rem;
    line-height: 1.65;
    tab-size: 2;
}

.cl-code [data-lang-panel][hidden] { display: none; }

/* Tiny, honest highlighting applied server-side: strings, keywords, comments. */
.cl-code .tk-str { color: #9ece8c; }
.cl-code .tk-kw { color: #82aaff; }
.cl-code .tk-com { color: rgba(232, 234, 240, 0.4); }
.cl-code .tk-fn { color: #ffc98a; }

/* Inline copyable identifier (project ids, key prefixes) */
.cl-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--cl-mono);
    font-size: 0.76rem;
    padding: 2px 4px 2px 8px;
    border: 1px solid var(--cl-border);
    border-radius: 6px;
    background: var(--cl-surface-2);
    color: var(--cl-text-mute);
}

.cl-copy button {
    display: inline-flex;
    border: none;
    background: none;
    color: var(--cl-text-faint);
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
}

.cl-copy button:hover { color: var(--cl-text); background: var(--cl-surface-3); }
.cl-copy button.is-copied { color: var(--cl-ok); }

/* ------------------------------------------------------------ Empty state */

.cl-empty {
    text-align: center;
    padding: 52px 24px;
    border: 1px dashed var(--cl-border-strong);
    border-radius: var(--cl-radius);
    background:
        radial-gradient(400px 160px at 50% 0%, var(--cl-accent-soft), transparent 75%),
        var(--cl-surface);
}

.cl-empty .cl-empty-glyph {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--cl-surface-3);
    color: var(--cl-text-mute);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cl-empty h3 { font-size: 1.02rem; font-weight: 750; }
.cl-empty p { color: var(--cl-text-mute); font-size: 0.85rem; max-width: 420px; margin: 6px auto 16px; }

/* ------------------------------------------------------------- Quickstart */

.cl-quickstart { margin-bottom: 20px; }

.cl-quickstart summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    font-weight: 700;
    font-size: 0.9rem;
}

.cl-quickstart summary::-webkit-details-marker { display: none; }

.cl-quickstart .cl-qs-progress {
    margin-left: auto;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--cl-text-mute);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cl-qs-bar {
    width: 90px;
    height: 5px;
    border-radius: 3px;
    background: var(--cl-surface-3);
    overflow: hidden;
}

.cl-qs-bar i { display: block; height: 100%; background: var(--cl-flare); border-radius: 3px; }

.cl-qs-steps { padding: 0 18px 14px; display: grid; gap: 2px; }

.cl-qs-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: var(--cl-radius-sm);
    color: var(--cl-text-mute);
    text-decoration: none;
    font-size: 0.86rem;
}

.cl-qs-step:hover { background: var(--cl-surface-2); color: var(--cl-text); }

.cl-qs-step .cl-qs-tick {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    border: 1.6px solid var(--cl-border-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cl-qs-step.done { color: var(--cl-text-faint); }
.cl-qs-step.done .cl-qs-tick { border-color: var(--cl-ok); background: var(--cl-ok-bg); color: var(--cl-ok); }

/* ------------------------------------------------------------ Project card */

.cl-project-card {
    display: block;
    padding: 17px 18px;
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    background: var(--cl-surface);
    text-decoration: none;
    color: var(--cl-text);
    transition: border-color 0.15s var(--cl-ease), transform 0.15s var(--cl-ease), box-shadow 0.15s var(--cl-ease);
    position: relative;
    overflow: hidden;
}

.cl-project-card::after {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: var(--cl-flare);
    opacity: 0;
    transition: opacity 0.15s var(--cl-ease);
}

.cl-project-card:hover {
    border-color: var(--cl-border-strong);
    box-shadow: var(--cl-shadow);
    transform: translateY(-1px);
}

.cl-project-card:hover::after { opacity: 1; }
.cl-project-card h3 { font-size: 0.98rem; font-weight: 750; }
.cl-project-card .cl-project-card-id { font-family: var(--cl-mono); font-size: 0.7rem; color: var(--cl-text-faint); margin-top: 2px; word-break: break-all; }
.cl-project-card .cl-project-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.cl-project-card.is-new {
    border-style: dashed;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--cl-text-mute);
    font-weight: 650;
    min-height: 118px;
}

.cl-project-card.is-new:hover { color: var(--cl-text); }
.cl-project-card.is-new::after { content: none; }

/* ------------------------------------------------------------------ Forms */

.cl-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.cl-field label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--cl-text-mute);
}

.cl-input, .cl-select {
    padding: 7px 11px;
    border: 1px solid var(--cl-border-strong);
    border-radius: var(--cl-radius-sm);
    background: var(--cl-surface);
    color: var(--cl-text);
    font: inherit;
    font-size: 0.86rem;
    transition: border-color 0.15s var(--cl-ease), box-shadow 0.15s var(--cl-ease);
    width: 100%;
}

.cl-input:focus, .cl-select:focus {
    outline: none;
    border-color: var(--cl-accent);
    box-shadow: 0 0 0 3px var(--cl-accent-soft);
}

.cl-input::placeholder { color: var(--cl-text-faint); }
.cl-input.mono { font-family: var(--cl-mono); font-size: 0.8rem; }

.cl-form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.cl-form-row .cl-field { flex: 1; min-width: 150px; }
.cl-hint { font-size: 0.75rem; color: var(--cl-text-faint); }

/* ----------------------------------------------------------------- Drawer */

.cl-drawer[open] { display: flex; }

.cl-drawer {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    justify-content: flex-end;
    background: rgba(10, 10, 14, 0.45);
    border: none;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    padding: 0;
    margin: 0;
    color: inherit;
}

.cl-drawer-panel {
    width: min(460px, 92vw);
    height: 100%;
    background: var(--cl-surface);
    border-left: 1px solid var(--cl-border);
    box-shadow: var(--cl-shadow-pop);
    display: flex;
    flex-direction: column;
    animation: cl-slide-in 0.22s var(--cl-ease);
}

@keyframes cl-slide-in { from { transform: translateX(30px); opacity: 0.4; } }

.cl-drawer-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--cl-border);
}

.cl-drawer-head h3 { font-size: 0.95rem; font-weight: 750; }
.cl-drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.cl-drawer-foot { padding: 12px 18px; border-top: 1px solid var(--cl-border); display: flex; gap: 8px; }

.cl-kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: 0.84rem; }
.cl-kv dt { color: var(--cl-text-faint); font-weight: 650; }
.cl-kv dd { min-width: 0; word-break: break-word; }

/* ------------------------------------------------------------------ Modal */

.cl-modal[open] { display: grid; place-items: center; }

.cl-modal {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: none;
    background: rgba(10, 10, 14, 0.5);
    border: none;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    padding: 20px;
    margin: 0;
    color: inherit;
}

.cl-modal-panel {
    width: min(520px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: 14px;
    box-shadow: var(--cl-shadow-pop);
    animation: cl-rise 0.2s var(--cl-ease);
}

@keyframes cl-rise { from { transform: translateY(10px); opacity: 0.4; } }

.cl-modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.cl-modal-head h3 { font-size: 1.02rem; font-weight: 780; }
.cl-modal-body { padding: 12px 20px 18px; }
.cl-modal-foot { padding: 0 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }

/* -------------------------------------------------------------- Bar chart
   Server-rendered SVG; these only colour it. */

.cl-chart { width: 100%; }
.cl-chart .cl-bar { fill: var(--cl-accent); opacity: 0.85; }
.cl-chart .cl-bar:hover { opacity: 1; }
.cl-chart .cl-bar-2 { fill: var(--cl-text-faint); opacity: 0.5; }
.cl-chart text { fill: var(--cl-text-faint); font-size: 9px; font-family: var(--cl-mono); }
.cl-chart line { stroke: var(--cl-border); }

.cl-legend { display: flex; gap: 14px; font-size: 0.74rem; color: var(--cl-text-mute); }
.cl-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ------------------------------------------------------------ Danger zone */

.cl-danger-zone { border-color: color-mix(in srgb, var(--cl-bad) 45%, var(--cl-border)); }
.cl-danger-zone .cl-card-pad { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.cl-danger-zone h2 { color: var(--cl-bad); }

/* ------------------------------------------------------- Realtime tester */

.cl-events {
    font-family: var(--cl-mono);
    font-size: 0.76rem;
    background: var(--cl-code-bg);
    color: var(--cl-code-fg);
    border-radius: var(--cl-radius);
    padding: 12px 14px;
    min-height: 180px;
    max-height: 320px;
    overflow-y: auto;
    line-height: 1.7;
}

.cl-events .ev-time { color: rgba(232, 234, 240, 0.45); }
.cl-events .ev-insert { color: #9ece8c; }
.cl-events .ev-update { color: #82aaff; }
.cl-events .ev-delete { color: #ff9d8f; }
.cl-events .ev-sys { color: rgba(232, 234, 240, 0.55); font-style: italic; }

/* ---------------------------------------------------------- Flash banners */

.cl-main .alerts { margin-bottom: 16px; }

.cl-main .alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--cl-radius);
    border: 1px solid var(--cl-border);
    background: var(--cl-surface);
    font-size: 0.86rem;
}

.cl-main .alert.success { border-color: var(--cl-ok); color: var(--cl-ok); background: var(--cl-ok-bg); }
.cl-main .alert.error { border-color: var(--cl-bad); color: var(--cl-bad); background: var(--cl-bad-bg); }
.cl-main .alert.warning { border-color: var(--cl-warn); color: var(--cl-warn); background: var(--cl-warn-bg); }
.cl-main .alert .alert-dismiss { margin-left: auto; background: none; border: none; color: inherit; cursor: pointer; display: inline-flex; padding: 3px; }

/* -------------------------------------------------------- Command palette */

.cl-palette[open] { display: block; }

.cl-palette {
    position: fixed;
    inset: 0;
    z-index: 99;
    display: none;
    background: rgba(10, 10, 14, 0.4);
    border: none;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    padding: 0;
    margin: 0;
}

.cl-palette-panel {
    width: min(560px, 92vw);
    margin: 12vh auto 0;
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: 14px;
    box-shadow: var(--cl-shadow-pop);
    overflow: hidden;
    animation: cl-rise 0.18s var(--cl-ease);
}

.cl-palette input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--cl-text);
    font: inherit;
    font-size: 1rem;
    padding: 15px 18px;
    outline: none;
    border-bottom: 1px solid var(--cl-border);
}

.cl-palette-list { max-height: 320px; overflow-y: auto; padding: 7px; }

.cl-palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 9px 11px;
    border: none;
    background: none;
    color: var(--cl-text);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--cl-radius-sm);
    cursor: pointer;
    text-decoration: none;
}

.cl-palette-item:hover, .cl-palette-item.is-active { background: var(--cl-surface-3); }
.cl-palette-item .cl-faint { margin-left: auto; font-weight: 500; font-size: 0.74rem; }
.cl-palette-empty { padding: 18px; text-align: center; color: var(--cl-text-faint); font-size: 0.85rem; }

/* -------------------------------------------------------------- Skeletons */

.cl-skeleton {
    background: linear-gradient(90deg, var(--cl-surface-3) 25%, var(--cl-surface-2) 45%, var(--cl-surface-3) 65%);
    background-size: 200% 100%;
    animation: cl-shimmer 1.3s infinite linear;
    border-radius: 6px;
    color: transparent;
}

@keyframes cl-shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------- Responsive */

@media (max-width: 1060px) {
    .cl-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cl-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .cl-frame { grid-template-columns: 1fr; }

    .cl-sidebar {
        position: fixed;
        left: 0;
        top: var(--cl-topbar-h);
        width: var(--cl-sidebar-w);
        z-index: 70;
        transform: translateX(-100%);
        transition: transform 0.22s var(--cl-ease);
        box-shadow: var(--cl-shadow-pop);
    }

    .cl-shell.nav-open .cl-sidebar { transform: none; }
    .cl-nav-toggle { display: inline-flex !important; }
    .cl-main { padding: 18px 16px 48px; }
    .cl-kbd { display: none; }
    .cl-project-switch { max-width: 180px; }
    .cl-drawer-panel { width: 100vw; }
}

@media (max-width: 620px) {
    .cl-grid.cols-2, .cl-grid.cols-3, .cl-grid.cols-4 { grid-template-columns: 1fr; }
    .cl-topbar { gap: 8px; padding: 0 10px; }
    .cl-lockup .cl-lockup-flares { display: none; }
    .cl-service-head .cl-service-meta { margin-left: 0; width: 100%; }
}

.cl-nav-toggle { display: none; }

/* ------------------------------------------------------------ Motion & a11y */

:focus-visible { outline: 2px solid var(--cl-accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .cl-shell *, .cl-shell *::before, .cl-shell *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.cl-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------------------------------------------- Project-first structure ---
   Everything below supports Cloud -> Project -> Service -> Resource: the
   project header in the sidebar, the coming-soon service badges, the Basket
   service sub-navigation, breadcrumbs, and the services grid on the overview. */

.cl-sidebar-project {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--cl-border);
    flex-wrap: wrap;
}

.cl-sidebar-project-name {
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cl-sidebar-project-env { flex-shrink: 0; }

.cl-nav-soon {
    margin-left: auto;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cl-text-faint);
    border: 1px solid var(--cl-border);
    border-radius: 999px;
    padding: 1px 6px;
}

/* Basket's screens, nested under it in the sidebar while you are inside it. */
.cl-nav-sub {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 2px 0 4px 20px;
    padding-left: 10px;
    border-left: 1px solid var(--cl-border);
}

.cl-nav-subitem {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: var(--cl-radius-sm);
    text-decoration: none;
    color: var(--cl-text-mute);
    font-size: 0.82rem;
    font-weight: 550;
}

.cl-nav-subitem:hover { background: var(--cl-surface-3); color: var(--cl-text); }
.cl-nav-subitem[aria-current="page"] { color: var(--cl-text); font-weight: 700; }
.cl-nav-subitem .cl-nav-count { margin-left: auto; }

/* Breadcrumb: Flares Cloud / Project / Service / … */
.cl-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--cl-text-faint);
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.cl-breadcrumb a { color: var(--cl-text-mute); text-decoration: none; }
.cl-breadcrumb a:hover { color: var(--cl-text); text-decoration: underline; }
.cl-breadcrumb-here { color: var(--cl-text); font-weight: 650; }

/* Basket service sub-tabs (Collections / Data / Rules / Realtime / Backups). */
.cl-subnav {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--cl-border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.cl-subnav-item {
    padding: 9px 14px;
    text-decoration: none;
    color: var(--cl-text-mute);
    font-size: 0.86rem;
    font-weight: 650;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}

.cl-subnav-item:hover { color: var(--cl-text); }
.cl-subnav-item.is-active { color: var(--cl-text); border-bottom-color: var(--cl-accent); }

/* Service cards on the project overview. */
.cl-service-card {
    display: flex;
    flex-direction: column;
    padding: 16px 17px;
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    background: var(--cl-surface);
    box-shadow: var(--cl-shadow);
    min-height: 168px;
}

.cl-service-card.is-soon {
    background: var(--cl-surface-2);
    box-shadow: none;
    border-style: dashed;
}

.cl-service-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cl-service-card-glyph {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--cl-surface-3);
    color: var(--cl-text-mute);
}

.cl-service-card-glyph.is-real { background: var(--cl-flare); color: #fff; }
.cl-service-card h3 { font-size: 1rem; font-weight: 750; }
.cl-service-card-tag { font-size: 0.82rem; color: var(--cl-text-mute); margin-top: 3px; }
.cl-service-card-by { font-size: 0.72rem; color: var(--cl-text-faint); margin-top: 2px; }
.cl-service-card-foot { margin-top: auto; padding-top: 14px; }

/* Project cards on the Cloud home get a service summary row. */
.cl-project-card-services {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--cl-border);
}

.cl-project-card-service {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    color: var(--cl-text-mute);
}

.cl-project-card-service .cl-svc-state { color: var(--cl-text-faint); }
.cl-project-card-service .cl-svc-state.ok { color: var(--cl-ok); }
