:root {
    --primary: #1a56db;
    --primary-dark: #1e429f;
    --success: #057a55;
    --danger: #e02424;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
}

.light-nav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.logo { font-size: 1.5rem; font-weight: 800; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { text-decoration: none; color: var(--text-muted); font-weight: 500; }
.nav-links a.active, .nav-links a:hover { color: var(--primary); }
.btn-link { background: none; border: none; cursor: pointer; color: var(--text-muted); font-weight: 500; }
.btn-link.light { color: rgba(255,255,255,0.8); }

.hero {
    background: linear-gradient(135deg, #1a56db 0%, #6366f1 50%, #8b5cf6 100%);
    color: white;
    min-height: 70vh;
}

.hero .navbar { background: transparent; }
.hero .nav-links a { color: rgba(255,255,255,0.85); }
.hero .nav-links a:hover { color: white; }

.hero-content {
    max-width: min(1400px, calc(100vw - 4rem));
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
    text-align: center;
}

.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 1rem; }
.hero-subtitle { font-size: 1.125rem; opacity: 0.9; margin-bottom: 2.5rem; }

.search-form {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    color: var(--text);
    width: 100%;
}

.search-form.inline {
    margin-bottom: 2rem;
    align-items: center;
    box-shadow: none;
    border: 1px solid var(--border);
}

.search-field { flex: 1; text-align: left; min-width: 0; }
.search-field.city-autocomplete { flex: 3 1 12rem; }
.search-field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--text-muted); }
.search-field select, .search-form select, .search-form input[type=date], .search-form input[type=text],
.booking-panel select, .booking-panel input[type=text], .auth-card select, .auth-card textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.city-autocomplete { position: relative; }
.city-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 10;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    max-height: 220px;
    overflow-y: auto;
}
.city-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 0.95rem;
}
.city-dropdown-item:hover { background: #eff6ff; }
.city-dropdown-note {
    padding: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.city-dropdown-hint {
    padding: 0 0.75rem 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.city-dropdown-request {
    display: block;
    width: calc(100% - 1rem);
    margin: 0 0.5rem 0.5rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}
.city-dropdown-request:hover { background: #dbeafe; }
.city-dropdown-request:disabled { opacity: 0.6; cursor: wait; }
.search-field-date { flex: 0 0 11rem; min-width: 11rem; }
.search-form .btn { flex-shrink: 0; white-space: nowrap; }

.search-swap { font-size: 1.5rem; padding-bottom: 0.5rem; color: var(--text-muted); }

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-size: 0.95rem;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; }

.features { padding: 4rem 0; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 2rem; }
.features h2 { text-align: center; font-size: 1.75rem; margin-bottom: 2rem; }

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    background: var(--card);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border);
    text-align: center;
}

.feature-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.feature-card h3 { margin-bottom: 0.5rem; }

.trip-list { display: grid; gap: 1rem; margin-top: 1.5rem; }

.trip-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}

.trip-route { font-size: 1.25rem; font-weight: 700; }
.trip-route .arrow { margin: 0 0.5rem; color: var(--primary); }
.trip-meta { color: var(--text-muted); margin: 0.5rem 0; display: flex; gap: 1rem; }
.trip-driver { margin: 0.5rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.driver-profile-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }

.passenger-card-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.passenger-card-header .trip-route { margin-bottom: 0.25rem; }

.avatar-wrap { display: inline-flex; flex-shrink: 0; }
.avatar-clickable { cursor: zoom-in; }
.avatar-clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 50%; }

.avatar-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.avatar-lightbox[hidden] { display: none !important; }
.avatar-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
}
.avatar-lightbox-content {
    position: relative;
    z-index: 1;
}
.avatar-lightbox-preview {
    display: flex;
    align-items: center;
    justify-content: center;
}
.avatar-lightbox-img,
.avatar-lightbox-placeholder {
    width: min(320px, 80vw);
    height: min(320px, 80vw);
    border-radius: 50%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.avatar-lightbox-img { object-fit: cover; display: block; }
.avatar-lightbox-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    font-size: clamp(3rem, 12vw, 5rem);
    font-weight: 700;
    text-transform: uppercase;
}
.avatar-lightbox-close {
    position: absolute;
    top: -0.75rem;
    right: -0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #0f172a;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
body.avatar-lightbox-open { overflow: hidden; }

.avatar-wrap.avatar-sm .avatar-img { width: 32px; height: 32px; font-size: 0.85rem; line-height: 32px; }
.avatar-wrap.avatar-md .avatar-img { width: 64px; height: 64px; font-size: 1.5rem; line-height: 64px; }
.avatar-img {
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
}
.avatar-wrap .avatar-placeholder {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
}

.trip-pickup { font-size: 0.9rem; color: var(--text-muted); }
.pickup-badge { background: #eff6ff; color: var(--primary); padding: 0.15rem 0.5rem; border-radius: 6px; font-size: 0.8rem; margin-left: 0.5rem; }
.trip-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.trip-price .price { font-size: 1.5rem; font-weight: 800; color: var(--primary); }

.trip-detail { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; margin-top: 1rem; }
.trip-detail-main { background: var(--card); border-radius: 16px; padding: 2rem; border: 1px solid var(--border); }
.trip-detail h1 { font-size: 1.75rem; }
.departure { color: var(--text-muted); margin-bottom: 1.5rem; }
.detail-section { margin: 1.5rem 0; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.detail-section h3 { margin-bottom: 0.5rem; font-size: 1rem; color: var(--text-muted); }

.booking-panel {
    background: var(--card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.price-big { font-size: 2rem; font-weight: 800; color: var(--primary); }
.radio-group { display: grid; gap: 0.5rem; margin: 0.5rem 0; }
.radio-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: #def7ec; color: var(--success); }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-error { background: #fde8e8; color: var(--danger); }
.alert-success { background: #def7ec; color: var(--success); }

.text-muted { color: var(--text-muted); }
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a56db, #8b5cf6);
}

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

.auth-card h1 { font-size: 1.25rem; margin-bottom: 1.5rem; text-align: center; }
.auth-card .logo { text-align: center; font-size: 2rem; margin-bottom: 0.5rem; }
.auth-card label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }
.auth-card input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1rem; font-size: 1rem; }
.auth-card .btn { width: 100%; }

.auth-card-wide { max-width: 520px; }
.auth-divider { margin: 1rem 0; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.role-switch { text-align: center; margin-top: 0.75rem; font-size: 0.9rem; }
.role-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }
.role-switch a:hover { text-decoration: underline; }

.profile-page { padding: 2rem 2rem 4rem; }
.profile-page h1 { margin-bottom: 1.5rem; }
.profile-grid { display: grid; grid-template-columns: 220px 1fr 1.4fr; gap: 1.5rem; align-items: start; }
.profile-avatar-card { text-align: center; }
.avatar-block { margin-bottom: 1rem; }
.avatar-preview-wrap {
    position: relative;
    width: 126px;
    height: 126px;
    margin: 0 auto;
    border-radius: 50%;
    padding: 3px;
    transition: box-shadow 0.2s, background 0.2s;
    overflow: hidden;
}
.avatar-preview-wrap.avatar-clickable { cursor: zoom-in; }
.avatar-preview-wrap.avatar-clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }
.avatar-preview-wrap .avatar-preview,
.avatar-preview-wrap .avatar-placeholder {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0;
}
.avatar-preview-wrap .avatar-placeholder {
    line-height: 120px;
    text-align: center;
}
.avatar-preview-wrap--selected {
    background: linear-gradient(135deg, #3b82f6, #22c55e);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}
.avatar-selected-hint {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #16a34a;
    font-weight: 500;
}
.avatar-file-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}
.avatar-upload-form .btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.avatar-file-label .btn-selected {
    border-color: #16a34a;
    color: #16a34a;
    background: #f0fdf4;
}
.avatar-preview, .avatar-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
}
.profile-avatar-card .avatar-placeholder {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
}
.avatar-upload-form { display: flex; flex-direction: column; gap: 0.75rem; align-items: center; }
.avatar-file-label input[type="file"] { display: none; }
.avatar-hint { font-size: 0.8rem; margin-top: 0.75rem; }
.avatar-delete-form { margin-top: 0.5rem; }
.text-danger { color: #dc2626; }
.profile-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem 2rem;
}
.profile-card h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.profile-hint { font-size: 0.9rem; margin-bottom: 1rem; }
.profile-info { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1.5rem; }
.profile-info dt { color: var(--text-muted); font-size: 0.875rem; }
.profile-info dd { font-weight: 600; margin: 0; }

.role-switcher { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.role-option {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 1.25rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}
.role-option:hover:not(:disabled) { border-color: var(--primary); background: #eff6ff; }
.role-option.active {
    border-color: var(--primary);
    background: #eff6ff;
    cursor: default;
}
.role-option:disabled { opacity: 1; }
.role-icon { font-size: 1.5rem; }
.role-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.role-desc { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.profile-form label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }
.profile-form input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1rem; font-size: 1rem; }

.page-with-actions { padding: 2rem 2rem 4rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.trip-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.pickup-highlight { background: #eff6ff; padding: 0.5rem 0.75rem; border-radius: 8px; }

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2rem 0 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}
.pagination-info { color: var(--text-muted); font-size: 0.9rem; }
.pagination-links { display: flex; gap: 0.5rem; }

@media (max-width: 768px) {
    .profile-grid { grid-template-columns: 1fr; }
    .role-switcher { flex-direction: column; }
    .search-form { flex-direction: column; }
    .search-field.city-autocomplete,
    .search-field-date { flex: 1 1 auto; min-width: 0; }
    .trip-detail { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.75rem; }
    .hero-content { padding: 2rem 1rem 3rem; }
    .referral-grid { grid-template-columns: 1fr; }
}

.referral-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.referral-card { grid-column: 1 / -1; }
.referral-code-box {
    background: var(--bg);
    border: 2px dashed var(--primary);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    margin-bottom: 1rem;
}
.referral-code {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: var(--primary);
}
.referral-link-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.referral-link-input {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}
.referral-balance {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--success);
    margin: 0.5rem 0;
}
.referral-steps {
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.referral-stats-row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}
.stat-mini-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}
.stat-mini-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.table-simple {
    width: 100%;
    border-collapse: collapse;
}
.table-simple th, .table-simple td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}
