* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1f2937;
    --light: #f3f4f6;
    --border: #e5e7eb;
    --text: #111827;
    --text-light: #6b7280;
    --bg: #f9fafb;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --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);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

/* Navbar */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--dark);
}

.nav-brand i {
    color: var(--primary);
}

.nav-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    border-bottom: 2px solid transparent;
}

.nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--light);
}

.nav-link.logout {
    color: var(--danger);
    border-bottom-color: transparent;
}

.nav-link.logout:hover {
    background: #fef2f2;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 1rem;
}

.flash-message {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 3px solid;
    background: var(--white);
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.flash-success {
    border-left-color: var(--success);
    background: #f0fdf4;
    color: #166534;
}

.flash-error {
    border-left-color: var(--danger);
    background: #fef2f2;
    color: #991b1b;
}

.flash-info {
    border-left-color: var(--info);
    background: #eff6ff;
    color: #1e40af;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.login-card {
    background: var(--white);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
    font-weight: 600;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.875rem;
}

.login-form {
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    font-size: 0.875rem;
    transition: all 0.2s;
    background: var(--white);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    color: var(--text-light);
    font-size: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    background: var(--white);
    color: var(--text);
    border-color: var(--border);
}

.btn:hover {
    background: var(--light);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--light);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Dashboard */
.dashboard {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.section-title {
    font-size: 1.125rem;
    margin: 1.5rem 0 1rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

.stat-primary .stat-icon { background: var(--primary); }
.stat-success .stat-icon { background: var(--success); }
.stat-info .stat-icon { background: var(--info); }
.stat-warning .stat-icon { background: var(--warning); }
.stat-danger .stat-icon { background: var(--danger); }

.stat-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: var(--dark);
    font-weight: 600;
}

.stat-content p {
    color: var(--text-light);
    font-size: 0.8125rem;
}

/* Quick Actions */
.quick-actions {
    margin-top: 1.5rem;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.action-card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    text-align: center;
}

.action-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.action-card i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.action-card h3 {
    margin-bottom: 0.5rem;
    color: var(--dark);
    font-size: 1rem;
    font-weight: 600;
}

.action-card p {
    color: var(--text-light);
    font-size: 0.8125rem;
}

/* Search Page */
.search-page {
    animation: fadeIn 0.3s;
}

.search-form-container {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.search-form {
    width: 100%;
}

.search-input-group {
    display: flex;
    gap: 0.75rem;
}

.search-input {
    flex: 1;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    font-size: 0.875rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.results-header {
    margin-bottom: 1rem;
}

.results-header h2 {
    color: var(--dark);
    font-size: 1.125rem;
    font-weight: 600;
}

/* Users Grid */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.user-card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.user-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.user-header h3 {
    color: var(--dark);
    font-size: 1rem;
    font-weight: 600;
}

.user-room {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.user-info {
    margin-bottom: 1rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    color: var(--text);
    font-size: 0.875rem;
}

.info-row i {
    color: var(--primary);
    width: 16px;
    font-size: 0.8125rem;
}

.user-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.no-results, .search-hint {
    text-align: center;
    padding: 3rem;
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.no-results i, .search-hint i {
    font-size: 3rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* User Detail Page */
.user-detail-page {
    animation: fadeIn 0.3s;
}

.user-header-section {
    margin-bottom: 1.5rem;
}

.back-link {
    margin-bottom: 1rem;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.user-info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.info-card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.info-card h3 {
    margin-bottom: 1rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.info-grid {
    display: grid;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--light);
    font-size: 0.875rem;
}

.info-item label {
    font-weight: 500;
    color: var(--text-light);
}

.info-item span {
    color: var(--text);
}

.balance-value {
    color: var(--success);
    font-weight: 600;
}

.debt-value {
    color: var(--danger);
    font-weight: 600;
}

/* Quick Actions Grid */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.quick-action-card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.quick-action-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-action-card i {
    font-size: 1.5rem;
    color: var(--primary);
}

.quick-action-card span {
    font-weight: 500;
    color: var(--text);
    font-size: 0.8125rem;
}

/* PDF Actions */
.pdf-actions {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.pdf-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.user-actions-section {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Tabs */
.tabs-section {
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--light);
}

.tab-btn {
    flex: 1;
    padding: 0.875rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-light);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    background: var(--white);
    color: var(--primary);
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

.tab-content {
    display: none;
    padding: 1.5rem;
}

.tab-content.active {
    display: block;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.data-table thead {
    background: var(--light);
    border-bottom: 2px solid var(--border);
}

.data-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: var(--light);
}

.text-center {
    text-align: center;
}

.text-success {
    color: var(--success);
    font-weight: 600;
}

.text-danger {
    color: var(--danger);
    font-weight: 600;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s;
}

.modal-content {
    background-color: var(--white);
    margin: 5% auto;
    padding: 0;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.2s;
}

.modal-large {
    max-width: 900px;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.close {
    color: var(--text-light);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--light);
}

.current-value {
    padding: 0.625rem;
    background: var(--light);
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary);
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--white);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s;
    border: 1px solid var(--border);
    min-width: 300px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left: 3px solid var(--success);
}

.notification-error {
    border-left: 3px solid var(--danger);
}

.notification-info {
    border-left: 3px solid var(--info);
}

/* Статистика в модальном окне */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.stat-item {
    padding: 0.875rem;
    background: var(--light);
    border-left: 3px solid var(--primary);
    font-size: 0.875rem;
}

.stat-item strong {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--text-light);
    font-size: 0.8125rem;
}

/* Edit Balance Page */
.edit-balance-page {
    animation: fadeIn 0.3s;
}

.edit-form-card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-top: 1.5rem;
}

.edit-form {
    margin-top: 1.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 1rem;
    }

    .nav-menu {
        width: 100%;
        justify-content: space-around;
        margin-top: 0.75rem;
    }

    .container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .users-grid {
        grid-template-columns: 1fr;
    }

    .user-info-section {
        grid-template-columns: 1fr;
    }

    .search-input-group {
        flex-direction: column;
    }

    .pdf-buttons {
        flex-direction: column;
    }

    .tabs {
        flex-direction: column;
    }

    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
