@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

/* =========================================
   GLOBAL VARIABLES (THEME SYSTEM)
   ========================================= */

/* --- СВЕТЛАЯ ТЕМА (MODERN & SOFT) --- */
:root {
    --sidebar-width: 260px;
    
    /* Основные фоны */
    --primary-bg: #f0f2f5;          /* Мягкий серо-голубой фон */
    --card-bg: #ffffff;             /* Чисто белые карточки */
    
    /* Текст */
    --text-color: #344767;          /* Темно-синий/серый (Дорогой, читабельный) */
    --text-muted: #7b809a;          /* Мягкий серый для второстепенного */
    
    /* Акцент */
    --accent-color: #cb0c9f;        /* Твой основной цвет */
    --accent-hover: #ad0a88;
    
    /* Сайдбар */
    --sidebar-bg: #ffffff; 
    --sidebar-text: #67748e;
    --sidebar-border: transparent;
    --sidebar-item-hover: #f8f9fa;
    --sidebar-shadow: 0 0 2rem 0 rgba(136, 152, 170, 0.15);

    /* Поля ввода */
    --input-bg: #ffffff;
    --input-border: #d2d6da;
    --input-text: #495057;
    
    /* Границы и Тени */
    --border-color: #e9ecef;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* --- ЦВЕТА ТАБЛИЦ (СВЕТЛАЯ) --- */
    --table-head-bg: #f8f9fa;       /* Светлый фон шапки */
    --table-head-text: #7b809a;     /* Серый текст шапки */
    --table-hover-bg: #f8f9fa;      /* Цвет строки при наведении */
}

/* --- ТЕМНАЯ ТЕМА (DEEP & CLEAN - КАК ТЫ ПРОСИЛ) --- */
[data-theme="dark"] {
    --primary-bg: #111315;          
    --card-bg: #1a1d21;             
    
    --text-color: #e9ecef;          
    --text-muted: #a0aec0;
    
    --accent-color: #4e73df;        
    
    /* Сайдбар */
    --sidebar-bg: #1a1d21; 
    --sidebar-text: #a0aec0;
    --sidebar-border: rgba(255, 255, 255, 0.05);
    --sidebar-item-hover: rgba(255, 255, 255, 0.05);
    --sidebar-shadow: none;

    /* Поля ввода */
    --input-bg: #0f1113;
    --input-border: #2d3748;
    --input-text: #e9ecef; 
    
    --border-color: rgba(255, 255, 255, 0.08);
    --card-shadow: none;
    --modal-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

    /* --- ЦВЕТА ТАБЛИЦ (ТЕМНАЯ) --- */
    --table-head-bg: #212529;       /* Темный фон шапки */
    --table-head-text: #e9ecef;     /* Светлый текст шапки */
    --table-hover-bg: rgba(255, 255, 255, 0.05);
}

/* =========================================
   LAYOUT & BASE STYLES
   ========================================= */
body { 
    font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; 
    font-size: 0.9em; 
    background-color: var(--primary-bg); 
    color: var(--text-color); 
    margin: 0; 
    display: flex; 
    height: 100vh; 
    overflow: hidden; 
    transition: background 0.3s, color 0.3s; 
    -webkit-font-smoothing: antialiased; 
}

/* --- GLOBAL TABLE FIX (ГЛАВНОЕ ИСПРАВЛЕНИЕ) --- */
/* Этот блок заставляет все таблицы подчиняться теме */

.table, .table-dark, .table-bordered {
    color: var(--text-color) !important;
    background-color: transparent !important;
    border-color: var(--border-color) !important;
    margin-bottom: 0;
}

/* Шапка таблицы */
.table thead th, 
.table-dark thead th,
.table thead.table-dark th {
    background-color: var(--table-head-bg) !important;
    color: var(--table-head-text) !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color) !important;
    border-top: none !important;
    vertical-align: middle;
    padding: 12px 15px !important;
}

/* Ячейки */
.table tbody td, .table-dark tbody td {
    background-color: transparent !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-color) !important;
    vertical-align: middle;
    padding: 10px 15px !important;
}

/* Ховер эффект */
.table-hover tbody tr:hover td {
    background-color: var(--table-hover-bg) !important;
    color: var(--text-color) !important;
}

/* Скругление таблиц */
.table-responsive {
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* Календарь (особый стиль) */
.calendar-table th, .calendar-table td {
    padding: 5px !important;
    text-align: center;
    border: 1px solid var(--border-color) !important;
}

/* Inputs & Selects */
.form-control, .form-select { 
    background-color: var(--input-bg) !important; 
    border: 1px solid var(--input-border) !important; 
    color: var(--input-text) !important; 
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    font-weight: 400;
}
.form-control::placeholder {
    color: var(--text-muted) !important; 
    opacity: 0.8;
}
.form-control:focus, .form-select:focus { 
    box-shadow: 0 0 0 2px rgba(203, 12, 159, 0.2); 
    border-color: var(--accent-color) !important; 
}
.form-control[readonly], .form-control:disabled {
    background-color: rgba(0,0,0,0.05) !important;
    opacity: 0.7;
    cursor: not-allowed;
}

/* Карточки и Модалки */
.crm-card, .modal-content {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--card-shadow);
}
.modal-content { box-shadow: var(--modal-shadow); border-radius: 1rem; }

/* Modal Header/Footer */
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-footer { border-top: 1px solid var(--border-color); }
.btn-close { filter: none; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* --- GRAPHIC HEADERS --- */
.crm-card h3 {
    font-size: 1.3rem;
    font-weight: 800;
    padding-bottom: 5px;
    border-bottom: 3px solid var(--accent-color); 
    width: fit-content; 
    margin-bottom: 1rem !important;
    color: var(--text-color);
}

/* --- SIDEBAR (Адаптивный) --- */
.sidebar { 
    width: var(--sidebar-width); 
    background: var(--sidebar-bg); 
    color: var(--sidebar-text); 
    border-right: 1px solid var(--border-color);
    box-shadow: var(--sidebar-shadow);
    display: flex; 
    flex-direction: column; 
    padding: 20px; 
    z-index: 100; 
    flex-shrink: 0; 
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.brand { 
    color: var(--text-color); 
    text-decoration: none; 
    font-weight: 700; 
    font-size: 1.2rem; 
    margin-bottom: 30px; 
    display: flex; 
    align-items: center; 
}
.nav-item { 
    color: var(--sidebar-text); 
    padding: 10px 15px; 
    border-radius: 8px; 
    text-decoration: none; 
    margin-bottom: 5px; 
    display: flex; 
    align-items: center; 
    transition: 0.2s; 
    font-weight: 500;
}
.nav-item i { 
    margin-right: 1rem;
    font-size: 1.1em;
    color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1); 
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
[data-theme="dark"] .nav-item i {
    background: rgba(255,255,255,0.05);
    box-shadow: none;
}
.nav-item:hover, .nav-item.active { 
    background: var(--sidebar-item-hover); 
    color: var(--text-color); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}
[data-theme="dark"] .nav-item:hover, [data-theme="dark"] .nav-item.active {
    box-shadow: none;
}
.nav-cat { 
    font-size: 0.7rem; 
    text-transform: uppercase; 
    margin: 25px 0 10px 10px; 
    font-weight: 700; 
    color: var(--text-muted); 
    letter-spacing: 1px; 
}

/* --- MAIN WRAPPER --- */
.main-wrapper { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    overflow: hidden; 
}

/* --- TICKER --- */
.ticker-wrap { background: #dc3545; color: white; padding: 6px 15px; display: flex; align-items: center; font-size: 0.85rem; font-weight: 700; overflow: hidden; height: 32px; }
.ticker-content { white-space: nowrap; animation: scroll 30s linear infinite; flex-grow: 1; margin-right: 10px; }
@keyframes scroll { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

/* --- TOP HEADER --- */
.topbar { 
    height: 75px; 
    background: rgba(255, 255, 255, 0.8); 
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 30px; 
    gap: 15px; 
    position: relative;
    transition: background 0.3s;
    z-index: 90;
}
[data-theme="dark"] .topbar { background: rgba(26, 29, 33, 0.8); }

.user-greeting a {
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s;
}
.user-greeting a:hover { color: var(--accent-color); }

.user-welcome { 
    font-size: 1.1rem; 
    font-weight: 700; 
    margin-bottom: 2px; 
    display: flex; 
    align-items: center;
}
.days-badge { 
    font-size: 0.7rem; 
    background: linear-gradient(310deg, #7928CA, #FF0080); 
    color: white; 
    padding: 4px 10px; 
    border-radius: 6px; 
    font-weight: 600; 
    display: inline-block; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Center: Mini Focus FM */
.focus-fm-mini {
    background: rgba(203, 12, 159, 0.1); 
    color: var(--accent-color);
    padding: 5px 15px;
    border-radius: 8px;
    font-weight: 600;
}

/* Right Group */
.top-right-group {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
}
.shift-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.header-ip-mini {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    padding: 5px 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid transparent;
    border-radius: 6px;
    color: #10b981;
    font-weight: 700;
}

/* --- WIDGET AREA --- */
.scroll-area { overflow-y: auto; padding: 30px; flex-grow: 1; }
.widgets-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; margin-bottom: 30px; }
.crm-card { 
    background: var(--card-bg); 
    border-radius: 1rem; 
    padding: 1.5rem; 
    box-shadow: var(--card-shadow); 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    border: 1px solid var(--border-color); 
    transition: background 0.3s;
}

/* CLOCK STRIP */
.clock-strip { display: flex; gap: 20px; margin-bottom: 30px; }
.mini-clock { 
    padding: 15px 20px; 
    border-left: 4px solid var(--accent-color); 
    border-radius: 12px; 
    background: var(--card-bg); 
    box-shadow: var(--card-shadow); 
    flex-grow: 1; 
    border: 1px solid var(--border-color); 
}
.mini-clock .time { font-size: 1.5rem; font-weight: 700; line-height: 1; color: var(--text-color); }
.mini-clock .city { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-top: 5px;}

/* CURRENCY */
.currency-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.currency-item { 
    background: var(--primary-bg); 
    border-radius: 12px; 
    padding: 15px; 
    text-align: center; 
    transition: transform 0.2s;
}
.currency-item:hover { transform: translateY(-3px); }
.curr-flag { font-size: 2rem; display: block; margin-bottom: 5px; }
.curr-val { font-weight: 700; color: var(--text-color); font-size: 1.1rem; }

/* TOOLS */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; }
.tool-btn { 
    background: var(--card-bg); 
    border: 1px solid var(--border-color); 
    padding: 20px; 
    border-radius: 12px; 
    text-align: center; 
    text-decoration: none; 
    color: var(--text-color); 
    transition: 0.2s; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 10px; 
    font-weight: 600; 
    box-shadow: var(--card-shadow);
}
.tool-btn i { font-size: 1.5rem; color: var(--accent-color); margin-bottom: 5px; }
.tool-btn:hover { 
    border-color: var(--accent-color); 
    transform: translateY(-5px); 
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

/* BDAY BANNER */
.bday-banner { background: linear-gradient(90deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%); color: #d63384; text-align: center; font-weight: bold; font-size: 0.9rem; padding: 8px; display: none; }