:root {
    --cockpit-bg: #f6f8fb;
    --cockpit-sidebar-bg: #ffffff;
    --cockpit-surface: #ffffff;
    --cockpit-border: #e9edf3;
    --cockpit-primary: #2563eb;
    --cockpit-primary-soft: #eff4ff;
    --cockpit-muted: #6b7280;
    --cockpit-heading: #0f172a;
    --cockpit-text: #1f2937;
    --cockpit-nav-link: #374151;
    --cockpit-placeholder-bg: #fbfcfe;
    --cockpit-placeholder-border: #d6dde7;
    --cockpit-auth-glow-1: #e7efff;
    --cockpit-auth-glow-2: #eef2ff;
    --cockpit-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
}

[data-bs-theme="dark"] {
    --cockpit-bg: #0b1120;
    --cockpit-sidebar-bg: #111827;
    --cockpit-surface: #111827;
    --cockpit-border: #1f2a3b;
    --cockpit-primary: #3b82f6;
    --cockpit-primary-soft: #1d2b45;
    --cockpit-muted: #94a3b8;
    --cockpit-heading: #f1f5f9;
    --cockpit-text: #cbd5e1;
    --cockpit-nav-link: #cbd5e1;
    --cockpit-placeholder-bg: #0e1626;
    --cockpit-placeholder-border: #2a3850;
    --cockpit-auth-glow-1: #16233f;
    --cockpit-auth-glow-2: #131c33;
    --cockpit-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
}

body {
    background-color: var(--cockpit-bg) !important;
    color: var(--cockpit-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- App shell ---------- */
.cockpit {
    display: flex;
    min-height: 100vh;
}

.cockpit-sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--cockpit-sidebar-bg);
    border-right: 1px solid var(--cockpit-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.cockpit-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.35rem;
    border-bottom: 1px solid var(--cockpit-border);
}

.cockpit-brand a {
    display: inline-flex;
}

.cockpit-brand-logo {
    max-width: 100%;
    max-height: 132px;
    width: auto;
    height: auto;
}

.cockpit-brand .cockpit-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--cockpit-primary);
    color: #fff;
    font-size: 1.05rem;
}

.cockpit-nav {
    padding: 1rem .85rem;
    overflow-y: auto;
    flex: 1;
}

.cockpit-nav .nav-section {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--cockpit-muted);
    padding: .75rem .65rem .35rem;
    font-weight: 600;
}

.cockpit-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .58rem .65rem;
    margin-bottom: .15rem;
    border-radius: 9px;
    color: var(--cockpit-nav-link);
    font-weight: 500;
    transition: background-color .12s ease, color .12s ease;
}

.cockpit-nav .nav-link i {
    font-size: 1.05rem;
    color: var(--cockpit-muted);
}

.cockpit-nav .nav-link:hover {
    background: var(--cockpit-bg);
    color: var(--cockpit-heading);
}

.cockpit-nav .nav-link.active {
    background: var(--cockpit-primary-soft);
    color: var(--cockpit-primary);
}

.cockpit-nav .nav-link.active i {
    color: var(--cockpit-primary);
}

/* ---------- Main area ---------- */
.cockpit-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cockpit-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.75rem;
    background: var(--cockpit-surface);
    border-bottom: 1px solid var(--cockpit-border);
}

.cockpit-topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cockpit-heading);
    margin: 0;
}

.cockpit-content {
    padding: 1.75rem;
}

/* ---------- Cards ---------- */
.cockpit-card {
    background: var(--cockpit-surface);
    border: 1px solid var(--cockpit-border);
    border-radius: 14px;
    box-shadow: var(--cockpit-shadow);
    height: 100%;
}

.cockpit-card .card-body {
    padding: 1.25rem 1.35rem;
}

.cockpit-stat .label {
    color: var(--cockpit-muted);
    font-size: .85rem;
    font-weight: 500;
}

.cockpit-stat .value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--cockpit-heading);
}

.cockpit-placeholder {
    border: 1px dashed var(--cockpit-placeholder-border);
    border-radius: 12px;
    background: var(--cockpit-placeholder-bg);
    color: var(--cockpit-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    text-align: center;
}

.cockpit-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--cockpit-primary-soft);
    color: var(--cockpit-primary);
    font-size: 1.2rem;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cockpit-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .9rem;
}

/* ---------- Auth screens ---------- */
.auth-wrapper {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 500px at 100% -10%, var(--cockpit-auth-glow-1) 0, transparent 60%),
        radial-gradient(900px 500px at -10% 110%, var(--cockpit-auth-glow-2) 0, transparent 55%),
        var(--cockpit-bg);
}

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--cockpit-surface);
    border: 1px solid var(--cockpit-border);
    border-radius: 18px;
    box-shadow: var(--cockpit-shadow);
    padding: 2.25rem 2rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.75rem;
}

.auth-logo {
    max-width: 320px;
    width: 100%;
    height: auto;
}

.auth-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--cockpit-heading);
}

.auth-card .form-label {
    font-weight: 600;
    font-size: .9rem;
    color: var(--cockpit-nav-link);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--cockpit-border);
    background: var(--cockpit-surface);
    color: var(--cockpit-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: color .12s ease, border-color .12s ease;
}

.theme-toggle:hover {
    color: var(--cockpit-primary);
    border-color: var(--cockpit-primary);
}

.auth-theme-toggle {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
}

@media (max-width: 768px) {
    .cockpit-sidebar {
        display: none;
    }
}

/* ---------- Uniwersalne kafelki dashboardu (async) ---------- */
.cockpit-widget__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: 1rem;
}

.cockpit-widget__controls {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.cockpit-widget__interval {
    width: auto;
    font-size: .78rem;
    padding-top: .15rem;
    padding-bottom: .15rem;
}

.cockpit-widget__refresh {
    line-height: 1;
}

.cockpit-widget.is-loading .cockpit-widget__refresh i {
    display: inline-block;
    animation: cockpit-spin .8s linear infinite;
}

@keyframes cockpit-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cockpit-widget.is-loading .cockpit-widget__refresh i {
        animation: none;
    }
}

.cockpit-widget__loading,
.cockpit-widget__error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 140px;
    color: var(--cockpit-muted);
    font-size: .85rem;
}

.cockpit-widget__error {
    color: #b45309;
}

/* ---------- Kafelek LiveOps ---------- */
.lo-widget-list {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.lo-widget-item {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    padding: .7rem .8rem;
    border: 1px solid var(--cockpit-border);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, background .15s;
}

.lo-widget-item:hover {
    border-color: var(--cockpit-primary);
    background: var(--cockpit-primary-soft);
}

.lo-widget-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.lo-widget-item__title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--cockpit-heading);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lo-widget-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .9rem;
    font-size: .76rem;
    color: var(--cockpit-muted);
}

.lo-widget-item__meta strong {
    color: var(--cockpit-heading);
    font-weight: 700;
}

.lo-widget-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    color: var(--cockpit-muted);
    font-size: .85rem;
    text-align: center;
}

/* ---------- Status liveOpsa (współdzielone: lista + kafelek) ---------- */
.lo-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 3px 10px;
    border-radius: 99px;
    white-space: nowrap;
    border: 1px solid transparent;
}

.lo-pill--draft     { background: rgba(100, 116, 139, .12); color: #64748b; border-color: rgba(100, 116, 139, .30); }
.lo-pill--scheduled { background: rgba(37, 99, 235, .10);   color: #2563eb; border-color: rgba(37, 99, 235, .30); }
.lo-pill--ongoing   { background: rgba(16, 185, 129, .12);  color: #059669; border-color: rgba(16, 185, 129, .30); }
.lo-pill--finished  { background: rgba(20, 184, 166, .12);  color: #0d9488; border-color: rgba(20, 184, 166, .30); }
.lo-pill--archived  { background: rgba(139, 92, 246, .10);  color: #7c3aed; border-color: rgba(139, 92, 246, .30); }
.lo-pill--paused    { background: rgba(245, 158, 11, .12);  color: #b45309; border-color: rgba(245, 158, 11, .30); }

[data-bs-theme="dark"] .lo-pill--draft     { color: #cbd5e1; }
[data-bs-theme="dark"] .lo-pill--scheduled { color: #93c5fd; }
[data-bs-theme="dark"] .lo-pill--ongoing   { color: #6ee7b7; }
[data-bs-theme="dark"] .lo-pill--finished  { color: #5eead4; }
[data-bs-theme="dark"] .lo-pill--archived  { color: #c4b5fd; }
[data-bs-theme="dark"] .lo-pill--paused    { color: #fcd34d; }
