/* ==========================================================================
   SD Engine — Admin Panel Stylesheet
   Neon/cyberpunk dark theme — fully standalone (no CSS framework)
   ========================================================================== */


/* ==========================================================================
   1. @font-face
   ========================================================================== */

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/JetBrainsMono-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/JetBrainsMono-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}


/* ==========================================================================
   2. CSS Reset
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

img {
    max-width: 100%;
    display: block;
}

body {
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}


/* ==========================================================================
   3. CSS Custom Properties (:root)
   ========================================================================== */

:root {
    /* --- Background tiers --- */
    --sd-bg-deep: #06060f;
    --sd-bg-primary: #0a0a1a;
    --sd-bg-panel: #0f1029;
    --sd-bg-panel-hover: #141438;
    --sd-bg-input: #0c0c20;

    /* --- Neon accents --- */
    --sd-cyan: #00e5ff;
    --sd-lime: #39ff14;
    --sd-red: #ff1744;
    --sd-amber: #ffbf00;
    --sd-magenta: #ff00e5;
    --sd-purple: #b388ff;

    /* --- Accent translucents --- */
    --sd-cyan-dim: rgba(0, 229, 255, 0.12);
    --sd-lime-dim: rgba(57, 255, 20, 0.10);
    --sd-red-dim: rgba(255, 23, 68, 0.10);
    --sd-amber-dim: rgba(255, 191, 0, 0.10);
    --sd-magenta-dim: rgba(255, 0, 229, 0.10);

    /* --- Text (contrast ratios vs #06060f) --- */
    --sd-text: #e0e6f0;              /* ~15:1 */
    --sd-text-secondary: #8892b0;    /* ~5.8:1 */
    --sd-text-muted: #7a8299;        /* ~5.0:1 WCAG AA */

    /* --- Borders --- */
    --sd-border: rgba(136, 146, 176, 0.15);
    --sd-border-glow: rgba(0, 229, 255, 0.3);

    /* --- Fonts --- */
    --sd-font-ui: system-ui, -apple-system, 'Segoe UI', sans-serif;
    --sd-font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* --- Glow shadows --- */
    --sd-glow-cyan: 0 0 15px rgba(0, 229, 255, 0.3), 0 0 30px rgba(0, 229, 255, 0.1);
    --sd-glow-lime: 0 0 15px rgba(57, 255, 20, 0.3), 0 0 30px rgba(57, 255, 20, 0.1);
    --sd-glow-red: 0 0 15px rgba(255, 23, 68, 0.3), 0 0 30px rgba(255, 23, 68, 0.1);
    --sd-glow-amber: 0 0 15px rgba(255, 191, 0, 0.3), 0 0 30px rgba(255, 191, 0, 0.1);

    /* --- Pico CSS compatibility aliases --- */
    --pico-muted-color: var(--sd-text-muted);
    --pico-muted-border-color: var(--sd-border);
    --pico-primary: var(--sd-cyan);
    --pico-primary-background: var(--sd-cyan);
    --pico-primary-inverse: var(--sd-bg-primary);
    --pico-secondary-background: var(--sd-cyan-dim);
    --pico-secondary-inverse: var(--sd-cyan);
    --pico-card-background-color: var(--sd-bg-panel);
    --pico-color: var(--sd-text);
}


/* ==========================================================================
   4. Base Styles
   ========================================================================== */

body {
    background: var(--sd-bg-deep);
    color: var(--sd-text);
    font-family: var(--sd-font-ui);
    font-size: 1rem;
    line-height: 1.6;
    padding-top: 60px; /* space for fixed nav */
}

::selection {
    background: var(--sd-cyan-dim);
    color: var(--sd-cyan);
}

:focus-visible {
    outline: 2px solid var(--sd-cyan);
    outline-offset: 2px;
}

a {
    color: var(--sd-cyan);
    text-decoration: none;
    transition: text-shadow 0.2s;
}

a:hover {
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

hr {
    border: none;
    border-top: 1px solid var(--sd-border);
    margin: 1.5rem 0;
}


/* ==========================================================================
   5. Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    color: var(--sd-text);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; font-weight: 600; }
h5 { font-size: 0.95rem; font-weight: 600; }
h6 { font-size: 0.85rem; font-weight: 600; }

p {
    margin-bottom: 1rem;
}

code, kbd {
    font-family: var(--sd-font-mono);
    background: var(--sd-bg-panel);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--sd-cyan);
    font-size: 0.88em;
}

pre {
    background: #000;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: var(--sd-font-mono);
    font-size: 0.85rem;
    color: var(--sd-lime);
    line-height: 1.6;
    margin-bottom: 1rem;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

small {
    color: var(--sd-text-muted);
    font-size: 0.85rem;
}

strong {
    font-weight: 600;
}

ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.25rem;
}


/* ==========================================================================
   6. Layout
   ========================================================================== */

.container {
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1.5rem;
}

main.container {
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}


/* ==========================================================================
   7. Navigation (.top-nav)
   ========================================================================== */

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--sd-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    font-weight: 800;
    font-size: 1.3rem;
    text-decoration: none;
    color: var(--sd-text);
}

.brand:hover {
    text-shadow: none;
}

.brand-accent {
    color: var(--sd-cyan);
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--sd-text-secondary);
    transition: all 0.2s;
}

.nav-links a:hover {
    color: var(--sd-cyan);
    background: var(--sd-cyan-dim);
    text-shadow: none;
}

.nav-links a.nav-active {
    color: var(--sd-cyan);
    border-bottom: 2px solid var(--sd-cyan);
    font-weight: 600;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.nav-logout {
    color: var(--sd-text-muted);
    transition: color 0.2s;
}

.nav-logout:hover {
    color: var(--sd-red);
    text-shadow: none;
}

.sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--sd-cyan);
    font-size: 0.8rem;
    font-weight: 600;
}

.sync-dot {
    width: 8px;
    height: 8px;
    background: var(--sd-cyan);
    border-radius: 50%;
    animation: neon-pulse 1.5s ease-in-out infinite;
}


/* ==========================================================================
   8. Cards (.neon-card)
   ========================================================================== */

.neon-card {
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.neon-card:hover {
    border-color: var(--sd-border-glow);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.05);
}

/* Card variants — colored left border */
.neon-card--healthy {
    border-left: 3px solid var(--sd-lime);
}

.neon-card--error {
    border-left: 3px solid var(--sd-red);
}

.neon-card--stale {
    border-left: 3px solid var(--sd-amber);
}

.neon-card--disabled {
    opacity: 0.6;
}

.neon-card--running {
    border-left: 3px solid var(--sd-cyan);
}


/* ==========================================================================
   9. Forms
   ========================================================================== */

/* --- Input elements --- */

input,
select,
textarea {
    background: var(--sd-bg-input);
    border: 1px solid var(--sd-border);
    color: var(--sd-text);
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--sd-font-ui);
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--sd-cyan);
    box-shadow: 0 0 0 3px var(--sd-cyan-dim);
    outline: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--sd-text-muted);
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2rem;
}

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

/* Textarea inside code-oriented contexts */
textarea.mono,
textarea[name*="credentials"],
textarea[name*="config"],
textarea[name*="json"] {
    font-family: var(--sd-font-mono);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--sd-text-secondary);
    font-weight: 500;
}

fieldset {
    border: none;
    padding: 0;
}

/* Checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin-right: 0.4rem;
    accent-color: var(--sd-cyan);
}

/* --- Buttons --- */

button,
.btn {
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--sd-border);
    background: transparent;
    color: var(--sd-text-secondary);
    font-family: var(--sd-font-ui);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    line-height: 1.4;
}

/* Default submit buttons styled as cyan neon */
button[type="submit"],
.btn-neon {
    border-color: var(--sd-cyan);
    color: var(--sd-cyan);
}

button[type="submit"]:hover,
.btn-neon:hover {
    background: var(--sd-cyan);
    color: var(--sd-bg-primary);
    box-shadow: var(--sd-glow-cyan);
}

/* Pico pattern: a[role="button"] */
a[role="button"] {
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--sd-cyan);
    background: transparent;
    color: var(--sd-cyan);
    font-family: var(--sd-font-ui);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    line-height: 1.4;
}

a[role="button"]:hover {
    background: var(--sd-cyan);
    color: var(--sd-bg-primary);
    box-shadow: var(--sd-glow-cyan);
    text-shadow: none;
}

.btn-danger {
    border-color: var(--sd-red);
    color: var(--sd-red);
}

.btn-danger:hover {
    background: var(--sd-red);
    color: #fff;
    box-shadow: var(--sd-glow-red);
}

.btn-warning {
    border-color: var(--sd-amber);
    color: var(--sd-amber);
}

.btn-warning:hover {
    background: var(--sd-amber);
    color: var(--sd-bg-primary);
    box-shadow: var(--sd-glow-amber);
}

.btn-success {
    border-color: var(--sd-lime);
    color: var(--sd-lime);
}

.btn-success:hover {
    background: var(--sd-lime);
    color: var(--sd-bg-primary);
    box-shadow: var(--sd-glow-lime);
}

.btn-outline {
    border-color: var(--sd-border);
    color: var(--sd-text-secondary);
}

.btn-outline:hover {
    border-color: var(--sd-text);
    color: var(--sd-text);
}

.btn-sm {
    padding: 0.25rem 0.7rem;
    font-size: 0.78rem;
}


/* ==========================================================================
   10. Tables
   ========================================================================== */

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

th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--sd-text-muted);
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--sd-border);
    font-weight: 600;
}

td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(136, 146, 176, 0.08);
    color: var(--sd-text);
    font-size: 0.85rem;
    vertical-align: top;
}

tr:hover td {
    background: rgba(0, 229, 255, 0.03);
}


/* ==========================================================================
   11. Badges
   ========================================================================== */

.status-badge {
    display: inline-block;
    padding: 0.15em 0.6em;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-success {
    background: var(--sd-lime-dim);
    color: var(--sd-lime);
}

.status-error {
    background: var(--sd-red-dim);
    color: var(--sd-red);
}

.status-running {
    background: var(--sd-cyan-dim);
    color: var(--sd-cyan);
    animation: neon-pulse 2s ease-in-out infinite;
}

.type-badge {
    display: inline-block;
    padding: 0.15em 0.6em;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--sd-magenta-dim);
    color: var(--sd-magenta);
}

.auth-badge {
    display: inline-block;
    padding: 0.15em 0.6em;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.auth-ok {
    background: var(--sd-lime-dim);
    color: var(--sd-lime);
}

.auth-warn {
    background: var(--sd-amber-dim);
    color: var(--sd-amber);
}

.auth-error {
    background: var(--sd-red-dim);
    color: var(--sd-red);
}


/* ==========================================================================
   12. Status Dots
   ========================================================================== */

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-dot--healthy {
    background: var(--sd-lime);
    box-shadow: 0 0 6px var(--sd-lime);
}

.status-dot--error {
    background: var(--sd-red);
    box-shadow: 0 0 6px var(--sd-red);
}

.status-dot--running {
    background: var(--sd-cyan);
    box-shadow: 0 0 6px var(--sd-cyan);
    animation: neon-pulse 1.5s ease-in-out infinite;
}

.status-dot--stale {
    background: var(--sd-amber);
}

.status-dot--disabled {
    background: var(--sd-text-muted);
    opacity: 0.5;
}

.status-dot--none {
    border: 1px solid var(--sd-text-muted);
    background: transparent;
}


/* ==========================================================================
   13. Metric Cards
   ========================================================================== */

.summary-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.metric-card {
    flex: 1;
    min-width: 140px;
    padding: 1.25rem 1rem;
    text-align: center;
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.metric-card:hover {
    border-color: var(--sd-border-glow);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.05);
}

.metric-card .stat-value {
    font-family: var(--sd-font-mono);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.metric-card .stat-label {
    font-size: 0.75rem;
    color: var(--sd-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.metric-card--success .stat-value {
    color: var(--sd-lime);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.5);
}

.metric-card--error .stat-value {
    color: var(--sd-red);
    text-shadow: 0 0 8px rgba(255, 23, 68, 0.5);
}

.metric-card--running .stat-value {
    color: var(--sd-cyan);
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.metric-card--warning .stat-value {
    color: var(--sd-amber);
}

/* Legacy alias — templates may use .summary-stat */
.summary-stat {
    flex: 1;
    min-width: 140px;
    padding: 1.25rem 1rem;
    text-align: center;
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-radius: 12px;
}

.summary-stat .stat-value {
    font-family: var(--sd-font-mono);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.summary-stat .stat-label {
    font-size: 0.75rem;
    color: var(--sd-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}


/* ==========================================================================
   14. Sync Bar Chart
   ========================================================================== */

.sync-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 32px;
}

.sync-bar {
    width: 12px;
    min-height: 4px;
    border-radius: 2px 2px 0 0;
    cursor: default;
    transition: box-shadow 0.2s;
}

.sync-bar--success {
    background: var(--sd-lime);
}

.sync-bar--success:hover {
    box-shadow: var(--sd-glow-lime);
}

.sync-bar--error {
    background: var(--sd-red);
}

.sync-bar--error:hover {
    box-shadow: var(--sd-glow-red);
}

.sync-bar--running {
    background: var(--sd-cyan);
}

.sync-bar--running:hover {
    box-shadow: var(--sd-glow-cyan);
}


/* ==========================================================================
   15. Tabs
   ========================================================================== */

.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--sd-border);
    margin-bottom: 1.5rem;
}

.tab-nav button {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--sd-text-muted);
    font-weight: 500;
    transition: all 0.2s;
}

.tab-nav button.tab-active {
    color: var(--sd-cyan);
    border-bottom-color: var(--sd-cyan);
    font-weight: 600;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

.tab-nav button:hover {
    color: var(--sd-text);
}

.tab-content {
    display: none;
}

.tab-content.tab-visible {
    display: block;
}


/* ==========================================================================
   16. Terminal
   ========================================================================== */

.terminal {
    background: #000;
    border: 1px solid rgba(57, 255, 20, 0.15);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-family: var(--sd-font-mono);
    font-size: 0.8rem;
    color: var(--sd-lime);
    line-height: 1.7;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    position: relative;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Scanline overlay */
.terminal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    pointer-events: none;
    border-radius: 8px;
}

.terminal .log-error {
    color: var(--sd-red);
}

.terminal .log-warning {
    color: var(--sd-amber);
}

.terminal .log-success {
    color: var(--sd-lime);
}

.terminal .log-muted {
    color: var(--sd-text-muted);
}


/* ==========================================================================
   17. Toast
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

.toast {
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-left: 3px solid var(--sd-cyan);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--sd-text);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: slide-in 0.3s ease;
}

.toast-success {
    border-left-color: var(--sd-lime);
}

.toast-error {
    border-left-color: var(--sd-red);
}

.toast-fade {
    opacity: 0;
    transition: opacity 0.5s;
}


/* ==========================================================================
   18. Flash Messages
   ========================================================================== */

.flash-message {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sd-lime);
    background: var(--sd-lime-dim);
    color: var(--sd-lime);
}

.flash-message button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.flash-error {
    border-color: var(--sd-red);
    background: var(--sd-red-dim);
    color: var(--sd-red);
}


/* ==========================================================================
   19. Filter Bar
   ========================================================================== */

.filter-bar {
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-bar select,
.filter-bar input {
    max-width: 200px;
}

.search-input {
    max-width: 300px;
}


/* ==========================================================================
   20. Existing component classes (used in templates)
   ========================================================================== */

/* --- Client card --- */
.client-card {
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.client-card:hover {
    border-color: var(--sd-border-glow);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.05);
}

.client-card h3 {
    margin-bottom: 0.5rem;
}

.client-card .meta {
    color: var(--sd-text-muted);
    font-size: 0.9rem;
}

.client-card .connector-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* --- Connector card (with colored left border) --- */
.connector-card {
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-left: 4px solid var(--sd-text-muted);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.connector-card--healthy {
    border-left-color: var(--sd-lime);
}

.connector-card--error {
    border-left-color: var(--sd-red);
}

.connector-card--stale {
    border-left-color: var(--sd-amber);
}

.connector-card--disabled {
    border-left-color: var(--sd-text-muted);
    opacity: 0.6;
}

/* --- Connector row (integrations page) --- */
.connector-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--sd-border);
    flex-wrap: wrap;
}

.connector-row:last-child {
    border-bottom: none;
}

.connector-row .connector-info {
    flex: 1;
    min-width: 200px;
}

.connector-row .connector-meta {
    color: var(--sd-text-muted);
    font-size: 0.85rem;
}

.connector-row .connector-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* --- Client group (details/summary) --- */
.client-group {
    margin-bottom: 1.5rem;
}

.client-group summary {
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.5rem 0;
    color: var(--sd-text);
}

/* --- Actions --- */
.actions,
.action-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-group form {
    margin: 0;
}

/* --- Token display --- */
.token-masked {
    font-family: var(--sd-font-mono);
    background: var(--sd-bg-panel);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    color: var(--sd-cyan);
    font-size: 0.85rem;
}

/* --- Field list (scope/field selectors) --- */
.field-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--sd-border);
    border-radius: 4px;
    padding: 1rem;
}

.field-list label {
    display: block;
    padding: 0.3rem 0;
}

/* --- Log table --- */
.log-table {
    font-size: 0.85rem;
}

.log-table td {
    vertical-align: top;
}

/* --- Details text (truncated log details) --- */
.details-text {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Copy button --- */
.copy-btn {
    display: inline-block;
    background: none;
    border: 1px solid var(--sd-border);
    border-radius: 4px;
    padding: 0.1em 0.4em;
    font-size: 0.75rem;
    cursor: pointer;
    margin-left: 0.25rem;
    vertical-align: middle;
    color: var(--sd-text-muted);
    transition: all 0.2s;
}

.copy-btn:hover {
    border-color: var(--sd-cyan);
    color: var(--sd-cyan);
}

/* --- Cursor table (pipeline state display) --- */
.cursor-table {
    font-size: 0.85rem;
}

.cursor-table td,
.cursor-table th {
    padding: 0.4rem 0.75rem;
}

/* --- Connector detail row (dashboard expand) --- */
.connector-detail-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--sd-border);
}

.connector-detail-row:last-child {
    border-bottom: none;
}

/* --- Expand toggle button --- */
.expand-toggle {
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* --- Edit credentials form (inline expand animation) --- */
.edit-creds-form {
    animation: slideDown 0.2s ease-out;
}

/* --- Threshold colors (monitoring page) --- */
.threshold-green {
    color: var(--sd-lime);
}

.threshold-yellow {
    color: var(--sd-amber);
}

.threshold-red {
    color: var(--sd-red);
}


/* ==========================================================================
   21. Animations
   ========================================================================== */

@keyframes neon-pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 6px currentColor;
    }
    50% {
        opacity: 0.6;
        box-shadow: 0 0 12px currentColor, 0 0 24px rgba(0, 229, 255, 0.3);
    }
}

@keyframes slide-in {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ==========================================================================
   22. Utility Classes
   ========================================================================== */

.text-cyan    { color: var(--sd-cyan); }
.text-lime    { color: var(--sd-lime); }
.text-red     { color: var(--sd-red); }
.text-amber   { color: var(--sd-amber); }
.text-magenta { color: var(--sd-magenta); }
.text-muted   { color: var(--sd-text-muted); }

.mono {
    font-family: var(--sd-font-mono);
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

.hidden {
    display: none;
}


/* ==========================================================================
   23. Article element (Pico styled <article> as cards)
   ========================================================================== */

article {
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

article:hover {
    border-color: var(--sd-border-glow);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.05);
}


/* ==========================================================================
   24. Details/Summary elements
   ========================================================================== */

details {
    background: var(--sd-bg-panel);
    border: 1px solid var(--sd-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--sd-text);
    padding: 0.25rem 0;
}

details[open] summary {
    margin-bottom: 0.75rem;
}


/* ==========================================================================
   25. hgroup (Pico element)
   ========================================================================== */

hgroup {
    margin-bottom: 1rem;
}

hgroup h1,
hgroup h2,
hgroup h3 {
    margin-bottom: 0.25rem;
}

hgroup p {
    color: var(--sd-text-muted);
    margin-bottom: 0;
}


/* ==========================================================================
   26. .grid class (Pico auto-column grid)
   ========================================================================== */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}


/* ==========================================================================
   27. .outline button class (Pico pattern)
   ========================================================================== */

.outline {
    background: transparent;
    border: 1px solid var(--sd-border);
    color: var(--sd-text-secondary);
}

.outline:hover {
    border-color: var(--sd-text);
    color: var(--sd-text);
}


/* ==========================================================================
   28a. Small action buttons
   ========================================================================== */

.btn-sm {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-family: var(--sd-font-mono);
    border: 1px solid var(--sd-border);
    border-radius: 4px;
    background: transparent;
    color: var(--sd-text);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.btn-sm:hover {
    border-color: var(--sd-cyan);
    color: var(--sd-cyan);
}
.btn-sm--danger {
    border-color: var(--sd-red);
    color: var(--sd-red);
}
.btn-sm--danger:hover {
    background: var(--sd-red);
    color: var(--sd-bg);
}

/* ==========================================================================
   28. Responsive (@media max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    .top-nav {
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .top-nav .nav-left {
        width: 100%;
    }

    .top-nav .nav-links {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .summary-bar {
        flex-direction: column;
    }

    .metric-card {
        min-width: auto;
    }

    .connector-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .grid-2,
    .grid-3,
    .grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar select,
    .filter-bar input {
        max-width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body {
        padding-top: 120px;
    }
}


/* ==========================================================================
   29. Print (@media print)
   ========================================================================== */

@media print {
    body {
        background: white;
        color: black;
        padding-top: 0;
    }

    .top-nav,
    .toast-container,
    .sync-indicator,
    button,
    .btn,
    form,
    .copy-btn {
        display: none;
    }

    .neon-card,
    article,
    details {
        border-color: #ccc;
        background: white;
    }

    .btn-sm { font-size: 0.75rem; }
    .terminal {
        background: #f5f5f5;
        color: #333;
        border-color: #ccc;
    }

    * {
        text-shadow: none !important;
        box-shadow: none !important;
    }

    table {
        border-collapse: collapse;
    }

    td, th {
        border: 1px solid #ccc;
    }
}
