/* =========================================
   1. ГЛОБАЛЬНІ ЗМІННІ ТА БАЗА
   ========================================= */
:root {
    --bg-main: #131314;
    --bg-card: #1a1a1c;
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-active: rgba(168, 199, 250, 0.1);
    --text-main: #e3e3e3;
    --text-muted: #858585; 
    --text-active: #a8c7fa;
    --border-color: #2b2d31;
    --bg-status: #4ea1ff;
    --success: #51ba74;
    --danger: #c96c4c;
    --warning: #d97706;
}

body {
    margin: 0; padding: 0; width: 100vw; height: 100vh;
    background-color: var(--bg-main) !important; color: var(--text-main);
    font-family: 'Segoe UI', 'UAF Sans', sans-serif; font-size: 14px; overflow: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.3); }

/* =========================================
   2. ФОРМИ ТА ІНПУТИ
   ========================================= */
input[type="text"], input[type="password"], input[type="date"], textarea, select, .tactical-input, .login-input {
    background-color: rgba(255, 255, 255, 0.03) !important; 
    border: none !important; color: #ffffff !important; padding: 12px 16px !important; 
    border-radius: 8px !important; outline: none !important; font-family: inherit !important; 
    font-size: 14px !important; transition: 0.2s !important; box-sizing: border-box !important; 
    width: 100%; color-scheme: dark; 
}

/* Прибираємо стандартну рамку і квадрат при кліку */
input:focus, textarea:focus, select:focus, .tactical-input:focus {
    background-color: rgba(255, 255, 255, 0.06) !important;
    box-shadow: none !important; 
    outline: none !important;
}

.input-with-icon { position: relative; width: 100%; margin-bottom: 16px; }
.input-with-icon i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 18px; pointer-events: none; transition: 0.2s; }
.input-with-icon input:focus + i { color: var(--bg-status); }
.input-with-icon input.login-input { padding-left: 48px !important; text-align: left !important; margin-bottom: 0 !important; }

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.form-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; margin-bottom: 2px; padding-left: 2px; letter-spacing: 0.5px;}

/* =========================================
   3. СТОРІНКА ЛОГІНУ (ВІДНОВЛЕНО)
   ========================================= */
.login-page { 
    display: flex !important; align-items: center !important; justify-content: center !important; 
    min-height: 100vh; width: 100vw; background-color: var(--bg-main) !important; margin: 0; padding: 0; 
}
.login-box { 
    width: 100%; max-width: 400px; background-color: var(--bg-card); padding: 48px 40px; 
    border-radius: 16px; border: 1px solid var(--border-color); text-align: center; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); box-sizing: border-box;
}
.login-title { font-size: 24px; color: #ffffff; margin: 16px 0 6px 0; font-weight: 600; }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 32px; }

/* =========================================
   4. КНОПКИ
   ========================================= */
.tactical-btn, button[type="submit"], .login-btn-submit {
    height: 44px; padding: 0 24px; border-radius: 8px !important; 
    font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; 
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; 
    transition: 0.2s; border: none !important; background-color: var(--bg-status) !important; 
    color: #ffffff !important; box-sizing: border-box; text-decoration: none; width: auto;
}
.tactical-btn:hover, button[type="submit"]:hover, .login-btn-submit:hover { filter: brightness(1.1); box-shadow: 0 4px 12px rgba(78, 161, 255, 0.2); }
.tactical-btn.secondary { background-color: rgba(255, 255, 255, 0.05) !important; color: var(--text-main) !important; border: 1px solid var(--border-color) !important;}
.tactical-btn.secondary:hover { background-color: rgba(255, 255, 255, 0.1) !important; color: #ffffff !important; }

.login-btn-submit { width: 100%; margin-top: 16px; }

/* =========================================
   5. КАСТОМНІ СЕЛЕКТИ ТА РАДІО
   ========================================= */
.custom-select-wrapper { position: relative; width: 100%; font-family: inherit; }
.custom-select-trigger { background-color: rgba(255, 255, 255, 0.03); border-radius: 8px; padding: 12px 16px; color: #fff; font-size: 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: all 0.2s ease; }
.custom-select-wrapper.open .custom-select-trigger { background-color: rgba(255, 255, 255, 0.06); }
.custom-select-trigger i { color: var(--text-muted); transition: transform 0.3s ease; }
.custom-select-wrapper.open .custom-select-trigger i { transform: rotate(180deg); color: var(--bg-status); }
.custom-select-options { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background-color: #1e1e20; border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); z-index: 99; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.2s ease; overflow: hidden; padding: 6px;}
.custom-select-wrapper.open .custom-select-options { opacity: 1; visibility: visible; transform: translateY(0); }
.custom-select-option { padding: 12px 16px; font-size: 14px; color: var(--text-main); cursor: pointer; transition: 0.2s; border-radius: 6px;}
.custom-select-option:hover { background-color: var(--bg-hover); color: #fff; }
.custom-select-option.selected { color: var(--bg-status); font-weight: 500; background-color: rgba(78, 161, 255, 0.1); }

/* =========================================
   6. КАРКАС ТА САЙДБАР
   ========================================= */
.gemini-layout { display: flex; height: 100vh; width: 100vw; }
.gemini-sidebar { width: 280px; background-color: var(--bg-main); display: flex; flex-direction: column; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); flex-shrink: 0; z-index: 100; border-right: none; }
.gemini-sidebar.collapsed { width: 72px; }

.sidebar-header { padding: 12px 16px; height: 72px; display: flex; align-items: center; justify-content: space-between; box-sizing: border-box; overflow: hidden; }
.sidebar-logo-container { display: flex; align-items: center; gap: 12px; text-decoration: none; flex: 1; overflow: hidden; padding-left: 8px;}
.logo-img { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }
.sidebar-logo-text { font-size: 20px; font-weight: 600; color: #fff; white-space: nowrap; }

.toggle-sidebar-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; transition: 0.2s; flex-shrink: 0; padding: 0; }
.toggle-sidebar-btn:hover { background-color: var(--bg-hover); color: #fff; }

.gemini-sidebar.collapsed .sidebar-header { padding: 12px; justify-content: center; cursor: pointer; }
.gemini-sidebar.collapsed .sidebar-logo-container { justify-content: center; width: 100%; display: flex; padding-left: 0;}
.gemini-sidebar.collapsed .sidebar-logo-text, .gemini-sidebar.collapsed .toggle-sidebar-btn { display: none; }

.sidebar-menu { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; margin-top: 10px; padding: 0 12px; }
.nav-pill { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-radius: 8px; color: var(--text-muted); text-decoration: none; font-size: 14px; transition: 0.2s; cursor: pointer; white-space: nowrap; height: 44px; box-sizing: border-box; }
.nav-pill i { font-size: 18px; flex-shrink: 0; color: var(--text-muted); transition: 0.2s;}
.nav-pill:hover { background-color: var(--bg-hover); color: #ffffff;}
.nav-pill.active { background-color: rgba(255,255,255,0.05); color: #ffffff; font-weight: 500; }
.nav-pill.active i { color: #ffffff; }

.sidebar-group { display: flex; flex-direction: column; }
.sidebar-group-title { justify-content: space-between; }
.sidebar-group-title .arrow { font-size: 16px; transition: transform 0.3s; margin-left: auto; }
.sidebar-group.open .sidebar-group-title .arrow { transform: rotate(180deg); }
.sidebar-group-items { display: flex; flex-direction: column; gap: 2px; overflow: hidden; max-height: 0; transition: max-height 0.3s ease-out; padding-left: 20px;}
.sidebar-group.open .sidebar-group-items { max-height: 300px; margin-top: 4px; }
.sub-item { display: flex; align-items: center; gap: 12px; height: 38px; padding: 8px 16px; border-radius: 8px; font-size: 13px; color: var(--text-muted); text-decoration: none; transition: 0.2s; }
.sub-item i { font-size: 16px; color: var(--text-muted); transition: 0.2s;}
.sub-item:hover { background-color: var(--bg-hover); color: var(--text-main); }
.sub-item.active { background-color: var(--bg-active); color: var(--text-active); font-weight: 500; }

.gemini-sidebar.collapsed .nav-pill { padding: 10px; width: 44px; justify-content: center; margin: 0 auto; }
.gemini-sidebar.collapsed .nav-text, .gemini-sidebar.collapsed .arrow, .gemini-sidebar.collapsed .sidebar-group-items { display: none !important; }

.sidebar-bottom { margin-top: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.profile-pill { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text-muted); transition: 0.2s; cursor: pointer; }
.profile-pill:hover { background-color: var(--bg-hover); color: #ffffff;}
.profile-pill.active { color: #ffffff; background-color: rgba(255,255,255,0.05); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background-color: rgba(255,255,255,0.1); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; flex-shrink: 0; }
.profile-info { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.profile-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; }
.gemini-sidebar.collapsed .profile-pill { padding: 6px; width: 44px; justify-content: center; margin: 0 auto;}
.gemini-sidebar.collapsed .profile-info { display: none; }

/* =========================================
   7. HEADER ТА ПОШУК
   ========================================= */
.gemini-main { flex: 1; display: flex; flex-direction: column; background-color: var(--bg-main); overflow: hidden; }
.main-header { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 40px; position: relative; flex-shrink: 0; }
.header-left, .header-right { flex: 1; display: flex; align-items: center; }
.header-right { justify-content: flex-end; }
.header-actions { display: flex; align-items: center; gap: 16px; }

.search-box { background-color: rgba(255,255,255,0.04); border: 1px solid transparent; border-radius: 50px; display: flex; align-items: center; padding: 0 16px; height: 42px; width: 350px; transition: 0.2s; }
.search-box:focus-within { background-color: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.1); }
.search-box input { border: none !important; background: transparent !important; padding-left: 10px !important; width: 100% !important; color: #fff !important; border-radius: 0 !important;}

.action-btn { position: relative; color: var(--text-muted); cursor: pointer; width: 40px; height: 40px; border-radius: 50%; transition: 0.2s; display: flex; align-items: center; justify-content: center; background: transparent; border: none; text-decoration: none; font-size: 20px;}
.action-btn:hover { background-color: var(--bg-hover); color: #fff; }

/* =========================================
   8. КОНТЕНТНА ЗОНА
   ========================================= */
.gemini-content { flex: 1; overflow-y: auto; padding: 0 40px 40px 40px; }
.dashboard-view { display: flex; flex-direction: column; width: 100%; box-sizing: border-box; max-width: 1400px; margin: 0 auto;}

.security-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 50px; font-size: 12px; font-weight: 500; border: 1px solid;}
.security-badge.active { color: var(--success); border-color: rgba(81, 186, 116, 0.3); background: rgba(81, 186, 116, 0.1); }

/* =========================================
   9. ФІЛЬТРИ ДЛЯ БІБЛІОТЕКИ
   ========================================= */
.advanced-filters { 
    display: flex; gap: 16px; background: rgba(255,255,255,0.02); 
    padding: 16px 24px; border-radius: 12px; border: 1px solid var(--border-color); 
    margin-bottom: 24px; align-items: flex-end; flex-wrap: wrap; 
}
.filter-col { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px; }
.filter-col label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600;}

/* =========================================
   10. СТРУКТУРОВАНІ КАРТКИ СПРАВ
   ========================================= */
.inv-list { display: flex; flex-direction: column; gap: 24px; margin-top: 24px; }
.inv-card { 
    background: rgba(255,255,255,0.02); border: 1px solid var(--border-color); 
    border-radius: 12px; display: flex; flex-direction: column; transition: 0.2s;
    /* УВАГА: Тут немає overflow:hidden, тому тултіпи обрізатись не будуть! */
}
.inv-card:hover { border-color: rgba(255,255,255,0.1); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }

.inv-card-header { 
    border-radius: 12px 12px 0 0; padding: 16px 24px; border-bottom: 1px solid var(--border-color); 
    display: flex; justify-content: space-between; align-items: center; background: rgba(78, 161, 255, 0.05); 
}
.inv-header-title { font-size: 16px; font-weight: 500; color: #fff; display: flex; align-items: center; gap: 10px; }
.inv-header-title strong { font-weight: 600; color: var(--bg-status); font-size: 18px;}

.inv-card-body { padding: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.inv-data-group { display: flex; flex-direction: column; gap: 4px; }
.inv-data-group.full-width { grid-column: 1 / -1; }
.inv-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.inv-value { font-size: 14px; color: #e3e3e3; line-height: 1.5; font-weight: 500;}
.inv-value.highlight { color: #fff; font-weight: 600; font-size: 15px;}
.dept-badge { display: inline-block; padding: 4px 10px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-active); font-weight: 600; font-size: 12px;}

.inv-card-footer { 
    border-radius: 0 0 12px 12px; padding: 16px 24px; border-top: 1px solid var(--border-color); 
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: rgba(0,0,0,0.2); 
}
.chain-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; background: rgba(255,255,255,0.03); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-color);}
.chain-item.act { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.1); color: #fff; font-weight: 600;}
.chain-badge { width: 10px; height: 10px; border-radius: 50%; display: inline-block;}
.chain-badge.orange { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.chain-badge.green { background: var(--success); box-shadow: 0 0 8px var(--success); }

/* =========================================
   11. TOOLTIPS (ТЕПЕР БЕЗ ОБРІЗАННЯ)
   ========================================= */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after { 
    content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); 
    background-color: #27272a; color: #fff; padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; 
    white-space: nowrap; z-index: 9999; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 4px 12px rgba(0,0,0,0.5); pointer-events: none;
}

/* =========================================
   12. ВИЇЗНА ПАНЕЛЬ, TOASTS, LOADER
   ========================================= */
.panel-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); z-index: 9000; opacity: 0; visibility: hidden; transition: 0.3s ease; }
.panel-overlay.active { opacity: 1; visibility: visible; }

.side-panel { position: fixed; top: 0; right: -520px; width: 500px; height: 100vh; background-color: #1a1a1c; border-left: 1px solid var(--border-color); z-index: 9001; transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; box-shadow: -15px 0 40px rgba(0,0,0,0.6); }
.side-panel.open { right: 0; }
.side-panel-header { padding: 24px 30px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; border-bottom: 1px solid var(--border-color); }
.side-panel-title { font-size: 18px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 10px; }
.close-panel-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 24px; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: 0.2s;}
.close-panel-btn:hover { background-color: rgba(255,255,255,0.05); color: #fff; }
.side-panel-body { padding: 30px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.side-panel-footer { padding: 20px 30px; display: flex; justify-content: flex-end; gap: 16px; border-top: 1px solid var(--border-color); background: var(--bg-main);}

#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 12px; z-index: 99999; }
.toast { background: #1a1a1c; color: #fff; padding: 16px 24px; border-radius: 12px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 12px; border: 1px solid var(--border-color); box-shadow: 0 10px 30px rgba(0,0,0,0.8); animation: slideInRight 0.3s ease forwards; }
.toast i { color: var(--bg-status); font-size: 18px; }
.toast.toast-error i { color: var(--danger); }
.toast.fade-out { animation: fadeOutRight 0.3s ease forwards; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

#global-loader { position: fixed; top: 0; left: 0; width: 0%; height: 3px; background-color: var(--bg-status); z-index: 99999; opacity: 0; transition: width 0.3s ease, opacity 0.3s ease; pointer-events: none; }
#global-loader.loading { opacity: 1; }