:root {
    --primary-color: #0F172A; 
    --accent-color: #3B82F6;  
    --accent-hover: #2563EB;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --bg-light: #F1F5F9;      
    --card-bg: #FFFFFF;
    --sheet-border: #E2E8F0;
    --sheet-header-bg: #F8FAFC;
    --sheet-active-cell: #3B82F6;
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-up { animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* ЭКРАН АВТОРИЗАЦИИ */
.auth-wrapper {
    display: flex; justify-content: center; align-items: center;
    height: 100vh; position: relative; background: #0F172A; overflow: hidden;
}
.auth-ornament-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('../img/ornament.png'); background-size: 250px;
    background-repeat: repeat; opacity: 0.12; 
    mask-image: radial-gradient(circle, rgba(0,0,0,0) 20%, rgba(0,0,0,1) 80%);
    -webkit-mask-image: radial-gradient(circle, rgba(0,0,0,0) 20%, rgba(0,0,0,1) 80%);
    pointer-events: none; z-index: 0;
}
.auth-card {
    background: var(--card-bg); padding: 40px; border-radius: 12px;
    width: 100%; max-width: 400px; z-index: 1; position: relative;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.auth-logo { text-align: center; margin-bottom: 30px; }
.auth-logo img { display: block; height: 84px; width: auto; margin: 0 auto 14px; }
.auth-logo h2 { color: var(--primary-color); font-size: 26px; font-weight: 700; letter-spacing: 1px; }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 5px; }

.egov-input-group { margin-bottom: 20px; }
.egov-input-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.egov-input-group input {
    width: 100%; padding: 12px 14px; border: 1px solid #CBD5E1; 
    border-radius: 6px; font-size: 15px; outline: none; transition: 0.2s; background-color: #F8FAFC;
}
.egov-input-group input:focus { border-color: var(--accent-color); background-color: #FFF; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }

.egov-btn-primary {
    background: var(--accent-color); color: white; border: none; padding: 12px 20px; font-size: 15px; font-weight: 600;
    border-radius: 6px; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
}
.egov-btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.egov-btn-primary.block { width: 100%; }
.egov-btn-success { background: #10B981; color: white; border: none; padding: 10px 18px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.egov-btn-success:hover { background: #059669; }
.egov-btn-secondary { background: white; color: var(--text-main); border: 1px solid #CBD5E1; padding: 10px 18px; border-radius: 6px; font-size: 14px; cursor: pointer; font-weight: 500; transition: 0.2s; }
.egov-btn-secondary:hover { background: #F1F5F9; }

/* ШАПКА (TOP HEADER) - ОРНАМЕНТ НА ВСЮ ШИРИНУ */
.top-header {
    background: #FFFFFF; border-bottom: 1px solid #E2E8F0; height: 64px; 
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 24px; position: relative; z-index: 10; overflow: hidden; 
}
.header-ornament-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('../img/ornament-h.png'); background-size: auto 44px;
    background-position: center; background-repeat: space no-repeat; opacity: 0.10;
    pointer-events: none; z-index: 1;
}
.header-left { display: flex; align-items: center; gap: 16px; position: relative; z-index: 2; }
.header-logo { height: 48px; width: auto; object-fit: contain; }
.header-title { display: flex; flex-direction: column; }
.ru-title { font-size: 16px; font-weight: 700; color: var(--primary-color); }
.kz-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;}

.header-right { display: flex; align-items: center; gap: 24px; position: relative; z-index: 2; }
.user-profile { display: flex; align-items: center; gap: 12px; border-right: 1px solid #E2E8F0; padding-right: 24px; }
.avatar { width: 38px; height: 38px; border-radius: 8px; background: var(--accent-color); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: var(--text-muted); }
.logout-btn { background: none; border: none; color: #EF4444; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.logout-btn:hover { color: #B91C1C; }

/* ЛЕЙАУТ ПРИЛОЖЕНИЯ */
.app-body { display: flex; height: calc(100vh - 64px); }

/* БОКОВОЕ МЕНЮ */
.sidebar { width: 260px; background: var(--primary-color); color: white; display: flex; flex-direction: column; z-index: 5; }
.sidebar-nav { padding: 24px 0; flex: 1; }
.nav-section { margin-bottom: 30px; }
.nav-label { display: block; padding: 0 24px 10px; font-size: 11px; font-weight: 700; color: #94A3B8; text-transform: uppercase; letter-spacing: 1px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    padding: 12px 24px; background: none; border: none; border-left: 3px solid transparent;
    font-size: 14px; color: #CBD5E1; cursor: pointer; transition: 0.2s; font-weight: 500;
}
.nav-item .icon { font-size: 18px; opacity: 0.7; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: white; }
.nav-item.active { background: rgba(59, 130, 246, 0.1); border-left-color: var(--accent-color); color: white; font-weight: 600; }
.nav-item.active .icon { opacity: 1; color: var(--accent-color); }

.sidebar-support { padding: 20px 24px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-support a { color: #94A3B8; font-size: 13px; text-decoration: none; transition: 0.2s; }
.sidebar-support a:hover { color: white; }

/* РАБОЧАЯ ОБЛАСТЬ */
.main-content { flex: 1; position: relative; display: flex; flex-direction: column; overflow: hidden;}
.view-panel { display: none; flex-direction: column; height: 100%; padding: 30px; position: relative; z-index: 1; }
.view-panel.active { display: flex; }
/* Для аналитики делаем скролл */
.view-scrollable { overflow-y: auto; padding-right: 15px; }

.panel-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; flex-shrink: 0;}
.panel-header h2 { font-size: 24px; color: var(--primary-color); font-weight: 700; letter-spacing: -0.5px;}
.toolbar { display: flex; gap: 12px; align-items: center; }
.egov-select { padding: 10px 14px; border: 1px solid #CBD5E1; border-radius: 6px; font-size: 14px; outline: none; background: white; min-width: 200px; font-weight: 500;}

/* КАРТОЧКИ И СПАРКЛАЙНЫ */
.dash-card { background: var(--card-bg); border: 1px solid #E2E8F0; border-radius: 12px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.flex-card { display: flex; flex-direction: column; flex: 1; }
.chart-container { position: relative; flex: 1; min-height: 0; margin-top: 15px; }
.sparkline-container { flex: 1; min-height: 100px; margin-top: 20px; position: relative; }

.dash-card h3 { color: var(--primary-color); margin-bottom: 20px; font-size: 16px; font-weight: 700;}
.stat-box { display: flex; flex-direction: column; position: relative; }
.stat-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.stat-value { font-size: 36px; font-weight: 800; color: var(--primary-color); margin-top: 8px; }

/* СЕТКА АНАЛИТИКИ */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; flex-shrink: 0; margin-bottom: 30px; min-height: 380px;}

/* GOOGLE SHEETS (ЖУРНАЛ) */
.spreadsheet-container { flex: 1; overflow: auto; background: white; border: 1px solid var(--sheet-border); border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.google-sheet { border-collapse: collapse; table-layout: fixed; min-width: 100%; }
.google-sheet th, .google-sheet td { border: 1px solid var(--sheet-border); padding: 0; min-width: 80px; height: 32px; }
.google-sheet th { background: var(--sheet-header-bg); color: #334155; font-size: 13px; font-weight: 600; text-align: center; padding: 6px; position: sticky; top: 0; z-index: 2; border-bottom: 2px solid #CBD5E1; }
.google-sheet th small { color: #94A3B8; font-size: 11px; font-weight: 400;}

.row-num-col { width: 40px; min-width: 40px; background: var(--sheet-header-bg); position: sticky; left: 0; z-index: 3 !important; }
.row-num { background: var(--sheet-header-bg); color: #64748B; text-align: center; font-size: 12px; font-weight: 600; position: sticky; left: 0; z-index: 1; border-right: 2px solid #CBD5E1; }
.frozen-col { position: sticky; left: 40px; background: white; z-index: 1; width: 280px; min-width: 280px; padding: 0 15px !important; font-size: 14px; font-weight: 500; text-align: left; }
.google-sheet th.frozen-col { z-index: 3; background: var(--sheet-header-bg); text-align: left; padding-left: 15px; }
.google-sheet td input { width: 100%; height: 100%; border: none; outline: none; text-align: center; font-size: 15px; font-weight: 600; color: var(--primary-color); background: transparent; cursor: cell; transition: 0.1s;}
.google-sheet td input:focus { box-shadow: inset 0 0 0 2px var(--sheet-active-cell); background: rgba(59, 130, 246, 0.05); }

/* Итоговая колонка */
.final-col, .final-td { background-color: #F8FAFC !important; border-left: 2px solid #3B82F6 !important; }
.final-td { font-weight: 700; color: #3B82F6 !important; text-align: center; font-size: 16px; }

.data-table th { padding: 12px 15px; text-align: left; }
.data-table td { padding: 12px 15px; font-size: 14px; }
.data-table tr:hover td { background: #F8FAFC; }