:root {
    --bg: #e8eeff;
    --bg2: #f4f7ff;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-d: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.12);
    --success: #059669;
    --danger: #dc2626;
    --border: #e2e8f0;
    --shadow: 0 8px 32px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.1);
    --radius: 18px;
    --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
    --nav-h: 56px;
    --bottom-h: 62px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.15), transparent),
        linear-gradient(180deg, var(--bg) 0%, var(--bg2) 300px);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

body.app-body { padding-bottom: 0; }
body.no-nav { padding-bottom: 0 !important; }

/* ── Site Header ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.3);
    backdrop-filter: blur(12px);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
}
.brand-badge {
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.brand-text strong { display: block; font-size: 0.95rem; line-height: 1.2; }
.brand-text small { font-size: 0.65rem; opacity: 0.8; font-weight: 400; }

.header-nav { display: flex; align-items: center; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 6px;
    text-decoration: none;
    color: rgba(255,255,255,0.85);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    background: none;
    font-family: var(--font);
    cursor: pointer;
    white-space: nowrap;
}
/* ── Lucide icons ── */
.ic, .ic-sm, .ic-xs, .ic-lg, .ic-xl {
    display: inline-block;
    vertical-align: middle;
    stroke-width: 2;
    flex-shrink: 0;
}
.ic { width: 18px; height: 18px; }
.ic-sm { width: 16px; height: 16px; }
.ic-xs { width: 14px; height: 14px; }
.ic-lg { width: 36px; height: 36px; stroke-width: 1.5; }
.ic-xl { width: 48px; height: 48px; stroke-width: 1.5; }
.ic-inline { margin-left: 4px; }
.tab .ic-sm, .btn .ic-sm, .nav-item .ic { margin-left: 0; }
.brand-badge .ic { color: #fff; }
.logo-icon .ic-xl { color: var(--primary); }
.empty-icon .ic-xl { color: var(--muted); }
.header-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
}
.header-menu-btn .ic { color: #fff; }
.mtab .ic { width: 20px; height: 20px; margin-bottom: 2px; }
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
}
.nav-logout-form { display: inline; margin: 0; }
.nav-logout:hover { background: rgba(239,68,68,0.3) !important; }


/* ── Mobile tabs ── */
.mobile-tabs { display: none; }

/* ── Action buttons in page ── */
.action-card {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.panel-elevated {
    box-shadow: var(--shadow-lg);
    border-color: rgba(37, 99, 235, 0.08);
}
.btn-action { flex: 1; min-width: 120px; padding: 12px 16px; font-size: 0.9rem; }
.head-info { flex: 1; }

/* ── Page ── */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 24px;
}
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 1.45rem; font-weight: 700; line-height: 1.3; }
.page-head.compact h1 { font-size: 1.2rem; }
.muted { color: var(--muted); font-size: 0.875rem; }
.back {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.8rem;
    display: inline-block;
    margin-bottom: 4px;
}

/* ── Quota ── */
.quota-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.quota-project { margin-bottom: 16px; }
.quota-over {
    border-color: #fecaca;
    background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
}
.quota-over .progress-bar { background: linear-gradient(90deg, #ef4444, #f87171) !important; }
.quota-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
}
.progress {
    height: 8px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    border-radius: 99px;
    min-width: 2%;
    transition: width 0.4s ease;
}
.progress-bar.progress-warn {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.progress-sm { height: 5px; margin-top: 4px; }
.room-quota { margin-bottom: 12px; }
.room-quota .quota-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0;
}

/* ── Room cards ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
}
.room-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.room-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(37, 99, 235, 0.15);
}
.room-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.room-top h3 { font-size: 1rem; font-weight: 700; }
.room-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 14px;
}
.room-stats small {
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
    margin-bottom: 2px;
}
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}
.pill-running { background: #d1fae5; color: #065f46; }
.pill-stopped { background: #f1f5f9; color: #64748b; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1.5px solid var(--danger);
}
.btn-soft { background: #f1f5f9; color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ── Panels / split ── */
.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    min-width: 0;
}
.split > .panel {
    min-width: 0;
    overflow: hidden;
}
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.panel-title h3 { font-size: 0.95rem; }

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 14px;
}
.tab {
    flex: 1;
    padding: 8px 6px;
    border: none;
    background: transparent;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
}
.tab.active { background: #eff6ff; color: var(--primary); }
.tab-pane { display: none; min-width: 0; overflow: hidden; }
.tab-pane.active { display: block; }

.toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    align-items: center;
}
.toolbar select,
.input-compact,
.form-stack input,
.form-stack input[type="file"] {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font);
    font-size: 0.875rem;
}
.toolbar select { flex: 1; min-width: 120px; }
.form-stack input,
.form-stack input[type="file"] { width: 100%; }
.input-compact { width: 90px; }

.editor {
    width: 100%;
    min-height: 300px;
    padding: 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    background: #fafbfc;
    direction: ltr;
    text-align: left;
    resize: vertical;
    display: block;
}
.editor-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 420px;
    max-height: 420px;
    border-radius: 14px;
    overflow: hidden;
    border: 1.5px solid #334155;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    contain: layout style;
    isolation: isolate;
}
.editor-wrap .CodeMirror {
    height: 420px !important;
    max-height: 420px !important;
    width: 100% !important;
    max-width: 100% !important;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    border-radius: 14px;
    direction: ltr;
    text-align: left;
}
.editor-wrap .CodeMirror-scroll {
    overflow: auto !important;
    max-height: 420px !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}
.editor-wrap .CodeMirror-vscrollbar,
.editor-wrap .CodeMirror-hscrollbar {
    z-index: 2;
}
.editor-wrap .CodeMirror-gutters {
    border-radius: 14px 0 0 14px;
}
.editor-hint { display: block; margin-top: 8px; }

.form-stack label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin: 10px 0 6px;
}
.hint { font-size: 0.75rem; color: var(--muted); margin: 6px 0 12px; }

.upload-zone {
    text-align: center;
    padding: 28px 16px;
    border: 2px dashed var(--border);
    border-radius: 14px;
    margin-bottom: 14px;
    background: #f8fafc;
}
.upload-zone .ic-lg { color: var(--primary); margin-bottom: 10px; }
.upload-zone p { font-size: 0.9rem; margin-bottom: 4px; }

.pkg-installed { margin-bottom: 4px; }
.pkg-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.pkg-head h4 {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pkg-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    background: #fafbfc;
}
.pkg-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 0.8rem;
    border-bottom: 1px solid #f1f5f9;
    direction: ltr;
    text-align: left;
}
.pkg-item:last-child { border-bottom: none; }
.pkg-name { flex: 1; font-weight: 600; font-family: Consolas, monospace; }
.pkg-ver { color: var(--muted); font-size: 0.75rem; }

.install-status {
    text-align: center;
    color: var(--primary);
    font-weight: 600;
    padding: 10px;
    font-size: 0.875rem;
}

.files-mini {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.files-mini h4 { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.files-mini ul { list-style: none; }
.files-mini li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.8rem;
    border-bottom: 1px solid #f1f5f9;
    gap: 8px;
}
.files-mini li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Logs ── */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.log-header h3 {
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.log-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ltab {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}
.ltab.active {
    background: #eff6ff;
    color: var(--primary);
    border-color: #bfdbfe;
}
.logs {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    height: 360px;
    overflow-y: auto;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.65;
    direction: ltr;
    text-align: left;
    -webkit-overflow-scrolling: touch;
}
.log-panel .logs { height: 420px; }
.logs-full .logs { height: 65vh; min-height: 300px; }
.log-line {
    padding: 3px 0;
    word-break: break-word;
    display: flex;
    flex-wrap: wrap;
    gap: 0 6px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.lt { color: #64748b; flex-shrink: 0; }
.ll {
    flex-shrink: 0;
    font-weight: 700;
    min-width: 42px;
    padding: 0 4px;
    border-radius: 4px;
    font-size: 0.68rem;
    text-align: center;
}
.lp { color: #94a3b8; flex-shrink: 0; }
.lm { flex: 1; min-width: 0; }
.log-info .ll { background: rgba(96,165,250,0.15); color: #60a5fa; }
.log-error .ll { background: rgba(248,113,113,0.15); color: #f87171; }
.log-warn .ll, .log-stderr .ll { background: rgba(251,191,36,0.15); color: #fbbf24; }
.log-stdout .ll { background: rgba(74,222,128,0.15); color: #4ade80; }
.log-pip .ll { background: rgba(192,132,252,0.15); color: #c084fc; }
.log-pip .lm { color: #e9d5ff; }

/* ── Status ── */
.status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.timer { font-size: 0.85rem; color: var(--primary); font-weight: 600; }

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, #dbeafe 0%, #eef2ff 50%, #f8fafc 100%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border-radius: 24px;
    padding: 36px 28px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(37, 99, 235, 0.1);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { font-size: 2.8rem; line-height: 1; }
.login-logo h1 { font-size: 1.45rem; margin-top: 10px; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.login-form label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
}
.login-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: var(--font);
    font-size: 1rem;
    margin-bottom: 14px;
    display: block;
}
.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.login-footer {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.badge {
    background: #eff6ff;
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
}
.error-msg {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ── Modal ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}
.modal-box {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border-radius: 20px;
    padding: 24px;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.modal-box h2 { margin-bottom: 16px; font-size: 1.15rem; }
.modal-box label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.85rem;
}
.modal-box input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font);
    margin-bottom: 14px;
    font-size: 0.95rem;
}
.modal-foot {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}

/* ── Empty ── */
.empty {
    text-align: center;
    padding: 48px 24px;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.empty-icon { margin-bottom: 12px; }
.empty h3 { margin-bottom: 8px; }

/* ── Settings ── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.settings-grid .wide { grid-column: 1 / -1; }
.settings-grid h3 { font-size: 1rem; margin-bottom: 4px; }
.settings-grid form label {
    display: block;
    font-weight: 600;
    margin: 10px 0 6px;
    font-size: 0.85rem;
}
.settings-grid input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font);
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th,
.data-table td {
    padding: 10px 8px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-size: 0.75rem; }
.data-table code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.hidden { display: none !important; }
.desktop-only { display: inline-flex; }
.mobile-only { display: none; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #0f172a;
    color: #fff;
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 0.875rem;
    z-index: 500;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    max-width: 90vw;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: #991b1b; }
.toast-info { background: #1e40af; }

.quota-tip-warn { display: block; margin-top: 8px; color: var(--danger); font-size: 0.8rem; }
.quota-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.quota-lib { border-color: rgba(37, 99, 235, 0.15); }
.pkg-list-tall { max-height: 400px; }
.lib-server-note {
    text-align: center;
    padding: 24px 16px;
    background: #f8fafc;
    border-radius: 14px;
    border: 1px dashed var(--border);
}
.lib-server-note .ic-lg { color: var(--primary); margin-bottom: 10px; }
.lib-server-note h4 { margin-bottom: 8px; }
.lib-server-note p { margin-bottom: 14px; font-size: 0.85rem; }

.modal-install { max-width: 480px; }
.install-modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.install-modal-head h3 { font-size: 1rem; margin: 0; }
.ic-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.install-modal-log {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    max-height: 220px;
    overflow-y: auto;
    font-family: Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.5;
    direction: ltr;
    text-align: left;
    margin-bottom: 12px;
}
.install-log-line { padding: 1px 0; word-break: break-word; }
.install-modal-result {
    padding: 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 12px;
    text-align: center;
}
.install-modal-result.ok { background: #d1fae5; color: #065f46; }
.install-modal-result.err { background: #fef2f2; color: #991b1b; }

.quota-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--muted);
}
.quota-breakdown span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f8fafc;
    padding: 4px 8px;
    border-radius: 8px;
}

/* ── Logs v2 (mobile-first) ── */
.page-logs { padding-bottom: 32px; }
.logs-head { margin-bottom: 12px; }
.logs-shell {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.logs-shell-compact { padding: 0; }
.logs-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.logs-toolbar-compact {
    flex-direction: column;
    align-items: stretch;
}
.logs-title {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.log-tabs-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.log-tabs-scroll::-webkit-scrollbar { display: none; }
.logs-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}
.logs-toolbar-compact .logs-actions {
    justify-content: space-between;
    margin-right: 0;
}
.log-time-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    padding: 6px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border);
}
.log-time-toggle input { accent-color: var(--primary); width: 15px; height: 15px; }
.logs-viewer {
    background: #0b1220;
    min-height: 55vh;
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
    direction: ltr;
    text-align: left;
    -webkit-overflow-scrolling: touch;
}
.logs-viewer-compact {
    min-height: 260px;
    max-height: 360px;
}
.logs-foot {
    padding: 10px 14px;
    font-size: 0.72rem;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}
.log-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
}
.log-item-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.log-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.log-badge-stdout { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.log-badge-stderr { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.log-badge-pip { background: rgba(192, 132, 252, 0.15); color: #c084fc; }
.log-badge-info { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.log-badge-warn { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.log-badge-error { background: rgba(248, 113, 113, 0.15); color: #f87171; }
.log-item-time {
    font-size: 0.68rem;
    color: #94a3b8;
    font-family: system-ui, sans-serif;
}
.log-item-proj {
    font-size: 0.65rem;
    color: #64748b;
    background: rgba(255,255,255,0.06);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: auto;
}
.log-item-sys { color: #60a5fa; }
.log-item-msg {
    color: #e2e8f0;
    word-break: break-word;
    white-space: pre-wrap;
}
.log-stdout .log-item-msg { color: #bbf7d0; }
.log-stderr .log-item-msg { color: #fde68a; }
.log-pip .log-item-msg { color: #e9d5ff; }
.log-error .log-item-msg { color: #fecaca; }

@media (max-width: 768px) {
    body.app-body { padding-bottom: calc(var(--bottom-h) + 8px); }

    .mobile-tabs {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 200;
        height: var(--bottom-h);
        background: #fff;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mtab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        text-decoration: none;
        color: var(--muted);
        font-size: 0.62rem;
        font-weight: 700;
        padding: 6px 0;
        position: relative;
    }
    .mtab.active { color: var(--primary); }
    .mtab.active::before {
        content: '';
        position: absolute;
        top: 0; left: 25%; right: 25%;
        height: 3px;
        background: var(--primary);
        border-radius: 0 0 3px 3px;
    }
    .header-nav { display: none; }
    .header-nav.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 58px; left: 0; right: 0;
        background: #1e40af;
        padding: 12px 16px 16px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.2);
        z-index: 99;
    }
    .header-nav.open .nav-item {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 14px;
    }
    .header-menu-btn { display: flex; }

    .split { grid-template-columns: 1fr; }
    .log-panel { order: -1; }
    .logs-viewer-compact { min-height: 220px; max-height: 280px; }
    .logs-viewer { min-height: 50vh; max-height: 60vh; }
    .editor-wrap { height: 280px; max-height: 280px; }
    .editor-wrap .CodeMirror { height: 280px !important; max-height: 280px !important; }
    .editor-wrap .CodeMirror-scroll { max-height: 280px !important; }

    .action-card .btn-action { min-width: calc(50% - 5px); flex: 1 1 calc(50% - 5px); }
    .room-actions .btn { flex: 1; min-width: calc(50% - 4px); }
    .toast { bottom: calc(var(--bottom-h) + 12px); }
}

/* ══ DESKTOP ══ */
@media (min-width: 769px) {
    .mobile-tabs { display: none !important; }
    body.app-body { padding-bottom: 0; }
}
