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

:root {
    /* Color Palette */
    --primary: #4F46E5; /* Indigo */
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --success: #10B981;
    --success-hover: #059669;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --warning: #F59E0B;
    
    /* Grays & Backgrounds */
    --bg-app: #F3F4F6;
    --bg-card: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    
    /* Metrics */
    --sidebar-width: 280px;
    --header-height: 80px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===============================
   LAYOUT
=============================== */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}

.sidebar-logo img {
    max-height: 48px;
    width: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.sidebar-nav ul { list-style: none; }
.sidebar-nav li { margin-bottom: 8px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* Custom Icons via background */
.icon-home { background: url('img/home.png') no-repeat center; background-size: contain; width: 20px; height: 20px; margin-right: 16px; opacity: 0.6; }
.icon-uchet { background: url('img/uchet.png') no-repeat center; background-size: contain; width: 20px; height: 20px; margin-right: 16px; opacity: 0.6; }
.icon-rashod { background: url('img/rashod.png') no-repeat center; background-size: contain; width: 20px; height: 20px; margin-right: 16px; opacity: 0.6; }
.icon-analitika { background: url('img/analitika.png') no-repeat center; background-size: contain; width: 20px; height: 20px; margin-right: 16px; opacity: 0.6; }

.sidebar-nav a:hover .icon-home, .sidebar-nav a:hover .icon-uchet, .sidebar-nav a:hover .icon-rashod, .sidebar-nav a:hover .icon-analitika {
    opacity: 1;
    filter: brightness(0) saturate(100%) invert(27%) sepia(85%) saturate(2335%) hue-rotate(231deg) brightness(97%) contrast(92%); /* Primary Color Filter */
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin 0.3s ease;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-app);
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    width: 360px;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.search-box:focus-within {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: var(--text-main);
    margin-left: 8px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    font-weight: 500;
    color: var(--text-main);
}

.user-profile .avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 16px;
}

/* Page Body */
.page-body {
    padding: 32px;
    flex: 1;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===============================
   COMPONENTS
=============================== */

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 24px;
}

/* Dashboard Widgets */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.widget {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.widget:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.widget-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}

.widget h3 {
    font-size: 18px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.widget p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Action Bar (Toolbar above tables) */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-app); border-color: #D1D5DB; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: var(--danger-hover); box-shadow: var(--shadow-md); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-hover); box-shadow: var(--shadow-md); }

/* Tables */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.table th {
    background: #F9FAFB;
    color: var(--text-muted);
    font-weight: 600;
    padding: 16px 24px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-size: 14px;
    vertical-align: middle;
}

.table tbody tr:hover { background-color: #F9FAFB; }
.table tbody tr:last-child td { border-bottom: none; }
.table td a { color: var(--primary); font-weight: 500; text-decoration: none; }
.table td a:hover { text-decoration: underline; }

/* Forms & Inputs */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

input[type="text"], input[type="date"], input[type="number"], select, .form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid #D1D5DB;
    font-size: 15px;
    color: var(--text-main);
    background: var(--bg-card);
    transition: all 0.2s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Modals / Popups */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show { display: flex; }

.modal, .popup1, .filter-popup, .popup-vozduh, .popup {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: none;
    flex-direction: column;
    
    /* Legacy positioning fallback */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 1001;
}

.modal.show, .popup1.show, .filter-popup.show, .popup-vozduh.show, .popup.show {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    z-index: 1001;
}

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

.modal-title { font-size: 18px; font-weight: 600; }

.modal-close {
    background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer;
}
.modal-close:hover { color: var(--text-main); }

.modal-body { padding: 24px; }
.modal-footer { padding: 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; }

/* Status Badges */
.badge {
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-danger { background: #FEE2E2; color: #991B1B; }

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-main);
    cursor: pointer;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-toggle { display: block; margin-right: 16px; }
    
    .sidebar-overlay {
        display: none;
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5); z-index: 40;
    }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 768px) {
    .page-title { flex-direction: column; align-items: flex-start; gap: 16px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { width: 100%; }
    .page-body { padding: 16px; }
    .top-header { padding: 0 16px; }
}

/* Калькулятор (request.php) */
.popup-vozduh {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    width: 900px;
    max-width: 95vw;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1001;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
}

.popup-vozduh.show-voz {
    display: block !important;
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

.popup-vozduh .content {
    display: flex;
    gap: 30px;
    margin-bottom: 24px;
}

.popup-vozduh .inputs-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.popup-vozduh .table-section {
    flex: 1;
}

.popup-vozduh label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.popup-vozduh select,
.popup-vozduh input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.popup-vozduh #button-callculate {
    margin-top: 15px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.popup-vozduh #button-callculate:hover {
    background: var(--primary-hover);
}

.popup-vozduh .table-section table {
    width: 100%;
    border-collapse: collapse;
}

.popup-vozduh .table-section th,
.popup-vozduh .table-section td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.popup-vozduh .table-section th {
    font-weight: 500;
    color: var(--text-secondary);
}

.popup-vozduh .save-vozduh,
.popup-vozduh .close-vozduh,
.popup-vozduh .save-zayavka {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.popup-vozduh .save-vozduh,
.popup-vozduh .save-zayavka {
    background: var(--success);
    color: white;
}

.popup-vozduh .save-vozduh:hover,
.popup-vozduh .save-zayavka:hover {
    background: var(--success-hover);
}

.popup-vozduh .close-vozduh {
    background: #E5E7EB;
    color: var(--text-muted);
    margin-left: 10px;
}

.popup-vozduh .close-vozduh:hover {
    background: #D1D5DB;
}

@media (max-width: 768px) {
    .popup-vozduh .content {
        flex-direction: column;
    }
}
