/* ================================================================
   Medburg CRM — Design System
   Colors · Layout · Components
   ================================================================ */

/* ── CSS Variables ─────────────────────────────── */
:root {
    --brand-primary:  #efa743;
    --brand-gold:     #efa743;
    --brand-success:  #22c55e;
    --brand-danger:   #ef4444;
    --brand-info:     #3b82f6;
    --brand-warning:  #f59e0b;

    --primary:        var(--brand-primary);
    --primary-dark:   #d9922e;
    --secondary:      #9bc3ba;
    --secondary-dark: #7aada2;
    --sidebar-bg:     #1e293b;
    --sidebar-hover:  #283548;
    --sidebar-active: rgba(239, 167, 67, .15);
    --topbar-bg:      #ffffff;
    --body-bg:        #f8fafb;
    --card-bg:        #ffffff;
    --text-primary:   #1e293b;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;
    --border-color:   #e2e8f0;
    --success:        var(--brand-success);
    --danger:         var(--brand-danger);
    --info:           var(--brand-info);
    --warning:        var(--brand-warning);
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.06);
    --shadow-md:      0 4px 16px rgba(0,0,0,.06);
    --shadow-lg:      0 8px 30px rgba(0,0,0,.08);
    --sidebar-width:  250px;
    --topbar-height:  64px;
    --transition:     all .2s ease;

    /* Typography Hierarchy */
    --font-size-page-title: 1.5rem;
    --font-size-section-title: 1.15rem;
    --font-size-card-title: 1rem;
    --font-size-body: 0.95rem;
    --font-size-meta: 0.85rem;
}


/* ── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}


/* ── App Layout ────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-content {
    flex: 1;
    padding: 28px 32px;
}


/* ── Sidebar ───────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 24px 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand .brand-logo-icon {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: contain;
}

.sidebar-brand .brand-text {
    font-size: .78rem;
    font-weight: 600;
    color: rgba(255,255,255,.7);
    letter-spacing: .8px;
    text-transform: uppercase;
}


.sidebar-label {
    padding: 10px 24px 4px;
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--brand-primary);
    display: flex;
    align-items: center;
}

.sidebar-label::after {
    content: '';
    flex: 1;
    margin-left: 8px;
    height: 1px;
    background: linear-gradient(90deg, rgba(239, 167, 67, 0.25), transparent);
}

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

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 24px;
    color: #94a3b8;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .25s cubic-bezier(.4,0,.2,1);
    position: relative;
}

.sidebar-nav li a i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    transition: transform .25s ease;
}

.sidebar-nav li a:hover {
    color: #f1f5f9;
    background: var(--sidebar-hover);
    padding-left: 28px;
}

.sidebar-nav li a:hover i {
    transform: scale(1.12);
}

.sidebar-nav li a.active {
    color: var(--primary);
    background: var(--sidebar-active);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-nav li a.active i {
    filter: drop-shadow(0 0 4px rgba(239,167,67,.4));
}

.sidebar-nav li a .nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-footer .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .user-name {
    font-size: .82rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-role {
    font-size: .72rem;
    color: #64748b;
}

.sidebar-footer .btn-logout {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.sidebar-footer .btn-logout:hover {
    color: var(--danger);
}


/* ── Topbar ────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: .3px;
    white-space: nowrap;
}

.topbar-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    margin: 0 16px;
}

.topbar-left {
    display: flex;
    flex-direction: column;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.topbar-subtitle {
    font-size: .78rem;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-search {
    position: relative;
}

.topbar-search input {
    width: 240px;
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px 8px 36px;
    font-size: .82rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(239,167,67,.1);
}

.topbar-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .85rem;
}

.btn-topbar-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.btn-topbar-icon:hover {
    background: var(--body-bg);
    color: var(--text-primary);
}

.btn-topbar-icon .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}


/* ── Sidebar Toggle (Mobile) ───────────────────── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    margin-right: 12px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1035;
}


/* ── KPI / Summary Cards ──────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: all .3s cubic-bezier(.4,0,.2,1);
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity .3s ease;
}

.kpi-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,.08);
    transform: translateY(-3px);
    border-color: transparent;
}

.kpi-card:hover::after {
    opacity: 1;
}

.kpi-card .kpi-info {
    flex: 1;
    min-width: 0;
}

.kpi-card .kpi-label {
    font-size: .76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-card .kpi-sub {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.kpi-card .kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.kpi-icon.investment {
    background: rgba(239,167,67,.12);
    color: var(--primary);
}

.kpi-icon.achieved {
    background: rgba(34,197,94,.1);
    color: var(--success);
}

.kpi-icon.balance {
    background: rgba(239,68,68,.08);
    color: var(--danger);
}

.kpi-icon.target {
    background: rgba(59,130,246,.1);
    color: var(--info);
}

.kpi-icon.doctors {
    background: rgba(155,195,186,.2);
    color: var(--secondary-dark);
}

.kpi-icon.entries {
    background: rgba(245,158,11,.1);
    color: var(--warning);
}

.kpi-icon.quantity {
    background: rgba(34,197,94,.1);
    color: var(--success);
}


/* ── Data Cards / Panels ──────────────────────── */
.data-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.data-card-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.data-card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.data-card-title .count-badge {
    background: var(--primary);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
}

.data-card-body {
    padding: 0;
}

.data-card-body.padded {
    padding: 24px;
}


/* ── Tables ────────────────────────────────────── */
.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.crm-table thead th {
    background: var(--body-bg);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 12px 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.crm-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    color: var(--text-primary);
    border-bottom: 1px solid #f1f5f9;
    transition: all .2s ease;
}

.crm-table tbody tr:last-child td {
    border-bottom: none;
}

.crm-table tbody tr:hover td {
    background: rgba(239,167,67,.03);
}

.crm-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--primary);
}

.crm-table .text-right { text-align: right; }
.crm-table .text-center { text-align: center; }

.crm-table .value-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}


/* ── Badges ────────────────────────────────────── */
.crm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .2px;
    white-space: nowrap;
}

.crm-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.crm-badge.completed {
    background: rgba(34,197,94,.1);
    color: #16a34a;
}
.crm-badge.completed::before { background: #22c55e; }

.crm-badge.in-progress {
    background: rgba(59,130,246,.1);
    color: #2563eb;
}
.crm-badge.in-progress::before { background: #3b82f6; }

.crm-badge.pending {
    background: rgba(239,167,67,.1);
    color: #b45309;
}
.crm-badge.pending::before { background: #efa743; }

.crm-badge.no-investment {
    background: rgba(148,163,184,.1);
    color: #64748b;
}
.crm-badge.no-investment::before { background: #94a3b8; }

.crm-badge.postpaid {
    background: rgba(107,114,128,.1);
    color: #4b5563;
}
.crm-badge.postpaid::before { background: #6b7280; }

.crm-badge.prepaid {
    background: rgba(239,167,67,.1);
    color: var(--primary-dark);
}
.crm-badge.prepaid::before { background: var(--primary); }


/* ── Buttons ───────────────────────────────────── */
.btn-crm-primary {
    background: linear-gradient(135deg, var(--primary), #f5c066);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 20px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .25s cubic-bezier(.4,0,.2,1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.btn-crm-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239,167,67,.35);
}

.btn-crm-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(239,167,67,.2);
}

.btn-crm-secondary {
    background: var(--secondary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 20px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.btn-crm-secondary:hover {
    background: var(--secondary-dark);
    color: #fff;
}

.btn-crm-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.btn-crm-outline:hover {
    background: var(--body-bg);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-crm-mark-paid {
    background: rgba(34,197,94,.1);
    color: #16a34a;
    border: 1px solid rgba(34,197,94,.25);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .25s cubic-bezier(.4,0,.2,1);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.btn-crm-mark-paid:hover {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34,197,94,.3);
}

.btn-crm-mark-paid:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(34,197,94,.2);
}

.btn-crm-partial {
    background: rgba(59,130,246,.1);
    color: #2563eb;
    border-color: rgba(59,130,246,.25);
}

.btn-crm-partial:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59,130,246,.3);
}

/* ── Filter Bar ────────────────────────────────── */
.filter-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.filter-card .form-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.filter-card .form-control,
.filter-card .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: .85rem;
    padding: 9px 14px;
    color: var(--text-primary);
    transition: var(--transition);
    background: #fff;
}

.filter-card .form-control:focus,
.filter-card .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(239,167,67,.1);
}


/* ── Forms ─────────────────────────────────────── */
.crm-form .form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.crm-form .form-control,
.crm-form .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    font-size: .88rem;
    color: var(--text-primary);
    transition: all .25s ease;
    background: #fff;
}

.crm-form .form-control:hover,
.crm-form .form-select:hover {
    border-color: #cbd5e1;
}

.crm-form .form-control:focus,
.crm-form .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(239,167,67,.1), 0 1px 3px rgba(0,0,0,.06);
    outline: none;
}

.crm-form .btn-submit {
    background: linear-gradient(135deg, var(--primary), #f5c066);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-size: .9rem;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: all .25s cubic-bezier(.4,0,.2,1);
    letter-spacing: .3px;
}

.crm-form .btn-submit:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    box-shadow: 0 6px 20px rgba(239,167,67,.35);
    transform: translateY(-1px);
}

.crm-form .btn-submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(239,167,67,.2);
}


/* ── Progress Bars ─────────────────────────────── */
.crm-progress {
    height: 6px;
    background: #e8ecf1;
    border-radius: 6px;
    overflow: hidden;
}

.crm-progress .crm-progress-bar {
    height: 100%;
    border-radius: 6px;
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

.crm-progress-bar.bg-crm-primary { background: linear-gradient(90deg, #efa743, #f5c066); }
.crm-progress-bar.bg-crm-success { background: linear-gradient(90deg, #22c55e, #4ade80); }
.crm-progress-bar.bg-crm-info { background: var(--info); }
.crm-progress-bar.bg-crm-danger { background: var(--danger); }


/* ── Text helpers ──────────────────────────────── */
.text-positive { color: var(--success) !important; font-weight: 600; }
.text-negative { color: var(--danger) !important; font-weight: 600; }
.text-crm-primary { color: var(--primary) !important; }
.text-crm-muted { color: var(--text-muted) !important; }


/* ── Empty State ───────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    opacity: .4;
}

.empty-state p {
    font-size: .95rem;
    margin: 0;
}


/* ── Alerts ────────────────────────────────────── */
.crm-alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    margin-bottom: 16px;
}

.crm-alert.success {
    background: rgba(34,197,94,.08);
    color: #16a34a;
    border: 1px solid rgba(34,197,94,.15);
}

.crm-alert.error {
    background: rgba(239,68,68,.08);
    color: #dc2626;
    border: 1px solid rgba(239,68,68,.15);
}


/* ── Login page (no sidebar) ───────────────────── */
.login-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card .login-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 14px;
    margin: 0 auto 16px;
    display: block;
}

.login-card h4 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-card .subtitle {
    font-size: .88rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}


/* ── Responsive ────────────────────────────────── */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .sidebar-toggle {
        display: block;
    }
    .app-main {
        margin-left: 0;
    }
    .topbar-search input { width: 180px; }
}

@media (max-width: 768px) {
    .app-content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .topbar-search { display: none; }
    .filter-card .row > div { margin-bottom: 8px; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Typography Hierarchy ─────────────────────── */
.topbar-title { font-size: var(--font-size-page-title); }
.sidebar-label { font-size: 0.74rem; margin-top: 0.75rem; margin-bottom: 0.25rem; }
.kpi-label { font-size: var(--font-size-meta); }
.data-card-title { font-size: var(--font-size-card-title); }
.crm-form .form-label { font-size: var(--font-size-body); }
.kpi-value { font-size: var(--font-size-page-title); }

/* ── Spacing System ───────────────────────────── */
.data-card { margin-bottom: 24px; }
.data-card-header { padding: 16px 24px; }
.data-card-body { padding: 24px; }
.filter-card { padding: 16px 24px; margin-bottom: 24px; }
.crm-table tbody td, .crm-table thead th { padding: 14px 16px; }

/* ── Responsive Tables ────────────────────────── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.table-responsive .crm-table {
    min-width: 800px; /* Force scroll on small screens */
}

/* ── Touch Targets & Forms ────────────────────── */
.crm-form .form-control,
.crm-form .form-select,
.filter-card .form-control,
.filter-card .form-select,
.btn-crm-primary,
.btn-crm-secondary,
.btn-crm-outline,
.btn-submit {
    min-height: 44px;
}

/* ── Tablet Optimization (768px to 1194px) ────── */
@media (max-width: 1194px) {
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .app-main { margin-left: 220px; }
    .app-content { padding: 24px; }
}

@media (max-width: 834px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .sidebar-toggle { display: block; }
    .app-main { margin-left: 0; }
}

@media (max-width: 768px) {
    .app-content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
    .topbar-search { display: none; }
    .filter-card .row > div { margin-bottom: 12px; }
}

/* ── CRM Switcher ──────────────────────────────── */
.crm-switcher {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    display: inline-flex;
    box-shadow: var(--shadow-sm);
}

.switcher-btn {
    padding: 10px 24px;
    font-weight: 600;
    font-size: .9rem;
    transition: all .2s ease;
    border-radius: 8px;
    border: none;
    outline: none;
    cursor: pointer;
    background: transparent;
    color: var(--brand-primary);
}

.switcher-btn:hover {
    background: rgba(212, 163, 57, .12);
}

.switcher-btn.active {
    background: var(--brand-gold);
    color: var(--text-primary);
}

.switcher-btn.active:hover {
    background: var(--brand-gold);
    color: var(--text-primary);
}

/* ── Bootstrap Primary overrides for consistency ─ */
.text-primary {
    color: var(--brand-primary) !important;
}

.btn-primary {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: var(--text-primary) !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    color: var(--text-primary) !important;
}

.btn-outline-primary {
    color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
}

.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
    background-color: var(--brand-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--brand-primary) !important;
}

.alert-info {
    background-color: rgba(239, 167, 67, 0.08) !important;
    color: var(--primary-dark) !important;
    border: 1px solid rgba(239, 167, 67, 0.15) !important;
}
