/* ─── Spadzetto Dashboard — Global Styles ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0d0e17;
    --bg2:          #0b0c14;
    --surface:      #13141f;
    --surface2:     #1a1b2e;
    --surface3:     #1e2035;
    --border:       #1e2035;
    --border2:      rgba(255,255,255,0.06);
    --text:         #f1f5f9;
    --text-muted:   #64748b;
    --text-dim:     #94a3b8;
    --accent:       #8b5cf6;
    --accent2:      #7c3aed;
    --accent3:      #6d28d9;
    --accent-glow:  rgba(139,92,246,0.25);
    --gradient-btn: linear-gradient(135deg, #7c3aed, #4f46e5);
    --gradient-stop: linear-gradient(135deg, #dc2626, #b91c1c);
    --gradient-go:  linear-gradient(135deg, #16a34a, #15803d);
    --danger:       #ef4444;
    --success:      #22c55e;
    --warn:         #f59e0b;
    --info:         #3b82f6;
    --good:         #22c55e;
    --radius-card:  12px;
    --radius-input: 8px;
    --radius-btn:   6px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg:    0 8px 40px rgba(0,0,0,0.6);
    --sidebar-w:    240px;
    --topbar-h:     60px;
    --transition:   0.2s ease;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.sidebar-logo .logo-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sidebar-logo .logo-sub {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-status {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    position: relative;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(34,197,94,0.6);
    animation: pulse-green 2s infinite;
}

.status-dot.offline {
    background: var(--danger);
}

.status-dot.error {
    background: var(--warn);
    box-shadow: 0 0 0 0 rgba(245,158,11,0.6);
    animation: pulse-yellow 2s infinite;
}

@keyframes pulse-green {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
    70%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

@keyframes pulse-yellow {
    0%   { box-shadow: 0 0 0 0 rgba(245,158,11,0.6); }
    70%  { box-shadow: 0 0 0 6px rgba(245,158,11,0); }
    100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
}

.sidebar nav {
    flex: 1;
    padding: 8px 0;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
    position: relative;
}

.sidebar nav a svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.sidebar nav a:hover {
    color: var(--text);
    background: rgba(139,92,246,0.08);
    border-left-color: rgba(139,92,246,0.4);
}

.sidebar nav a:hover svg { opacity: 1; }

.sidebar nav a.active {
    color: var(--text);
    background: rgba(139,92,246,0.15);
    border-left-color: var(--accent);
}

.sidebar nav a.active svg { opacity: 1; color: var(--accent); }

.sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 8px 0;
}

.sidebar-bottom .sidebar-meta {
    padding: 8px 20px 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-bottom .sidebar-version {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ─── Hamburger (mobile) ─────────────────────────────────────────────────────── */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 99;
}

/* ─── Main layout ────────────────────────────────────────────────────────────── */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 6px 14px 6px 6px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ─── Content area ───────────────────────────────────────────────────────────── */
.content {
    padding: 28px 24px;
    flex: 1;
    max-width: 1400px;
    width: 100%;
}

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 20px 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card:last-child { margin-bottom: 0; }

.card-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

/* ─── Stats grid ─────────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    border-color: rgba(139,92,246,0.3);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(139,92,246,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.stat-body { flex: 1; min-width: 0; }

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

/* ─── Sekcja nagłówek ────────────────────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
    appearance: none;
}

input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    cursor: pointer;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.field-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.field-row .form-group {
    flex: 1;
    min-width: 180px;
}

/* ─── Toggle switch ──────────────────────────────────────────────────────────── */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface3);
    border-radius: 24px;
    cursor: pointer;
    transition: background var(--transition);
    border: 1px solid var(--border);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: rgba(139,92,246,0.3);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: var(--accent);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
    font-family: inherit;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn:hover:not(:disabled) {
    opacity: 0.88;
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary {
    background: var(--gradient-btn);
    color: #fff;
    box-shadow: 0 2px 12px rgba(124,58,237,0.35);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(124,58,237,0.5);
}

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239,68,68,0.25);
}

.btn-success {
    background: rgba(34,197,94,0.15);
    color: var(--success);
    border: 1px solid rgba(34,197,94,0.3);
}

.btn-success:hover:not(:disabled) {
    background: rgba(34,197,94,0.25);
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface3);
    color: var(--text);
}

.btn-start-big {
    background: var(--gradient-go);
    color: #fff;
    padding: 16px 40px;
    font-size: 1.05rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(22,163,74,0.4);
}

.btn-start-big:hover:not(:disabled) {
    box-shadow: 0 6px 28px rgba(22,163,74,0.55);
}

.btn-stop-big {
    background: var(--gradient-stop);
    color: #fff;
    padding: 16px 40px;
    font-size: 1.05rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(220,38,38,0.4);
}

.btn-stop-big:hover:not(:disabled) {
    box-shadow: 0 6px 28px rgba(220,38,38,0.55);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    transition: all 0.28s ease;
    pointer-events: auto;
    max-width: 360px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.success::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.toast.error   { border-color: rgba(239,68,68,0.4); }
.toast.error::before   { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.toast.info    { border-color: rgba(59,130,246,0.4); }
.toast.info::before    { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--info); flex-shrink: 0; }
.toast.warn    { border-color: rgba(245,158,11,0.4); }
.toast.warn::before    { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }

/* ─── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td {
    background: rgba(139,92,246,0.04);
}

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: #f87171; border: 1px solid rgba(239,68,68,0.25); }
.badge-info    { background: rgba(59,130,246,0.15);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.25); }
.badge-warn    { background: rgba(245,158,11,0.15);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.badge-purple  { background: rgba(139,92,246,0.15);  color: #a78bfa; border: 1px solid rgba(139,92,246,0.25); }

/* ─── Perm tag ───────────────────────────────────────────────────────────────── */
.perm-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'Consolas', monospace;
    margin: 1px;
}

.perm-write { background: rgba(139,92,246,0.2); color: #a78bfa; }
.perm-read  { background: rgba(59,130,246,0.15); color: #60a5fa; }
.perm-none  { background: rgba(255,255,255,0.05); color: var(--text-muted); }

/* ─── Avatar kółko ───────────────────────────────────────────────────────────── */
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ─── Logi terminal ──────────────────────────────────────────────────────────── */
#log-container {
    background: #08090f;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    height: 520px;
    overflow-y: auto;
    padding: 14px 16px;
    font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
}

#log-container::-webkit-scrollbar { width: 6px; }
#log-container::-webkit-scrollbar-track { background: transparent; }
#log-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.log-entry {
    display: flex;
    gap: 10px;
    padding: 2px 0;
    border-radius: 3px;
}

.log-entry:hover { background: rgba(255,255,255,0.03); }

.log-entry .ts {
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 0.78rem;
    min-width: 72px;
}

.log-level {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.72rem;
    min-width: 38px;
    text-transform: uppercase;
    padding: 1px 0;
}

.log-entry.info  .log-level { color: var(--info); }
.log-entry.warn  .log-level { color: var(--warn); }
.log-entry.error .log-level { color: var(--danger); }
.log-entry.good  .log-level { color: var(--success); }
.log-entry.info  .msg { color: #94a3b8; }
.log-entry.warn  .msg { color: #fcd34d; }
.log-entry.error .msg { color: #fca5a5; }
.log-entry.good  .msg { color: #86efac; }

.log-entry .msg {
    flex: 1;
    word-break: break-word;
}

/* ─── Pill filters ───────────────────────────────────────────────────────────── */
.pill-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.pill {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text-muted);
    transition: all var(--transition);
    user-select: none;
}

.pill:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pill.active {
    background: rgba(139,92,246,0.2);
    border-color: var(--accent);
    color: var(--accent);
}

.pill.pill-info.active  { background: rgba(59,130,246,0.2); border-color: var(--info); color: var(--info); }
.pill.pill-warn.active  { background: rgba(245,158,11,0.2); border-color: var(--warn); color: var(--warn); }
.pill.pill-error.active { background: rgba(239,68,68,0.2);  border-color: var(--danger); color: var(--danger); }
.pill.pill-good.active  { background: rgba(34,197,94,0.2);  border-color: var(--success); color: var(--success); }

/* ─── Config accordion ───────────────────────────────────────────────────────── */
.config-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    margin-bottom: 12px;
    overflow: hidden;
}

.config-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.config-section-header:hover {
    background: rgba(255,255,255,0.03);
}

.config-section-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.config-section-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(139,92,246,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.config-chevron {
    color: var(--text-muted);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.config-section.open .config-chevron {
    transform: rotate(180deg);
}

.config-section-body {
    display: none;
    padding: 0 18px 18px;
    border-top: 1px solid var(--border);
}

.config-section.open .config-section-body {
    display: block;
}

/* ─── Cennik editor panel ────────────────────────────────────────────────────── */
.cennik-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.cennik-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform var(--transition), border-color var(--transition);
    cursor: default;
}

.cennik-card:hover {
    transform: translateY(-2px);
    border-color: rgba(139,92,246,0.3);
}

.cennik-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.cennik-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(139,92,246,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.cennik-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.cennik-card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cennik-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ─── Sliding panel (cennik editor) ─────────────────────────────────────────── */
.slide-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    backdrop-filter: blur(2px);
}

.slide-panel-overlay.active {
    display: flex;
    justify-content: flex-end;
}

.slide-panel {
    width: 100%;
    max-width: 600px;
    height: 100%;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 40px rgba(0,0,0,0.5);
    animation: slide-in 0.28s ease;
}

@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

.slide-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.slide-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.slide-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
}

.slide-panel-body::-webkit-scrollbar { width: 6px; }
.slide-panel-body::-webkit-scrollbar-track { background: transparent; }
.slide-panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.slide-panel-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.embed-preview {
    border-radius: 6px;
    padding: 12px 14px;
    border-left: 4px solid var(--accent);
    background: rgba(139,92,246,0.08);
    margin-bottom: 16px;
    font-size: 0.82rem;
}

.embed-preview-title {
    font-weight: 700;
    margin-bottom: 4px;
}

/* ─── Bot control ────────────────────────────────────────────────────────────── */
.bot-status-hub {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
    text-align: center;
}

.bot-pulse-ring {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(100,116,139,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    position: relative;
}

.bot-pulse-ring.online {
    background: rgba(34,197,94,0.1);
    box-shadow: 0 0 0 0 rgba(34,197,94,0.4);
    animation: ring-pulse 2.5s infinite;
}

.bot-pulse-ring.offline {
    background: rgba(239,68,68,0.1);
}

.bot-pulse-ring.error {
    background: rgba(245,158,11,0.1);
    box-shadow: 0 0 0 0 rgba(245,158,11,0.4);
    animation: ring-pulse-warn 2.5s infinite;
}

@keyframes ring-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    70%  { box-shadow: 0 0 0 20px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

@keyframes ring-pulse-warn {
    0%   { box-shadow: 0 0 0 0 rgba(245,158,11,0.4); }
    70%  { box-shadow: 0 0 0 20px rgba(245,158,11,0); }
    100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
}

.bot-status-icon {
    color: var(--text-muted);
}

.bot-pulse-ring.online .bot-status-icon  { color: var(--success); }
.bot-pulse-ring.offline .bot-status-icon { color: var(--danger); }
.bot-pulse-ring.error .bot-status-icon   { color: var(--warn); }

.bot-status-text {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.bot-status-text.online  { color: var(--success); }
.bot-status-text.offline { color: var(--danger); }
.bot-status-text.error   { color: var(--warn); }

.bot-status-msg {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.control-btns {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(3px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-card);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.22s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

@keyframes modal-in {
    from { transform: scale(0.95) translateY(-10px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--text); }

/* ─── Error/warn banner ──────────────────────────────────────────────────────── */
.banner {
    border-radius: var(--radius-card);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.banner-warn {
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.3);
    color: #fbbf24;
}

.banner-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: #f87171;
}

/* ─── Mini log feed (botcontrol) ─────────────────────────────────────────────── */
#mini-log-feed {
    background: #08090f;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    height: 240px;
    overflow-y: auto;
    padding: 12px 14px;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.55;
}

#mini-log-feed::-webkit-scrollbar { width: 4px; }
#mini-log-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Perm toggle (3-state) ──────────────────────────────────────────────────── */
.perm-group {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.perm-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.perm-selector {
    display: flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.perm-opt {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--surface2);
    color: var(--text-muted);
    transition: all var(--transition);
    user-select: none;
}

.perm-opt:hover { color: var(--text); background: var(--surface3); }
.perm-opt.sel-none  { background: rgba(255,255,255,0.05); color: var(--text-dim); }
.perm-opt.sel-read  { background: rgba(59,130,246,0.2);   color: #60a5fa; }
.perm-opt.sel-write { background: rgba(139,92,246,0.25);  color: #a78bfa; }

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

/* ─── Misc ───────────────────────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }

.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }

/* ─── Scrollbar global ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Readonly overlay ───────────────────────────────────────────────────────── */
.readonly-mode input,
.readonly-mode select,
.readonly-mode textarea {
    opacity: 0.55;
    pointer-events: none;
}

.readonly-mode .btn-primary { display: none; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.active {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

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

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

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

    .slide-panel {
        max-width: 100%;
    }

    .field-row { flex-direction: column; }
    .field-row .form-group { min-width: unset; }
}

@media (max-width: 480px) {
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .control-btns { flex-direction: column; align-items: center; }
}
