/* ==================== */
/* CSS Variables & Reset */
/* ==================== */
:root {
    --primary: #764ba2;
    --primary-dark: #5e3a82;
    --secondary: #6366f1;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --success: #22c55e;

    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;

    --sidebar-width: 260px;
    --header-height: 60px;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Light theme */
html.light {
    --bg-dark: #f0f4f8;
    --bg-card: #ffffff;
    --bg-hover: #e8edf3;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #cbd5e1;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);

    /* webchat.css aliases */
    --bg-main: #f0f4f8;
    --border: #cbd5e1;
    --text: #1e293b;
}

/* Webchat light-mode fixes (rgba overrides) */
html.light .wc-session-item:hover { background: rgba(0,0,0,0.04); }
html.light .wc-thinking { background: rgba(0,0,0,0.04); }
html.light .wc-tool { background: rgba(0,0,0,0.04); }
html.light .wc-md :where(:not(pre) > code) { background: rgba(0,0,0,0.07); }
html.light .wc-md :where(pre) { background: rgba(0,0,0,0.06); }
html.light .wc-md :where(th) { background: rgba(0,0,0,0.05); }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== */
/* App Container Layout */
/* ==================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ==================== */
/* Sidebar */
/* ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.logo i {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin: 4px 12px;
}

.sidebar-nav li.separator {
    border-top: 1px solid var(--border-color);
    margin: 8px 12px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
}

.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: var(--primary);
    color: white;
}

/* Submenu nav */
.nav-has-sub {
    margin: 0 !important;
}

.nav-parent-row {
    display: flex;
    align-items: center;
    margin: 4px 12px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.nav-parent-row:hover {
    background: var(--bg-hover);
}

.nav-parent-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: color 0.2s;
    font-size: 0.9rem;
}

.nav-parent-link:hover {
    background: none;
    color: var(--text-primary);
}

.nav-parent-link.active {
    background: var(--primary);
    color: white;
}

.nav-parent-link i {
    width: 20px;
    text-align: center;
}

.nav-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 10px;
    color: var(--text-secondary);
    line-height: 1;
    flex-shrink: 0;
}

.nav-toggle-btn:hover {
    color: var(--text-primary);
}

.nav-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s;
    display: block;
}

.nav-has-sub.open .nav-chevron {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    list-style: none;
    padding-left: 16px;
}

.nav-has-sub.open .nav-submenu {
    display: block;
}

.nav-submenu li {
    margin: 2px 12px;
}

.nav-submenu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-submenu a i {
    width: 20px;
    text-align: center;
}

.nav-submenu a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-submenu a.active {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 8px 12px;
    flex-shrink: 0;
}

.sidebar-settings-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.sidebar-settings-link i {
    width: 20px;
    text-align: center;
}

.sidebar-settings-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-settings-link.active {
    background: var(--primary);
    color: white;
}

/* ── Sidebar back button (settings mode) ──────────────────── */
.sidebar-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: color 0.15s;
}
.sidebar-back-btn:hover { color: var(--text-primary); }
.sidebar-back-btn i { font-size: 0.78rem; }

/* ── Settings mode search ──────────────────────────────────── */
.ss-search-wrap {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.ss-search-wrap i { color: var(--text-secondary); font-size: 0.8rem; flex-shrink: 0; }
.ss-search-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
}
.ss-search-wrap input::placeholder { color: var(--text-secondary); }

/* ── Settings mode nav ─────────────────────────────────────── */
.ss-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 16px;
}
.ss-group {
    padding: 0;
    margin-bottom: 4px;
}
.ss-group-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    padding: 12px 18px 4px;
}
.ss-group ul { list-style: none; }
.ss-group ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.87rem;
    border-radius: 0;
    transition: background 0.12s, color 0.12s;
}
.ss-group ul li a i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.82rem;
}
.ss-group ul li a:hover {
    background: var(--bg-hover);
}
.ss-group ul li a.ss-active {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500;
}
.ss-group ul li a.ss-active i { color: var(--primary); }
.ss-group ul li a.ss-danger { color: var(--danger); }
.ss-group ul li a.ss-danger i { color: var(--danger); }

/* ==================== */
/* Main Content */
/* ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.main-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

#theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}
#theme-toggle:hover {
    background: rgba(0,0,0,0.05);
}

.header-user-info {
    position: relative;
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--primary);
    font-size: 1.1rem;
    transition: background 0.2s;
}
.header-user-info:hover {
    background: rgba(0,0,0,0.05);
}
.header-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    white-space: nowrap;
}
.header-user-info.open .header-user-dropdown {
    display: block;
}
.header-user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.header-user-role {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: capitalize;
    margin-top: 2px;
}
.header-user-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}
.header-user-logout {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    color: var(--danger);
    text-decoration: none;
    padding: 2px 0;
}
.header-user-logout:hover {
    opacity: 0.8;
}
.header-user-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    color: var(--text-primary);
    text-decoration: none;
    padding: 2px 0;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
}
.header-user-item:hover {
    color: var(--primary);
}

/* Change Password Modal */
.cp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cp-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 380px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.cp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
}
.cp-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.cp-close-btn:hover { color: var(--text-primary); }
.cp-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.cp-error {
    background: rgba(231,76,60,0.1);
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: var(--danger);
    font-size: 0.82rem;
    padding: 8px 12px;
}
.cp-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}
.cp-field input {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
}
.cp-field input:focus {
    outline: none;
    border-color: var(--primary);
}
.cp-modal-footer {
    padding: 14px 20px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}

.lang-switcher {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.lang-current:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.lang-current i:first-child {
    font-size: 0.85rem;
    color: var(--primary);
}

.lang-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.lang-switcher.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
}

.lang-switcher.open .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all 0.15s;
}

.lang-option:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.lang-option.active {
    color: var(--primary);
    background: rgba(16, 185, 129, 0.08);
}

.lang-option .lang-flag {
    font-size: 1.1rem;
}

.lang-option .lang-name {
    flex: 1;
}


/* Toggle Switch */
.switch {
    display: inline-block;
    width: 44px;
    height: 24px;
    position: relative;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dark);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: white;
}

.page-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ==================== */
/* Page Header & Desc */
/* ==================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    margin-top: 8px;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.page-desc code {
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.page-desc a {
    color: var(--primary);
    text-decoration: none;
}

.page-desc a:hover {
    text-decoration: underline;
}

/* ==================== */
/* Stats Grid (Dashboard) */
/* ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-color);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.ai {
    background: rgba(99, 102, 241, 0.2);
    color: var(--secondary);
}

.stat-icon.chat {
    background: rgba(16, 185, 129, 0.2);
    color: var(--primary);
}

.stat-icon.integration {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.stat-icon.repo {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ==================== */
/* Dashboard Grid */
/* ==================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* ==================== */
/* Connection List */
/* ==================== */
.connection-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: var(--radius);
}

.connection-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== */
/* Flash messages */
/* ==================== */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.flash-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.flash-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.flash-info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid #3b82f6;
    color: #2563eb;
}

.flash-warning {
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid #eab308;
    color: #b45309;
}

/* ==================== */
/* Cards */
/* ==================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2,
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ==================== */
/* Status Badge */
/* ==================== */
.status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status.online {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.status.offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.status.warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

/* ==================== */
/* Badges */
/* ==================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.badge.green {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge.teams {
    background: rgba(99, 102, 241, 0.2);
    color: var(--secondary);
}

.badge.telegram {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.action-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.action-badge.create {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.action-badge.update {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.action-badge.delete {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* ==================== */
/* Data Table */
/* ==================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table .actions {
    display: flex;
    gap: 8px;
}

/* ==================== */
/* Buttons */
/* ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-primary);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-icon.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-icon.warning:hover {
    background: #f39c12;
    border-color: #f39c12;
    color: white;
}

.btn-icon.success:hover {
    background: #2ecc71;
    border-color: #2ecc71;
    color: white;
}

.btn-group {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

/* ==================== */
/* Forms */
/* ==================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select {
    padding: 10px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    min-height: 150px;
    resize: vertical;
    tab-size: 2;
    line-height: 1.5;
}

textarea.editor-large {
    min-height: 500px;
}

.form-row {
    margin-bottom: 12px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.input-with-action {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-action input {
    flex: 1;
}

/* ==================== */
/* Pattern list (Exec Approvals) */
/* ==================== */
.pattern-list {
    margin: 8px 0;
}

.pattern-item {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.pattern-item input {
    flex: 1;
}

/* ==================== */
/* Cron job row */
/* ==================== */
.job-row {
    display: grid;
    grid-template-columns: 160px 120px 120px 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: var(--radius);
}

.job-row input,
.job-row select {
    width: 100%;
}

/* ==================== */
/* Integration row */
/* ==================== */
.integration-row {
    display: grid;
    grid-template-columns: 1fr 130px 1.5fr 1.5fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: var(--radius);
}

.integration-row input,
.integration-row select {
    width: 100%;
}

/* ==================== */
/* Repository row */
/* ==================== */
.repo-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 100px 130px auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: var(--radius);
}

.repo-row input,
.repo-row select {
    width: 100%;
}

/* ==================== */
/* Recipient row */
/* ==================== */
.recipient-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 120px auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: var(--radius);
}

.recipient-row input,
.recipient-row select {
    width: 100%;
}

/* ==================== */
/* File list */
/* ==================== */
.file-list {
    padding: 8px;
}

.file-list a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.file-list a:hover {
    background: var(--bg-hover);
}

.file-list a.active {
    background: var(--primary);
    color: white;
}

/* ==================== */
/* Log viewer */
/* ==================== */
.log-viewer {
    background: #000;
    color: #ddd;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    padding: 16px;
    border-radius: var(--radius);
    max-height: 600px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

/* ==================== */
/* 3-panel layout (Skills, Workspace) */
/* ==================== */
.panel-layout {
    display: flex;
    gap: 20px;
}

.panel-sidebar {
    width: 200px;
    flex-shrink: 0;
}

.panel-files {
    width: 260px;
    flex-shrink: 0;
}

.panel-main {
    flex: 1;
    min-width: 0;
}

.panel-main h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* ==================== */
/* Activity List */
/* ==================== */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.activity-icon.success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.activity-icon.warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.activity-icon.info {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.activity-info p {
    font-size: 0.9rem;
}

.activity-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==================== */
/* Integrations Grid */
/* ==================== */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.integration-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: all 0.2s;
}

.integration-card:hover {
    border-color: var(--primary);
}

/* ==================== */
/* Custom File Input */
/* ==================== */
.custom-file-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.custom-file-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-dark);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    position: relative;
    z-index: 1;
}

.file-input-wrapper:hover .custom-file-label {
    border-color: var(--primary);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.custom-file-label i {
    font-size: 1.2rem;
}

.integration-card.add-new {
    border-style: dashed;
    cursor: pointer;
}

.integration-card.add-new:hover {
    background: var(--bg-hover);
}

.integration-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    background: var(--bg-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
}

.integration-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.integration-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.integration-actions {
    margin-top: 16px;
}

/* ==================== */
/* Folder Tree */
/* ==================== */
.folder-tree {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-primary);
}

.folder-item:hover {
    background: var(--bg-dark);
    border: 1px solid var(--primary);
}

.folder-item.active {
    border: 1px solid var(--primary);
    background: var(--bg-dark);
}

.folder-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.folder-info i {
    color: var(--warning);
}

.folder-permissions {
    display: flex;
    gap: 8px;
}

.permission {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.permission.read {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.permission.write {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.folder-actions {
    display: flex;
    gap: 8px;
}

/* ==================== */
/* Filter Group */
/* ==================== */
.filter-group {
    display: flex;
    gap: 12px;
}

.filter-group select,
.filter-group input {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* ==================== */
/* Config Form */
/* ==================== */
.config-form {
    max-width: 600px;
}

.config-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* ==================== */
/* Restart overlay */
/* ==================== */
.restart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.restart-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px 40px;
    text-align: center;
    min-width: 320px;
    max-width: 400px;
}

.restart-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.restart-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.restart-detail {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.restart-steps {
    text-align: left;
    margin: 0 auto;
    display: inline-block;
}

.restart-step {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-color);
    display: inline-block;
    flex-shrink: 0;
    transition: background 0.3s;
}

.step-dot.active {
    background: var(--warning);
}

.step-dot.done {
    background: var(--success);
}

.step-dot.error {
    background: var(--danger);
}

.restart-step.current {
    color: var(--text-primary);
    font-weight: 500;
}

.restart-step.done {
    color: var(--success);
}

.restart-step.error {
    color: var(--danger);
}

.restart-icon-success {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.restart-icon-error {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

/* ==================== */
/* Loading overlay      */
/* ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px 40px;
    text-align: center;
    min-width: 280px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 500;
}

/* ==================== */
/* Tab Navigation */
/* ==================== */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ==================== */
/* Model Rows */
/* ==================== */
.model-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-dark);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.model-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-info i {
    color: var(--secondary);
}

.model-id {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85rem;
}

.section-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
    margin-top: 16px;
}

.add-model-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ==================== */
/* Plugin Toggle Rows */
/* ==================== */
.plugin-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.plugin-row:last-child {
    border-bottom: none;
}

.plugin-name {
    font-size: 0.9rem;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
}

/* ==================== */
/* Toggle Switch */
/* ==================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-hover);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider:before {
    background: white;
    transform: translateX(20px);
}

/* ==================== */
/* Responsive */
/* ==================== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .config-form .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .integrations-grid {
        grid-template-columns: 1fr;
    }

    .panel-layout {
        flex-direction: column;
    }

    .panel-sidebar,
    .panel-files {
        width: 100%;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    .job-row {
        grid-template-columns: 1fr;
    }

    .integration-row {
        grid-template-columns: 1fr;
    }

    .repo-row {
        grid-template-columns: 1fr;
    }

    .recipient-row {
        grid-template-columns: 1fr;
    }
}

/* ==================== */
/* Workflow Timeline    */
/* ==================== */
.workflow-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 24px;
}

.workflow-phase {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.workflow-step-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 48px;
}

.workflow-dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    z-index: 1;
}

.workflow-line {
    width: 2px;
    flex: 1;
    min-height: 24px;
    background: var(--border-color);
    margin: 4px 0;
}

.workflow-content {
    flex: 1;
    margin-bottom: 20px;
    min-width: 0;
}

.workflow-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-wrap: wrap;
}

.workflow-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.workflow-skill-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-hover);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.workflow-desc {
    padding: 12px 16px 4px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.workflow-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 14px;
}

.workflow-action-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text-primary);
}

/* ==================== */
/* Custom Scrollbar     */
/* ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 99px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}