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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* Login Screen */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2563eb;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

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

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Header */
.header {
    background: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header h1 {
    color: #2563eb;
    font-size: 24px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

#user-name {
    color: #666;
}

/* Navigation */
.nav {
    background: #fff;
    padding: 0 24px;
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e5e7eb;
}

.nav-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-btn:hover {
    color: #2563eb;
}

.nav-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Views */
.view {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

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

.view-header h2 {
    font-size: 24px;
    color: #1f2937;
}

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

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: #2563eb;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-section {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.dashboard-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: #1f2937;
}

/* Lists */
.list-item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item-info h4 {
    font-size: 14px;
    margin-bottom: 4px;
}

.list-item-info p {
    font-size: 12px;
    color: #666;
}

.list-item-date {
    font-size: 12px;
    color: #2563eb;
    white-space: nowrap;
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.filters select,
.filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.filters input {
    flex: 1;
    max-width: 300px;
}

/* Tables */
.table-container {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
}

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

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    font-size: 13px;
}

.data-table td {
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tbody tr {
    cursor: pointer;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-ceka_na_zavolani { background: #fef3c7; color: #92400e; }
.status-zavolano { background: #dbeafe; color: #1e40af; }
.status-ma_zajem { background: #d1fae5; color: #065f46; }
.status-nema_zajem { background: #fee2e2; color: #991b1b; }
.status-odeslana_nabidka { background: #e0e7ff; color: #3730a3; }
.status-domluvena_schuzka { background: #cffafe; color: #155e75; }
.status-uzavreno_uspech { background: #bbf7d0; color: #166534; }
.status-uzavreno_neuspech { background: #fecaca; color: #991b1b; }
.status-archivovano { background: #e5e7eb; color: #374151; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
}

.pagination button:hover {
    background: #f9fafb;
}

.pagination button.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

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

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

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 600px;
}

.modal-xlarge {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-content form {
    padding: 20px;
}

/* Lead Detail */
.lead-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 20px;
}

.lead-info, .lead-status-section {
    background: #f9fafb;
    padding: 16px;
    border-radius: 8px;
}

.lead-info h3, .lead-status-section h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
}

.lead-info p {
    margin-bottom: 8px;
}

.lead-info strong {
    color: #374151;
}

.lead-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.lead-history, .lead-communications {
    padding: 0 20px 20px;
}

.lead-history h3, .lead-communications h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
}

.history-item {
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    margin-bottom: 8px;
}

.history-item .status {
    font-weight: 600;
    margin-bottom: 4px;
}

.history-item .meta {
    font-size: 12px;
    color: #666;
}

.history-item .note {
    font-size: 13px;
    margin-top: 8px;
    color: #374151;
}

.comm-item {
    padding: 12px;
    background: #f0f9ff;
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid #2563eb;
}

.comm-item .type {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    color: #2563eb;
}

.comm-item .subject {
    font-weight: 500;
    margin: 4px 0;
}

.comm-item .content {
    font-size: 13px;
    color: #374151;
}

.comm-item .meta {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
}

/* Error */
.error {
    color: #ef4444;
    font-size: 14px;
    margin-top: 8px;
}

/* Role Badge */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-superadmin { background: #fef3c7; color: #92400e; }
.role-admin { background: #dbeafe; color: #1e40af; }
.role-user { background: #e5e7eb; color: #374151; }

/* Active badge */
.active-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.active-1 { background: #d1fae5; color: #065f46; }
.active-0 { background: #fee2e2; color: #991b1b; }

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .lead-detail-grid {
        grid-template-columns: 1fr;
    }

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

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }
}
