/* ═══════════════════════════════════════════════════════════
   base.css — базовые стили приложения (вынесено из base.html)
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-panel: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #059669;
    --success-light: #f0fdf4;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;

    /* Unified status colors for analyzers */
    --clr-ok: #16a34a;
    --clr-ok-bg: #dcfce7;
    --clr-warn: #d97706;
    --clr-warn-bg: #fef3c7;
    --clr-danger: #dc2626;
    --clr-danger-bg: #fef2f2;
    --clr-info: #2563eb;
    --clr-info-bg: #eff6ff;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);

    /* Layout */
    --header-height: 56px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;

    /* Kanban */
    --kanban-column-width: 280px;
    --kanban-card-gap: 10px;

    /* Priority colors */
    --priority-low: #3b82f6;
    --priority-medium: #f59e0b;
    --priority-high: #ef4444;
    --priority-critical: #7c3aed;

    /* Status colors */
    --status-new: #6b7280;
    --status-analysis: #3b82f6;
    --status-issues: #ef4444;
    --status-in-progress: #f59e0b;
    --status-done: #10b981;

    /* --- Дополнительные переменные для дизайн-системы --- */

    /* Фоны */
    --bg-hover: #f8fafc;
    --bg-surface: #fafbfc;
    --bg-tooltip: #1a202c;
    --bg-highlight: #fef08a;
    --bg-highlight-active: #f97316;

    /* Границы */
    --border-light: #f1f5f9;

    /* Тени */
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

    /* Типографика */
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Шкала отступов (4px-базис) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Z-index шкала */
    --z-sticky: 10;
    --z-dropdown: 100;
    --z-overlay: 1000;
    --z-modal: 1100;
    --z-tooltip: 1200;
    --z-top: 9999;

    /* Primary оттенки */
    --primary-border: #bfdbfe;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-secondary); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    height: var(--header-height);
    background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.header-burger { background: none; border: none; cursor: pointer; font-size: 1.25rem; padding: 6px 8px; border-radius: var(--radius); color: var(--text-secondary); display: flex; align-items: center; }
.header-burger:hover { background: var(--bg-secondary); }
.header-logo { font-size: 1.15rem; font-weight: 800; color: var(--text); letter-spacing: -.5px; white-space: nowrap; }
.header-logo span { color: var(--primary); }

/* Header search */
.header-search { flex: 1; max-width: 560px; position: relative; }
.header-search input {
    width: 100%; padding: 8px 70px 8px 36px;
    border: 1.5px solid var(--border); border-radius: var(--radius);
    font-size: .875rem; color: var(--text); background: var(--bg-secondary);
    outline: none; transition: all .15s;
}
.header-search input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.header-search .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: .9rem; color: var(--text-muted); pointer-events: none; }

/* Search dropdown */
.search-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-md); max-height: 420px; overflow-y: auto; z-index: 300;
}
.search-dropdown-item { padding: 10px 14px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; border-bottom: 1px solid var(--bg-secondary); }
.search-dropdown-item:hover { background: var(--primary-light); }
.search-dropdown-item .item-icon { font-size: 1.1rem; margin-top: 2px; }
.search-dropdown-item .item-name { font-weight: 600; font-size: .85rem; }
.search-dropdown-item .item-snippet { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.search-dropdown-item .item-project { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.search-dropdown-footer { padding: 8px 14px; text-align: center; font-size: .8rem; color: var(--primary); cursor: pointer; }
.search-dropdown-footer:hover { background: var(--primary-light); }
.search-dropdown-sep { border-top: 1px solid var(--border); margin: 0; }
.search-section-label { padding: 6px 14px 2px; font-size: .7rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: .3px; }

/* Advanced search modal */
.adv-search-overlay { display: none; position: fixed; inset: 0; z-index: 600; background: rgba(0,0,0,.45); justify-content: center; align-items: flex-start; padding-top: 80px; }
.adv-search-overlay.open { display: flex; }
.adv-search-box { background: #fff; border-radius: var(--radius-lg); width: 680px; max-width: 95vw; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.adv-search-header { padding: 18px 24px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.adv-search-header input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .95rem; outline: none; }
.adv-search-header input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.adv-search-header .modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px; }
.adv-search-filters { padding: 12px 24px; display: flex; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.adv-search-filters select { padding: 6px 10px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .82rem; background: #fff; outline: none; }
.adv-search-filters input[type=date] { padding: 6px 10px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .82rem; outline: none; }
.adv-search-results { flex: 1; overflow-y: auto; padding: 0; }
.adv-search-results .result-item { display: flex; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--bg-secondary); cursor: pointer; transition: background .1s; }
.adv-search-results .result-item:hover { background: var(--primary-light); }
.adv-search-results .result-icon { font-size: 1.2rem; margin-top: 2px; flex-shrink: 0; }
.adv-search-results .result-body { flex: 1; min-width: 0; }
.adv-search-results .result-name { font-weight: 600; font-size: .9rem; }
.adv-search-results .result-snippet { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }
.adv-search-results .result-snippet mark { background: #fef08a; padding: 0 2px; border-radius: 2px; }
.adv-search-results .result-meta { font-size: .72rem; color: var(--text-muted); margin-top: 3px; }
.adv-search-count { padding: 10px 24px; font-size: .8rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.adv-search-empty { padding: 40px 24px; text-align: center; color: var(--text-muted); font-size: .9rem; }
.adv-search-pager { padding: 12px 24px; display: flex; justify-content: center; gap: 8px; }
.adv-search-pager button { padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer; font-size: .82rem; }
.adv-search-pager button:hover { border-color: var(--primary); color: var(--primary); }
.adv-search-pager button:disabled { opacity: .4; cursor: default; }

.header-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.header-btn { background: none; border: none; cursor: pointer; font-size: 1.15rem; padding: 6px 8px; border-radius: var(--radius); color: var(--text-secondary); position: relative; }
.header-btn:hover { background: var(--bg-secondary); }
.header-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; font-size: .6rem; font-weight: 700; padding: 1px 4px; border-radius: 8px; min-width: 16px; text-align: center; line-height: 1.3; }

/* Notification dropdown */
.notif-dropdown { position: absolute; top: calc(100% + 4px); right: 0; width: 360px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 310; display: none; }
.notif-dropdown.show { display: block; }
.notif-dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .9rem; }
.notif-dropdown-header button { background: none; border: none; color: var(--primary); cursor: pointer; font-size: .8rem; padding: 0; }
.notif-dropdown-header button:hover { text-decoration: underline; }
.notif-dropdown-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--bg-secondary); transition: background .1s; }
.notif-item:hover { background: var(--primary-light); }
.notif-item.unread { background: #f0f7ff; }
.notif-item.unread:hover { background: #e0efff; }
.notif-icon { font-size: 1.1rem; margin-top: 2px; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: .85rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.notif-msg { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: .72rem; color: var(--text-muted); margin-top: 3px; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.notif-dropdown-footer { display: block; padding: 10px 16px; text-align: center; font-size: .82rem; color: var(--primary); border-top: 1px solid var(--border); text-decoration: none; }
.notif-dropdown-footer:hover { background: var(--primary-light); text-decoration: none; }

/* User menu dropdown */
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius); background: none; border: none; cursor: pointer; font-size: .85rem; color: var(--text); }
.user-menu-btn:hover { background: var(--bg-secondary); }
.user-menu-btn .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .75rem; }
.user-dropdown { position: absolute; top: calc(100% + 4px); right: 0; width: 200px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 300; display: none; }
.user-dropdown.show { display: block; }
.user-dropdown a, .user-dropdown button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; border: none; background: none; text-decoration: none; color: var(--text); font-size: .85rem; cursor: pointer; text-align: left; }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-secondary); }
.user-dropdown .sep { border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Sidebar ── */
.app-sidebar {
    position: fixed; top: var(--header-height); left: 0; bottom: 0;
    width: var(--sidebar-width); background: #fff;
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: width .2s ease; z-index: 100;
    overflow: hidden;
}
.app-sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius); color: var(--text-secondary);
    font-size: .875rem; font-weight: 500; white-space: nowrap; text-decoration: none;
    transition: all .12s;
}
.sidebar-nav a:hover { background: var(--bg-secondary); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-nav a .nav-icon { font-size: 1.15rem; min-width: 24px; text-align: center; }
.sidebar-nav a .nav-text { overflow: hidden; transition: opacity .15s; }
.app-sidebar.collapsed .nav-text { opacity: 0; width: 0; }
.sidebar-sep { border-top: 1px solid var(--border); margin: 8px 12px; }
.sidebar-section-label { padding: 8px 12px 4px; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.app-sidebar.collapsed .sidebar-section-label { opacity: 0; }

/* ── Main content ── */
.app-main {
    margin-left: var(--sidebar-width); margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    transition: margin-left .2s ease;
    padding: 24px;
}
.app-sidebar.collapsed ~ .app-main { margin-left: var(--sidebar-collapsed); }

/* ── Public layout (no sidebar) ── */
.public-layout .app-sidebar { display: none; }
.public-layout .app-main { margin-left: 0; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 18px; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; cursor: pointer; border: none; transition: all .15s; line-height: 1; text-decoration: none !important; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-secondary); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-full { width: 100%; }
.btn-lg { padding: 12px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .3px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; color: var(--text); background: var(--bg); outline: none; transition: border-color .15s; font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.error { display: block; font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

/* Auth */
.auth-container { min-height: calc(100vh - var(--header-height)); display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: var(--bg-secondary); }
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.auth-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.auth-card .auth-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 28px; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 0.85rem; color: var(--text-muted); }
.auth-footer a { font-weight: 500; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 12px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; background: #fff; }
.site-footer-logo { font-size: 1rem; font-weight: 700; color: var(--text); }
.site-footer-logo span { color: var(--primary); }
.site-footer p { font-size: 0.82rem; color: var(--text-muted); }
.site-footer-links { display: flex; gap: 16px; }
.site-footer-links a { font-size: 0.82rem; color: var(--text-muted); }
.site-footer-links a:hover { color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
    .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    .app-sidebar.mobile-open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.12); }
    .app-sidebar.collapsed { transform: translateX(-100%); }
    .app-main { margin-left: 0 !important; }
    .sidebar-overlay { position: fixed; inset: 0; top: var(--header-height); background: rgba(0,0,0,.3); z-index: 99; display: none; }
    .sidebar-overlay.show { display: block; }
    .header-search kbd { display: none; }
}
