.dashboard-container {
    min-height: 100vh;
    background: var(--bg-secondary);
}

.dashboard-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0;
}

.dashboard-nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 52px;
}

.dashboard-logo {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.dashboard-logo i {
    font-size: 1.5rem;
}

.user-plan-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: 1rem;
    font-size: 0.875rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.user-info {
    text-align: right;
    cursor: pointer;
    position: relative;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 0.45rem;
    transition: all 0.2s;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.user-name:hover {
    background: #e5e7eb;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.user-name i {
    font-size: 0.75rem;
    color: var(--primary-color);
}

.user-name::before {
    content: '\f007';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 1rem;
    color: var(--primary-color);
    margin-right: 0.25rem;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.active {
    display: block;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.9375rem;
    cursor: pointer;
}

.user-dropdown-item:hover {
    background: var(--bg-secondary);
}

.user-dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.user-dropdown-item.logout {
    color: #dc2626;
    border-top: 1px solid var(--border-color);
}

.user-dropdown-item.logout:hover {
    background: #fef2f2;
}

.user-dropdown-item.logout i {
    color: #dc2626;
}

.telegram-link-btn {
    padding: 0.5rem;
    background: #0088cc;
    color: white;
    border: none;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

.telegram-link-btn:hover {
    background: #006699;
    transform: translateY(-2px);
}

.logout-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: var(--primary-dark);
}

.dashboard-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 20px;
}

.welcome-section {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.welcome-title {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--gradient-primary);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.quick-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 0.75rem 1.1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 150px;
}

.stat-header {
    display: contents;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.stat-icon.bots { background: var(--gradient-primary); }
.stat-icon.running { background: var(--gradient-secondary); }
.stat-icon.messages { background: var(--gradient-accent); }
.stat-icon.users { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.2;
}

.stat-text {
    display: flex;
    flex-direction: column;
}

.bots-section {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.add-bot-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--secondary-color);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.add-bot-btn:hover {
    background: #059669;
    transform: translateY(-2px);
}

.bots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 1.25rem;
}

.bot-card {
    border: 1px solid var(--border-color);
    border-radius: 0.875rem;
    padding: 1.125rem;
    transition: all 0.2s ease;
    background: white;
    min-width: 0;       /* не даёт карточке расти шире grid-ячейки */
    overflow: hidden;
}

.bot-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.bot-card--deleted {
    opacity: 0.55;
    border-style: dashed;
    border-color: #d1d5db;
}
.bot-card--deleted:hover {
    opacity: 0.8;
    border-color: #9ca3af;
    box-shadow: none;
}

.bot-status--deleted {
    background: #f3f4f6;
    color: #6b7280;
}
.bot-status--deleted::before { background: #9ca3af; }

.bot-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    min-width: 0;
}

.bot-info {
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.bot-info h3 {
    color: var(--text-primary);
    font-size: 1.0625rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bot-id, .bot-language, .bot-node, .bot-location {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bot-platform {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.bot-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.275rem 0.65rem;
    border-radius: 2rem;
    font-size: 0.775rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
/* цветная точка-индикатор */
.bot-status::before {
    content: '';
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.bot-status.running {
    background: #dcfce7;
    color: #166534;
}
.bot-status.running::before { background: #16a34a; }

.bot-status.stopped {
    background: #fef2f2;
    color: #dc2626;
}
.bot-status.stopped::before { background: #dc2626; }

.bot-status.creating {
    background: #fef3c7;
    color: #92400e;
}
.bot-status.creating::before { background: #f59e0b; animation: pulse-dot 1s infinite; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.bot-stats {
    display: flex;
    gap: 0;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.bot-stat {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-right: 1px solid var(--border-color);
}
.bot-stat:last-child { border-right: none; }

.bot-stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.bot-stat-label {
    font-size: 0.675rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    /* две строки: первая — основные действия, вторая — утилиты */
}

.bot-action-btn {
    flex: 0 0 2.375rem;
    width: 2.375rem;
    height: 2.375rem;
    padding: 0;
    border: none;
    border-radius: 0.45rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
}

.bot-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.bot-action-btn.start  { background: #dcfce7; color: #166534; }
.bot-action-btn.stop   { background: #fef2f2; color: #dc2626; }
.bot-action-btn.restart{ background: #fef3c7; color: #92400e; }
.bot-action-btn.update { background: #dbeafe; color: #1e40af; }
.bot-action-btn.delete { background: #fef2f2; color: #dc2626; }
.bot-action-btn.logs   { background: #f0f9ff; color: #0369a1; }
.bot-action-btn.terminal { background: #f0fdf4; color: #16a34a; }

.bot-action-btn:hover {
    box-shadow: var(--shadow-sm);
    filter: brightness(0.95);
}

.bot-domain a {
    transition: color 0.3s ease;
}

.bot-domain a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.logs-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.logs-modal-content {
    background: white;
    border-radius: 1rem;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.logs-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logs-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.logs-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem; height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logs-modal-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary, #f9fafb);
}

.log-tab {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.log-tab:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent, #6366f1);
}

.log-tab.active {
    background: var(--accent, #6366f1);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.logs-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.logs-content {
    flex: 1;
    padding: 1rem;
    margin: 0;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.logs-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.logs-refresh-btn, .logs-close-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logs-refresh-btn {
    background: var(--accent, #6366f1);
    color: #ffffff;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.25);
    font-weight: 600;
}

.logs-close-btn {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #111827);
    border: 1px solid var(--border-color, #d1d5db);
}

.logs-refresh-btn:hover, .logs-close-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.logs-ws-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #059669;
    color: #fff;
    border: 1px solid rgba(0,0,0,0.05);
}
.logs-ws-btn:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.logs-ws-stop-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #dc2626;
    color: #fff;
}
.logs-ws-stop-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.beta-note {
    margin: 1.5rem auto 2rem;
    max-width: 1200px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
}
.beta-note a { color: #7c2d12; font-weight: 700; text-decoration: underline; }

.subscription-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.subscription-modal.active {
    display: flex;
}
.subscription-modal-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.subscription-modal h2 {
    margin-top: 0;
    color: #111827;
}
.subscription-modal p {
    color: #6b7280;
    margin: 1rem 0;
}
.telegram-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    margin: 1rem 0;
    font-size: 1rem;
}
.telegram-input:focus {
    outline: none;
    border-color: #6366f1;
}

/* ===== DARK THEME ===== */
body.dark-theme {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-light: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

body.dark-theme .dashboard-container {
    background: #0f172a;
}

body.dark-theme .dashboard-header {
    background: #1e293b;
    border-bottom-color: #334155;
}

body.dark-theme .welcome-section {
    background: #1e293b;
}

/* Docs link in header */
.header-docs-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    border-radius: 0.5rem;
    transition: background 0.15s, color 0.15s;
}

.header-docs-link:hover {
    background: var(--bg-secondary, #f1f5f9);
    color: var(--primary-color);
}

body.dark-theme .header-docs-link:hover {
    background: #1e293b;
    color: #818cf8;
}

body.dark-theme .stat-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-theme .bots-section {
    background: #1e293b;
}

body.dark-theme .bot-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-theme .bot-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(99,102,241,0.2);
}

body.dark-theme .bot-stat {
    background: #0f172a;
}

body.dark-theme .user-name {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-theme .user-name:hover {
    background: #334155;
}

body.dark-theme .user-dropdown {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

body.dark-theme .user-dropdown-item {
    color: #f1f5f9;
}

body.dark-theme .user-dropdown-item:hover {
    background: #0f172a;
}

body.dark-theme .user-dropdown-item i {
    color: #94a3b8;
}

body.dark-theme .user-dropdown-item.logout {
    border-top-color: #334155;
}

body.dark-theme .user-dropdown-item.logout:hover {
    background: rgba(220,38,38,0.15);
}

body.dark-theme .logs-modal-content {
    background: #1e293b;
    border: 1px solid #334155;
}

body.dark-theme .logs-modal-header {
    border-bottom-color: #334155;
}

body.dark-theme .logs-modal-header h3 {
    color: #f1f5f9;
}

body.dark-theme .logs-modal-tabs {
    background: #0f172a;
    border-bottom-color: #334155;
}

body.dark-theme .logs-modal-footer {
    border-top-color: #334155;
}

body.dark-theme .logs-close-btn {
    background: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

body.dark-theme .subscription-modal-content {
    background: #1e293b;
    border: 1px solid #334155;
}

body.dark-theme .subscription-modal h2 {
    color: #f1f5f9;
}

body.dark-theme .subscription-modal p {
    color: #94a3b8;
}

body.dark-theme .telegram-input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-theme .telegram-input:focus {
    border-color: #6366f1;
}

/* Bot action buttons — dark mode */
body.dark-theme .bot-action-btn.start   { background: #14532d; color: #86efac; }
body.dark-theme .bot-action-btn.stop    { background: #450a0a; color: #fca5a5; }
body.dark-theme .bot-action-btn.restart { background: #451a03; color: #fcd34d; }
body.dark-theme .bot-action-btn.update  { background: #1e3a5f; color: #93c5fd; }
body.dark-theme .bot-action-btn.delete  { background: #450a0a; color: #fca5a5; }
body.dark-theme .bot-action-btn.logs    { background: #0c2a3f; color: #7dd3fc; }
body.dark-theme .bot-action-btn.terminal{ background: #052e16; color: #86efac; }

/* Bot status badges */
body.dark-theme .bot-status.running  { background: #14532d; color: #86efac; }
body.dark-theme .bot-status.running::before  { background: #4ade80; }
body.dark-theme .bot-status.stopped  { background: #450a0a; color: #fca5a5; }
body.dark-theme .bot-status.stopped::before  { background: #f87171; }
body.dark-theme .bot-status.creating { background: #451a03; color: #fcd34d; }
body.dark-theme .bot-status.creating::before { background: #fbbf24; }

/* Inline-style overrides for dark mode */
body.dark-theme [style*="background: #f0f9ff"],
body.dark-theme [style*="background:#f0f9ff"] {
    background: #0c2a3f !important;
    border-color: #1e4a6f !important;
    color: #7dd3fc !important;
}
body.dark-theme [style*="background: #f0fdf4"],
body.dark-theme [style*="background:#f0fdf4"] {
    background: #052e16 !important;
    border-color: #14532d !important;
    color: #86efac !important;
}
body.dark-theme [style*="background: #fef3c7"],
body.dark-theme [style*="background:#fef3c7"] {
    background: #451a03 !important;
    border-color: #78350f !important;
    color: #fcd34d !important;
}
body.dark-theme [style*="background: #eff6ff"],
body.dark-theme [style*="background:#eff6ff"] {
    background: #1e3a5f !important;
    border-color: #1d4ed8 !important;
    color: #93c5fd !important;
}
body.dark-theme [style*="background: #dcfce7"],
body.dark-theme [style*="background:#dcfce7"] {
    background: #14532d !important;
    border-color: #166534 !important;
    color: #86efac !important;
}
body.dark-theme [style*="background: #f9fafb"],
body.dark-theme [style*="background:#f9fafb"] {
    background: #0f172a !important;
    border-color: #334155 !important;
}
body.dark-theme [style*="background: white"],
body.dark-theme [style*="background:white"] {
    background: #1e293b !important;
    color: #f1f5f9 !important;
}
body.dark-theme [style*="background: #fef2f2"],
body.dark-theme [style*="background:#fef2f2"] {
    background: #450a0a !important;
    border-color: #7f1d1d !important;
    color: #fca5a5 !important;
}
body.dark-theme [style*="background: #ede9fe"],
body.dark-theme [style*="background:#ede9fe"] {
    background: #2e1065 !important;
    border-color: #5b21b6 !important;
    color: #c4b5fd !important;
}
body.dark-theme [style*="background: #dbeafe"],
body.dark-theme [style*="background:#dbeafe"] {
    background: #1e3a5f !important;
    border-color: #1d4ed8 !important;
    color: #93c5fd !important;
}
body.dark-theme [style*="background: #d1fae5"],
body.dark-theme [style*="background:#d1fae5"] {
    background: #14532d !important;
    border-color: #166534 !important;
    color: #6ee7b7 !important;
}

body.dark-theme [style*="color: #6b7280"],
body.dark-theme [style*="color:#6b7280"] {
    color: #94a3b8 !important;
}
body.dark-theme [style*="color: #1e40af"],
body.dark-theme [style*="color:#1e40af"] {
    color: #93c5fd !important;
}
body.dark-theme [style*="color: #0369a1"],
body.dark-theme [style*="color:#0369a1"] {
    color: #7dd3fc !important;
}
body.dark-theme [style*="color: #166534"],
body.dark-theme [style*="color:#166534"] {
    color: #86efac !important;
}
body.dark-theme [style*="color: #92400e"],
body.dark-theme [style*="color:#92400e"] {
    color: #fcd34d !important;
}
body.dark-theme [style*="color: #1d4ed8"],
body.dark-theme [style*="color:#1d4ed8"] {
    color: #93c5fd !important;
}

body.dark-theme input[type="text"][readonly] {
    background: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}

/* Dark theme toggle button */
.dark-mode-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 0.45rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.dark-mode-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

body.dark-theme .dark-mode-toggle {
    background: #0f172a;
    border-color: #334155;
    color: #fcd34d;
}

body.dark-theme .dark-mode-toggle:hover {
    background: #1e293b;
    border-color: #fcd34d;
    color: #fcd34d;
}

/* ===== END DARK THEME ===== */

@media (max-width: 768px) {
    .dashboard-nav {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .user-info { text-align: center; }
    .quick-actions { justify-content: center; }
    .stats-grid { grid-template-columns: 1fr; }
    .bots-grid { grid-template-columns: 1fr; }
    .section-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* ============================================================
   PROJECTS
   ============================================================ */

.projects-bots-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.projects-sidebar {
    flex-shrink: 0;
    width: 220px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.75rem;
    padding: 0.75rem 0;
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
}

.projects-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    margin-bottom: 0.25rem;
}

.projects-sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.projects-new-btn {
    background: none;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.375rem;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary, #6b7280);
    font-size: 0.75rem;
    transition: all 0.15s;
}
.projects-new-btn:hover {
    background: var(--accent, #6366f1);
    color: #fff;
    border-color: var(--accent, #6366f1);
}

.projects-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 0.5rem;
}

.projects-nav-item-wrap {
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
    transition: background 0.15s;
}
.projects-nav-item-wrap:hover,
.projects-nav-item-wrap.active {
    background: var(--bg-secondary, #f9fafb);
}
.projects-nav-item-wrap .projects-nav-item {
    border-radius: 0;
    flex: 1;
}
.projects-nav-item-wrap .projects-nav-item:hover,
.projects-nav-item-wrap.active .projects-nav-item {
    background: transparent;
}

.projects-nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
    transition: background 0.15s;
    cursor: pointer;
}
.projects-nav-item:hover {
    background: var(--bg-secondary, #f9fafb);
}
.projects-nav-item.active {
    background: #ede9fe;
    color: #4f46e5;
    font-weight: 600;
}
.projects-nav-item i {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}
.projects-nav-item span:first-of-type {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.projects-nav-count {
    font-size: 0.7rem;
    font-weight: 600;
    background: #e5e7eb;
    color: #6b7280;
    border-radius: 99px;
    padding: 0.1rem 0.45rem;
    min-width: 1.25rem;
    text-align: center;
}
.projects-nav-item.active .projects-nav-count {
    background: #c7d2fe;
    color: #4338ca;
}

.projects-nav-actions-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #9ca3af);
    padding: 0.35rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.projects-nav-item-wrap:hover .projects-nav-actions-btn,
.projects-nav-item-wrap.active .projects-nav-actions-btn {
    opacity: 1;
}
.projects-nav-actions-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.projects-nav-empty {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem;
    color: var(--text-secondary, #9ca3af);
    font-size: 0.8rem;
}

.bots-section {
    flex: 1;
    min-width: 0;
}

/* Modal */
.project-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.project-modal {
    background: #fff;
    border-radius: 0.875rem;
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.project-modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #111827;
}
.project-modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.project-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.project-form-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
}
.project-form-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    width: 100%;
    box-sizing: border-box;
    color: #111827;
    background: #fff;
    transition: border-color 0.15s;
}
.project-form-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.project-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.project-color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.project-color-dot {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
}
.project-color-dot:hover { transform: scale(1.15); }
.project-color-dot.selected { border-color: #111827; transform: scale(1.15); }

.project-icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.project-icon-btn {
    width: 2rem;
    height: 2rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    background: #f9fafb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #6b7280;
    transition: all 0.1s;
}
.project-icon-btn:hover { background: #ede9fe; color: #4f46e5; border-color: #a5b4fc; }
.project-icon-btn.selected { background: #6366f1; color: #fff; border-color: #6366f1; }

.project-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}
.project-btn-primary {
    padding: 0.5rem 1.25rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.project-btn-primary:hover { background: #4f46e5; }
.project-btn-secondary {
    padding: 0.5rem 1.25rem;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.project-btn-secondary:hover { background: #e5e7eb; }

.project-ctx-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.project-ctx-item:hover { background: #f3f4f6; }
.project-ctx-item.danger { color: #ef4444; }
.project-ctx-item.danger:hover { background: #fef2f2; }

/* Dark theme */
.dark-theme .projects-sidebar { background: var(--bg-primary); border-color: var(--border-color); }
.dark-theme .projects-nav-item { color: var(--text-primary); }
.dark-theme .projects-nav-item:hover { background: rgba(255,255,255,0.05); }
.dark-theme .projects-nav-item.active { background: rgba(99,102,241,0.2); color: #a5b4fc; }
.dark-theme .projects-nav-count { background: rgba(255,255,255,0.1); color: #9ca3af; }
.dark-theme .project-modal { background: #1f2937; }
.dark-theme .project-modal-title { color: #f9fafb; }
.dark-theme .project-form-group label { color: #d1d5db; }
.dark-theme .project-form-input { background: #374151; border-color: #4b5563; color: #f9fafb; }
.dark-theme .project-btn-secondary { background: #374151; border-color: #4b5563; color: #f9fafb; }
.dark-theme #projectContextMenu { background: #1f2937; border-color: #374151; }
.dark-theme .project-ctx-item { color: #d1d5db; }
.dark-theme .project-ctx-item:hover { background: rgba(255,255,255,0.05); }
.dark-theme .project-icon-btn { background: #374151; border-color: #4b5563; color: #9ca3af; }

@media (max-width: 900px) {
    .projects-bots-layout { flex-direction: column; }
    .projects-sidebar { width: 100%; position: static; max-height: none; flex-direction: row; }
    .projects-nav { flex-direction: row; flex-wrap: wrap; }
    .projects-nav-item-wrap, .projects-nav-item { padding: 0.35rem 0.6rem; }
    .projects-sidebar-header { padding-bottom: 0.5rem; }
    .project-form-row { grid-template-columns: 1fr; }
}
