:root {
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: 0.2s ease;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
}

[data-theme="light"] {
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-hover: #f0f2f5;
    --bg-glass: rgba(0,0,0,0.03);
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-bg: rgba(79,70,229,0.08);
    --success: #059669;
    --success-bg: rgba(5,150,105,0.08);
    --warning: #d97706;
    --warning-bg: rgba(217,119,6,0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220,38,38,0.08);
    --info: #0284c7;
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --sidebar-hover: rgba(255,255,255,0.08);
    --gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
    --gradient-success: linear-gradient(135deg, #059669, #10b981);
    --gradient-warning: linear-gradient(135deg, #d97706, #f59e0b);
    --gradient-danger: linear-gradient(135deg, #dc2626, #ef4444);
    --gradient-info: linear-gradient(135deg, #0284c7, #38bdf8);
    --gradient-accent: linear-gradient(135deg, #db2777, #f472b6);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-table-bg: var(--bg-card);
    --bs-table-color: var(--text);
    --bs-table-striped-color: var(--text);
    --bs-table-striped-bg: var(--bg-glass);
    --bs-table-hover-color: var(--text);
    --bs-table-hover-bg: var(--bg-glass);
    --bs-border-color: var(--border);
    --bs-card-bg: var(--bg-card);
    --bs-card-color: var(--text);
    --bs-card-border-color: var(--border);
    --bs-list-group-bg: var(--bg-card);
    --bs-list-group-color: var(--text);
    --bs-list-group-border-color: var(--border);
    --bs-list-group-hover-bg: var(--bg-glass);
    --bs-modal-bg: var(--bg-card);
    --bs-modal-color: var(--text);
    --bs-form-control-bg: var(--bg-card);
    --bs-form-control-color: var(--text);
    --bs-form-control-border-color: var(--border);
    --bs-input-bg: var(--bg-card);
    --bs-input-color: var(--text);
    --bs-input-border-color: var(--border);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-hover: #334155;
    --bg-glass: rgba(255,255,255,0.04);
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border: #334155;
    --primary: #818cf8;
    --primary-light: #a5b4fc;
    --primary-bg: rgba(129,140,248,0.1);
    --success: #34d399;
    --success-bg: rgba(52,211,153,0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251,191,36,0.1);
    --danger: #f87171;
    --danger-bg: rgba(248,113,113,0.1);
    --info: #38bdf8;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-hover: rgba(255,255,255,0.06);
    --gradient: linear-gradient(135deg, #818cf8, #a78bfa);
    --gradient-success: linear-gradient(135deg, #34d399, #6ee7b7);
    --gradient-warning: linear-gradient(135deg, #fbbf24, #fcd34d);
    --gradient-danger: linear-gradient(135deg, #f87171, #fca5a5);
    --gradient-info: linear-gradient(135deg, #38bdf8, #7dd3fc);
    --gradient-accent: linear-gradient(135deg, #f472b6, #f9a8d4);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-table-bg: var(--bg-card);
    --bs-table-color: var(--text);
    --bs-table-striped-color: var(--text);
    --bs-table-striped-bg: var(--bg-glass);
    --bs-table-hover-color: var(--text);
    --bs-table-hover-bg: var(--bg-glass);
    --bs-border-color: var(--border);
    --bs-card-bg: var(--bg-card);
    --bs-card-color: var(--text);
    --bs-card-border-color: var(--border);
    --bs-list-group-bg: var(--bg-card);
    --bs-list-group-color: var(--text);
    --bs-list-group-border-color: var(--border);
    --bs-list-group-hover-bg: var(--bg-glass);
    --bs-modal-bg: var(--bg-card);
    --bs-modal-color: var(--text);
    --bs-form-control-bg: var(--bg-card);
    --bs-form-control-color: var(--text);
    --bs-form-control-border-color: var(--border);
    --bs-input-bg: var(--bg-card);
    --bs-input-color: var(--text);
    --bs-input-border-color: var(--border);
}

/* Bootstrap overrides - MUST come after Bootstrap */
body, .app-container, .main-content, .content-wrapper {
    color: var(--text) !important;
    background-color: var(--bg) !important;
}

.card, .modal-content, .stat-card, .top-navbar, .login-card {
    background-color: var(--bg-card) !important;
    color: var(--text) !important;
}

.text-muted, .text-secondary, small, .small, .form-text, .list-group-item .text-muted, .calendar-day-header, .stat-label, .timeline-date, .calendar-more, .legend-item, .form-label {
    color: var(--text-secondary) !important;
}

.text-body, .page-title, h1, h2, h3, h4, h5, h6, p, th, td, .nav-link, .btn-logout, .user-name, .sidebar-text, .brand-text, .card-header, .modal-header h3, .list-group-item {
    color: var(--text) !important;
}

.table th {
    color: var(--text-secondary) !important;
}

.border, .card, .modal-content, .top-navbar, .stat-card, .profile-header, .login-card, .sidebar, .list-group-item, .timeline-item, .calendar-day, .calendar-day-header, .toast, .autocomplete-list {
    border-color: var(--border) !important;
}

.bg-light, .bg-white {
    background-color: var(--bg) !important;
}

.alert, .btn-secondary, .autocomplete-item {
    background-color: var(--bg-glass) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

input, select, textarea, .form-control, .form-select {
    background-color: var(--bg-card) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

input::placeholder, .form-control::placeholder {
    color: var(--text-muted) !important;
}

body {
    font-family: var(--font-sans);
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::selection { background: var(--primary); color: #fff; }

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

.sidebar {
    width: 260px;
    background: var(--bg-sidebar) !important;
    display: flex;
    flex-direction: column;
    position: fixed; top: 0; left: 0;
    height: 100vh; z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 16px 12px;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    color: var(--sidebar-text-active); text-decoration: none;
    font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
}

.brand-icon {
    width: 34px; height: 34px;
    background: var(--gradient); border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; color: #fff;
}

.sidebar-nav { list-style: none; padding: 8px 8px; margin: 0; flex: 1; }
.nav-item { margin-bottom: 1px; }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; color: var(--sidebar-text) !important;
    text-decoration: none; border-radius: 8px;
    transition: all var(--transition); font-size: 14px; font-weight: 500;
    position: relative;
}

.nav-link:hover, .nav-link.active { background: var(--sidebar-hover); color: var(--sidebar-text-active) !important; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.notification-badge {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-size: 10px; padding: 1px 6px; min-width: 18px; text-align: center;
    border-radius: 10px; background: var(--danger); color: #fff;
}

.sidebar-footer {
    padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.06);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--gradient); display: flex; align-items: center;
    justify-content: center; font-size: 13px; font-weight: 600; color: #fff;
}

.btn-logout {
    width: 100%; padding: 8px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px; color: var(--sidebar-text) !important;
    font-size: 13px; cursor: pointer; transition: var(--transition);
    text-decoration: none; display: block; text-align: center;
}
.btn-logout:hover { background: rgba(248,113,113,0.15); color: var(--danger) !important; }

.main-content { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-height: 100vh; }

.top-navbar {
    display: flex; align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    gap: 14px; position: sticky; top: 0; z-index: 900;
}

.menu-toggle {
    font-size: 18px; padding: 6px; background: none; border: none;
    cursor: pointer; border-radius: 6px;
    display: none; transition: var(--transition);
    color: var(--text);
}
.menu-toggle:hover { background: var(--bg-glass); }

.page-title { font-size: 18px; font-weight: 600; margin: 0; flex: 1; }

.top-nav-actions { display: flex; align-items: center; gap: 6px; }

.theme-toggle, .settings-btn, .notification-bell {
    background: none; border: none; cursor: pointer; padding: 6px 8px; border-radius: 6px;
    font-size: 16px; transition: var(--transition);
    color: var(--text-secondary) !important;
    text-decoration: none;
}
.theme-toggle:hover, .settings-btn:hover, .notification-bell:hover { background: var(--bg-glass); color: var(--text) !important; }

.notification-bell { position: relative; }
.notif-count {
    position: absolute; top: 0; right: 2px;
    font-size: 9px; padding: 1px 5px; min-width: 15px; text-align: center;
    border-radius: 8px; background: var(--danger); color: #fff;
}

.content-wrapper { padding: 24px; flex: 1; }

.card {
    border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border);
    margin-bottom: 16px; transition: box-shadow var(--transition);
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 15px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

.stat-card {
    border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    transition: all var(--transition);
}

.stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff; flex-shrink: 0;
}
.stat-icon.g-primary { background: var(--gradient); }
.stat-icon.g-success { background: var(--gradient-success); }
.stat-icon.g-warning { background: var(--gradient-warning); }
.stat-icon.g-danger { background: var(--gradient-danger); }
.stat-icon.g-info { background: var(--gradient-info); }
.stat-icon.g-accent { background: var(--gradient-accent); }

.stat-info { flex: 1; min-width: 0; }
.stat-number { display: block; font-size: 20px; font-weight: 700; line-height: 1.2; color: var(--text); }
.stat-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; color: var(--text-secondary) !important; }

.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    padding: 12px 16px; text-align: left; font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr { transition: background var(--transition); }
.table tr:hover { background: var(--bg-glass); }

.badge {
    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500;
    display: inline-block;
}
.badge-pending { background: var(--warning-bg); color: var(--warning) !important; border: 1px solid rgba(217,119,6,0.2); }
.badge-completed { background: var(--success-bg); color: var(--success) !important; border: 1px solid rgba(5,150,105,0.2); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger) !important; border: 1px solid rgba(220,38,38,0.2); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
    border: none; cursor: pointer; transition: all var(--transition);
    text-decoration: none; line-height: 1.4;
}
.btn-primary { background: var(--gradient); color: #fff !important; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-success { background: var(--gradient-success); color: #fff !important; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--gradient-danger); color: #fff !important; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--gradient-warning); color: #fff !important; }
.btn-info { background: var(--gradient-info); color: #fff !important; }
.btn-secondary { background: var(--bg-glass); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover, .btn-outline.active { border-color: var(--primary); color: var(--primary) !important; background: var(--primary-bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }

.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn + .btn { border-left: 1px solid var(--border); }

.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.form-control, .form-select {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-size: 14px; transition: all var(--transition);
    font-family: var(--font-sans);
}
.form-control:focus, .form-select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg) !important;
}
textarea.form-control { resize: vertical; min-height: 80px; }

.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 2000;
    align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-content {
    border-radius: var(--radius-lg);
    width: 100%; max-width: 560px; max-height: 85vh;
    overflow-y: auto; box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 22px 14px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 20px; cursor: pointer;
    color: var(--text-muted); padding: 4px 8px; border-radius: 6px;
    transition: var(--transition);
}
.modal-close:hover { background: var(--bg-glass); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.toast-container { position: fixed; top: 16px; right: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    border-radius: 10px; padding: 12px 16px;
    box-shadow: var(--shadow-lg); display: flex; align-items: flex-start; gap: 10px;
    min-width: 280px; max-width: 400px;
    animation: slideIn 0.3s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast-message { flex: 1; font-size: 14px; }
.toast-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-muted); padding: 0 4px; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.search-box { position: relative; max-width: 300px; }
.search-box .form-control { padding-right: 36px; }
.search-box .search-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }

.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.pagination .page-link {
    padding: 7px 14px; border: 1px solid var(--border); border-radius: 6px;
    text-decoration: none; font-size: 13px;
    transition: var(--transition); background: transparent;
}
.pagination .page-link:hover { background: var(--bg-glass); }
.pagination .active .page-link { background: var(--primary); color: #fff !important; }

.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.row.g-3 { margin: 0 -6px; }
.row.g-3 > [class*="col-"] { padding: 0 6px; margin-bottom: 12px; }
.col-6 { width: 50%; }
.col-4 { width: 33.333%; }
.col-12 { width: 100%; }
[class*="col-"] { padding: 0 10px; margin-bottom: 16px; }

@media (min-width: 768px) { .col-md-6 { width: 50%; } .col-md-4 { width: 33.333%; } }
@media (min-width: 992px) { .col-lg-2 { width: 16.666%; } .col-lg-3 { width: 25%; } .col-lg-4 { width: 33.333%; } .col-lg-6 { width: 50%; } .col-lg-8 { width: 66.666%; } }

.list-group { list-style: none; padding: 0; margin: 0; }
.list-group-item { padding: 14px 18px; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.list-group-item:last-child { border-bottom: none; }
.list-group-item:hover { background: var(--bg-glass); }

.actions-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.avatar-lg { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary); box-shadow: 0 4px 15px rgba(79,70,229,0.2); }

.profile-header {
    display: flex; align-items: center; gap: 24px; padding: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border); margin-bottom: 20px;
    flex-wrap: wrap;
    background: var(--bg-card);
}

/* Modern Profile */
.profile-hero {
    display: flex; align-items: center; gap: 20px; padding: 24px;
    border-radius: var(--radius); margin-bottom: 20px;
    background: var(--bg-card); border: 1px solid var(--border);
    flex-wrap: wrap;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary); }
.profile-avatar-letter {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--gradient); display: flex; align-items: center;
    justify-content: center; font-size: 28px; font-weight: 700; color: #fff;
}
.profile-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--danger); color: #fff; font-size: 10px;
    padding: 2px 7px; border-radius: 10px; font-weight: 600;
    border: 2px solid var(--bg-card);
}
.profile-hero-info { flex: 1; min-width: 180px; }
.profile-hero-name { margin: 0 0 6px; font-size: 20px; font-weight: 700; color: var(--text); }
.profile-hero-contacts {
    display: flex; flex-wrap: wrap; gap: 4px 14px;
    font-size: 13px; color: var(--text-secondary);
}
.profile-hero-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
.profile-stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;
}
.profile-content-grid {
    display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start;
}
.profile-main { min-width: 0; }
.profile-side { min-width: 0; }
.profile-chart { max-height: 200px; max-width: 100%; }

.notes-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.notes-status { font-size: 12px; font-weight: 500; }
.notes-status.saved { color: var(--success); }
.notes-status.error { color: var(--danger); }

.history-list { }
.history-item {
    display: flex; gap: 12px; padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s; align-items: flex-start;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--bg-glass); }
.history-item-left { flex: 1; min-width: 0; }
.history-item-right { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.history-date { font-weight: 600; font-size: 13px; color: var(--text); }
.history-time { font-weight: 400; font-size: 12px; color: var(--text-muted); margin-left: 8px; }
.history-service { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.history-obs { font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.history-price { font-weight: 600; font-size: 14px; color: var(--text); }
.history-actions { display: flex; gap: 4px; margin-top: 4px; }
.history-more { padding: 12px 20px; border-top: 1px solid var(--border); text-align: center; }

.maps-wrap { position: relative; width: 100%; padding-bottom: 50%; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.maps-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

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

/* History Filters */
.history-filters { padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--bg-glass); }
.hf-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.hf-field label { display: block; font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }
.hf-field input, .hf-field select { width: 150px; }
.hf-svc select { width: 160px; }
.hf-actions { display: flex; gap: 6px; padding-bottom: 1px; }
.history-count { padding: 8px 20px; font-size: 12px; color: var(--text-secondary); background: var(--bg-glass); border-bottom: 1px solid var(--border); }

/* Notes Tab System */
.notes-tabs { display: flex; border-bottom: 1px solid var(--border); }
.ntab { flex: 1; padding: 10px 12px; border: none; background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s; position: relative; }
.ntab.active { color: var(--primary); background: var(--primary-bg); }
.ntab.active::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--primary); }
.ntab:hover { color: var(--text); background: var(--bg-glass); }
.notes-panel { padding: 16px; }
.notes-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notes-private-wrap { }
.note-card { border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; position: relative; }
.note-text { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.note-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 11px; opacity: 0.8; }
.note-date { }
.note-actions { display: flex; gap: 4px; }
.note-btn { background: none; border: none; cursor: pointer; opacity: 0.6; font-size: 13px; padding: 2px 4px; }
.note-btn:hover { opacity: 1; }
.note-color-row { display: flex; gap: 16px; margin: 12px 0; flex-wrap: wrap; }
.nc-group { flex: 1; min-width: 140px; }
.nc-group label { display: block; font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.nc-presets { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.nc-swatch { width: 24px; height: 24px; border-radius: 4px; border: 2px solid transparent; cursor: pointer; transition: all 0.15s; }
.nc-swatch.active { border-color: var(--primary); transform: scale(1.15); }
.nc-swatch:hover { transform: scale(1.1); }
.nc-picker { width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; cursor: pointer; background: var(--bg-card); }

@media (max-width: 767px) {
    .hf-field input, .hf-field select { width: 100%; }
    .hf-row { flex-direction: column; }
    .hf-actions { width: 100%; }
    .hf-actions button { flex: 1; }
    .note-color-row { flex-direction: column; }
    .nc-group { min-width: 100%; }
}

@media (max-width: 1100px) {
    .profile-content-grid { grid-template-columns: 1fr; }
    .profile-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
    .profile-hero { flex-direction: column; text-align: center; padding: 20px; }
    .profile-hero-actions { justify-content: center; }
    .profile-hero-contacts { justify-content: center; }
    .profile-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .profile-content-grid { grid-template-columns: 1fr; }
    .profile-avatar, .profile-avatar-letter { width: 60px; height: 60px; }
    .profile-avatar-letter { font-size: 22px; }
    .profile-chart { max-height: 160px; }
    .history-item { flex-direction: column; padding: 12px 16px; }
    .history-item-right { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
    .history-obs { max-width: 100%; }
}
@media (max-width: 575px) {
    .profile-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .profile-hero { padding: 14px; }
    .profile-hero-name { font-size: 17px; }
}
.profile-info { flex: 1; }
.profile-info h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.profile-info p { margin: 2px 0; font-size: 14px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-whatsapp { background: #25d366; color: #fff !important; }
.btn-whatsapp:hover { opacity: 0.9; }

.timeline { position: relative; padding-left: 24px; max-height: 500px; overflow-y: auto; }
.timeline::before {
    content: ''; position: absolute; left: 8px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 12px; padding: 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-glass); }
.timeline-item::before {
    content: ''; position: absolute; left: -20px; top: 18px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--bg-card);
}
.timeline-date { font-size: 12px; }
.timeline-content { margin-top: 4px; }
.timeline-content strong { font-size: 14px; }

.autocomplete-wrapper { position: relative; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px; box-shadow: var(--shadow-lg);
    max-height: 200px; overflow-y: auto;
    background: var(--bg-card);
}
.autocomplete-item { padding: 10px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg-glass); }

.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
}
.login-container { width: 100%; max-width: 400px; }
.login-card {
    border-radius: var(--radius-lg);
    padding: 40px 32px; box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-icon {
    width: 56px; height: 56px; margin: 0 auto 14px;
    background: var(--gradient); border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: #fff;
}
.login-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.login-header p { margin: 4px 0 0; font-size: 14px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form .form-control { padding: 12px 16px; font-size: 15px; }
.btn-block { width: 100%; padding: 12px; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }.gap-3 { gap: 16px; }
.mb-4 { margin-bottom: 24px; }.mb-3 { margin-bottom: 16px; }.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 8px; }.mt-3 { margin-top: 16px; }
.p-0 { padding: 0; }
.text-center { text-align: center; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }
.d-none { display: none; }
.hidden { display: none; }

.fab-quick {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1500;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    border: none;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(79,70,229,0.4);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.fab-quick:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(79,70,229,0.5); }
.fab-quick:active { transform: scale(0.95); }

@media (max-width: 767px) {
    .fab-quick {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
}

/* Touch optimizations */
html {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button, .btn, a, .calendar-day, .calendar-event, .list-group-item, .nav-link, .timeline-item, .autocomplete-item {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.table { background: var(--bg-card) !important; color: var(--text) !important; }
.table td, .table th { color: inherit !important; }
.list-group-item { background: var(--bg-card) !important; color: var(--text) !important; }
.list-group-item:hover { background: var(--bg-glass) !important; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .top-navbar { padding: 10px 14px; }
    .content-wrapper { padding: 16px; }
}

@media (max-width: 767px) {
    .page-title { font-size: 15px; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 38px; height: 38px; font-size: 16px; }
    .stat-number { font-size: 17px; }
    .profile-header { flex-direction: column; text-align: center; padding: 20px; }
    .profile-actions { justify-content: center; }
    .table { font-size: 13px; }
    .table th, .table td { padding: 8px 10px; }
    .actions-bar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: 100%; }
    .col-md-6 { width: 100%; }
}

@media (max-width: 575px) {
    .content-wrapper { padding: 8px; }
    .col-6 { width: 50%; }
    .card-body { padding: 14px; }
}

/* Mobile table helpers */
.client-cell-main { display: flex; align-items: center; gap: 10px; }
.client-avatar-sm {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--gradient); display: flex; align-items: center;
    justify-content: center; font-size: 13px; font-weight: 600;
    color: #fff; flex-shrink: 0;
}
.client-name { color: var(--text) !important; font-size: 14px; }
.show-mobile { display: none; }

@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block; }
    .table { font-size: 13px; }
    .table td { padding: 10px 12px; white-space: normal; }
    .table th { padding: 10px 12px; font-size: 11px; }
    .btn-sm { padding: 5px 10px; font-size: 11px; }
    .stat-card { padding: 12px; }
    .stat-icon { width: 34px; height: 34px; font-size: 14px; }
    .stat-number { font-size: 16px; }
    .stat-label { font-size: 10px; }
}