/* 5CBot Dashboard — style.css
 * Theme applied via <html data-theme="light|dark"> set by inline script in layout.php.
 * Admin pages get <body class="area-admin"> for distinct purple accent.
 */

:root,
:root[data-theme="light"] {
    --bg:           #F8FAFC;
    --surface:      #FFFFFF;
    --surface-2:    #F1F5F9;
    --border:       #CBD5E1;
    --primary:      #2563EB;
    --primary-soft: rgba(37, 99, 235, 0.10);
    --success:      #22C55E;
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning:      #F59E0B;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --danger:       #EF4444;
    --danger-soft:  rgba(239, 68, 68, 0.10);
    --text:         #0F172A;
    --muted:        #64748B;
    --admin-accent: #7C3AED;
    --admin-soft:   rgba(124, 58, 237, 0.10);
    --shadow:       0 1px 3px rgba(15,23,42,0.08), 0 4px 16px rgba(15,23,42,0.06);
    --radius:       8px;
    color-scheme:   light;
    /* Aliases used by inline styles in layout.php and the code blocks in docs pages. */
    --accent:       var(--primary);
    --accent-soft:  var(--primary-soft);
    --card-bg:      var(--surface);
    --code-bg:      #1E293B;
    --code-text:    #E2E8F0;
}

:root[data-theme="dark"] {
    --bg:           #0F172A;
    --surface:      #1E293B;
    --surface-2:    #334155;
    --border:       #475569;
    --primary:      #3B82F6;
    --primary-soft: rgba(59, 130, 246, 0.14);
    --success:      #4ADE80;
    --success-soft: rgba(74, 222, 128, 0.14);
    --warning:      #FBBF24;
    --warning-soft: rgba(251, 191, 36, 0.14);
    --danger:       #F87171;
    --danger-soft:  rgba(248, 113, 113, 0.13);
    --text:         #F8FAFC;
    --muted:        #94A3B8;
    --admin-accent: #A78BFA;
    --admin-soft:   rgba(167, 139, 250, 0.14);
    --shadow:       0 1px 2px rgba(0,0,0,0.35), 0 6px 20px rgba(0,0,0,0.30);
    --radius:       8px;
    color-scheme:   dark;
    --accent:       var(--primary);
    --accent-soft:  var(--primary-soft);
    --card-bg:      var(--surface);
    --code-bg:      #0B1220;
    --code-text:    #CBD5E1;
}

/* ── Skip link ───────────────────────────────────────────────── */
/* Keyboard users tab to it as the first stop; everyone else never sees it.
   Positioned off-screen rather than display:none, which would drop it out of the
   tab order and defeat the point. */

.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 200;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0 0 var(--radius) 0;
    text-decoration: none;
    transform: translateY(-150%);
    transition: transform 0.15s ease;
}

.skip-link:focus {
    transform: translateY(0);
    color: #fff;
    text-decoration: none;
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

/* ── Reset & Base ────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary); text-decoration: underline; }

code {
    font-family: "Cascadia Code", "Fira Code", Consolas, Monaco, monospace;
    font-size: .9em;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 2px 5px;
    border-radius: 4px;
}

pre, .monospace {
    font-family: "Cascadia Code", "Fira Code", Consolas, Monaco, monospace;
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
p  { color: var(--muted); margin-bottom: 12px; }

/* ── Topbar ──────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.area-admin .topbar {
    border-bottom: 2px solid var(--admin-accent);
}

.topbar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.25rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-logo  { display: block; height: 32px; width: auto; object-fit: contain; }
.brand-name  { font-size: 1rem; font-weight: 700; }

.admin-chip {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--admin-accent);
    color: #fff;
    line-height: 1.4;
    margin-left: 6px;
}
.view-as-chip {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .03em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--warning);
    color: #000;
    line-height: 1.4;
    margin-left: 6px;
}

.spacer { flex: 1; }

/* ── Main navigation pill ────────────────────────────────────── */

.mainnav {
    display: flex;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }

.nav-group {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.2rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}

.nav-group a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.3rem 0.7rem;
    border-radius: 7px;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.nav-group a:hover { background: var(--primary-soft); color: var(--text); text-decoration: none; }
.nav-group a.active { background: var(--primary); color: #fff; }

.nav-icon { width: 15px; height: 15px; flex-shrink: 0; }

/* Admin variant */
.nav-group-admin { border-color: var(--admin-accent); }
.nav-group-admin a:hover { background: var(--admin-soft); }
.nav-group-admin a.active { background: var(--admin-accent); color: #fff; }

/* ── Second-level nav (Management sections) ──────────────────── */
/* Reuses .nav-group, sitting under a hairline so the two levels read as a
   hierarchy rather than two competing bars. Scrolls horizontally on narrow
   screens instead of wrapping into a second row. */

.subnav {
    display: flex;
    align-items: center;
    margin: -0.25rem 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }

/* Subordinate to the topbar: no border/fill of its own, lighter weight. */
.subnav .nav-group {
    border-color: transparent;
    background: transparent;
    padding: 0;
    gap: 0.25rem;
}
.subnav .nav-group a { font-weight: 500; padding: 0.35rem 0.75rem; }
.subnav .nav-group a:not(.active) { color: var(--muted); }

/* ── Theme toggle ────────────────────────────────────────────── */

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--primary); }
:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="dark"]  .icon-sun  { display: none; }
.icon-sun svg, .icon-moon svg { width: 16px; height: 16px; }

/* ── Profile ─────────────────────────────────────────────────── */

.avatar {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
.avatar-lg { width: 36px; height: 36px; font-size: .9rem; }
.area-admin .avatar    { background: var(--admin-soft); color: var(--admin-accent); }
.area-admin .avatar-lg { background: var(--admin-soft); color: var(--admin-accent); }

.profile-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
.profile-btn:hover { border-color: var(--primary); }
.profile-wrap { position: relative; }

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--danger, #ef4444);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 120;
    overflow: hidden;
}
.pd-head { display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; }
.pd-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pd-meta strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-meta small  { font-size: .72rem; color: var(--muted); }
.pd-sep { height: 1px; background: var(--border); }
.pd-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem 1rem;
    font-size: .84rem;
    color: var(--text);
    text-decoration: none;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}
.pd-row:hover { background: var(--primary-soft); text-decoration: none; }
.area-admin .pd-row:hover { background: var(--admin-soft); }
.pd-logout:hover { background: var(--danger-soft) !important; color: var(--danger) !important; }

.pd-lang { padding: .5rem 1rem .6rem; }
.pd-lang-label { display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem; }
.pd-lang-options { display: flex; gap: .35rem; flex-wrap: wrap; }
.pd-lang-opt { font-size: .72rem; padding: .2rem .5rem; border-radius: 6px; border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.pd-lang-opt:hover { background: var(--primary-soft); text-decoration: none; }
.pd-lang-opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.lang-switch { position: relative; }
.lang-switch-options {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 130px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    overflow: hidden;
    z-index: 120;
}
.lang-switch-options.open { display: block; }
.lang-switch-options a { display: block; padding: .5rem .8rem; font-size: .82rem; color: var(--text); text-decoration: none; }
.lang-switch-options a:hover { background: var(--primary-soft); text-decoration: none; }
.lang-switch-options a.active { color: var(--accent); font-weight: 600; }

/* ── Hamburger (mobile) ──────────────────────────────────────── */

.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    width: 34px;
    height: 34px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.hamburger span {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}

/* ── Main container ──────────────────────────────────────────── */

.container {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
    flex: 1;
}

/* ── Maintenance banner ──────────────────────────────────────── */
/* Was inline, referencing a "warn" custom property that does not exist — the
   token is named "warning". With no fallback the background resolved to nothing,
   leaving hardcoded black text on the page background: invisible in dark theme,
   on the one banner that has to be readable when it appears. */

.maintenance-banner {
    background: var(--warning);
    color: #0F172A;               /* amber is light in both themes, so dark ink both ways */
    font-weight: 600;
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

/* ── URL row ─────────────────────────────────────────────────── */
/* The "here is your bot's address" block: monospace text plus Copy/Open buttons.
   It is a UI surface, NOT a code snippet, so it follows the theme rather than
   using --code-bg. Code blocks are deliberately dark in both themes; that only
   works when nothing interactive lives inside them. This one holds buttons, and
   light-theme buttons on a dark block are invisible. */

.url-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-family: "Cascadia Code", "Fira Code", Consolas, Monaco, monospace;
    font-size: 13px;
    word-break: break-all;
}

.url-row code {
    flex: 1;
    min-width: 0;
    background: transparent;
    color: inherit;
    padding: 0;
}

.url-row .btn { flex-shrink: 0; }

@media (max-width: 640px) {
    .url-row { flex-wrap: wrap; }
    .url-row code { flex-basis: 100%; }
}

/* Narrow column for form and detail pages (profile, settings, the deploy flow).
   These pages used to put a max-width on each card inside the full 1100px
   container, which left the card against the left edge with ~600px of dead
   space beside it. Constraining the container instead keeps the heading and the
   cards in one centred column, aligned with each other. */
.container.narrow { max-width: 720px; }

footer.footer {
    text-align: center;
    padding: 1rem;
    font-size: .8rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ── Page header ─────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-header h1 { margin-bottom: 0; }

/* ── Section title ───────────────────────────────────────────── */

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: 12px;
    margin-top: 0;
}

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 85%, #000); border-color: color-mix(in srgb, var(--primary) 85%, #000); color: #fff; }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 85%, #000); color: #fff; }

.btn-warning { background: transparent; color: var(--warning); border-color: var(--warning); }
.btn-warning:hover:not(:disabled) { background: var(--warning-soft); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: color-mix(in srgb, var(--success) 85%, #000); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Admin accent on destructive actions */
.area-admin .btn-warning { border-color: var(--admin-accent); color: var(--admin-accent); }
.area-admin .btn-warning:hover:not(:disabled) { background: var(--admin-soft); }
.area-admin .btn-danger { border-color: var(--admin-accent); }
.area-admin .btn-danger:hover:not(:disabled) { background: var(--admin-soft); }

/* ── Forms ───────────────────────────────────────────────────── */

label { display: block; margin-bottom: 14px; }

label > span:first-child {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 5px;
}

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=url],
input[type=search],
select,
textarea {
    display: block;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    padding: 9px 12px;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

select {
    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='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}
select option { background: var(--surface); color: var(--text); }

textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ── Form card ───────────────────────────────────────────────── */

.form-card {
    max-width: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin: 0 auto;
}

/* ── Cards ───────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.area-admin .stat { border-left-color: var(--admin-accent); }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 6px;
}
.stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

/* ── Bot grid and cards ──────────────────────────────────────── */

.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
}

.bot-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: border-color .15s, box-shadow .15s;
}
.bot-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }

.bot-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }

.bot-card-id {
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 11px;
    color: var(--primary);
    margin-bottom: 3px;
    letter-spacing: .04em;
}

.bot-card-name { font-size: 15px; font-weight: 600; line-height: 1.3; }

.bot-card-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.bot-card-actions { display: flex; gap: 8px; margin-top: auto; }

/* ── Status bar ──────────────────────────────────────────────── */

.status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    flex-wrap: wrap;
    font-size: 13px;
    margin-bottom: 24px;
}

/* ── Status dot ──────────────────────────────────────────────── */

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 5px;
    vertical-align: middle;
    flex-shrink: 0;
}
.status-dot-running  { background: var(--success); animation: pulse 2s infinite; }
.status-dot-sleeping { background: #93c5fd; }
.status-dot-stopped  { background: var(--muted); }
.status-dot-failed   { background: var(--danger); }
.status-dot-unknown  { background: var(--muted); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

/* ── Badges ──────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: .02em;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-running  { background: var(--success-soft); color: var(--success); border-color: rgba(34,197,94,.3); }
.badge-sleeping { background: rgba(147,197,253,.15); color: #93c5fd; border-color: rgba(147,197,253,.3); }
.badge-stopped  { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge-failed   { background: var(--danger-soft); color: var(--danger); border-color: rgba(239,68,68,.3); }
.badge-unknown  { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge-enabled  { background: var(--success-soft); color: var(--success); border-color: rgba(34,197,94,.2); }
.badge-disabled { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge-admin    { background: var(--admin-soft); color: var(--admin-accent); border-color: var(--admin-accent); }
.badge-current  { background: var(--primary-soft); color: var(--primary); border-color: rgba(37,99,235,.25); }

/* ── Alerts ──────────────────────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: var(--success-soft); color: var(--success); border-color: rgba(34,197,94,.25); }
.alert-error   { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(239,68,68,.25); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(245,158,11,.25); }
.alert-info    { background: var(--primary-soft); color: var(--primary); border-color: rgba(37,99,235,.25); }

/* ── Tables ──────────────────────────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead tr { background: var(--surface-2); border-bottom: 1px solid var(--border); }

th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    white-space: nowrap;
}

td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ── Log viewer ──────────────────────────────────────────────── */

.log-viewer {
    background: #0a0c12;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    max-height: 420px;
    overflow-y: auto;
    font-family: "Cascadia Code", "Fira Code", Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 1.8;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.log-viewer::-webkit-scrollbar { width: 6px; }
.log-viewer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.log-line {
    padding: 0 4px;
    border-radius: 3px;
    color: #4b5563;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-line:hover                { background: rgba(255,255,255,.03); }
.log-line[data-level=info]     { color: #94a3b8; }
.log-line[data-level=warn]     { color: #fcd34d; background: rgba(245,158,11,.06); }
.log-line[data-level=error]    { color: #f87171; background: rgba(239,68,68,.08); }
.log-line[data-level=debug]    { color: #475569; }

/* ── Env-var rows ────────────────────────────────────────────── */

.env-header {
    display: grid;
    grid-template-columns: 1fr 1.6fr 72px 36px;
    gap: 8px;
    padding: 0 4px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.env-row {
    display: grid;
    grid-template-columns: 1fr 1.6fr 72px 36px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.env-row input[type=text] { margin-bottom: 0; padding: 7px 10px; }

.sens-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
}
.sens-toggle input { width: auto; margin: 0; }
.sens-toggle:has(input:checked) { color: var(--warning); }

/* ── Upload zone ─────────────────────────────────────────────── */

.upload-label {
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.upload-label:hover { border-color: var(--primary); background: var(--primary-soft); }
.upload-icon  { font-size: 2rem; margin-bottom: 8px; line-height: 1; }
.upload-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.upload-hint  { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.5; }
.upload-filename { font-size: 12px; color: var(--primary); font-family: monospace; min-height: 1.4em; }

.upload-required {
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
}

/* ── Empty state ─────────────────────────────────────────────── */

.empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty p { color: var(--muted); margin-bottom: 0; }

/* ── Login page ──────────────────────────────────────────────── */

.area-public {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.area-public .topbar { display: none; }
.area-public .container { max-width: 400px; padding: 24px; flex: none; }
.area-public .container .form-card { margin: 0; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand img { height: 48px; width: auto; }
.login-brand h1 { margin-top: 12px; margin-bottom: 0; font-size: 1.5rem; }

/* ── Marketing / landing page ────────────────────────────────── */

.area-marketing .container { max-width: 960px; }
.marketing-hero { text-align: center; padding: 48px 0 32px; }
.marketing-eyebrow {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .78rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: .75rem;
}
.marketing-hero h1 { font-size: 2.4rem; line-height: 1.2; margin: 0 auto .75rem; max-width: 720px; }
.marketing-subtitle { font-size: 1.05rem; color: var(--muted); max-width: 620px; margin: 0 auto 1.75rem; }
.marketing-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.marketing-features { padding: 32px 0; }
.marketing-features h2, .marketing-how h2 { text-align: center; margin-bottom: 24px; }
.marketing-feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.marketing-feature h3 { margin-top: 0; }
.marketing-feature p { color: var(--muted); margin-bottom: 0; }

.marketing-how { padding: 32px 0; }
.marketing-steps {
    list-style: none;
    counter-reset: step;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 0;
    max-width: 900px;
    margin: 0 auto;
}
.marketing-steps li { counter-increment: step; text-align: center; }
.marketing-steps li::before {
    content: counter(step);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--accent);
    font-weight: 700;
}
.marketing-steps strong { display: block; margin-bottom: 4px; }
.marketing-steps span { color: var(--muted); font-size: .9rem; }

.marketing-cta-footer { text-align: center; padding: 40px 24px; margin: 32px 0 16px; }
.marketing-cta-footer h2 { margin-top: 0; }
.marketing-cta-footer p { color: var(--muted); }

/* ── RTL (Arabic) ─────────────────────────────────────────────
   ponytail: base mirroring for header/dropdowns only. A full pass over
   every component is deferred until real Arabic usage shows what needs it. */

[dir="rtl"] { text-align: right; }
[dir="rtl"] .profile-dropdown,
[dir="rtl"] .notif-dropdown,
[dir="rtl"] .lang-switch-options { right: auto; left: 0; }
[dir="rtl"] .pd-row { text-align: right; }
[dir="rtl"] .notif-badge { margin-left: 0; margin-right: 4px; }

/* ── Scrollbar ───────────────────────────────────────────────── */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Divider ─────────────────────────────────────────────────── */

hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Utilities ───────────────────────────────────────────────── */

.text-muted   { color: var(--muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }

.mt-0 { margin-top: 0; }    .mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.mb-0 { margin-bottom: 0; }    .mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }  .mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.muted { color: var(--muted); }

/* ── Dashboard grid ──────────────────────────────────────────── */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* ── Big stat number ─────────────────────────────────────────── */

.big {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    margin: 8px 0 6px;
}

/* ── Key-value row ───────────────────────────────────────────── */

.kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 13px;
    padding: 3px 0;
}
.kv .k {
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Progress bar ────────────────────────────────────────────── */

.progress {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin: 4px 0 10px;
}
.progress > div {
    height: 100%;
    background: linear-gradient(90deg, var(--admin-accent, var(--primary)), var(--primary));
    border-radius: 3px;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
    .hamburger { display: inline-flex; }

    .mainnav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 1rem;
        z-index: 49;
    }
    .mainnav.open { display: flex; flex-direction: column; align-items: stretch; }

    .nav-group { flex-direction: column; align-items: stretch; border-radius: 8px; }
    .nav-group a { justify-content: flex-start; }

    .topbar { position: relative; }
}

@media (max-width: 640px) {
    .container { padding: 20px 16px; }
    .bot-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .env-header, .env-row { grid-template-columns: 1fr 1fr 52px 36px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Toast notifications */
.toast-viewport {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: 22rem;
    max-width: calc(100vw - 2rem);
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: .625rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.06);
    animation: toastSlideIn .3s cubic-bezier(.21,1.02,.73,1);
    transition: opacity .2s, transform .2s;
    position: relative;
}
.toast.toast-out { opacity: 0; transform: translateX(100%); }
.toast-icon { font-size: 1.15rem; line-height: 1; flex-shrink: 0; margin-top: .1rem; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: .875rem; line-height: 1.3; color: var(--text); }
.toast-desc { font-size: .8rem; color: var(--muted); margin-top: .15rem; line-height: 1.35; }
.toast-close {
    flex-shrink: 0; background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 1rem; padding: 0 0 0 .25rem; line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast-progress {
    position: absolute; bottom: 0; left: 0; height: 2px; border-radius: 0 0 8px 8px;
    transition: width linear;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-success .toast-progress { background: var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-error .toast-progress { background: var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-warning .toast-progress { background: var(--warning); }
.toast-info { border-left: 3px solid var(--primary); }
.toast-info .toast-icon { color: var(--primary); }
.toast-info .toast-progress { background: var(--primary); }
@keyframes toastSlideIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) { .toast-viewport { left: 1rem; right: 1rem; bottom: 1rem; } }

/* Onboarding tour */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: none;
}
.onboarding-hole {
    position: absolute;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
    pointer-events: none;
}
.onboarding-tooltip {
    position: absolute;
    z-index: 9001;
    width: 300px;
    max-width: calc(100vw - 24px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    pointer-events: auto;
}
.onboarding-tooltip h3 { font-size: 14px; margin-bottom: 6px; color: var(--text); }
.onboarding-tooltip p { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.onboarding-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.onboarding-skip { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 6px 4px; }
.onboarding-skip:hover { color: var(--text); }
