:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--gray-50); color: var(--gray-900); min-height: 100vh; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--gray-900); color: white; padding: 20px 0; flex-shrink: 0; }
.sidebar h2 { padding: 0 20px 20px; font-size: 16px; border-bottom: 1px solid var(--gray-700); margin-bottom: 10px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--gray-300); text-decoration: none; font-size: 14px; transition: background 0.15s; }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--gray-700); color: white; }
.sidebar nav a svg { flex-shrink: 0; }
.main { flex: 1; padding: 24px; overflow-x: auto; }

/* Header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; }
.count { font-size: 14px; font-weight: 400; color: var(--gray-500); margin-left: 4px; }

/* Filters */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select, .filters input { padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 14px; background: white; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card .label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* Table */
.table-wrap { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 12px 16px; background: var(--gray-50); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); }
td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:hover { background: var(--gray-50); }
tr { cursor: pointer; }
td small { color: var(--gray-500); font-size: 11px; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-new { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress, .badge-working { background: #fef3c7; color: #92400e; }
.badge-paid, .badge-done, .badge-confirmed { background: #dcfce7; color: #166534; }
.badge-rejected, .badge-closed, .badge-not_purchased { background: #fee2e2; color: #991b1b; }
.badge-waiting_manager, .badge-waiting_client { background: #fef3c7; color: #92400e; }
.badge-booking { background: #e0e7ff; color: #3730a3; }
.badge-service_done { background: #d1fae5; color: #065f46; }
.badge-review_requested { background: #fce7f3; color: #9d174d; }
.badge-telegram { background: #e0f2fe; color: #0369a1; }
.badge-whatsapp { background: #dcfce7; color: #166534; }
.badge-site { background: #f3e8ff; color: #7c3aed; }
.badge-email { background: #fef3c7; color: #92400e; }
.badge-excursions { background: #fff7ed; color: #c2410c; }
.badge-rental { background: #ecfdf5; color: #065f46; }
.badge-realestate { background: #fdf2f8; color: #9d174d; }
.badge-prava { background: #fef3c7; color: #78350f; }

/* Report buttons */
.btn-small { padding: 4px 12px; font-size: 12px; border-radius: 6px; }
.btn-green { background: #059669; color: #fff; border: none; cursor: pointer; }
.btn-green:hover { background: #047857; }
.btn-ghost { background: none; color: var(--gray-500); border: 1px solid var(--gray-300); cursor: pointer; }
.btn-ghost:hover { background: var(--gray-50); }
.badge-usage_check { background: #fef3c7; color: #92400e; }
.badge-service_not_used { background: #fee2e2; color: #991b1b; }
.badge-review_requested { background: #fce7f3; color: #9d174d; }
.badge-review_received { background: #d1fae5; color: #065f46; }

/* Buttons */
.btn { padding: 8px 16px; border-radius: var(--radius); border: none; font-size: 14px; font-weight: 500; cursor: pointer; transition: opacity 0.15s; }
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; border: 1px solid var(--gray-200); color: var(--gray-700); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: white; border-radius: 12px; padding: 24px; max-width: 700px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-wide { max-width: 960px; }
.modal h2 { margin-bottom: 16px; font-size: 18px; }
.modal .close { float: right; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray-500); }
.modal .close:hover { color: var(--gray-900); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 14px; }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.full-width { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 14px; }
select.full-width { background: white; }

/* Lead detail */
.lead-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.lead-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.lead-grid { display: grid; grid-template-columns: 320px 1fr; gap: 24px; }
.lead-info { min-width: 0; }
.lead-chat-col { min-width: 0; }

/* Contact card */
.contact-card { background: var(--gray-50); border-radius: var(--radius); padding: 12px 14px; }
.contact-name { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.contact-row { font-size: 13px; color: var(--gray-700); margin: 3px 0; }
.contact-row a { color: var(--primary); text-decoration: none; }
.contact-row a:hover { text-decoration: underline; }

/* Deal info */
.deal-info { background: #f0fdf4; border-radius: var(--radius); padding: 12px 14px; font-size: 13px; }
.deal-info div { margin: 3px 0; }

/* Lead card sections */
.lead-card-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--gray-100); }
.lead-card-section:last-child { border-bottom: none; }
.lead-card-section h3 { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

/* Chat messages */
.chat-messages { max-height: 350px; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { padding: 8px 12px; border-radius: 12px; max-width: 85%; font-size: 13px; line-height: 1.4; }
.msg-in { background: var(--gray-100); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-out { background: var(--primary-light); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-ai { background: #fef3c7; border: 1px solid #fde68a; }
.msg-supplier { background: #ecfdf5; border: 1px solid #a7f3d0; align-self: flex-start; }
.msg-supplier .msg-sender { color: #065f46; }
.msg-sender { font-size: 11px; font-weight: 600; color: var(--gray-500); margin-bottom: 2px; }
.msg-text { word-wrap: break-word; white-space: pre-wrap; }
.msg-time { font-size: 10px; color: var(--gray-500); margin-top: 4px; text-align: right; }

/* Timeline */
.timeline { list-style: none; }
.timeline li { padding: 6px 0 6px 18px; border-left: 2px solid var(--gray-200); position: relative; font-size: 12px; line-height: 1.4; }
.timeline li::before { content: ''; position: absolute; left: -4px; top: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.timeline .time { font-size: 10px; color: var(--gray-500); }
.timeline .event-desc { color: var(--gray-700); }

/* Empty state */
.empty-state { text-align: center; color: var(--gray-500); padding: 20px; font-size: 13px; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); }
.login-box { background: white; padding: 32px; border-radius: 12px; box-shadow: var(--shadow); width: 360px; }
.login-box h1 { font-size: 20px; margin-bottom: 20px; text-align: center; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { padding: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
    .lead-grid { grid-template-columns: 1fr; }
    .modal-wide { max-width: 100%; }
}
