:root {
    --bg-app: #0d0d0f;
    --bg-sidebar: #0a0a0c;
    --bg-sidebar-hover: #1c1c20;
    --surface: #17171a;
    --surface-2: #1c1c20;
    --accent: #5e6ad2;
    --accent-hover: #4e59c0;
    --accent-soft: rgba(94, 106, 210, 0.18);
    --text-main: #ececed;
    --text-muted: #8a8b93;
    --text-sidebar: #8a8b93;
    --text-sidebar-active: #ffffff;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --white: var(--surface);
    --radius: 8px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);

    --danger-bg: rgba(224, 82, 82, 0.12);
    --danger-text: #f2938e;
    --danger-border: rgba(224, 82, 82, 0.35);
    --success-bg: rgba(56, 161, 105, 0.14);
    --success-text: #7bdba0;
    --success-border: rgba(56, 161, 105, 0.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
}

a { text-decoration: none; color: inherit; }

.shell {
    display: block;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 232px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    overflow-y: auto;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px 8px;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.3px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { color: var(--text-sidebar-active); font-weight: 600; font-size: 13.5px; }
.brand-sub { color: var(--text-sidebar); font-size: 11px; }

.nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--text-sidebar);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.nav-item.active {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.nav-icon { display: flex; align-items: center; opacity: 0.85; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 10px;
}

.nav-item.logout:hover { background: var(--danger-bg); color: var(--danger-text); }

/* Main area */
.main {
    margin-left: 232px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 52px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    padding: 6px;
    border-radius: 6px;
}
.topbar-toggle:hover { background: var(--bg-sidebar-hover); }

.topbar-title { font-size: 14.5px; font-weight: 500; margin: 0; flex: 1; color: var(--text-main); }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 4px 12px 4px 4px;
    border-radius: 999px;
    font-weight: 500;
}
.topbar-user:hover { background: var(--bg-sidebar-hover); }

.topbar-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.topbar-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-size: 10.5px;
    font-weight: 600;
}

.content {
    flex: 1;
    padding: 24px 28px;
}

/* Cards / widgets */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
}

.card + .card { margin-top: 16px; }
.analytics-grid .card { margin-top: 0; }

.card-title { font-size: 14px; font-weight: 500; margin: 0 0 4px 0; color: var(--text-main); }
.card-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 16px 0; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
}

.stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 24px; font-weight: 500; margin-top: 6px; color: var(--text-main); }
.stat-value.accent { color: var(--accent); }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.5; }
.empty-state p { margin: 4px 0; font-size: 13.5px; }

/* Login page */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-app);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.login-title { font-size: 18px; font-weight: 500; margin: 0 0 4px 0; color: var(--text-main); }
.login-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 22px 0; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-main);
}
.field input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text-main);
}
.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 7px;
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease;
}
.btn-primary:hover { background: var(--accent-hover); }

.error-msg {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Workspace switcher — pinned at the bottom of the sidebar */
.ws-switcher {
    padding: 4px 0 0 0;
}

.ws-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 7px 10px;
    cursor: pointer;
    text-align: left;
    color: var(--text-sidebar);
    font-size: 13.5px;
    font-weight: 500;
}
.ws-trigger:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }
.ws-switcher.open .ws-trigger { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }

.ws-avatar {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ws-avatar.small { width: 18px; height: 18px; font-size: 10px; border-radius: 5px; }

.ws-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-chevron {
    color: var(--text-sidebar);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.ws-switcher.open .ws-chevron { transform: rotate(180deg); }

/* Accordion: expands inline (pushing Log out down, and the footer's own
   top edge up into the sidebar's empty space) instead of floating over
   whatever's above it. */
.ws-menu-wrap {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.ws-switcher.open .ws-menu-wrap { max-height: 320px; }

.ws-menu {
    padding: 6px 0 2px 0;
}

.ws-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-sidebar);
}
.ws-menu-item:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }
.ws-menu-item.active { color: var(--text-sidebar-active); font-weight: 500; }
.ws-menu-add {
    margin-top: 4px;
    border-top: 1px solid var(--border);
    padding-top: 9px;
    color: var(--accent);
    font-weight: 500;
}
.ws-menu-add:hover { color: var(--accent-hover); background: none; }

/* Flash / success message */
.success-msg {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Settings-style form inside a card */
.card form .field:last-of-type { margin-bottom: 20px; }
.card .btn-primary { width: auto; padding: 9px 20px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

@media (max-width: 720px) {
    .sidebar { z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .content { padding: 16px; }
}

/* Agents tab */
.agents-toolbar { margin-bottom: 16px; }
.new-folder-form { display: flex; gap: 10px; max-width: 420px; }
.new-folder-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text-main);
}
.new-folder-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.btn-small { padding: 8px 14px; font-size: 13px; white-space: nowrap; }
.btn-secondary {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-main);
    border-radius: 7px;
    font-weight: 500;
    cursor: pointer;
}
.btn-secondary:hover { background: var(--bg-sidebar-hover); border-color: var(--border-strong); }

.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.folder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.folder-card-head { display: flex; align-items: center; gap: 8px; }
.folder-icon { color: var(--accent); display: flex; }
.folder-name { font-weight: 500; font-size: 14px; flex: 1; color: var(--text-main); }
.folder-count {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 999px;
}

.folder-agents-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.folder-agents-list li {
    font-size: 12.5px;
    color: var(--text-main);
    background: var(--surface-2);
    padding: 6px 9px;
    border-radius: 6px;
}
.folder-empty-hint { font-size: 12px; color: var(--text-muted); margin: 0; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 14.5px; font-weight: 500; margin: 0; color: var(--text-main); }
.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}
.modal-close:hover { color: var(--text-main); }

.modal-body {
    padding: 10px 12px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-loading, .modal-error { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px 10px; }
.modal-error { color: var(--danger-text); }

.agent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 7px;
    cursor: pointer;
    border: 1px solid transparent;
}
.agent-row:hover { background: var(--bg-sidebar-hover); }
.agent-row.selected {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.agent-row-name { font-size: 13px; font-weight: 500; color: var(--text-main); }
.agent-row-id { font-size: 11px; color: var(--text-muted); font-family: monospace; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.modal-selected-count { font-size: 13px; color: var(--text-muted); }
.modal-footer .btn-primary { width: auto; padding: 9px 20px; }
.modal-footer .btn-primary:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

/* Agents — folder tabs across the top, table below */
.agents-tabs-row {
    display: flex;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.agents-tab {
    padding: 9px 14px;
    font-size: 13.5px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.agents-tab:hover { color: var(--text-main); }
.agents-tab.active { color: var(--text-main); font-weight: 500; border-bottom-color: var(--accent); }
.agents-tab-count { font-size: 11px; color: var(--text-muted); background: var(--surface-2); padding: 1px 7px; border-radius: 999px; }
.agents-tab.active .agents-tab-count { color: var(--text-main); }
.agents-tab-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 5px;
    margin-left: 2px;
}
.agents-tab-delete:hover { background: var(--danger-bg); color: var(--danger-text); }
.agents-tab-new {
    padding: 9px 12px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.agents-tab-new:hover { color: var(--accent); }
.agents-tab-new-form { display: flex; align-items: center; gap: 6px; padding: 6px 4px; }
.agents-tab-new-form input {
    width: 140px;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface-2);
    color: var(--text-main);
    font-family: inherit;
}
.agents-tab-new-form input:focus { outline: none; border-color: var(--accent); }

.agents-main-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.agents-main-head-actions { display: flex; align-items: center; gap: 8px; }
.agents-main-head .btn-primary { width: auto; padding: 8px 16px; flex-shrink: 0; }

.agents-search-wrap { position: relative; flex: 1; max-width: 280px; min-width: 160px; }
.agents-search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.agents-search-wrap input {
    width: 100%;
    padding: 7px 10px 7px 32px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    background: var(--surface-2);
    color: var(--text-main);
    font-family: inherit;
}
.agents-search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.agents-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.agents-table-head, .agents-table-row {
    display: grid;
    grid-template-columns: 18px 16px 24px 1.2fr 0.7fr 0.7fr 0.8fr 1fr 40px;
    gap: 10px;
    padding: 11px 16px;
    align-items: center;
}
.agents-table-head {
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.agents-table-row { border-top: 1px solid var(--border); font-size: 13px; }
.agents-table-row:hover { background: var(--surface-2); }
.agents-table-row.dragging { opacity: 0.4; }
.agents-table-row.hidden-by-search { display: none; }
.agent-drag-handle {
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: -1px;
    cursor: grab;
}
.agent-name-cell { font-weight: 500; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-meta-cell { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-meta-cell.is-empty { opacity: 0.6; }
.agent-id-cell { font-family: monospace; font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.row-remove-btn:hover { background: var(--danger-bg); color: var(--danger-text); }

.modal-search { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.modal-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text-main);
}
.modal-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Edit dropdown */
.dropdown-wrap { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 40;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-main);
}
.dropdown-item:hover { background: var(--bg-sidebar-hover); }

/* Change Voice / Model / Prompt modal extras */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    padding: 6px 0;
}
.checkbox-row input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
    background-color: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
}
.checkbox-row input[type="checkbox"]:checked { background-color: var(--accent); border-color: var(--accent); }
.checkbox-row input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.cv-options {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.cv-agents-list {
    margin-top: 6px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 10px;
}
.cv-agent-row { border-bottom: 1px solid var(--border); }
.cv-agent-row:last-child { border-bottom: none; }

/* Home — status text & activity log */
.status-text { font-size: 19px; }
.status-ok { color: var(--success-text); }
.status-error { color: var(--danger-text); }

.stat-value-small { font-size: 14px; font-weight: 500; margin-top: 6px; line-height: 1.3; color: var(--text-main); }
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.activity-log-card {
    height: 440px;
    display: flex;
    flex-direction: column;
}
.activity-log-card .card-title,
.activity-log-card .card-desc { flex-shrink: 0; }

.activity-log-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.activity-log-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.activity-log-row:hover { background: var(--surface-2); }
.activity-log-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.activity-log-user { font-weight: 500; font-size: 13px; flex-shrink: 0; color: var(--text-main); }
.activity-log-action { font-size: 13px; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-log-time { font-size: 11.5px; color: var(--text-muted); flex-shrink: 0; }

.activity-log-list .empty-state { padding: 40px 10px; }

.log-detail-body {
    padding: 16px 20px;
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-main);
}

#newPromptText {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text-main);
    resize: vertical;
    line-height: 1.5;
}
#newPromptText:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Model catalog (Settings) */
.model-catalog-list { margin-bottom: 16px; }
.model-catalog-row {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 12px;
    align-items: center;
    padding: 9px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.model-catalog-label { font-weight: 500; color: var(--text-main); }
.model-catalog-id { font-family: monospace; font-size: 11.5px; color: var(--text-muted); }

.model-add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.model-add-form input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text-main);
    flex: 1;
    min-width: 140px;
}
.model-add-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.new-user-password code {
    display: block;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--success-bg);
    color: var(--success-text);
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    user-select: all;
}

/* Toast notifications */
.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--text-muted);
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    font-size: 13px;
    color: var(--text-main);
    transform: translateX(24px);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}
.toast.toast-show { transform: translateX(0); opacity: 1; }
.toast.toast-hide { transform: translateX(24px); opacity: 0; }

.toast.toast-success { border-left-color: #38a169; }
.toast.toast-error { border-left-color: #e25252; }
.toast.toast-info { border-left-color: var(--accent); }

.toast-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.toast-success .toast-icon { background: var(--success-bg); color: var(--success-text); }
.toast-error .toast-icon { background: var(--danger-bg); color: var(--danger-text); }
.toast-info .toast-icon { background: var(--accent-soft); color: var(--accent); }

.toast-body { flex: 1; min-width: 0; line-height: 1.45; white-space: pre-wrap; }
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0 0 6px;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}
.toast-close:hover { color: var(--text-main); }

/* Custom confirm dialog (replaces window.confirm) */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 600;
    padding: 20px;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    padding: 20px;
    box-shadow: var(--shadow);
    transform: scale(0.96);
    opacity: 0;
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.16s ease;
}
.confirm-overlay.open .confirm-box { transform: scale(1); opacity: 1; }
.confirm-message { font-size: 13.5px; color: var(--text-main); line-height: 1.5; margin: 0 0 18px 0; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-actions .btn-secondary,
.confirm-actions .btn-primary { width: auto; padding: 8px 16px; }
.confirm-actions .btn-danger {
    width: auto;
    padding: 8px 16px;
    border: none;
    border-radius: 7px;
    background: #b93a3a;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.confirm-actions .btn-danger:hover { background: #9e2f2f; }

/* Agent row checkbox + icon */
.agent-checkbox-cell { display: flex; align-items: center; }
.agent-checkbox-cell input,
.agents-table-head input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
    background-color: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
}
.agent-checkbox-cell input:checked,
.agents-table-head input[type="checkbox"]:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
.agent-checkbox-cell input:checked::after,
.agents-table-head input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.agent-icon-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e8994a;
}

/* Bulk selection actions bar */
.bulk-actions-bar {
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-main);
}
.bulk-actions-bar.visible { display: flex; }
.bulk-action-btn {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
}
.bulk-action-btn:hover { background: var(--bg-sidebar-hover); }
.bulk-action-danger {
    margin-left: auto;
    color: var(--danger-text);
    border-color: var(--danger-border);
    background: transparent;
}
.bulk-action-danger:hover { background: var(--danger-bg); }

.bulk-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.bulk-action-btn:disabled:hover { background: var(--surface-2); }

/* Theme picker (Settings → Appearance) */
.theme-options { display: flex; gap: 12px; flex-wrap: wrap; }
.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    color: var(--text-main);
    min-width: 180px;
    text-align: left;
}
.theme-option:hover { border-color: var(--border-strong); }
.theme-option.active { border-color: var(--accent); background: var(--accent-soft); }
.theme-option-swatch {
    width: 36px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    flex-shrink: 0;
}
.theme-swatch-dark { background: #0d0d0f; }
.theme-swatch-light { background: #f4f5f6; }
.theme-option-name { display: block; font-size: 13.5px; font-weight: 500; }
.theme-option-hint { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Light theme override */
html[data-theme="light"] {
    --bg-app: #f4f5f6;
    --bg-sidebar: #ffffff;
    --bg-sidebar-hover: #ececef;
    --surface: #ffffff;
    --surface-2: #f2f3f5;
    --text-main: #17181c;
    --text-muted: #6b6d76;
    --text-sidebar: #6b6d76;
    --text-sidebar-active: #111114;
    --border: rgba(0, 0, 0, 0.09);
    --border-strong: rgba(0, 0, 0, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.06);

    --danger-bg: rgba(224, 82, 82, 0.08);
    --danger-text: #b3271f;
    --danger-border: rgba(224, 82, 82, 0.3);
    --success-bg: rgba(56, 161, 105, 0.10);
    --success-text: #1f7a4d;
    --success-border: rgba(56, 161, 105, 0.3);
}
html[data-theme="light"] .theme-swatch-dark { border-color: var(--border); }

/* Profile avatar */
.profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}
.profile-avatar-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-strong);
    flex-shrink: 0;
}
.profile-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-size: 22px;
    font-weight: 600;
}

/* Analytics (Home) */
.analytics-section { margin-top: 20px; }
.analytics-heading { font-size: 16px; font-weight: 500; margin: 0 0 4px 0; color: var(--text-main); }

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}
.analytics-card { grid-column: span 2; height: 104px; overflow: hidden; }
.analytics-card-half { grid-column: span 3; height: auto; min-height: 220px; overflow: visible; }

.analytics-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
}

.analytics-range {
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-main);
    font-family: inherit;
    cursor: pointer;
}

.analytics-donut-row {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.analytics-donut {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    flex-shrink: 0;
    -webkit-mask: radial-gradient(circle, transparent 42%, black 43%);
    mask: radial-gradient(circle, transparent 42%, black 43%);
}
.analytics-legend { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 200px; }
.analytics-legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.analytics-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.analytics-legend-label { color: var(--text-main); text-transform: capitalize; flex: 1; }
.analytics-legend-value { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

@media (max-width: 900px) {
    .analytics-grid { grid-template-columns: 1fr; }
}

/* Result — stacked horizontal bars per day */
.analytics-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 12px;
}
.analytics-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}
.analytics-bar-day {
    font-size: 11px;
    color: var(--text-muted);
    width: 36px;
    flex-shrink: 0;
    text-align: right;
}
.analytics-bar-track {
    display: flex;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
    background: var(--surface-2);
    min-width: 2px;
}
.analytics-bar-segment { height: 100%; }

.analytics-legend-wrap {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 16px;
}
.analytics-legend-wrap .analytics-legend-row { flex: 0 0 auto; }

/* News */
.news-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.news-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    color: var(--text-main);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.news-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.news-card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--surface-2);
    display: block;
}

.news-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.news-card-date { font-size: 11.5px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.news-card-title { font-size: 14px; font-weight: 500; line-height: 1.4; margin: 0; color: var(--text-main); }
.news-card-video-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: var(--accent);
    font-weight: 500;
    margin-top: 2px;
}