/* ============================================================================
   DDMF Admin Portal — "Sentinel" Design System
   Premium · Futuristic · Security-oriented
   Generated with guidance from the UI/UX Pro Max skill.

   Direction: OLED-dark security console. Deep midnight-navy base, restrained
   cyan/blue glow, security-green for "protected" states, amber-gold premium
   CTAs. Glassmorphism panels, Fira Code (data/headings) + Fira Sans (body).
   All motion is gated behind prefers-reduced-motion.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
    /* Surfaces */
    --bg-0: #05070f;
    --bg-1: #0a0e27;
    --bg-2: #0f172a;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-2: rgba(255, 255, 255, 0.07);
    --surface-solid: #111726;
    /* opaque, dark panel fill so content stays legible over the background */
    --panel-bg: linear-gradient(180deg, rgba(14, 20, 40, 0.80), rgba(9, 13, 28, 0.72));

    /* Borders */
    --border: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(148, 163, 184, 0.32);
    --border-glow: rgba(34, 211, 238, 0.45);

    /* Brand / accents */
    --primary: #3b82f6;      /* trust blue        */
    --primary-2: #22d3ee;    /* futuristic cyan   */
    --accent: #f59e0b;       /* premium amber CTA */
    --accent-2: #fbbf24;
    --success: #10b981;      /* security green    */
    --danger: #f43f5e;

    /* Text */
    --text: #f8fafc;
    --muted: #94a3b8;
    --muted-2: #64748b;

    /* Type */
    --font-head: 'Fira Code', ui-monospace, 'Cascadia Code', monospace;
    --font-body: 'Fira Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Radii & shadow */
    --r-sm: 8px;
    --r-md: 14px;
    --r-lg: 20px;
    --shadow-1: 0 8px 30px rgba(0, 0, 0, 0.45);
    --shadow-2: 0 20px 60px rgba(0, 0, 0, 0.55);
    --glow-cyan: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 0 24px rgba(34, 211, 238, 0.25);
    --glow-amber: 0 0 22px rgba(245, 158, 11, 0.4);

    /* z-index scale */
    --z-bg: 0;
    --z-content: 10;
    --z-nav: 30;
    --z-overlay: 900;
    --z-popup: 1000;
}

/* ----------------------------------------------------------------- base ---- */
* { box-sizing: border-box; }

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

body {
    font-family: var(--font-body);
    color: var(--text);
    background-color: var(--bg-1);
    background-image:
        radial-gradient(1100px 600px at 85% -10%, rgba(34, 211, 238, 0.12), transparent 60%),
        radial-gradient(900px 600px at 0% 110%, rgba(59, 130, 246, 0.14), transparent 55%),
        linear-gradient(160deg, var(--bg-1) 0%, var(--bg-0) 100%);
    background-attachment: fixed;
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* WebGL "Liquid Light" fluid background (rendered by bg.js) */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
    pointer-events: none;
}

/* faint security "grid" overlay (sits just above the fluid) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(circle at 50% 35%, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(circle at 50% 35%, #000 0%, transparent 78%);
}

body > * { position: relative; z-index: var(--z-content); }

h1, h2, h3, h4 {
    font-family: var(--font-head);
    color: var(--text);
    letter-spacing: -0.01em;
    margin: 0 0 16px;
}

a { color: var(--primary-2); }

::selection { background: rgba(34, 211, 238, 0.3); color: #fff; }

/* custom scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(34, 211, 238, 0.45); background-clip: padding-box; }

/* --------------------------------------------------------- auth layout ---- */
/* shared by login + signup (centered single card) */
.auth-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 28px 16px 56px;
}

/* ------------------------------------------------------------- header ----- */
.header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 26px 20px 14px;
    width: 100%;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, var(--primary), var(--primary-2));
    box-shadow: var(--glow-cyan);
}
.logo svg { width: 22px; height: 22px; color: #04121f; }
/* image logo (sirius-mark.png): fill the 40px box, no gradient/box */
img.logo { background: none; box-shadow: none; border-radius: 0; object-fit: contain; }

.company-name {
    font-family: var(--font-head);
    font-size: clamp(18px, 2.4vw, 26px);
    font-weight: 600;
    margin: 0;
    background: linear-gradient(90deg, #e2e8f0, var(--primary-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* security tagline chip under header */
.trust-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 6px 0 22px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    font-family: var(--font-head);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.badge svg { width: 13px; height: 13px; color: var(--success); }

/* --------------------------------------------------------- glass card ----- */
.glass {
    position: relative;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}

/* smooth return for the pointer-driven 3D tilt (bg.js) */
.glass, .panel {
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease;
    will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
    .glass, .panel { transition: none; transform: none !important; }
}
/* top accent hairline */
.glass::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: linear-gradient(90deg, transparent, var(--primary-2), transparent);
    opacity: 0.7;
}

.login-container {
    width: 100%;
    max-width: 430px;
    padding: 34px 32px 30px;
}
.login-container > h1 {
    text-align: center;
    font-size: 28px;
    margin-bottom: 6px;
}
.auth-sub {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 22px;
}

/* --------------------------------------------------------- form fields ---- */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;
    max-width: 100%;
    padding: 13px 15px;
    margin: 9px 0;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    background: rgba(2, 6, 16, 0.55);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    border-color: var(--border-glow);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
    background: rgba(2, 6, 16, 0.75);
}

select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}
select option { background: var(--surface-solid); color: var(--text); }

label { color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------- buttons ---- */
button,
.btn {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
    color: #04121f;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border: none;
    border-radius: var(--r-sm);
    padding: 13px 22px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.2s ease;
}
button:hover,
.btn:hover {
    box-shadow: var(--glow-cyan);
    filter: brightness(1.05);
}
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible,
a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary-2);
    outline-offset: 2px;
}

/* primary login/submit button: full width, centered */
.login-container button,
.btn-block {
    display: block;
    width: 100%;
    margin: 18px auto 0;
}

/* amber "premium" call to action */
.btn-cta,
.login-container button[type="submit"] {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #2a1a00;
}
.btn-cta:hover { box-shadow: var(--glow-amber); }

/* disabled */
button:disabled,
#submit-btn:disabled {
    background: rgba(148, 163, 184, 0.18) !important;
    color: var(--muted-2) !important;
    cursor: not-allowed;
    box-shadow: none;
    filter: none;
}

/* ghost / nav buttons (top bar) */
.profile-btn,
.logout-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-head);
    font-weight: 500;
    font-size: 14px;
    padding: 10px 16px;
    box-shadow: none;
}
.profile-btn:hover { border-color: var(--border-glow); box-shadow: var(--glow-cyan); filter: none; }
.logout-btn { color: #fecdd3; }
.logout-btn:hover { border-color: var(--danger); box-shadow: 0 0 18px rgba(244, 63, 94, 0.35); filter: none; }

/* ------------------------------------------------------- top app bar ------ */
.company-btn {
    font-family: var(--font-head) !important;
    font-weight: 600;
    background: transparent;
    color: var(--text);
    padding: 10px 4px;
    box-shadow: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.company-btn:hover { filter: brightness(1.1); }
.company-btn::before { display: none; }   /* the logo image replaces the old gradient box */
.product-btn {
    font-family: var(--font-head) !important;
    font-weight: 500 !important;
    color: var(--muted) !important;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 8px 16px;
    border-radius: 999px;
}

/* --------------------------------------------------------- signup links --- */
.signup-link {
    text-align: center;
    margin-top: 18px;
    color: var(--muted);
    font-size: 14px;
}
.signup-link a {
    color: var(--primary-2);
    text-decoration: none;
    font-weight: 600;
}
.signup-link a:hover { text-decoration: underline; }

/* --------------------------------------- password requirement tooltip ----- */
.password-container { position: relative; }
.password-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    width: 260px;
    padding: 12px 14px;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-1);
    font-size: 13px;
    color: var(--muted);
    z-index: var(--z-nav);
}
.password-tooltip::after {
    content: "";
    position: absolute;
    top: -8px; left: 24px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent var(--surface-solid) transparent;
}
.password-tooltip label { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; color: var(--muted); }
.password-tooltip input[type="checkbox"] { width: auto; accent-color: var(--success); margin: 0; }
.password-tooltip input[type="checkbox"]:checked + span,
.password-tooltip label:has(:checked) { color: var(--success); }
small#emailError { display: block; color: var(--danger); font-size: 12px; margin: -4px 0 4px; }

/* --------------------------------------------------- dashboard content ---- */
.container {
    width: min(1100px, 92%);
    margin: 96px auto 40px;     /* clears the fixed top bar */
    padding: 28px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    min-height: 320px;
}
.container::before {
    content: "";
    display: block;
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-2), transparent);
}
.container h2,
.container h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}
.container h3 { font-size: 16px; color: var(--text); }
.container h3::before {
    /* lock glyph */
    content: "";
    width: 16px; height: 16px; flex: none;
    background: var(--primary-2);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.container h2 { font-size: 20px; margin-top: 22px; }

.home-container {
    width: min(1000px, 92%);
    margin: 116px auto 40px;
    padding: 30px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
}
.user-info {
    margin-bottom: 20px;
    padding: 20px 22px;
    background: rgba(2, 6, 16, 0.45);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.user-info p { font-size: 15px; margin: 0 0 10px; color: var(--muted); }
.user-info p strong { color: var(--text); font-weight: 600; }

textarea {
    height: 56px;
    min-height: 56px;
    resize: vertical;
    font-family: var(--font-head);
    width: 100%;
}

/* query controls row */
#table { width: auto; min-width: 240px; display: inline-block; }
.container button { margin-top: 14px; }

/* ------------------------------------------------------- welcome popup ---- */
/* Welcome banner: starts centred, then auto-docks to the top-left via a CSS
   animation. CSS animations fire the moment the element is parsed — including
   after a document.write navigation — so this never depends on JS timing. */
.welcome-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface-solid);
    border: 1px solid var(--border-glow);
    color: var(--text);
    font-family: var(--font-head);
    padding: 16px 26px;
    font-size: 17px;
    border-radius: var(--r-md);
    box-shadow: var(--glow-cyan), var(--shadow-2);
    z-index: var(--z-popup);
    animation: welcomeDock 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.9s both;
}
@keyframes welcomeDock {
    to {
        top: 66px;
        left: 18px;
        right: auto;
        transform: none;
        font-size: 13px;
        padding: 9px 16px;
    }
}
/* legacy class (JS no longer toggles it; kept harmless) */
.welcome-message.move-to-corner {
    top: 66px; left: 18px; right: auto; transform: none; font-size: 13px; padding: 9px 16px;
}

/* ---- DB / cloud status chip (centered, under the top bar) ---------------- */
.db-status-row { display: flex; justify-content: center; }
.db-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 14px; border: 1px solid var(--border-strong);
    border-radius: 999px; color: var(--muted); font-size: .82rem;
    white-space: nowrap; background: var(--surface);
}
.db-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--success); box-shadow: 0 0 8px var(--success);
    transition: background .3s ease, box-shadow .3s ease;
}
.db-dot.offline { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.muted { color: var(--muted); }

/* Blur overlay: auto-dismisses via CSS, no JS required. */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 14, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: var(--z-overlay);
    animation: overlayDismiss 0.7s ease 0.9s both;
}
@keyframes overlayDismiss {
    from { opacity: 1; }
    to   { opacity: 0; visibility: hidden; pointer-events: none; }
}
.hidden { opacity: 0 !important; pointer-events: none !important; visibility: hidden !important; }

/* ----------------------------------------------- Tabulator dark theme ----- */
#resultsTable { margin-top: 18px; }
.results { min-height: 100px; overflow: auto; }

.tabulator {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    font-family: var(--font-body);
}
.tabulator .tabulator-header {
    background: rgba(2, 6, 16, 0.6);
    border-bottom: 1px solid var(--border-strong);
    color: var(--text);
}
.tabulator .tabulator-header .tabulator-col {
    background: transparent;
    border-right: 1px solid var(--border);
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
    font-family: var(--font-head);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary-2);
}
/* Rows — force OPAQUE dark zebra striping so Tabulator's white defaults can
   never leak through and hide the text. Two subtle navy shades + soft off-white
   text = readable and easy on the eyes. */
.tabulator,
.tabulator .tabulator-tableholder { background: transparent; }

.tabulator .tabulator-row {
    background-color: #0e1426 !important;   /* odd rows */
    border-bottom: 1px solid var(--border);
}
.tabulator .tabulator-row.tabulator-row-even {
    background-color: #131c31 !important;   /* even rows (slightly lighter) */
}
.tabulator .tabulator-row.tabulator-selected {
    background-color: rgba(59, 130, 246, 0.22) !important;
}
/* hover: OPAQUE dark teal highlight (never light) so text stays readable */
.tabulator .tabulator-row.tabulator-selectable:hover,
.tabulator .tabulator-row:hover {
    background-color: #14314a !important;
}
.tabulator .tabulator-row.tabulator-selectable:hover .tabulator-cell,
.tabulator .tabulator-row:hover .tabulator-cell {
    background-color: transparent !important;
    color: #eaf6ff !important;
}
/* explicit, readable cell text (soft off-white, not harsh pure white) */
.tabulator .tabulator-row .tabulator-cell {
    color: #e6ecf7 !important;
    background-color: transparent !important;
    border-right: 1px solid var(--border);
    font-size: 13.5px;
}
/* Frozen ("freeze pane") columns — dbname / colname / enable + the Edit/Delete
   actions are pinned left. They must be OPAQUE so the horizontally scrolling
   columns never bleed through underneath them, and they reuse the same zebra
   shades so a frozen cell matches the rest of its row. */
.tabulator .tabulator-header .tabulator-col.tabulator-frozen {
    background: rgba(2, 6, 16, 0.96) !important;
}
.tabulator .tabulator-row .tabulator-cell.tabulator-frozen {
    background-color: #0e1426 !important;        /* odd rows */
}
.tabulator .tabulator-row.tabulator-row-even .tabulator-cell.tabulator-frozen {
    background-color: #131c31 !important;        /* even rows */
}
.tabulator .tabulator-row:hover .tabulator-cell.tabulator-frozen {
    background-color: #14314a !important;        /* match hover highlight */
}
.tabulator .tabulator-row.tabulator-selected .tabulator-cell.tabulator-frozen {
    background-color: #1b2a44 !important;        /* opaque variant of selection */
}
/* Divider line marking the freeze boundary (the right edge of the pinned group). */
.tabulator .tabulator-col.tabulator-frozen.tabulator-frozen-left,
.tabulator .tabulator-cell.tabulator-frozen.tabulator-frozen-left {
    box-shadow: 6px 0 10px -6px rgba(0, 0, 0, 0.6);
    border-right: 1px solid var(--border-strong) !important;
}

#resultsTable > p { color: var(--muted); font-family: var(--font-head); padding: 8px 2px; }
.tabulator .tabulator-footer {
    background: rgba(2, 6, 16, 0.6);
    border-top: 1px solid var(--border-strong);
    color: var(--muted);
}
.tabulator .tabulator-footer .tabulator-page {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
}
.tabulator .tabulator-footer .tabulator-page.active { background: var(--primary); color: #04121f; }

/* ----------------------------------------------------- entrance anim ------ */
/* hidden initial state ONLY applied when JS confirms motion is allowed */
.js-anim [data-reveal] { opacity: 0; }

/* login error states (used by login.html JS) */
.error { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.18) !important; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-6px); }
}
.shake { animation: shake 0.3s ease-in-out; }
#error-message { color: var(--danger); font-weight: 600; text-align: center; margin-top: 8px; }

.flash-message { color: var(--danger); text-align: center; font-size: 14px; }

/* --------------------------------------------------------- responsive ----- */
@media (max-width: 768px) {
    .product-btn { display: none; }
    .welcome-message.move-to-corner { right: 16px; top: 64px; }
    .container, .home-container { margin-top: 120px; }
    #table { width: 100%; min-width: 0; }
}
@media (max-width: 420px) {
    .company-btn { font-size: 14px !important; }
    .profile-btn, .logout-btn { padding: 8px 12px; font-size: 13px; }
}

/* ====================================================== console v2 ======== */
/* vertical stack of glass panels that clears the fixed top bar */
.stack {
    width: min(1140px, 93%);
    margin: 116px auto 48px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* ===================================================== fixed top bar ======= */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: var(--z-nav);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    background: linear-gradient(180deg, rgba(5, 7, 15, 0.72), rgba(5, 7, 15, 0));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.topbar-left   { justify-self: start; min-width: 0; }
.topbar-center { justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.topbar-right  { justify-self: end; display: flex; align-items: center; gap: 10px; }

/* neutralise the legacy absolute positioning when inside the bar */
.topbar .company-btn,
.topbar .product-btn,
.topbar .profile-btn,
.topbar .logout-btn {
    position: static;
    top: auto; left: auto; right: auto;
    transform: none;
    margin: 0;
}
.topbar .company-btn { font-size: clamp(15px, 1.8vw, 19px); }
.topbar-center .company-btn { display: inline-flex; align-items: center; gap: 9px; }
.topbar-center .company-logo { height: 26px; width: 26px; object-fit: contain; flex: 0 0 26px; }
.topbar-center .db-status-row { margin-top: 4px; }
.topbar .product-btn { font-size: 11px !important; padding: 5px 13px; }

@media (max-width: 720px) {
    .topbar { padding: 10px 14px; gap: 8px; }
    .topbar .product-btn { display: none; }
    .topbar .company-btn { font-size: 14px; }
    .topbar-right .profile-btn,
    .topbar-right .logout-btn { padding: 8px 12px; font-size: 13px; }
}

.panel {
    position: relative;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    backdrop-filter: blur(18px) saturate(135%);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
    padding: 24px 26px;
}
.panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: linear-gradient(90deg, transparent, var(--primary-2), transparent);
    opacity: 0.7;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.panel-head h2,
.panel-head h3 { margin: 0; }
.panel-head .panel-icon {
    width: 18px; height: 18px; flex: none;
    color: var(--primary-2);
}
.panel-sub {
    color: var(--muted);
    font-size: 13px;
    margin: 2px 0 18px;
    max-width: 70ch;
}

/* segmented table picker */
.seg {
    display: inline-flex;
    padding: 4px;
    gap: 4px;
    background: rgba(2, 6, 16, 0.5);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.seg button {
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}
.seg button:hover { filter: none; box-shadow: none; color: var(--text); }
.seg button.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #04121f;
    box-shadow: var(--glow-cyan);
}

/* form layout */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    font-family: var(--font-head);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.field label .req { color: var(--accent); margin-left: 2px; }
.field input, .field select { margin: 0; }
.field .hint { font-size: 11px; color: var(--muted-2); }

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.btn-secondary {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: none;
}
.btn-secondary:hover { border-color: var(--border-glow); box-shadow: var(--glow-cyan); filter: none; }

/* query runner row */
.query-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 14px;
}

/* status line above table */
.status-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-head);
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0 0;
    min-height: 18px;
}
.status-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); flex: none; }

/* in-table action buttons (edit / delete) */
.row-edit, .row-del {
    padding: 5px 12px;
    font-size: 12px;
    font-family: var(--font-head);
    border-radius: 7px;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.action-cell { white-space: nowrap; }
.row-edit {
    background: rgba(34, 211, 238, 0.12);
    color: #a5f0fb;
    border: 1px solid rgba(34, 211, 238, 0.38);
    margin-right: 6px;
}
.row-edit:hover { background: var(--primary-2); color: #04121f; box-shadow: var(--glow-cyan); filter: none; }
.row-del {
    background: rgba(244, 63, 94, 0.12);
    color: #fda4af;
    border: 1px solid rgba(244, 63, 94, 0.35);
}
.row-del:hover { background: var(--danger); color: #fff; box-shadow: 0 0 14px rgba(244, 63, 94, 0.45); filter: none; }

.modal-card--wide { width: min(640px, 94vw); }
.modal-card--wide .field-grid { margin-bottom: 4px; }

/* busy state */
.is-busy { opacity: 0.6; pointer-events: none; }
.spinner {
    width: 15px; height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #04121f;
    border-radius: 50%;
    display: inline-block;
    vertical-align: -2px;
    margin-right: 8px;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* toasts */
#toast-wrap {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(380px, 92vw);
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 15px;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--primary-2);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-2);
    color: var(--text);
    font-size: 13.5px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--primary-2); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success svg { color: var(--success); }
.toast.error svg   { color: var(--danger); }
.toast.info svg    { color: var(--primary-2); }

/* confirm modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: grid;
    place-items: center;
    padding: 24px;                 /* keep the card off the viewport edges */
    background: rgba(3, 6, 14, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overscroll-behavior: contain;
}
.modal-card {
    width: min(440px, 92vw);
    max-height: 88vh;              /* tall forms scroll INSIDE the card... */
    overflow-y: auto;              /* ...instead of overflowing the viewport */
    overscroll-behavior: contain;  /* and don't scroll the page behind it */
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    padding: 24px;
}
.modal-card h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.modal-card h3 svg { width: 20px; height: 20px; color: var(--danger); }
.modal-card p { color: var(--muted); font-size: 14px; margin: 0 0 20px; word-break: break-word; }
/* Keep Cancel/Save reachable without scrolling to the very bottom of a long form. */
.modal-card .form-actions {
    position: sticky;
    bottom: -24px;                 /* cancel the card's bottom padding */
    margin: 0 -24px -24px;         /* stretch across the padded card */
    padding: 14px 24px;
    justify-content: flex-end;
    background: var(--surface-solid);
    border-top: 1px solid var(--border);
}

/* Lock the page behind any open modal so the wheel/touch scroll stays in the modal. */
body.modal-open { overflow: hidden; }

/* ---- guided tour (spotlight overlay) ------------------------------------ */
.tour-spot {
    position: fixed;
    z-index: 1201;
    border-radius: 12px;
    /* highlight ring + dim everything else via a huge outer shadow */
    box-shadow: 0 0 0 3px var(--primary-2), 0 0 0 9999px rgba(2, 6, 16, 0.72);
    pointer-events: none;
    transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-tip {
    position: fixed;
    z-index: 1202;
    width: min(340px, 92vw);
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    padding: 16px 18px;
}
.tour-tip h4 { margin: 0 0 6px; font-family: var(--font-head); font-size: 1rem; color: var(--text); }
.tour-tip p  { margin: 0 0 14px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.tour-tip b  { color: var(--text); }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-foot .spacer { flex: 1; }
.tour-foot .btn-secondary, .tour-foot .btn-cta { padding: 8px 14px; font-size: 13px; }
.tour-foot .tour-skip { background: transparent; box-shadow: none; color: var(--muted); padding: 8px 10px; }
.tour-step-count { color: var(--muted-2); font-size: .8rem; }

@media (max-width: 768px) {
    .stack { margin-top: 128px; }
}

/* ============================================ fluidic page transition ===== */
/* A liquid "portal" overlay used to wipe between pages (fx.js). Default state
   is fully open (invisible); .cover collapses the page behind a glowing
   radial veil. The soft gradient edge reads as a fluid sweep. */
#page-fx {
    position: fixed;
    inset: 0;
    z-index: 2000;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 50%,
            #070b18 0%,
            #070b18 52%,
            rgba(34, 211, 238, 0.16) 70%,
            rgba(59, 130, 246, 0.10) 80%,
            #05070f 100%);
    clip-path: circle(0% at 50% 50%);
    transition: clip-path 0.62s cubic-bezier(0.83, 0, 0.17, 1);
    will-change: clip-path;
}
#page-fx.cover { clip-path: circle(150% at 50% 50%); }

@media (prefers-reduced-motion: reduce) {
    #page-fx { display: none !important; }
}

/* honour reduced-motion: kill all transitions/animations */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .js-anim [data-reveal] { opacity: 1 !important; }
}

/* ===================================================== sidebar console ==== */
/* Shared shell used across every authenticated page (landing/profile/releases)
   so the whole site uses one template: a fixed left nav + a content column. */
.console-shell{display:flex;min-height:100vh;position:relative;z-index:1}
.console-sidebar{width:236px;flex:0 0 236px;background:var(--panel-bg);border-right:1px solid var(--border);
  display:flex;flex-direction:column;gap:6px;padding:22px 16px;position:sticky;top:0;height:100vh;z-index:60}
.console-brand{display:flex;align-items:center;gap:11px;font-family:var(--font-head,monospace);font-weight:700;
  font-size:17px;color:var(--text);padding:4px 6px 16px;border-bottom:1px solid var(--border);margin-bottom:8px}
.console-brand .mk{width:36px;height:36px;display:grid;place-items:center;flex:0 0 36px}
.console-brand .mk img{width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 1px 6px rgba(34,211,238,.4))}
.nav-item{display:flex;align-items:center;gap:12px;padding:11px 14px;border-radius:12px;color:var(--muted);
  cursor:pointer;font-size:15px;border:1px solid transparent;transition:.15s;user-select:none;text-decoration:none}
.nav-item svg{width:18px;height:18px;flex:0 0 18px}
.nav-item:hover{background:var(--surface);color:var(--text)}
.nav-item.active{background:rgba(34,211,238,.12);color:var(--text);border-color:var(--border-glow)}
.nav-item.danger:hover{color:#fda4af;border-color:var(--danger)}
.nav-spacer{margin-top:auto}
.console-main{flex:1;min-width:0;display:flex;flex-direction:column}
.console-main>.stack,.console-main .cview{width:100%}
.cview{padding:14px 34px 44px}
#view-console{padding:0}
/* topbar lives in the content column (not fixed over the sidebar) */
.console-main .topbar{position:sticky;top:0;left:auto;right:auto;margin:0;z-index:40;
  grid-template-columns:1fr auto 1fr}   /* center column truly centered in the content area */
.console-main .stack{margin-top:22px}
/* pages wrapped in the console shell: drop the legacy fixed-topbar top offset */
.console-main .home-container, .console-main .container { margin-top: 22px; }
.console-main .home-container { width: min(820px, 94%); }
/* welcome banner fades out instead of docking on top of the sidebar */
@keyframes welcomeDock{to{opacity:0;visibility:hidden;pointer-events:none}}

/* ---- Audit page ---- */
.audit-head{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin:8px 0 18px}
.audit-title{font-family:var(--font-head,monospace);font-size:25px;font-weight:700;color:var(--text)}
.stream-badge{display:inline-flex;align-items:center;gap:8px;padding:7px 14px;border-radius:999px;
  background:var(--surface);border:1px solid var(--border);color:var(--muted);font-size:13px}
.stream-badge .dot{width:8px;height:8px;border-radius:50%;background:var(--muted-2)}
.stream-badge.live .dot{background:#10b981;box-shadow:0 0 0 0 rgba(16,185,129,.6);animation:lpulse 1.8s infinite}
@keyframes lpulse{70%{box-shadow:0 0 0 8px rgba(16,185,129,0)}100%{box-shadow:0 0 0 0 rgba(16,185,129,0)}}
.stat-row{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:18px}
.stat-card{background:var(--panel-bg);border:1px solid var(--border);border-radius:16px;padding:18px 20px}
.stat-card .v{font-family:var(--font-head,monospace);font-size:30px;font-weight:700;color:var(--primary-2)}
.stat-card .l{color:var(--muted);font-size:13px;margin-top:4px}
.audit-tabs{display:flex;gap:4px;border-bottom:1px solid var(--border)}
.audit-tab{padding:11px 18px;cursor:pointer;color:var(--muted);font-size:14px;border-bottom:2px solid transparent;
  font-family:var(--font-head,monospace)}
.audit-tab.active{color:var(--text);border-bottom-color:var(--primary-2)}
.audit-toolbar{display:flex;gap:10px;align-items:center;margin:14px 0}
.audit-toolbar input{flex:1;max-width:340px}
.log-viewer{background:#04060d;border:1px solid var(--border);border-radius:14px;height:440px;overflow:auto;
  font-family:var(--font-head,'Fira Code',monospace);font-size:12.5px;line-height:1.7;padding:14px 16px}
.log-line{white-space:pre-wrap;word-break:break-word;color:var(--text);padding:1px 0}
.log-line .t{color:var(--muted-2)}
.log-line .lv{color:var(--primary-2)}
.log-line.warn{color:#fde68a}
.log-line.warn .lv{color:var(--accent)}
.log-empty{color:var(--muted-2);padding:10px}
@media(max-width:820px){.console-sidebar{display:none}.stat-row{grid-template-columns:1fr}}
