:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary: #7c3aed;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --header-height: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 2px;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 12px;
}

.sidebar-menu li {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-300);
}

.sidebar-menu li:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.sidebar-menu li.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.menu-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.sidebar-menu li.active .menu-icon,
.sidebar-menu li:hover .menu-icon {
    opacity: 1;
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--gray-900);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.visible {
    opacity: 1;
}

/* Main content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 20px 24px;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -1px;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
    font-weight: 500;
}

/* Filters */
.filters-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--gray-200);
    margin-bottom: 16px;
    overflow: hidden;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    padding: 20px 24px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.filter-badge button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.filter-badge button:hover {
    background: rgba(255,255,255,0.3);
}

select, input[type="text"], input[type="number"] {
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 14px;
    min-width: 180px;
    background: white;
    transition: all 0.2s ease;
    font-family: inherit;
}

select:hover, input:hover {
    border-color: var(--gray-300);
}

select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray-700);
    padding: 10px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.year-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: var(--gray-100);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    color: var(--gray-600);
}

.year-checkbox:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.year-checkbox.selected {
    background: var(--primary);
    color: white;
}

.year-checkbox.overdue {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--danger);
}

.year-checkbox.overdue:hover {
    background: #fee2e2;
}

.year-checkbox.overdue.selected {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Table */
.table-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: sticky;
    top: 0;
    z-index: 10;
}

th:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

tr {
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: var(--gray-50);
}

tr.clickable-row:hover {
    background: #eff6ff;
}

tr.clickable-row:hover td:first-child {
    color: var(--primary);
}

td {
    font-size: 14px;
}

.balance {
    font-weight: 600;
    color: var(--success);
    font-variant-numeric: tabular-nums;
}

.elevators-count {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    display: inline-block;
}

.replacement-soon {
    color: var(--danger);
    font-weight: 600;
}

.mc-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.mc-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.fund-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.fund-badge.special {
    background: #ecfdf5;
    color: #059669;
}

.fund-badge.regional {
    background: #fff7ed;
    color: #ea580c;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.pagination-info {
    color: var(--gray-500);
    font-size: 14px;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

.pagination-buttons button {
    padding: 8px 16px;
    border: 2px solid var(--gray-200);
    background: white;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.pagination-buttons button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-buttons button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-buttons button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
    font-size: 15px;
}

.loading::before {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error {
    background: #fef2f2;
    color: var(--danger);
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #fecaca;
    font-weight: 500;
}

/* Auth styles */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    padding: 20px;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 16px;
}

.auth-logo-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.auth-logo-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: 12px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    border-radius: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.auth-tab.active {
    background: white;
    color: var(--gray-900);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.auth-field input {
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.auth-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-btn {
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    font-family: inherit;
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-message {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
}

.auth-message.success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.auth-message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    margin-bottom: 0;
}

.auth-message.warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

/* User menu */
.user-menu {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.user-position {
    font-size: 12px;
    color: var(--gray-400);
}

.logout-btn {
    width: 100%;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    color: var(--gray-300);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* Admin badge */
.admin-badge {
    display: inline-block;
    background: var(--warning);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 8px;
}

.pending-badge {
    background: var(--danger);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: auto;
}

/* Notification bell */
.notification-bell {
    position: relative;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.notification-bell:hover {
    background: rgba(255,255,255,0.15);
}

.notification-bell svg {
    width: 20px;
    height: 20px;
    color: var(--gray-300);
    flex-shrink: 0;
}

.notification-bell.has-unread svg {
    color: var(--warning);
    animation: bell-ring 0.5s ease;
}

@keyframes bell-ring {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(15deg); }
    50% { transform: rotate(-15deg); }
    75% { transform: rotate(10deg); }
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.notification-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    margin-bottom: 8px;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.notification-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--gray-900);
}

.notification-mark-all {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.notification-mark-all:hover {
    background: var(--gray-100);
}

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s ease;
}

.notification-item:hover {
    background: var(--gray-50);
}

.notification-item.unread {
    background: rgba(59, 130, 246, 0.05);
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.notification-item {
    position: relative;
    padding-left: 24px;
}

.notification-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.notification-message {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 4px;
    line-height: 1.4;
}

.notification-time {
    font-size: 11px;
    color: var(--gray-400);
}

.notification-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
}

/* Admin panel */
.admin-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--gray-200);
}

.admin-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: 12px;
    margin-bottom: 12px;
}

.user-card-info {
    flex: 1;
}

.user-card-name {
    font-weight: 600;
    color: var(--gray-900);
}

.user-card-details {
    font-size: 13px;
    color: var(--gray-500);
}

.user-card-actions {
    display: flex;
    gap: 8px;
}

.btn-approve {
    padding: 8px 16px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-approve:hover {
    background: #059669;
}

.btn-reject {
    padding: 8px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-reject:hover {
    background: #dc2626;
}

/* Companies page */
.companies-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.companies-stat {
    background: white;
    padding: 20px 28px;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--gray-200);
}

.companies-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

.companies-stat-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

/* Reset button */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border: 2px solid var(--gray-200);
}

.btn-ghost:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Address cell */
.address-cell {
    min-width: 250px;
}

.address-region {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 500;
}

.address-municipality {
    font-size: 12px;
    color: var(--gray-500);
}

.address-street {
    font-weight: 500;
    color: var(--gray-800);
    margin-top: 2px;
}

/* Touch-friendly interactions */
button, a, .clickable-row, .mc-link {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
}

/* Ensure minimum tap target sizes */
.mobile-menu-btn,
.logout-btn,
.notification-bell,
button,
input[type="checkbox"] {
    min-height: 44px;
    min-width: 44px;
}

/* Responsive adjustments for better mobile UX */
@media (max-width: 1280px) {
    .main {
        padding: 24px 20px;
    }

    .page-header {
        flex-wrap: wrap;
        gap: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

/* Tablet breakpoint (641px - 1024px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .main {
        padding: 20px 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .page-title {
        font-size: 24px;
    }

    .filters {
        gap: 12px;
    }

    .filter-group {
        min-width: 160px;
    }

    select, input[type="text"], input[type="number"] {
        min-width: 160px;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 1000px;
    }

    th, td {
        padding: 12px 10px;
        font-size: 13px;
    }

    .modal-content {
        max-width: 90%;
        padding: 20px;
    }
}

/* Mobile breakpoint (max-width: 768px) */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-overlay.visible {
        display: block;
    }

    .main {
        margin-left: 0;
        padding: 70px 16px 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
        margin-bottom: 20px;
    }

    .page-title {
        font-size: 22px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-label {
        font-size: 12px;
    }

    .filters-card {
        border-radius: 12px;
    }

    .filters {
        padding: 16px 12px;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
        min-width: 100%;
    }

    .filter-label {
        font-size: 11px;
    }

    select, input[type="text"], input[type="number"] {
        min-width: 100%;
        width: 100%;
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px 14px;
    }

    .checkbox-label {
        font-size: 14px;
        padding: 12px 0;
        min-height: 44px;
    }

    .checkbox-label input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .checkbox-group {
        width: 100%;
    }

    .year-checkbox {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .filter-badge {
        font-size: 12px;
        padding: 10px 14px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .filter-badge button {
        min-width: 32px;
        min-height: 32px;
        font-size: 18px;
    }

    .table-container {
        border-radius: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 16px;
    }

    table {
        min-width: 900px;
        font-size: 13px;
    }

    th {
        padding: 12px 8px;
        font-size: 11px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    td {
        padding: 12px 8px;
        font-size: 13px;
    }

    .address-cell {
        min-width: 200px;
    }

    .address-region {
        font-size: 10px;
    }

    .address-municipality {
        font-size: 11px;
    }

    .address-street {
        font-size: 13px;
    }

    .elevators-count {
        font-size: 12px;
        padding: 3px 8px;
    }

    .pagination {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 12px 16px;
    }

    .pagination-info {
        font-size: 13px;
    }

    .pagination-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination-buttons button {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        min-height: 44px;
    }

    .btn-primary, .btn-ghost {
        width: 100%;
    }

    /* Modal responsive */
    .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 20px 16px;
        max-height: 85vh;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-close {
        font-size: 28px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Auth page mobile */
    .auth-container {
        padding: 16px;
    }

    .auth-card {
        padding: 28px 20px;
        border-radius: 16px;
    }

    .auth-logo-title {
        font-size: 20px;
    }

    .auth-field input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 14px 16px;
    }

    .auth-btn {
        padding: 16px;
        font-size: 16px;
        min-height: 50px;
    }

    /* User menu mobile adjustments */
    .user-menu {
        padding: 12px 16px;
    }

    .user-info {
        gap: 10px;
        margin-bottom: 10px;
    }

    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .user-name {
        font-size: 13px;
    }

    .user-position {
        font-size: 11px;
    }

    .logout-btn {
        padding: 12px;
        font-size: 14px;
        min-height: 44px;
    }

    /* Notification bell mobile */
    .notification-bell {
        padding: 12px;
        min-height: 44px;
    }

    .notification-dropdown {
        width: calc(100vw - 40px);
        left: -10px;
        right: -10px;
    }

    .notification-item {
        padding: 12px 14px;
    }

    .notification-title {
        font-size: 12px;
    }

    .notification-message {
        font-size: 11px;
    }

    /* Admin panel mobile */
    .admin-section {
        padding: 16px;
        border-radius: 12px;
    }

    .admin-section-title {
        font-size: 16px;
    }

    .user-card {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .user-card-actions {
        justify-content: stretch;
        flex-direction: column;
    }

    .user-card-actions button {
        width: 100%;
        min-height: 44px;
    }

    .btn-approve, .btn-reject {
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Companies page mobile */
    .companies-stats {
        flex-direction: column;
        gap: 12px;
    }

    .companies-stat {
        padding: 16px 20px;
    }

    .companies-stat-value {
        font-size: 24px;
    }
}

/* Small mobile breakpoint (max-width: 640px) */
@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .page-title {
        font-size: 20px;
    }

    .filters {
        padding: 12px;
    }

    .year-checkbox {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 40px;
    }

    .modal-content {
        width: 98%;
        padding: 16px 12px;
    }

    .auth-card {
        padding: 24px 16px;
    }

    table {
        min-width: 800px;
        font-size: 12px;
    }

    th, td {
        padding: 10px 6px;
        font-size: 12px;
    }

    .address-cell {
        min-width: 180px;
    }
}

/* Extra small devices - iPhone SE, older phones (max-width: 375px) */
@media (max-width: 375px) {
    .main {
        padding: 65px 12px 12px;
    }

    .page-title {
        font-size: 18px;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 11px;
    }

    .filters {
        padding: 12px 10px;
        gap: 10px;
    }

    .filter-label {
        font-size: 10px;
    }

    select, input[type="text"], input[type="number"] {
        padding: 10px 12px;
        font-size: 16px;
    }

    .year-checkbox {
        padding: 8px 10px;
        font-size: 11px;
        min-height: 38px;
    }

    .btn {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 42px;
    }

    .pagination-buttons button {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 42px;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        padding: 16px 12px;
        border-radius: 12px;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    table {
        font-size: 11px;
    }

    th, td {
        padding: 8px 5px;
        font-size: 11px;
    }

    .address-street {
        font-size: 12px;
    }

    .elevators-count {
        font-size: 11px;
        padding: 2px 6px;
    }
}

/* Landscape mode for small devices */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }

    .main {
        padding: 60px 12px 12px;
    }

    .mobile-menu-btn {
        top: 8px;
        left: 8px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Tablet landscape optimizations */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .filters {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .filter-group {
        width: auto;
    }

    .checkbox-group {
        grid-column: 1 / -1;
    }
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: var(--gray-600);
}

/* Responsive modal form styles */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        border-radius: 16px 16px 0 0;
        max-height: 90vh;
    }

    /* Form inputs in modals */
    .modal-content input[type="text"],
    .modal-content input[type="number"],
    .modal-content select {
        font-size: 16px;
        padding: 12px;
        border-radius: 8px;
    }

    .modal-content label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    /* Grid forms become single column on mobile */
    .modal-content [style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column;
        gap: 16px;
    }

    /* Button groups in modals */
    .modal-content [style*="display: flex"][style*="gap"] {
        flex-direction: column;
    }

    .modal-content [style*="display: flex"][style*="gap"] button {
        width: 100%;
        min-height: 48px;
    }
}

/* Card layout improvements for mobile */
@media (max-width: 640px) {
    /* Make cards more compact */
    .stat-card,
    .user-card,
    .companies-stat,
    .admin-section {
        box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    }

    /* Improve touch targets for links */
    .mc-link {
        padding: 4px 0;
        display: inline-block;
        min-height: 32px;
        line-height: 1.6;
    }

    /* Better spacing for form elements */
    .auth-field,
    .filter-group {
        gap: 8px;
    }
}

/* Horizontal scroll indicator for tables */
@media (max-width: 768px) {
    .table-container::after {
        content: '← Прокрутите для просмотра →';
        display: block;
        text-align: center;
        padding: 8px;
        font-size: 11px;
        color: var(--gray-400);
        background: var(--gray-50);
        border-top: 1px solid var(--gray-200);
    }

    .table-container::-webkit-scrollbar {
        height: 8px;
    }

    .table-container::-webkit-scrollbar-track {
        background: var(--gray-100);
    }

    .table-container::-webkit-scrollbar-thumb {
        background: var(--gray-400);
        border-radius: 4px;
    }

    .table-container::-webkit-scrollbar-thumb:hover {
        background: var(--gray-500);
    }
}

/* Improve button spacing on mobile */
@media (max-width: 768px) {
    .btn + .btn {
        margin-top: 8px;
    }

    .pagination-buttons button + button {
        margin-top: 0;
        margin-left: 8px;
    }

    /* Improve page header button layout */
    .page-header button {
        width: 100%;
        justify-content: center;
    }
}

/* Focus states for accessibility */
@media (max-width: 768px) {
    button:focus-visible,
    select:focus-visible,
    input:focus-visible,
    a:focus-visible {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
    }

    /* Larger touch targets for checkboxes */
    input[type="checkbox"] {
        transform: scale(1.2);
    }
}

/* slideUp animation for modals */
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }


/* ========== Sidebar Sections ========== */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.sidebar-section-header {
    padding: 10px 28px 6px 28px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.08);
}

.sidebar-section-header.tenders-section {
    color: #a78bfa;
    margin-top: 4px;
}

.sidebar-section-header.tenders-section::after {
    background: rgba(167, 139, 250, 0.2);
}

.sidebar-section-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 28px 0 28px;
}

.sidebar-menu li.active.tenders-active {
    background: var(--secondary) !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.sidebar-menu li.tenders-active:hover {
    background: var(--secondary) !important;
}

/* Predotbor nav style */
.portal-nav-item.predotbor-nav.active {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
    border-color: #10b981 !important;
}
.portal-nav-item.predotbor-nav:hover:not(.active) {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
}
/* CRM nav style */
.portal-nav-item.crm-nav.active {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #f59e0b !important;
    border-color: #f59e0b !important;
}
.portal-nav-item.crm-nav:hover:not(.active) {
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
}


/* CRM sidebar divider */
.sidebar-menu li.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 16px;
    padding: 0;
    cursor: default;
    pointer-events: none;
}
.sidebar-menu li.sidebar-divider:hover {
    background: rgba(255,255,255,0.08) !important;
}

/* Goszakupki nav styling */
.portal-nav-item.goszakupki-nav.active {
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
}
.portal-nav-item.goszakupki-nav:hover:not(.active) {
    background: rgba(124, 58, 237, 0.08);
    color: #c4b5fd;
}

/* Admin enrichment button */
.portal-enrich-btn:hover {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
}

/* AI Chat Widget animations */
@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* Contracts section nav */
.portal-nav-item.contracts-nav.active {
    color: #60a5fa !important;
    background: rgba(96,165,250,0.15) !important;
    border-color: #60a5fa !important;
}
.portal-nav-item.contracts-nav:hover:not(.active) {
    color: #93c5fd !important;
    background: rgba(96,165,250,0.08) !important;
}
