/* ==========================================================================
   VADware Panel — design system
   Light-first SaaS console with an optional dark theme ([data-theme="dark"]).
   No framework: tokens, app shell, components, page modules.
   ========================================================================== */

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --surface-3: #f1f2f7;
    --surface-inverse: #111322;
    --border: #e6e8f0;
    --border-strong: #d5d8e3;
    --overlay: rgba(17, 19, 34, 0.45);

    --text-strong: #111322;
    --text: #373c52;
    --text-muted: #6b7189;
    --text-faint: #9ca1b6;
    --text-inverse: #ffffff;

    --accent: #6d5dfc;
    --accent-hover: #5b4aef;
    --accent-active: #4c3cd8;
    --accent-soft: #f0eeff;
    --accent-soft-strong: #e3dfff;
    --accent-text: #5543e6;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #6d5dfc 55%, #a855f7 100%);

    --success: #12b76a;
    --success-strong: #039855;
    --success-soft: #ecfdf3;
    --success-text: #027a48;
    --danger: #f04438;
    --danger-strong: #d92d20;
    --danger-soft: #fef3f2;
    --danger-text: #b42318;
    --warning: #f79009;
    --warning-strong: #dc6803;
    --warning-soft: #fffaeb;
    --warning-text: #b54708;
    --info: #2e90fa;
    --info-soft: #eff8ff;
    --info-text: #175cd3;
    --pink-soft: #fdf2fa;
    --pink-text: #c11574;
    --neutral-soft: #f2f4f7;
    --neutral-text: #475467;

    --hover: rgba(17, 19, 34, 0.04);
    --hover-strong: rgba(17, 19, 34, 0.07);

    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 16px 32px -8px rgba(16, 24, 40, 0.16), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
    --shadow-xl: 0 24px 64px -12px rgba(16, 24, 40, 0.28);
    --ring: 0 0 0 4px rgba(109, 93, 252, 0.16);

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0b0d14;
    --surface: #121521;
    --surface-2: #161a28;
    --surface-3: #1b2030;
    --surface-inverse: #f5f6fa;
    --border: #232839;
    --border-strong: #2f3549;
    --overlay: rgba(3, 4, 10, 0.7);

    --text-strong: #f3f4f8;
    --text: #c9cdda;
    --text-muted: #8c92a8;
    --text-faint: #5f6680;
    --text-inverse: #111322;

    --accent: #7c6dff;
    --accent-hover: #8e81ff;
    --accent-active: #6d5dfc;
    --accent-soft: rgba(124, 109, 255, 0.14);
    --accent-soft-strong: rgba(124, 109, 255, 0.24);
    --accent-text: #a79eff;

    --success-soft: rgba(18, 183, 106, 0.14);
    --success-text: #4ade9a;
    --danger-soft: rgba(240, 68, 56, 0.14);
    --danger-text: #ff8a80;
    --warning-soft: rgba(247, 144, 9, 0.14);
    --warning-text: #fdb022;
    --info-soft: rgba(46, 144, 250, 0.14);
    --info-text: #7cb8ff;
    --pink-soft: rgba(238, 70, 188, 0.14);
    --pink-text: #f58fd0;
    --neutral-soft: rgba(255, 255, 255, 0.06);
    --neutral-text: #b3b8c9;

    --hover: rgba(255, 255, 255, 0.04);
    --hover-strong: rgba(255, 255, 255, 0.07);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 32px -8px rgba(0, 0, 0, 0.55);
    --shadow-xl: 0 24px 64px -12px rgba(0, 0, 0, 0.7);
    --ring: 0 0 0 4px rgba(124, 109, 255, 0.25);

    color-scheme: dark;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--text-strong);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

p {
    margin: 0;
}

a {
    color: var(--accent-text);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

code,
kbd,
pre {
    font-family: var(--font-mono);
    font-size: 0.86em;
}

code {
    padding: 0.12em 0.4em;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-3);
    color: var(--text-strong);
    word-break: break-all;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

::selection {
    background: var(--accent-soft-strong);
}

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

.modal-dialog:focus,
.modal-dialog:focus-visible,
.layer-content:focus,
.layer-content:focus-visible,
.ui-modal:focus,
.layer:focus {
    outline: none;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- Utilities ---------- */
.hidden,
.d-none,
[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.grid { display: grid; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.w-100 { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted) !important; }
.text-faint { color: var(--text-faint) !important; }
.text-strong { color: var(--text-strong) !important; }
.text-normal { color: var(--text) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.upper { text-transform: uppercase; }
.block { display: block; }

.eyebrow {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: -3px;
}

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

@keyframes pulse {
    50% { opacity: 0.35; }
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 2;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--topbar-h);
    padding: 0 22px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    text-decoration: none !important;
}

.brand-logo {
    display: block;
    height: 32px;
    width: auto;
}

:root:not([data-theme="dark"]) .brand-logo {
    filter: invert(1) hue-rotate(180deg) saturate(1.4);
}

.sidebar-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 14px 16px;
}

.nav-category {
    margin-top: 20px;
}

.nav-category:first-child {
    margin-top: 4px;
}

.nav-category-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 10px 6px;
    border: 0;
    background: none;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.nav-category-toggle:hover {
    color: var(--text-muted);
}

.nav-category-toggle .fa-chevron-down {
    order: 2;
    margin-left: auto;
    font-size: 9px;
    opacity: 0;
    transition: transform 0.15s var(--ease), opacity 0.15s;
}

.nav-category-toggle:hover .fa-chevron-down,
.nav-category.collapsed .nav-category-toggle .fa-chevron-down {
    opacity: 1;
}

.nav-category.collapsed .nav-category-toggle .fa-chevron-down {
    transform: rotate(-90deg);
}

.nav-category.collapsed .nav-link:not(.active) {
    display: none;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 38px;
    margin: 2px 0;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    transition: background-color 0.12s, color 0.12s;
}

.nav-link i {
    width: 18px;
    text-align: center;
    font-size: 15px;
    color: var(--text-faint);
    flex: 0 0 auto;
    transition: color 0.12s;
}

.nav-link:hover {
    background: var(--hover);
    color: var(--text-strong);
}

.nav-link:hover i {
    color: var(--text-muted);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}

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

.nav-link-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link-badge {
    flex: 0 0 auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--danger-soft);
    color: var(--danger-text);
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.nav-link-badge.neutral {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.nav-link-badge.danger {
    background: var(--danger);
    color: #fff;
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 14px;
}

.fleet-widget {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: inherit;
    text-decoration: none !important;
    display: block;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fleet-widget:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xs);
}

.fleet-widget-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-strong);
    font-size: 13px;
    font-weight: 600;
}

.fleet-widget-value {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.fleet-widget-note {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.fleet-widget-note.danger {
    color: var(--danger-text);
}

/* ---------- Avatars ---------- */
.avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
    font-size: 13px;
    flex: 0 0 auto;
    text-transform: uppercase;
}

.avatar > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-xl { width: 80px; height: 80px; font-size: 28px; }

.avatar-square {
    border-radius: 10px;
}

[data-lightbox] {
    cursor: pointer;
}

.avatar[data-lightbox]::after {
    content: "\f002";
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    background: rgba(8, 9, 16, 0.55);
    color: #fff;
    font-family: "Font Awesome 5 Free";
    font-size: 14px;
    font-weight: 900;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.avatar[data-lightbox]:hover::after,
.avatar[data-lightbox]:focus-visible::after {
    opacity: 1;
}

.avatar[data-lightbox] .avatar-status {
    z-index: 2;
}

.avatar[data-lightbox]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.lightbox {
    background: rgba(8, 9, 16, 0.82);
}

.lightbox-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin: auto;
    outline: none;
}

.ui-modal.show > .lightbox-dialog {
    animation: modal-pop-in 0.26s var(--ease);
}

.lightbox-image {
    display: block;
    width: auto;
    height: auto;
    min-width: 160px;
    max-width: min(80vw, 640px);
    max-height: 75vh;
    max-height: 75dvh;
    border-radius: var(--radius-lg);
    background: var(--surface-3);
    box-shadow: var(--shadow-xl);
    object-fit: contain;
    image-rendering: auto;
}

.lightbox-caption {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-md);
}

.lightbox-close:hover {
    background: var(--surface-2);
}

.lightbox.wide .lightbox-image {
    max-width: min(92vw, 1400px);
    max-height: 82vh;
    max-height: 82dvh;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-md);
}

.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }

.lightbox-nav:hover:not(:disabled) {
    background: var(--surface-2);
}

.lightbox-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.lightbox-nav[hidden] {
    display: none;
}


.avatar-xl.avatar-square {
    border-radius: 18px;
}

.mr-auto {
    margin-right: auto;
}

.avatar-status {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    background: var(--success);
}

.avatar-lg .avatar-status {
    width: 13px;
    height: 13px;
    right: -2px;
    bottom: -2px;
}

.avatar-status.offline { background: var(--text-faint); }

.avatar[data-tint="0"] { background: #eef0ff; color: #4f46e5; }
.avatar[data-tint="1"] { background: #e8faf0; color: #067647; }
.avatar[data-tint="2"] { background: #fdf2fa; color: #c11574; }
.avatar[data-tint="3"] { background: #fef3f2; color: #b42318; }
.avatar[data-tint="4"] { background: #fffaeb; color: #b54708; }
.avatar[data-tint="5"] { background: #eff8ff; color: #175cd3; }
.avatar[data-tint="6"] { background: #f4f3ff; color: #5925dc; }
.avatar[data-tint="7"] { background: #f2f4f7; color: #344054; }

:root[data-theme="dark"] .avatar[data-tint] {
    background: var(--surface-3);
}

:root[data-theme="dark"] .avatar[data-tint="0"] { color: #a5b4fc; }
:root[data-theme="dark"] .avatar[data-tint="1"] { color: #6ee7b7; }
:root[data-theme="dark"] .avatar[data-tint="2"] { color: #f9a8d4; }
:root[data-theme="dark"] .avatar[data-tint="3"] { color: #fca5a5; }
:root[data-theme="dark"] .avatar[data-tint="4"] { color: #fcd34d; }
:root[data-theme="dark"] .avatar[data-tint="5"] { color: #93c5fd; }
:root[data-theme="dark"] .avatar[data-tint="6"] { color: #c4b5fd; }
:root[data-theme="dark"] .avatar[data-tint="7"] { color: #cbd5e1; }

/* ---------- Main + topbar ---------- */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    z-index: 5;
    flex: 0 0 auto;
}

.topbar .topbar-menu-btn {
    display: none;
}

.search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(420px, 100%);
    height: 38px;
    padding: 0 8px 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-faint);
    font-size: 14px;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-trigger:hover {
    border-color: var(--border-strong);
    color: var(--text-muted);
}

.search-trigger > span {
    flex: 1 1 auto;
}

.search-trigger .kbd {
    height: 22px;
}

.topbar-spacer {
    flex: 1 1 auto;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 4px 10px 4px 4px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: transparent;
    text-align: left;
}

.user-menu-trigger:hover,
.dropdown.open > .user-menu-trigger {
    border-color: var(--border);
    background: var(--surface-2);
}

.user-menu-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.user-menu-name {
    color: var(--text-strong);
    font-size: 13px;
    font-weight: 600;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-role {
    color: var(--text-muted);
    font-size: 12px;
}

.user-menu-trigger .fa-chevron-down {
    color: var(--text-faint);
    font-size: 10px;
}

.dropdown-header {
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.dropdown-header-name {
    color: var(--text-strong);
    font-weight: 600;
}

.dropdown-header-sub {
    color: var(--text-muted);
    font-size: 12px;
}

.content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding: 28px 32px 48px;
    scroll-behavior: smooth;
}

.content-inner {
    max-width: 1400px;
    margin: 0 auto;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-head-main {
    min-width: 0;
}

.page-head-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-strong);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.page-head-sub {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 14px;
}

.page-head-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.notice-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 44px;
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    flex: 0 0 auto;
}

.notice-bar.danger {
    background: var(--danger-strong);
}

.notice-bar .btn {
    min-height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: transparent;
    color: #fff;
    box-shadow: none;
}

.notice-bar .btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.drawer-backdrop {
    display: none;
}

/* ==========================================================================
   Components
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none !important;
    white-space: nowrap;
    user-select: none;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.45;
    pointer-events: none;
    box-shadow: none;
}

.btn i {
    font-size: 13px;
}

.btn-sm {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-xs {
    min-height: 28px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: var(--radius-xs);
}

.btn-lg {
    min-height: 46px;
    padding: 0 20px;
    font-size: 15px;
}

.btn-block,
.btn.w-100 {
    display: flex;
    width: 100%;
}

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(80, 60, 220, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
}

.btn-primary:active {
    background: var(--accent-active);
}

.btn-secondary {
    background: var(--surface);
}

.btn-success {
    border-color: var(--success-strong);
    background: var(--success-strong);
    color: #fff;
}

.btn-success:hover {
    background: #027a48;
    border-color: #027a48;
}

.btn-danger {
    border-color: var(--danger-strong);
    background: var(--danger-strong);
    color: #fff;
}

.btn-danger:hover {
    background: #b42318;
    border-color: #b42318;
}

.btn-warning {
    border-color: var(--warning-strong);
    background: var(--warning-strong);
    color: #fff;
}

.btn-warning:hover {
    background: #b54708;
    border-color: #b54708;
}

.btn-link {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
}

.btn-link:hover {
    border-color: transparent;
    background: var(--hover);
    color: var(--text-strong);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text);
    box-shadow: none;
}

.btn-ghost:hover {
    border-color: transparent;
    background: var(--hover-strong);
    color: var(--text-strong);
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-light {
    background: var(--surface);
}

.btn-outline-primary {
    border-color: var(--accent-soft-strong);
    color: var(--accent-text);
}

.btn-outline-primary:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.btn-outline-danger {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--danger-text);
}

.btn-outline-danger:hover {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.btn-outline-success {
    border-color: var(--border-strong);
    color: var(--success-text);
}

.btn-outline-success:hover {
    border-color: var(--success);
    background: var(--success-soft);
}

.btn-outline-warning {
    border-color: var(--border-strong);
    color: var(--warning-text);
}

.btn-outline-warning:hover {
    border-color: var(--warning);
    background: var(--warning-soft);
}

.btn-icon {
    width: 36px;
    min-height: 36px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
}

.btn-icon i {
    font-size: 14px;
}

.btn-icon:hover {
    border-color: transparent;
    background: var(--hover-strong);
    color: var(--text-strong);
}

.btn-icon.btn-sm {
    width: 30px;
    min-height: 30px;
}

.btn-icon.btn-sm i {
    font-size: 13px;
}

.btn-icon.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Text shown only when a table is stacked into cards on phones. */
.stack-only {
    display: none;
}
.btn-icon.success:hover { color: var(--success-strong); background: var(--success-soft); }
.btn-icon.warning:hover { color: var(--warning-strong); background: var(--warning-soft); }

.btn.loading {
    color: transparent !important;
    pointer-events: none;
}

.btn.loading i {
    opacity: 0;
}

.btn.loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid var(--text-muted);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-primary.loading::after,
.btn-danger.loading::after,
.btn-success.loading::after,
.btn-warning.loading::after {
    border-color: #fff;
    border-right-color: transparent;
}

.btn-group {
    display: inline-flex;
    align-items: stretch;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
}

.btn-group .btn {
    min-height: 28px;
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
    border-radius: var(--radius-xs);
}

.btn-group .btn:hover {
    color: var(--text-strong);
}

.btn-group .btn.active {
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-xs);
}

.toolbar-divider {
    width: 1px;
    align-self: stretch;
    min-height: 24px;
    margin: 0 4px;
    background: var(--border);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    background: var(--neutral-soft);
    color: var(--neutral-text);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
}

.badge i {
    font-size: 10px;
}

.badge-primary,
.badge-soft.primary { background: var(--accent-soft); color: var(--accent-text); }
.badge-secondary,
.badge-soft,
.badge-light { background: var(--neutral-soft); color: var(--neutral-text); }
.badge-success,
.badge-soft.success { background: var(--success-soft); color: var(--success-text); }
.badge-danger,
.badge-soft.danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-warning,
.badge-soft.warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-info,
.badge-soft.info { background: var(--info-soft); color: var(--info-text); }

.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.role-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--role-color, var(--text-faint));
    flex: 0 0 auto;
}

.role-pill[data-role="administrator"] { --role-color: #6d5dfc; }
.role-pill[data-role="moderator"] { --role-color: #2e90fa; }
.role-pill[data-role="viewer"] { --role-color: #98a2b3; }

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
    flex: 0 0 auto;
}

.dot.online { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.offline { background: var(--text-faint); }
.dot.danger { background: var(--danger); }
.dot.warning { background: var(--warning); }

/* ---------- Cards ---------- */
.card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.card + .card {
    margin-top: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 600;
}

.card-title > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
}

.card-subtitle {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 13px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 32px 0 14px;
    color: var(--text-strong);
    font-size: 16px;
    font-weight: 600;
}

.section-title:first-child {
    margin-top: 0;
}

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

.form-label,
label.form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-strong);
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
}

.form-label .req {
    color: var(--danger);
    margin-left: 2px;
}

.form-hint {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 13px;
}

.form-control {
    display: block;
    width: 100%;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-strong);
    font-size: 14px;
    line-height: 22px;
    outline: none;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control::placeholder {
    color: var(--text-faint);
}

.form-control:hover {
    border-color: var(--text-faint);
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.form-control[readonly] {
    background: var(--surface-2);
    color: var(--text-muted);
}

.form-control:disabled {
    background: var(--surface-3);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-control-sm {
    height: 34px;
    padding: 6px 10px;
    font-size: 13px;
}

textarea.form-control {
    height: auto;
    min-height: 96px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    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='%239ca1b6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

select.form-control option {
    background: var(--surface);
    color: var(--text-strong);
}

input[type="file"].form-control {
    height: 40px;
    padding: 4px;
    font-size: 13px;
    line-height: 30px;
}

input[type="file"].form-control::file-selector-button {
    height: 30px;
    margin-right: 12px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    color: var(--text-strong);
    font-weight: 600;
    cursor: pointer;
}

.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

.input-group .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 13px;
    pointer-events: none;
    z-index: 1;
}

.input-group .input-icon + .form-control {
    padding-left: 34px;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-top: -16px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-faint);
}

.password-toggle:hover {
    background: var(--hover-strong);
    color: var(--text-muted);
}

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

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-form .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

/* Checkbox */
.check {
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    line-height: 20px;
    user-select: none;
}

.check input[type="checkbox"],
input[type="checkbox"].check-input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    background: var(--surface);
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

/* A checkbox framed like a .form-control-sm, for toolbars next to inputs. */
.check.check-field {
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    color: var(--text-strong);
    font-size: 13px;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.check.check-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}

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

.check.check-field input[type="checkbox"]:focus-visible {
    box-shadow: none;
}

.check.check-field:focus-within {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.check.check-field:has(input:checked),
.check.check-field:has(input:indeterminate) {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.check input[type="checkbox"]:hover {
    border-color: var(--accent);
}

.check input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.check input[type="checkbox"]:checked,
.check input[type="checkbox"]:indeterminate {
    border-color: var(--accent);
    background: var(--accent);
}

.check input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1.5px;
    width: 4.5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.check input[type="checkbox"]:indeterminate::after {
    content: "";
    position: absolute;
    left: 3.5px;
    top: 7px;
    width: 8px;
    height: 2px;
    border-radius: 1px;
    background: #fff;
}

.check input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.check-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Toggle switch */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--border-strong);
    flex: 0 0 auto;
    transition: background-color 0.2s var(--ease);
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.2);
    transition: transform 0.2s var(--ease);
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track::after {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
    box-shadow: var(--ring);
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    cursor: pointer;
}

.switch-row + .switch-row {
    border-top: 1px solid var(--border);
}

.switch-row-title {
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 500;
}

.switch-row-desc {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- Alerts ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
}

.alert > i {
    margin-top: 3px;
    flex: 0 0 auto;
}

.alert-info { border-color: transparent; background: var(--info-soft); color: var(--info-text); }
.alert-success { border-color: transparent; background: var(--success-soft); color: var(--success-text); }
.alert-warning { border-color: transparent; background: var(--warning-soft); color: var(--warning-text); }
.alert-danger { border-color: transparent; background: var(--danger-soft); color: var(--danger-text); }

/* ---------- Tables ---------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.card > .table-wrap:first-child {
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.card > .table-wrap:last-child {
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 11px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr {
    transition: background-color 0.1s;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

.table tbody tr.is-selected {
    background: var(--accent-soft);
}



.table .form-control {
    min-width: 140px;
}

/* ---------- Tabs ---------- */
.tabs {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-strong);
}

.tab.active {
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-xs);
}

.tab-count {
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--neutral-soft);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.tab.active .tab-count {
    background: var(--accent-soft);
    color: var(--accent-text);
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
}

.page-link:hover {
    background: var(--hover-strong);
    color: var(--text-strong);
}

.page-item.active .page-link {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-xs);
}

.page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
}

/* ---------- Empty state ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 56px 16px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 20px;
    box-shadow: var(--shadow-xs);
}

.empty-state-title {
    color: var(--text-strong);
    font-size: 16px;
    font-weight: 600;
}

.empty-state-text {
    max-width: 420px;
    font-size: 14px;
}

.inline-empty {
    padding: 20px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

/* ---------- Dropdowns ---------- */
.dropdown {
    position: relative;
    display: inline-flex;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1100;
    display: none;
    min-width: 200px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.dropdown.open > .dropdown-menu {
    display: block;
    animation: pop-in 0.12s var(--ease);
}

.dropdown-menu.dropup {
    top: auto;
    bottom: calc(100% + 6px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    text-decoration: none !important;
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-faint);
}

.dropdown-item:hover {
    background: var(--hover-strong);
    color: var(--text-strong);
}

.dropdown-item.danger,
.dropdown-item.danger i {
    color: var(--danger-text);
}

.dropdown-item.danger:hover {
    background: var(--danger-soft);
}

.dropdown-divider {
    height: 1px;
    margin: 6px 0;
    background: var(--border);
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

/* ---------- Modals ---------- */
.ui-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    overflow-y: auto;
}

.ui-modal.show {
    display: flex;
    animation: fade-in 0.15s ease;
}

.ui-modal.show > .modal-dialog {
    animation: modal-pop-in 0.26s var(--ease);
}

/* Closing: panel-ui.js keeps "closing" on for the length of the pop-out. */
.ui-modal.closing,
.layer.closing,
.switcher.closing {
    display: flex;
    pointer-events: none;
    animation: fade-out 0.18s ease forwards;
}

.ui-modal.closing > .modal-dialog,
.ui-modal.closing > .lightbox-dialog,
.layer.closing .layer-sheet,
.switcher.closing .switcher-dialog {
    animation: modal-pop-out 0.18s ease-in forwards;
}

@keyframes fade-in {
    from { opacity: 0; }
}

@keyframes fade-out {
    to { opacity: 0; }
}

@keyframes modal-pop-in {
    0% { opacity: 0; transform: scale(0.9); }
    60% { opacity: 1; transform: scale(1.015); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes modal-pop-out {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.92); }
}

.modal-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 460px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    margin: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 580px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1180px; }

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 24px 14px;
    flex: 0 0 auto;
}

.modal-title {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-strong);
    font-size: 18px;
    font-weight: 600;
    line-height: 26px;
}

.modal-subtitle {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 400;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    margin: -4px -8px 0 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    font-size: 16px;
}

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

.modal-body {
    padding: 6px 24px 20px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    flex: 0 0 auto;
}

.modal-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 14px;
    flex: 0 0 auto;
}

body.modal-open,
body.modal-open .content {
    overflow: hidden;
}

body.modal-open .content {
    touch-action: none;
}

.ui-modal,
.layer,
.switcher,
.modal-body,
.layer-content,
.layer-nav,
.logs-viewer,
.switcher-results,
.config-sidebar,
.config-editor-body {
    overscroll-behavior: contain;
}

/* ---------- Insights ---------- */
.layer {
    position: fixed;
    inset: 0;
    z-index: 1150;
    display: none;
    padding: 32px;
    background: var(--overlay);
    backdrop-filter: blur(4px);
}

.layer.show {
    display: flex;
    animation: fade-in 0.15s ease;
}

.layer-sheet {
    display: flex;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modal-pop-in 0.26s var(--ease);
}

.layer-nav {
    display: flex;
    flex: 0 0 240px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
}

.layer-nav-inner {
    width: 100%;
    padding: 20px 14px;
}

.layer-nav-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 38px;
    margin-bottom: 2px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
}

.layer-nav-item i {
    width: 18px;
    font-size: 14px;
    text-align: center;
    color: var(--text-faint);
}

.layer-nav-item:hover {
    background: var(--hover);
    color: var(--text-strong);
}

.layer-nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}

.layer-nav-item.active i {
    color: var(--accent);
}

.layer-nav-divider {
    height: 1px;
    margin: 10px 8px;
    background: var(--border);
}

.layer-content {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
}

.layer-content-inner {
    flex: 1 1 auto;
    min-width: 0;
    padding: 28px 32px 48px;
}

.layer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
}

.layer-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    box-shadow: var(--shadow-xs);
}

.layer-close-btn:hover {
    color: var(--text-strong);
    background: var(--surface-2);
}

.layer-close-btn .layer-close-circle {
    display: contents;
}

.layer-close-btn > span:not(.layer-close-circle) {
    display: none;
}

.layer-section-title {
    margin: 2px 60px 20px 0;
    color: var(--text-strong);
    font-size: 20px;
    font-weight: 600;
}

.layer-pane {
    display: none;
}

.layer-pane.active {
    display: block;
}

/* ---------- Toasts ---------- */
.toast-stack {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.panel-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(440px, calc(100vw - 48px));
    padding: 12px 16px 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    animation: toast-in 0.25s var(--ease);
}

.panel-toast.leaving {
    animation: toast-out 0.18s ease forwards;
}

.panel-toast .toast-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.panel-toast.success .toast-icon { color: var(--success); }
.panel-toast.error .toast-icon { color: var(--danger); }
.panel-toast.info .toast-icon { color: var(--accent); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(10px); }
}

/* ---------- Tooltips ---------- */
.tooltip-layer {
    position: fixed;
    z-index: 2000;
    max-width: min(280px, calc(100vw - 16px));
    padding: 6px 10px;
    border-radius: var(--radius-xs);
    background: var(--surface-inverse);
    color: var(--text-inverse);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    width: max-content;
    white-space: normal;
    overflow-wrap: break-word;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: opacity 0.1s;
}

.tooltip-layer.show {
    opacity: 1;
}

.tooltip-sub {
    display: block;
    margin-top: 2px;
    opacity: 0.7;
    font-weight: 400;
}

/* ---------- Command palette (Ctrl+K) ---------- */
.switcher {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 16px 16px;
    background: var(--overlay);
    backdrop-filter: blur(4px);
}

.switcher.show {
    display: flex;
    animation: fade-in 0.12s ease;
}

.switcher-dialog {
    width: 100%;
    max-width: 620px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modal-pop-in 0.24s var(--ease);
}

.switcher-input {
    width: 100%;
    height: 58px;
    padding: 0 20px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text-strong);
    font-size: 16px;
    outline: none;
}

.switcher-input::placeholder {
    color: var(--text-faint);
}

.switcher-results {
    max-height: 380px;
    padding: 8px;
    overflow-y: auto;
}

.switcher-group {
    padding: 10px 12px 6px;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.switcher-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    text-align: left;
}

.switcher-item i {
    width: 18px;
    text-align: center;
    color: var(--text-faint);
}

.switcher-item .switcher-hint {
    margin-left: auto;
    color: var(--text-faint);
    font-size: 12px;
}

.switcher-item.active {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.switcher-item.active i:not(.text-success) {
    color: var(--accent);
}

.switcher-empty {
    padding: 28px 12px;
    color: var(--text-muted);
    text-align: center;
}

.switcher-footer {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
}

/* ---------- Floating action bar ---------- */
.action-bar {
    position: fixed;
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2);
    bottom: 20px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: min(860px, calc(100vw - var(--sidebar-w) - 64px));
    margin: 0;
    padding: 10px 10px 10px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    transform: translate(-50%, 24px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.25s var(--ease), opacity 0.2s, visibility 0s linear 0.25s;
}

.action-bar.show {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.25s var(--ease), opacity 0.2s, visibility 0s;
}

.content:has(.action-bar.show) {
    padding-bottom: 112px;
}

.action-bar-text {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 150px;
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 600;
}

/* Selection dot: breathes like the "Online" dots; each change of the selection
   (app.js toggles .pinged) sends one expanding ring out of it. */
.action-bar-text::before {
    content: "";
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
    animation: pulse 2s ease-in-out infinite;
}

.action-bar-text.pinged::before {
    animation: selection-ping 0.6s ease-out, pulse 2s ease-in-out 0.6s infinite;
}

@keyframes selection-ping {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); transform: scale(1.35); }
    100% { box-shadow: 0 0 0 12px transparent; transform: scale(1); }
}

.action-bar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- Stat tiles ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.stat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--neutral-soft);
    color: var(--neutral-text);
    font-size: 13px;
    flex: 0 0 auto;
}

.stat-icon.green { background: var(--success-soft); color: var(--success-text); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger-text); }
.stat-icon.blurple { background: var(--accent-soft); color: var(--accent-text); }
.stat-icon.yellow { background: var(--warning-soft); color: var(--warning-text); }
.stat-icon.cyan { background: var(--info-soft); color: var(--info-text); }
.stat-icon.fuchsia { background: var(--pink-soft); color: var(--pink-text); }

.stat-value {
    color: var(--text-strong);
    font-size: 28px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-detail {
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.stat-compact-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.meter {
    height: 6px;
    margin-top: 6px;
    border-radius: 3px;
    background: var(--surface-3);
    overflow: hidden;
}

.meter > span,
.meter > div {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.5s var(--ease), background-color 0.3s;
}

.meter .progress-success { background: var(--success); }
.meter .progress-warning { background: var(--warning); }
.meter .progress-danger { background: var(--danger); }
.meter .progress-info { background: var(--accent); }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dash-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 28px 0 14px;
}

.dash-toolbar-title {
    margin-right: 4px;
    color: var(--text-strong);
    font-size: 16px;
    font-weight: 600;
}

.dash-search {
    width: 260px;
    max-width: 100%;
}

.chip-row {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    text-transform: uppercase;
}

.chip:hover {
    color: var(--text-strong);
}

.chip.active {
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-xs);
}

.chip-count {
    color: var(--text-faint);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.chip .dot {
    width: 6px;
    height: 6px;
    box-shadow: none;
}

.ops-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 14px 20px;
}

.ops-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.bot-groups {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bot-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.bot-group-header {
    border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0;
}

.bot-group.collapsed .bot-group-header {
    border-radius: calc(var(--radius-md) - 1px);
}

.bot-grid > .bot-card:last-child {
    border-radius: 0 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px);
}

.bot-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
}

.bot-group-header:hover {
    background: var(--surface-3);
}

.bot-group-header .fa-chevron-down {
    width: 14px;
    color: var(--text-faint);
    font-size: 11px;
    transition: transform 0.15s var(--ease);
}

.bot-group.collapsed .bot-group-header {
    border-bottom-color: transparent;
}

.bot-group.collapsed .bot-group-header .fa-chevron-down {
    transform: rotate(-90deg);
}

.bot-group.collapsed .bot-grid {
    display: none;
}

.bot-group-meta {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-transform: none;
}

.bot-group-meta .off {
    color: var(--danger-text);
}

.bot-grid {
    display: flex;
    flex-direction: column;
}

.bot-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.1s;
}

.bot-card:last-child {
    border-bottom: 0;
}

.bot-card:hover {
    background: var(--surface-2);
}

.bot-card.selected {
    background: var(--accent-soft);
}

.bot-card.focused {
    animation: focus-flash 1.8s ease;
}

@keyframes focus-flash {
    0%, 40% { background: var(--warning-soft); }
    100% { background: transparent; }
}

.bot-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1 1 auto;
    min-width: 0;
}

.bot-card .avatar {
    border-radius: 10px;
}

.bot-card .avatar-status {
    border-color: var(--surface);
}

.bot-card-info {
    flex: 1 1 auto;
    min-width: 0;
}

.bot-name {
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bot-name.upper {
    text-transform: none;
}

.bot-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.bot-sub i {
    font-size: 10px;
    color: var(--text-faint);
}

.bot-sub .truncate {
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.bot-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: 70px;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    flex: 0 0 auto;
}

.bot-status.online {
    background: var(--success-soft);
    color: var(--success-text);
}

.bot-status.offline {
    background: var(--neutral-soft);
    color: var(--neutral-text);
}

.bot-status .dot {
    width: 6px;
    height: 6px;
    box-shadow: none;
}

.bot-status.online .dot,
.badge .dot.online {
    animation: pulse 2s ease-in-out infinite;
}

.badge .dot.online {
    width: 6px;
    height: 6px;
    box-shadow: none;
}

.bot-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.bot-card-actions .spacer {
    width: 1px;
    height: 20px;
    margin: 0 6px;
    background: var(--border);
}

.bot-card-actions .btn-sm {
    min-height: 32px;
}

.bot-card-actions .btn-icon {
    width: 32px;
    min-height: 32px;
}

.dash-empty-filter {
    margin-top: 16px;
}

/* ---------- Logs viewer ---------- */
.logs-viewer {
    position: relative;
    overflow-anchor: none;
    min-height: 160px;
    max-height: calc(100vh - 280px);
    max-height: calc(100dvh - 280px);
    overflow: auto;
    border-radius: var(--radius-sm);
    background: #0d1017;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 20px;
}

/* Long lines wrap under their own text (after the line number) instead of
   scrolling sideways. */
.logs-lines {
    padding: 10px 0;
}

.log-line {
    position: relative;
    display: flex;
    gap: 14px;
    padding: 0 40px 0 0;
    white-space: pre-wrap;
    color: #c6cbd8;
}

.log-line:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Per-line copy button: shown on hover/focus (always, but faint, on touch). */
.log-copy {
    position: absolute;
    top: 0;
    right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 20px;
    padding: 0;
    border: 1px solid #2a3040;
    border-radius: 5px;
    background: #151922;
    color: #8a91a6;
    font-size: 11px;
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.12s, color 0.12s;
}

.log-line:hover .log-copy,
.log-copy:focus-visible,
.log-copy.copied {
    opacity: 1;
}

.log-copy:hover {
    color: #e6e9f2;
    border-color: #3a4256;
}

.log-copy.copied {
    color: #6ee7a8;
    border-color: rgba(110, 231, 168, 0.4);
}

@media (hover: none) {
    .log-copy {
        opacity: 0.55;
    }
}

.log-number {
    width: 52px;
    padding-right: 10px;
    text-align: right;
    color: #4c5468;
    background: #0d1017;
    user-select: none;
    flex: 0 0 auto;
}

.log-line:hover .log-number {
    background: #151922;
}

.log-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Phones: narrower line-number gutter. */
@media (max-width: 767px) {
    .log-line {
        gap: 10px;
        padding-right: 36px;
    }

    .log-number {
        width: 40px;
        padding-right: 6px;
    }
}

.log-error { color: #ff8f86; }
.log-warning { color: #fdc367; }
.log-info { color: #b5c2ff; }
.log-debug { color: #6b7389; }
.log-success { color: #6ee7a8; }
.log-timestamp { color: #7aa7e6; }

.logs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 180px;
    color: #8a91a6;
    font-family: var(--font);
}

.logs-empty svg {
    width: 30px;
    height: 30px;
    opacity: 0.6;
}

.logs-loading,
.logs-loading-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #8a91a6;
    font-family: var(--font);
    font-size: 13px;
}

.logs-loading {
    min-height: 180px;
}

.logs-loading-row {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    padding: 10px 0;
    background: #0d1017;
    box-shadow: 0 6px 12px -6px rgba(0, 0, 0, 0.6);
}

.logs-loading .spinner,
.logs-loading-row .spinner {
    width: 14px;
    height: 14px;
    color: #7c6dff;
}

.logs-marker {
    position: sticky;
    left: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 14px;
    color: #9aa3ff;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
}

.logs-marker::before,
.logs-marker::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.logs-marker.muted {
    color: #6b7389;
    font-weight: 500;
}

.logs-body {
    position: relative;
}

.logs-jump {
    position: absolute;
    left: 50%;
    bottom: 32px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
    animation: pop-in 0.15s var(--ease);
}

.logs-jump:hover {
    background: var(--accent-hover);
}

.logs-jump i {
    font-size: 11px;
}

.logs-toolbar select.form-control {
    width: auto;
    min-width: 200px;
    max-width: 320px;
}

/* Phones: file picker, Live badge and Refresh share one line; the picker takes
   whatever width is left. */
@media (max-width: 767px) {
    .logs-toolbar {
        flex-wrap: nowrap;
    }

    .logs-toolbar select.form-control {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
    }

    .logs-toolbar > .flex-1 {
        display: none;
    }

    .logs-toolbar > .badge,
    .logs-toolbar > .btn {
        flex: 0 0 auto;
    }
}

@media (max-width: 359px) {
    .logs-refresh-label {
        display: none;
    }
}

/* ---------- Insights ---------- */
.insights-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.insights-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.insights-stat span {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.insights-stat strong {
    color: var(--text-strong);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.insights-loading,
.insights-empty,
.insights-error {
    padding: 20px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.insights-error {
    border-style: solid;
    border-color: transparent;
    background: var(--danger-soft);
    color: var(--danger-text);
}

.insights-card {
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    font-size: 14px;
}

.insights-card + .insights-card,
.insights-empty + .insights-card,
.insights-card + .insights-empty,
.insights-card + .insights-table-wrap,
.insights-empty + .insights-empty {
    margin-top: 14px;
}

.insights-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.insights-card-header strong {
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 600;
}

.insights-card-header span {
    color: var(--text-muted);
    font-size: 13px;
}

.insights-card .kv {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 4px 12px;
    margin: 0 0 12px;
}

.insights-card .kv dt {
    color: var(--text-muted);
    font-size: 13px;
}

.insights-card .kv dd {
    margin: 0;
    color: var(--text-strong);
    word-break: break-word;
}

.insights-admin-form {
    display: grid;
    gap: 10px;
}

.insights-admin-form input,
.insights-admin-form textarea {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-strong);
    font-size: 14px;
    outline: none;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.insights-admin-form input:focus,
.insights-admin-form textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.insights-admin-form input:disabled,
.insights-admin-form textarea:disabled {
    background: var(--surface-3);
    color: var(--text-muted);
}

.insights-admin-form textarea {
    min-height: 90px;
    resize: vertical;
}

.insights-admin-form .row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.insights-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.insights-reply {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-xs);
    background: var(--accent-soft);
    color: var(--text-strong);
}

.insights-report-status {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.insights-message {
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-strong);
    white-space: pre-wrap;
    word-break: break-word;
}

.insights-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.insights-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.insights-table th {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

.insights-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.insights-table tbody tr:first-child td {
    border-top: 0;
}

.insights-table tr:hover td {
    background: var(--surface-2);
}

.insights-table code {
    white-space: nowrap;
    word-break: normal;
}

.insights-table .form-control {
    height: 34px;
    padding: 6px 10px;
    font-size: 13px;
    min-width: 140px;
}

.insights-guild-avatar {
    width: 34px;
    height: 34px;
}

.insights-guild-avatar-img,
.insights-guild-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    object-fit: cover;
}

.insights-guild-name {
    color: var(--text-strong);
    font-weight: 600;
}

.guild-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.guild-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(0, 2fr) 280px;
    align-items: center;
    gap: 12px 24px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.guild-row:last-child {
    border-bottom: 0;
}

.guild-row:hover {
    background: var(--surface-2);
}

.guild-row-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.guild-row-identity {
    min-width: 0;
}

.guild-row-id {
    display: inline-block;
    margin-top: 3px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 11.5px;
    white-space: nowrap;
    word-break: normal;
}

.guild-row-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px 16px;
    margin: 0;
    min-width: 0;
}

.guild-row-meta dt {
    color: var(--text-faint);
    font-size: 11.5px;
}

.guild-row-meta dd {
    margin: 0;
    color: var(--text-strong);
    font-size: 13.5px;
}

.guild-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    min-width: 0;
}

.guild-row-invite {
    max-width: 200px;
    font-size: 13px;
}

@media (max-width: 1100px) {
    .guild-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .guild-row-meta {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .guild-row-actions {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (max-width: 600px) {
    .guild-row-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .guild-row-actions {
        grid-column: 1 / -1;
        grid-row: 3;
        justify-content: space-between;
    }

    .guild-row-invite {
        max-width: none;
    }
}

.insights-read-only {
    margin-bottom: 14px;
}

.insights-filter {
    max-width: 340px;
    margin-bottom: 14px;
}

/* ---------- Config editor (legacy) ---------- */
.config-split {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 60vh;
    border-top: 1px solid var(--border);
}

.config-sidebar {
    border-right: 1px solid var(--border);
    background: var(--surface-2);
    overflow-y: auto;
}

.config-file-item,
.config-folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.config-file-item:hover,
.config-folder-header:hover {
    background: var(--hover-strong);
}

.config-file-item.active {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.config-folder-body {
    padding-left: 12px;
}

.config-folder-body.collapsed {
    display: none;
}

.folder-count {
    margin-left: auto;
    color: var(--text-faint);
    font-size: 12px;
}

.config-editor-body {
    padding: 20px;
    overflow: auto;
}

.config-raw-view {
    min-height: 50vh;
    font-family: var(--font-mono);
    font-size: 13px;
}

.json-field {
    margin-bottom: 12px;
}

.json-field-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.json-field-key {
    color: var(--text-strong);
    font-size: 13px;
    font-weight: 600;
}

.json-field-type {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 11px;
}

.json-field-input {
    width: 100%;
    height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-strong);
}

.json-object-group {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.json-object-header {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-2);
    cursor: pointer;
}

.json-object-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-strong);
    font-weight: 600;
}

.json-object-body {
    padding: 12px;
}

.json-object-body.collapsed {
    display: none;
}

.json-array-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.json-array-index {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 12px;
}

.json-array-remove,
.json-array-add {
    padding: 5px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
}

.json-field-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--border-strong);
    cursor: pointer;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}

.toggle-switch.active {
    background: var(--accent);
}

.toggle-switch.active::after {
    transform: translateX(18px);
}

/* ==========================================================================
   Workspace pages
   ========================================================================== */
.filters-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 1fr)) minmax(220px, 1.4fr);
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.table-footer .form-label {
    margin: 0;
    color: var(--text-muted);
    font-weight: 400;
}

.audit-time {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.audit-actor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-strong);
    font-weight: 500;
    white-space: nowrap;
}

.audit-details {
    max-width: 520px;
    color: var(--text);
    font-size: 13px;
    word-break: break-word;
}

.workspace-qr {
    width: 176px;
    height: 176px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
}

.setting-row-name {
    color: var(--text-strong);
    font-weight: 500;
}

.setting-row-key {
    margin-top: 2px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.settings-list {
    display: flex;
    flex-direction: column;
}

.settings-row {
    display: grid;
    grid-template-columns: minmax(200px, 36%) minmax(0, 1fr);
    align-items: center;
    gap: 8px 32px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
    border-bottom: 0;
}

.settings-row-control {
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    word-break: break-word;
}

.settings-row-control .form-control,
.settings-row-control .password-field {
    max-width: 520px;
}



.incident-sig {
    color: var(--danger-text);
    font-family: var(--font-mono);
    font-size: 12.5px;
    word-break: break-word;
}

/* ==========================================================================
   Users
   ========================================================================== */
.member-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
}

.member-name {
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 600;
}

.member-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 3px;
}

.member-tags .badge {
    height: 20px;
    font-size: 11px;
}

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

.member-search {
    width: 280px;
    max-width: 100%;
}

.member-list tr[data-modal-open] {
    cursor: pointer;
}

.manage-section + .manage-section {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.manage-section-title {
    margin-bottom: 10px;
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 600;
}

.danger-zone {
    padding: 16px;
    border: 1px solid var(--danger-soft);
    border-radius: var(--radius-md);
    background: var(--danger-soft);
}

/* ==========================================================================
   Account
   ========================================================================== */
.profile-card {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.profile-avatar {
    width: 72px;
    height: 72px;
    font-size: 26px;
}

.profile-avatar .avatar-status {
    width: 16px;
    height: 16px;
    border-width: 3px;
    right: 1px;
    bottom: 1px;
}

.profile-identity {
    flex: 1 1 240px;
    min-width: 0;
}

.profile-name {
    color: var(--text-strong);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.profile-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.profile-upload {
    flex: 1 1 360px;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.account-grid > .card + .card {
    margin-top: 0;
}

.account-grid > .card,
.account-grid > .card > form {
    display: flex;
    flex-direction: column;
}

.account-grid > .card > form {
    flex: 1 1 auto;
}

.account-grid > .card > form > .card-body,
.account-grid > .card > .card-body {
    flex: 1 1 auto;
}

.account-grid .span-2 {
    grid-column: 1 / -1;
}

.secret-box {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    word-break: break-all;
}

.passkey-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.passkey-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.passkey-item:last-child {
    border-bottom: 0;
}

.passkey-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
    flex: 0 0 auto;
}

.passkey-meta {
    color: var(--text-muted);
    font-size: 12px;
}

/* ==========================================================================
   Reconcile + To-do
   ========================================================================== */
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.id-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 4px 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-strong);
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.id-chip button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-faint);
    font-size: 11px;
}

.id-chip button:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.reconcile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.reconcile-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 14px;
}

.reconcile-search {
    width: 230px;
    max-width: 100%;
}

.reconcile-protected-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 14px;
}

.reconcile-protected-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
}

.reconcile-protected-title .fa-shield-alt {
    color: var(--accent);
}

.reconcile-protected-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    flex: 1;
    min-width: 0;
}

.reconcile-protected-content[hidden] {
    display: none;
}

.reconcile-protected-form {
    width: 300px;
    max-width: 100%;
    margin-left: auto;
}

.reconcile-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.reconcile-list:empty {
    display: none;
}

.reconcile-bot-card {
    border-bottom: 1px solid var(--border);
}

.reconcile-bot-card:last-child {
    border-bottom: 0;
}

.reconcile-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 5px 14px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.reconcile-row:hover {
    background: var(--surface-2);
}

.reconcile-bot-card:first-child .reconcile-row {
    border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0;
}

.reconcile-bot-card:last-child:not(.expanded) .reconcile-row {
    border-radius: 0 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px);
}

.reconcile-chevron {
    width: 12px;
    color: var(--text-faint);
    font-size: 11px;
    transition: transform 0.15s var(--ease);
}

.reconcile-bot-card.expanded .reconcile-chevron {
    transform: rotate(90deg);
}

.reconcile-row-name {
    min-width: 170px;
    color: var(--text-strong);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
}

.reconcile-row-summary {
    flex: 1 1 auto;
    color: var(--text-muted);
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reconcile-row .reconcile-badges {
    justify-content: flex-end;
}

.reconcile-body {
    padding: 4px 16px 16px 40px;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 2px 12px;
}

.check-grid .check-row {
    padding: 5px 8px;
}

.check-grid .check-row-label {
    font-size: 12.5px;
}

.check-grid .check-row-desc {
    font-size: 11.5px;
}

.check-grid-empty {
    grid-column: 1 / -1;
    padding: 6px 8px;
    color: var(--text-faint);
    font-size: 12.5px;
}

@media (max-width: 767px) {
    .reconcile-row {
        flex-wrap: wrap;
        gap: 4px 10px;
    }

    .reconcile-row-name {
        min-width: 0;
        flex: 1 1 auto;
    }

    .reconcile-row-summary {
        order: 3;
        flex-basis: 100%;
        padding-left: 22px;
    }

    .reconcile-row .reconcile-badges {
        order: 4;
        padding-left: 22px;
    }

    .reconcile-body {
        padding-left: 16px;
    }

    .reconcile-protected-row,
    .reconcile-protected-content {
        flex-direction: column;
        align-items: stretch;
    }

    .reconcile-protected-form {
        width: 100%;
        margin-left: 0;
    }

    .reconcile-search {
        width: 100%;
    }
}

.check-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.check-row:hover {
    background: var(--surface-2);
}

.check-row.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.check-row-label {
    color: var(--text-strong);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    word-break: break-all;
}

.check-row-desc {
    color: var(--text-muted);
    font-size: 12px;
}

.reconcile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.todo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.todo-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.todo-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.todo-card-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.todo-card[data-status="done"] .todo-desc {
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--text-faint);
}

.todo-desc {
    color: var(--text-strong);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.todo-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: var(--text-muted);
    font-size: 12px;
}

.todo-meta i {
    color: var(--text-faint);
}

.todo-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.todo-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    padding: 10px 12px 10px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.todo-pagination-info {
    color: var(--text-muted);
    font-size: 13px;
}

.todo-pagination-info strong {
    color: var(--text-strong);
    font-weight: 600;
}

.todo-foot select {
    width: auto;
    min-width: 140px;
}

a.badge.todo-nav-link:hover {
    background: var(--hover-strong);
    color: var(--text-strong);
}

.todo-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-bottom: 16px;
    padding: 10px 14px;
}

.todo-filter-select {
    width: 190px;
    max-width: 100%;
}

.todo-search {
    flex: 1 1 240px;
    max-width: 360px;
}

.todo-label-emoji {
    font-size: 12px;
    line-height: 1;
}

.todo-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.todo-thumb {
    position: relative;
    width: 64px;
    height: 48px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    cursor: zoom-in;
}

.todo-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.todo-thumb:hover,
.todo-thumb:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.todo-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

textarea.todo-autogrow {
    min-height: 84px;
    max-height: 260px;
    resize: none;
}

.todo-shots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.todo-shots:not(:empty) {
    margin-bottom: 10px;
}

.todo-shot {
    position: relative;
    width: 84px;
    height: 64px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface-2);
}

.todo-shot img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
}

.todo-shot.pending::after {
    content: "New";
    position: absolute;
    bottom: 4px;
    left: 4px;
    padding: 1px 5px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
}

.todo-shot-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(8, 9, 16, 0.7);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
}

.todo-shot-remove:hover {
    background: var(--danger);
}

.todo-dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.todo-dropzone i {
    font-size: 18px;
    color: var(--text-faint);
}

.todo-dropzone:hover,
.todo-dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.todo-dropzone.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.todo-dropzone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.todo-label-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.todo-label-editor.editing {
    border-color: var(--accent);
}

.todo-label-editor-row {
    display: flex;
    gap: 8px;
}

.todo-label-emoji-input {
    flex: 0 0 64px;
    text-align: center;
}

.todo-label-colors {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.todo-color-swatch {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.todo-color-swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.todo-color-swatch span {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: var(--neutral-soft);
    box-shadow: inset 0 0 0 5px var(--surface-2);
}

.todo-color-swatch.violet span { background: var(--accent-text); }
.todo-color-swatch.blue span { background: var(--info-text); }
.todo-color-swatch.green span { background: var(--success-text); }
.todo-color-swatch.amber span { background: var(--warning-text); }
.todo-color-swatch.red span { background: var(--danger-text); }
.todo-color-swatch.pink span { background: var(--pink-text); }
.todo-color-swatch.gray span { background: var(--neutral-text); }

.todo-color-swatch input:checked + span {
    border-color: var(--text-strong);
}

.todo-color-swatch input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.todo-label-preview-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
}

.todo-label-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.todo-label-manager li.editing {
    background: var(--accent-soft);
}

@media (max-width: 600px) {
    .todo-form-row {
        grid-template-columns: 1fr;
    }

    .todo-search,
    .todo-filter-select {
        flex: 1 1 100%;
        width: 100%;
        max-width: none;
    }

    .todo-label-preview-wrap {
        margin-left: 0;
    }
}

.todo-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.todo-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    max-width: 100%;
    padding: 0 9px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--neutral-soft);
    color: var(--neutral-text);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

a.todo-label:hover,
.todo-label.active {
    border-color: currentColor;
}

.todo-label.violet { background: var(--accent-soft); color: var(--accent-text); }
.todo-label.blue { background: var(--info-soft); color: var(--info-text); }
.todo-label.green { background: var(--success-soft); color: var(--success-text); }
.todo-label.amber { background: var(--warning-soft); color: var(--warning-text); }
.todo-label.red { background: var(--danger-soft); color: var(--danger-text); }
.todo-label.pink { background: var(--pink-soft); color: var(--pink-text); }

.todo-label-manager {
    display: flex;
    flex-direction: column;
    margin: -6px 0;
    padding: 0;
    list-style: none;
}

.todo-label-manager li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 2px 6px 6px;
    border-radius: var(--radius-xs);
    border-bottom: 1px solid var(--border);
}

.todo-label-manager li:last-child {
    border-bottom: 0;
}

/* ==========================================================================
   Auth / error pages
   ========================================================================== */
/* Split sign-in layout (same structure as the download portal): brand panel with a
   fading grid on the left, form on the right; follows the light/dark theme. */
.auth-page {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
}

.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    overflow: hidden;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--border-strong) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-strong) 1px, transparent 1px);
    background-size: 34px 34px;
    opacity: 0.35;
    -webkit-mask-image: radial-gradient(circle at 30% 30%, #000, transparent 70%);
    mask-image: radial-gradient(circle at 30% 30%, #000, transparent 70%);
    pointer-events: none;
}

:root:not([data-theme="dark"]) .auth-brand::before {
    opacity: 0.6;
}

.auth-brand > * {
    position: relative;
}

.auth-brand-logo {
    align-self: flex-start;
    width: auto;
    height: 38px;
}

/* The wordmark is white; invert it on the light theme (like the sidebar logo). */
:root:not([data-theme="dark"]) .auth-brand-logo {
    filter: invert(1) hue-rotate(180deg) saturate(1.4);
}

.auth-brand-copy {
    max-width: 380px;
}

.auth-kicker {
    margin-bottom: 10px;
    color: var(--accent-text);
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-brand-copy h2 {
    margin-bottom: 12px;
    color: var(--text-strong);
    font-size: 26px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.auth-brand-copy p {
    color: var(--text-muted);
    font-size: 14.5px;
    line-height: 1.55;
}

.auth-theme-toggle {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 34px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    box-shadow: var(--shadow-xs);
}

.auth-theme-toggle:hover {
    color: var(--text-strong);
    border-color: var(--accent);
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg);
}

.auth-page.single {
    grid-template-columns: minmax(0, 1fr);
    background: var(--bg);
}

.auth-page.single .auth-main {
    background: transparent;
}

.auth-card {
    width: 100%;
    max-width: 340px;
}

.auth-page.single .auth-card {
    max-width: 440px;
    padding: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.auth-title {
    color: var(--text-strong);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    margin-top: 4px;
    margin-bottom: 28px;
    color: var(--text-faint);
    font-size: 13.5px;
}

/* Portal-style fields on the split sign-in pages: small mono uppercase labels,
   squarer inputs, gradient primary button. */
.auth-page:not(.single) .auth-card .form-label {
    margin-bottom: 7px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.auth-page:not(.single) .auth-card .form-group {
    margin-bottom: 18px;
}

.auth-page:not(.single) .auth-card .form-control {
    height: 40px;
    border-radius: var(--radius-xs);
    background: var(--bg);
    box-shadow: none;
}

.auth-page:not(.single) .auth-card .form-control.otp-input {
    height: 52px;
}

.auth-page:not(.single) .auth-card .btn-lg {
    height: 36px;
    border-radius: var(--radius-xs);
    font-size: 14px;
}

.btn.auth-submit {
    border: 0;
    background: var(--accent-gradient);
    box-shadow: none;
}

.btn.auth-submit:hover:not(:disabled) {
    filter: brightness(1.08);
}

.auth-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--accent);
    font-size: 20px;
    box-shadow: var(--shadow-xs);
}

.auth-icon.danger { color: var(--danger); }
.auth-icon.success { color: var(--success); }
.auth-icon.warning { color: var(--warning); }

.text-center .auth-icon,
.auth-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-text);
    font-size: 14px;
    font-weight: 500;
}

.auth-link.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.auth-footer {
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 14px 0;
    color: var(--text-faint);
    font-size: 12.5px;
    font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: var(--border);
}

.auth-alert {
    margin-bottom: 18px;
}

.auth-form .form-control {
    height: 44px;
}

.label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.label-row .auth-link {
    font-size: 12.5px;
}

.auth-page .auth-card .label-row .form-label {
    margin-bottom: 0;
}

.otp-input {
    height: 56px !important;
    font-family: var(--font-mono);
    font-size: 26px;
    letter-spacing: 0.5em;
    text-align: center;
    padding-left: 0.5em;
}

.error-stage {
    position: relative;
    isolation: isolate;
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: calc(100vh - var(--topbar-h) - 96px);
    min-height: calc(100dvh - var(--topbar-h) - 96px);
    padding: 32px 16px;
    overflow: hidden;
    text-align: center;
}

.auth-page.error-layout .auth-main {
    padding: 0;
}

.auth-page.error-layout .error-stage {
    min-height: 100vh;
    min-height: 100dvh;
}

.error-stage::before {
    content: "";
    position: absolute;
    inset: -36px -40px;
    z-index: -2;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 34px 34px;
    -webkit-mask-image: radial-gradient(ellipse 55% 55% at 50% 42%, #000 0%, transparent 72%);
    mask-image: radial-gradient(ellipse 55% 55% at 50% 42%, #000 0%, transparent 72%);
}

.error-stage::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: -1;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
    transform: translate(-50%, -55%);
    pointer-events: none;
}

.error-stage-code {
    font-family: var(--font-mono);
    font-size: clamp(72px, 16vw, 136px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    background-image: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: error-stage-float 5s ease-in-out infinite;
}

@keyframes error-stage-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.error-stage-title {
    margin: 8px 0 8px;
    color: var(--text-strong);
    font-size: 21px;
    font-weight: 700;
}

.error-stage-message {
    max-width: 380px;
    margin: 0 0 28px;
    color: var(--text-muted);
    font-size: 14.5px;
}

@media (prefers-reduced-motion: reduce) {
    .error-stage-code {
        animation: none;
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .account-grid,
    .reconcile-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .layer {
        padding: 16px;
    }
}

@media (max-width: 860px) {
    /* Phone/tablet: the brand panel becomes a top bar with the logo. */
    .auth-page {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr;
    }

    .auth-brand {
        padding: 18px 24px;
        padding-top: calc(18px + env(safe-area-inset-top));
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .auth-brand-logo {
        height: 30px;
    }

    .auth-brand-copy {
        display: none;
    }

    .auth-theme-toggle {
        top: calc(16px + env(safe-area-inset-top));
        right: 20px;
    }

    .auth-main {
        padding: 40px 24px;
    }
}

@media (max-width: 960px) {

    .bot-card {
        flex-wrap: wrap;
        gap: 10px 16px;
    }

    .bot-card-head {
        flex-basis: 100%;
    }

    .bot-card-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .bot-card-actions .spacer {
        margin-right: auto;
        visibility: hidden;
    }
}

@media (max-width: 767px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(var(--sidebar-w), calc(100vw - 48px));
        transform: translateX(-100%);
        transition: transform 0.25s var(--ease);
        z-index: 1000;
        box-shadow: var(--shadow-xl);
    }

    body.drawer-open .sidebar {
        transform: none;
    }

    .drawer-backdrop {
        position: fixed;
        inset: 0;
        z-index: 999;
        display: block;
        background: var(--overlay);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }

    body.drawer-open .drawer-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .topbar {
        gap: 8px;
        padding: 0 12px;
        height: 56px;
        min-height: 56px;
    }

    .topbar .topbar-menu-btn {
        display: inline-flex;
    }

    .search-trigger {
        width: 40px;
        padding: 0;
        justify-content: center;
        margin-left: auto;
    }

    .search-trigger > span,
    .search-trigger .kbd {
        display: none;
    }

    .topbar-spacer {
        display: none;
    }

    .user-menu-text,
    .user-menu-trigger .fa-chevron-down {
        display: none;
    }

    .user-menu-trigger {
        padding: 4px;
    }

    .toolbar-divider {
        display: none;
    }

    .content {
        padding: 20px 16px 40px;
    }

    .page-head {
        align-items: flex-start;
    }

    .page-head-title {
        font-size: 20px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat {
        padding: 14px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-icon {
        width: 28px;
        height: 28px;
    }

    .stat-compact-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        margin-top: 10px;
    }

    .member-search {
        width: 100%;
    }

    /* Group chips get their own line; "Select all" and the search share the next. */
    .dash-toolbar > .chip-row {
        flex: 1 0 100%;
    }

    .dash-toolbar > .flex-1 {
        display: none;
    }

    .dash-search {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }

    .chip-row {
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .bot-card {
        padding: 12px 14px;
    }

    .bot-status {
        width: auto;
    }

    .filters-bar {
        grid-template-columns: minmax(0, 1fr);
    }

    .ui-modal {
        padding:
            calc(12px + env(safe-area-inset-top))
            calc(12px + env(safe-area-inset-right))
            calc(12px + env(safe-area-inset-bottom))
            calc(12px + env(safe-area-inset-left));
    }

    .modal-dialog,
    .modal-md,
    .modal-lg,
    .modal-xl {
        max-width: none;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        border-radius: var(--radius-lg);
    }

    .modal-header,
    .modal-body,
    .modal-footer,
    .modal-toolbar {
        padding-left: 16px;
        padding-right: 16px;
    }

    .layer {
        padding: 0;
    }

    .layer-sheet {
        flex-direction: column;
        border-radius: 0;
        border: 0;
    }

    .layer-nav {
        flex: 0 0 auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }

    .layer-nav-inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        width: 100%;
        padding: 0 12px 12px;
    }

    .layer-nav-heading {
        flex: 0 0 100%;
        min-height: 52px;
        padding: 0 52px 0 4px;
        font-size: 14px;
    }

    .layer-nav-divider {
        display: none;
    }

    .layer-nav-item {
        width: auto;
        height: 32px;
        gap: 7px;
        margin: 0;
        padding: 0 11px;
        border: 1px solid var(--border);
        border-radius: var(--radius-pill);
        font-size: 13px;
        white-space: nowrap;
    }

    .layer-nav-item i {
        width: auto;
        font-size: 12px;
    }

    .layer-nav-item .tab-count {
        margin-left: 2px;
    }

    .layer-nav-item.active {
        border-color: transparent;
    }

    .layer-content-inner {
        padding: 18px 16px 48px;
    }

    .layer-close {
        position: fixed;
        top: 8px;
        right: 8px;
    }

    .insights-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .insights-stat {
        gap: 2px;
        padding: 12px 14px;
    }

    .insights-stat strong {
        font-size: 22px;
    }

    .layer-section-title {
        margin: 0 0 14px;
        font-size: 18px;
    }

    .config-split {
        grid-template-columns: minmax(0, 1fr);
    }

    .config-sidebar {
        max-height: 160px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .toast-stack {
        left: 12px;
        right: 12px;
        bottom: 12px;
        align-items: stretch;
    }

    .panel-toast {
        max-width: none;
    }

    .auth-page.single .auth-main {
        padding: 32px 20px;
        align-items: flex-start;
    }

    .auth-page.single .auth-card {
        padding: 24px 20px;
    }

    .action-bar {
        left: 50%;
        bottom: 12px;
        width: calc(100vw - 24px);
    }

    .insights-card .kv,
    .insights-admin-form .row-2 {
        grid-template-columns: minmax(0, 1fr);
    }

    .member-list .col-email,
    .member-list .col-actions {
        display: none;
    }

    .settings-row {
        grid-template-columns: minmax(0, 1fr);
        padding: 14px 16px;
    }

    .table th,
    .table td {
        padding-left: 16px;
        padding-right: 16px;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack tr {
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }

    .table-stack tbody tr:last-child {
        border-bottom: 0;
    }

    /* Stacked rows keep every label/value in the same two columns, even for cells
       right-aligned on desktop (e.g. Actions); cells with nothing to show are dropped. */
    .table-stack td {
        display: grid;
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 8px;
        align-items: start;
        padding: 4px 16px;
        border: 0;
        text-align: left;
    }

    .table-stack td.cell-empty {
        display: none;
    }

    /* Row actions: a real small button (icon + text) lined up with the values,
       instead of a borderless icon floating in a 30px box. */
    .table-stack td[data-label="Actions"] {
        align-items: center;
    }

    .table-stack td .btn-icon.btn-sm {
        width: auto;
        min-height: 28px;
        gap: 6px;
        padding: 0 10px;
        border: 1px solid var(--border-strong);
        color: var(--text);
        font-size: 12.5px;
    }

    .table-stack td .btn-icon.btn-sm.danger {
        border-color: color-mix(in srgb, var(--danger) 35%, transparent);
        color: var(--danger-text);
    }

    .table-stack td .btn-icon.btn-sm i {
        font-size: 11px;
    }

    .table-stack .stack-only {
        display: inline;
    }

    .table-stack td::before {
        content: attr(data-label);
        padding-top: 1px;
        color: var(--text-muted);
        font-size: 12px;
    }

    .table-stack td > * {
        min-width: 0;
        justify-self: start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Server admins (Sign in with Discord): "My servers" and per-server settings
   ========================================================================== */
.btn-discord {
    border: 0;
    background: #5865f2;
    color: #fff;
}

.btn-discord:hover:not(:disabled) {
    background: #4752c4;
    color: #fff;
}

.auth-hint {
    margin-top: 8px;
    color: var(--text-faint);
    font-size: 12.5px;
    text-align: center;
}

.servers-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
}

.servers-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.servers-brand .brand-logo {
    height: 28px;
}

.servers-nav {
    display: flex;
    gap: 4px;
    margin-left: 16px;
}

.servers-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.servers-nav-link.active,
.servers-nav-link:hover {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.servers-user {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 180px;
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 500;
}

.servers-main {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px 120px;
}

.servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.server-card {
    padding: 18px;
}

.server-card + .server-card {
    margin-top: 0;
}

.server-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.server-card-name {
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 600;
}

.server-card-sub {
    color: var(--text-muted);
    font-size: 12.5px;
}

.min-w-0 {
    min-width: 0;
}

.server-bot-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.server-bot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-strong);
    font-weight: 500;
    transition: border-color 0.15s, background 0.15s;
}

.server-bot:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.server-bot-name {
    flex: 1 1 auto;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.servers-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
}

.servers-back:hover {
    color: var(--accent-text);
}

.server-config-head .page-head-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-md {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

.cfg-section + .cfg-section {
    margin-top: 16px;
}

.cfg-fields {
    display: flex;
    flex-direction: column;
}

.cfg-field {
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    gap: 8px 20px;
    align-items: start;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.cfg-field:first-child {
    border-top: 0;
}

.cfg-field.changed {
    box-shadow: inset 3px 0 0 var(--accent);
    background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

.cfg-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 8px;
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 500;
}

.cfg-key {
    color: var(--text-faint);
    font-size: 11.5px;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.cfg-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.cfg-control .switch {
    padding-top: 8px;
}

.cfg-number {
    max-width: 180px;
}

.cfg-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 6px;
}

.cfg-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    max-width: 100%;
    padding: 0 4px 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-strong);
    font-size: 12.5px;
}

.cfg-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.cfg-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-faint);
    font-size: 10px;
    cursor: pointer;
}

.cfg-chip-remove:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.cfg-chip-add {
    max-width: 320px;
}

.cfg-records {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cfg-record {
    display: grid;
    grid-template-columns: repeat(var(--cfg-record-cols, 2), minmax(0, 1fr)) 30px;
    gap: 6px;
    align-items: center;
}

.cfg-control > .btn {
    align-self: flex-start;
}

.cfg-record-head span {
    color: var(--text-faint);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* No sidebar here: center the unsaved-changes bar on the whole viewport. */
.servers-shell .action-bar {
    left: 50%;
    width: min(860px, calc(100vw - 32px));
}

@media (max-width: 767px) {
    .servers-topbar {
        padding: 0 12px;
        gap: 8px;
    }

    .servers-nav,
    .servers-user-name,
    .servers-signout-label {
        display: none;
    }

    .servers-main {
        padding: 20px 14px 120px;
    }

    .cfg-field {
        grid-template-columns: minmax(0, 1fr);
        padding: 12px 14px;
    }

    .cfg-label {
        padding-top: 0;
    }

    .cfg-chip-add,
    .cfg-number {
        max-width: none;
    }

    .cfg-record {
        grid-template-columns: minmax(0, 1fr) 30px;
        padding: 8px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface-2);
    }

    .cfg-record > input:not(:first-child) {
        grid-column: 1;
    }

    .cfg-record > .btn {
        grid-row: 1;
        grid-column: 2;
    }

    .cfg-record-head {
        display: none;
    }
}
