/* DK Dynamic Ventures — Client Dashboard
   Mobile-first, dark theme, Orbitron + Exo 2 */

/* --- Custom Properties --- */
:root {
    --black: #0A0A0A;
    --dark-grey: #1C1C1C;
    --medium-grey: #2E2E2E;
    --light-grey: #6B6B6B;
    --off-white: #F5F5F5;
    --blue: #5BB8FF;
    --blue-glow: #A8D8FF;
    --blue-dim: rgba(91, 184, 255, 0.15);
    --green: #4ADE80;
    --yellow: #FACC15;
    --red: #F87171;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Exo 2', sans-serif;
    --sidebar-width: 240px;
    --header-height: 56px;
    --radius: 12px;
    --radius-sm: 8px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    background: var(--black);
    color: var(--off-white);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-glow); }

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--dark-grey);
    border-right: 1px solid var(--medium-grey);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--medium-grey);
}
.brand-mark {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--blue), var(--blue-glow));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--black);
    flex-shrink: 0;
}
.brand-mark.large {
    width: 56px; height: 56px;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}
.brand-name {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--off-white);
}

.nav-links {
    list-style: none;
    padding: 0.75rem 0;
    flex: 1;
}
.nav-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--light-grey);
    font-size: 0.9rem;
    font-weight: 400;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.nav-links a:hover { color: var(--off-white); background: rgba(255,255,255,0.04); }
.nav-links a.active {
    color: var(--blue);
    border-left-color: var(--blue);
    background: var(--blue-dim);
}
.nav-links svg { opacity: 0.6; flex-shrink: 0; }
.nav-links a.active svg { opacity: 1; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--medium-grey);
}
.logout-btn {
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius-sm);
    color: var(--light-grey);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* --- Mobile Header --- */
.mobile-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--header-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background: var(--dark-grey);
    border-bottom: 1px solid var(--medium-grey);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    z-index: 90;
}
.mobile-header .brand-mark { width: 30px; height: 30px; font-size: 0.7rem; }
.mobile-header .client-name {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--off-white);
    margin-left: auto;
}

.menu-toggle {
    width: 32px; height: 32px;
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
    padding: 4px;
}
.menu-toggle span {
    display: block;
    width: 100%; height: 2px;
    background: var(--off-white);
    border-radius: 1px;
    transition: all 0.3s;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 95;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

/* --- Main Content --- */
.main-content {
    padding: calc(var(--header-height) + env(safe-area-inset-top) + 1rem) 1rem calc(2rem + env(safe-area-inset-bottom));
    max-width: 1200px;
    margin: 0 auto;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
}
.client-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: var(--blue-dim);
    color: var(--blue);
    border-radius: 20px;
    font-weight: 500;
    display: none;
}

/* --- Cards --- */
.card {
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.card h3 {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--light-grey);
    text-transform: none;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.kpi-card.wide { grid-column: 1 / -1; }
.kpi-label {
    font-size: 0.7rem;
    text-transform: none;
    letter-spacing: 0.08em;
    color: var(--light-grey);
    margin-bottom: 0.25rem;
}
.kpi-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--off-white);
    line-height: 1.2;
}
.kpi-trend {
    font-size: 0.7rem;
    margin-top: 0.25rem;
}
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }
.kpi-trend.neutral { color: var(--light-grey); }

/* --- Charts --- */
.chart-card { min-height: 250px; }
.chart-container { position: relative; height: 200px; }

/* --- Activity Feed --- */
.activity-feed { list-style: none; }
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--blue);
    margin-top: 6px;
    flex-shrink: 0;
}
.activity-dot.lead-new { background: var(--green); }
.activity-dot.appointment-booked { background: var(--blue); }
.activity-dot.email-sent { background: var(--yellow); }
.activity-text { flex: 1; min-width: 0; }
.activity-desc { font-size: 0.85rem; color: var(--off-white); display: block; }
.activity-time { font-size: 0.7rem; color: var(--light-grey); }

/* --- Health Indicators --- */
.health-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.health-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
}
.health-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.health-dot.healthy { background: var(--green); box-shadow: 0 0 6px rgba(74,222,128,0.4); }
.health-dot.degraded { background: var(--yellow); box-shadow: 0 0 6px rgba(250,204,21,0.4); }
.health-dot.down { background: var(--red); box-shadow: 0 0 6px rgba(248,113,113,0.4); }
.health-name { flex: 1; font-size: 0.85rem; }
.health-uptime { font-size: 0.8rem; color: var(--light-grey); font-weight: 500; }

/* --- Health Cards (full page) --- */
.health-overview { margin-bottom: 1.5rem; }
.health-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.health-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.health-card-header h3 { margin-bottom: 0; flex: 1; }
.health-status-text { font-size: 0.75rem; font-weight: 500; text-transform: none; }
.health-status-text.healthy { color: var(--green); }
.health-status-text.degraded { color: var(--yellow); }
.health-status-text.down { color: var(--red); }

.health-stat { text-align: center; }
.health-stat-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
}
.health-stat-label {
    font-size: 0.7rem;
    color: var(--light-grey);
    text-transform: none;
}
.health-stat.small .health-stat-value { font-size: 1.1rem; }
.health-stats-row {
    display: flex;
    justify-content: space-around;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--medium-grey);
}
.uptime-bar {
    height: 4px;
    background: var(--medium-grey);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}
.uptime-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}
.uptime-fill.green { background: var(--green); }
.uptime-fill.yellow { background: var(--yellow); }
.uptime-fill.red { background: var(--red); }

/* --- Pipeline Funnel --- */
.pipeline-funnel { display: flex; flex-direction: column; gap: 0.5rem; }
.funnel-stage { padding: 0.5rem 0; }
.funnel-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.35rem;
}
.stage-name { font-size: 0.85rem; color: var(--off-white); }
.stage-count {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--blue);
}
.funnel-bar-track {
    height: 32px;
    background: var(--medium-grey);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.funnel-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--blue-glow));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    min-width: 2rem;
    transition: width 0.6s ease;
}
.stage-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--black);
    white-space: nowrap;
}
.conversion-arrow {
    text-align: center;
    font-size: 0.7rem;
    color: var(--light-grey);
    padding: 0.15rem 0;
}

/* --- Stats Row --- */
.stats-row {
    display: flex;
    justify-content: space-around;
    text-align: center;
}
.stat-value {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    display: block;
}
.stat-label {
    font-size: 0.7rem;
    color: var(--light-grey);
    text-transform: none;
}

/* --- Tables --- */
.table-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.search-input, .filter-select {
    padding: 0.5rem 0.75rem;
    background: var(--black);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius-sm);
    color: var(--off-white);
    font-family: var(--font-body);
    font-size: 0.85rem;
}
.search-input { flex: 1; min-width: 150px; }
.search-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--blue);
}
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: var(--light-grey);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--medium-grey);
}
.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.data-table tr:hover { background: rgba(255,255,255,0.02); }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: none;
}
.badge-new { background: rgba(74,222,128,0.15); color: var(--green); }
.badge-qualified { background: rgba(91,184,255,0.15); color: var(--blue); }
.badge-contacted { background: rgba(250,204,21,0.15); color: var(--yellow); }
.badge-converted { background: rgba(168,216,255,0.15); color: var(--blue-glow); }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--light-grey);
}
.empty-state h3 {
    color: var(--off-white);
    margin-bottom: 0.5rem;
    text-align: center;
}
.empty-state p { font-size: 0.9rem; }

/* --- Login --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: radial-gradient(ellipse at top, rgba(91,184,255,0.05), transparent 60%),
                var(--black);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
}
.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}
.login-brand h1 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.login-brand p {
    font-size: 0.8rem;
    color: var(--light-grey);
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--light-grey);
    margin-bottom: 0.35rem;
}
.form-group input {
    width: 100%;
    padding: 0.7rem 0.75rem;
    background: var(--black);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius-sm);
    color: var(--off-white);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.2s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(91,184,255,0.15);
}
.form-group input::placeholder { color: var(--light-grey); opacity: 0.5; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--blue-glow));
    color: var(--black);
}
.btn-primary:hover {
    box-shadow: 0 0 20px rgba(91,184,255,0.3);
    transform: translateY(-1px);
}
.btn-full { width: 100%; }

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--light-grey);
}

/* --- Alerts --- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.alert-error {
    background: rgba(248,113,113,0.1);
    border: 1px solid rgba(248,113,113,0.3);
    color: var(--red);
}

/* --- Services Grid (active + locked feature cards) --- */
.services-section { margin-top: 0.5rem; }
.services-section > h3 {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--light-grey);
    text-transform: none;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}
.services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}
.service-card {
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius);
    padding: 1rem;
    position: relative;
    transition: all 0.3s ease;
}
.service-card.active {
    border-color: rgba(91, 184, 255, 0.3);
}
.service-card.active:hover {
    border-color: var(--blue);
    box-shadow: var(--glow-sm, 0 0 10px rgba(91, 184, 255, 0.15));
}
.service-card.locked {
    opacity: 0.5;
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.08);
}
.service-card.locked:hover {
    opacity: 0.75;
    border-color: rgba(91, 184, 255, 0.2);
}
.service-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.service-card-link:hover .service-badge {
    color: var(--blue);
}

.service-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 0.6rem;
    font-size: 1rem;
}
.service-card.active .service-icon {
    background: var(--blue-dim);
    color: var(--blue);
}
.service-card.locked .service-icon {
    background: rgba(255, 255, 255, 0.04);
    color: var(--light-grey);
}

.service-name {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}
.service-card.active .service-name { color: var(--off-white); }
.service-card.locked .service-name { color: var(--light-grey); }

.service-desc {
    font-size: 0.75rem;
    color: var(--light-grey);
    line-height: 1.4;
}

.service-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.04em;
}
.service-card.active .service-badge {
    background: rgba(74, 222, 128, 0.12);
    color: var(--green);
}
.service-card.locked .service-badge {
    background: rgba(91, 184, 255, 0.08);
    color: var(--blue);
}
.service-badge.requested {
    background: rgba(250, 204, 21, 0.12);
    color: var(--yellow);
}

.upgrade-btn {
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid rgba(91, 184, 255, 0.25);
    border-radius: 6px;
    color: var(--blue);
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.upgrade-btn:hover {
    background: rgba(91, 184, 255, 0.1);
    border-color: var(--blue);
    box-shadow: 0 0 10px rgba(91, 184, 255, 0.15);
}
.upgrade-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.service-lock-icon {
    position: absolute;
    top: 0.75rem; right: 0.75rem;
    color: var(--light-grey);
    opacity: 0.4;
}

@media (min-width: 768px) {
    .services-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
    .services-grid { grid-template-columns: repeat(5, 1fr); }
}

/* --- Contact Dana Button --- */
.contact-btn {
    width: 100%;
    padding: 0.6rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, rgba(91, 184, 255, 0.1), rgba(91, 184, 255, 0.05));
    border: 1px solid rgba(91, 184, 255, 0.25);
    border-radius: var(--radius-sm);
    color: var(--blue);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.contact-btn:hover {
    background: rgba(91, 184, 255, 0.15);
    border-color: var(--blue);
    box-shadow: 0 0 12px rgba(91, 184, 255, 0.15);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-card {
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}
.modal-overlay.active .modal-card {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--off-white);
    text-transform: none;
    letter-spacing: 0.05em;
    margin-bottom: 0;
}
.modal-close {
    background: none;
    border: none;
    color: var(--light-grey);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--off-white); }

.modal-card .form-group select,
.modal-card .form-group textarea {
    width: 100%;
    padding: 0.7rem 0.75rem;
    background: var(--black);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius-sm);
    color: var(--off-white);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color 0.2s;
    resize: vertical;
}
.modal-card .form-group select:focus,
.modal-card .form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(91, 184, 255, 0.15);
}
.modal-card .form-group textarea::placeholder {
    color: var(--light-grey);
    opacity: 0.5;
}

.contact-success {
    text-align: center;
    padding: 1.5rem 1rem;
}
.contact-success svg { margin-bottom: 0.75rem; }
.contact-success p {
    color: var(--off-white);
    font-size: 0.9rem;
}

/* --- Info Tooltips --- */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.section-header h3 {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--light-grey);
    text-transform: none;
    letter-spacing: 0.05em;
    margin: 0;
}
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(91, 184, 255, 0.1);
    color: var(--blue);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: help;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
    vertical-align: middle;
    margin-left: 0.25rem;
}
.info-tip:hover {
    background: rgba(91, 184, 255, 0.25);
}
.info-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--off-white);
    line-height: 1.5;
    width: 280px;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 50;
}
.info-tip:hover::after {
    opacity: 1;
}
/* Position tooltip below on mobile to avoid clipping */
@media (max-width: 767px) {
    .info-tip::after {
        bottom: auto;
        top: calc(100% + 8px);
        left: 0;
        transform: none;
        width: 240px;
    }
}

/* --- Chat Widget --- */
.chat-widget {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 150;
}
.chat-toggle {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--blue-glow));
    border: none;
    color: var(--black);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(91, 184, 255, 0.3);
    transition: all 0.3s;
}
.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(91, 184, 255, 0.4);
}

.chat-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 360px;
    max-height: 500px;
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-header {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(91, 184, 255, 0.08), rgba(91, 184, 255, 0.02));
    border-bottom: 1px solid var(--medium-grey);
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.chat-avatar {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--blue), var(--blue-glow));
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--black);
    flex-shrink: 0;
}
.chat-title {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--off-white);
}
.chat-subtitle {
    font-size: 0.65rem;
    color: var(--light-grey);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem;
    max-height: 340px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-msg {
    display: flex;
    max-width: 90%;
    min-width: 0;
}
.chat-msg.user {
    align-self: flex-end;
}
.chat-msg.assistant {
    align-self: flex-start;
}
.chat-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden;
    max-width: 100%;
}
.chat-bubble pre,
.chat-bubble code {
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
    font-size: 0.85rem;
    margin: 0.3rem 0;
}
.chat-msg.user .chat-bubble {
    background: var(--blue);
    color: var(--black);
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant .chat-bubble {
    background: var(--medium-grey);
    color: var(--off-white);
    border-bottom-left-radius: 4px;
}
.chat-msg.assistant .chat-bubble a {
    color: var(--blue);
    text-decoration: underline;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--medium-grey);
    background: var(--black);
}
.chat-input {
    flex: 1;
    padding: 0.5rem 0.6rem;
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    color: var(--off-white);
    font-family: var(--font-body);
    font-size: 0.82rem;
}
.chat-input:focus {
    outline: none;
    border-color: var(--blue);
}
.chat-input::placeholder { color: var(--light-grey); opacity: 0.5; }
.chat-input:disabled { opacity: 0.5; }

.chat-send {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--blue);
    border: none;
    color: var(--black);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-send:hover {
    background: var(--blue-glow);
}

/* Typing indicator */
.dot-pulse {
    display: inline-flex;
    gap: 4px;
}
.dot-pulse::before, .dot-pulse::after, .dot-pulse {
    content: '';
}
.chat-msg.typing .chat-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.75rem 1rem;
}
.chat-msg.typing .chat-bubble::before,
.chat-msg.typing .chat-bubble::after {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--light-grey);
    animation: dotPulse 1.2s infinite ease-in-out;
}
.chat-msg.typing .dot-pulse {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--light-grey);
    animation: dotPulse 1.2s infinite ease-in-out 0.2s;
}
.chat-msg.typing .chat-bubble::after {
    animation-delay: 0.4s;
}
@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Mobile: full width panel */
@media (max-width: 767px) {
    .chat-panel {
        width: calc(100vw - 2rem);
        right: -0.25rem;
        max-height: 60vh;
    }
    .chat-widget { bottom: 1rem; right: 1rem; }
}

/* --- Utility --- */
.text-muted { color: var(--light-grey); }
.text-green { color: var(--green) !important; }
.text-yellow { color: var(--yellow) !important; }
.text-red { color: var(--red) !important; }

/* --- Desktop (768px+) --- */
@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
    }
    .mobile-header { display: none; }
    .sidebar-overlay { display: none; }
    .main-content {
        margin-left: var(--sidebar-width);
        padding: 2rem;
    }
    .client-badge { display: inline-block; }
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .health-cards { grid-template-columns: repeat(2, 1fr); }
    .page-title { font-size: 1.5rem; }
    .chart-container { height: 280px; }
}

/* --- Large desktop (1200px+) --- */
@media (min-width: 1200px) {
    .health-cards { grid-template-columns: repeat(3, 1fr); }
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.kpi-card, .card, .health-card {
    animation: fadeIn 0.4s ease both;
}
.kpi-card:nth-child(2), .card:nth-child(2) { animation-delay: 0.05s; }
.kpi-card:nth-child(3), .card:nth-child(3) { animation-delay: 0.1s; }
.kpi-card:nth-child(4), .card:nth-child(4) { animation-delay: 0.15s; }

/* --- Admin Event Feed --- */
.feed-filters {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.feed-chip {
    padding: 0.35rem 0.7rem;
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-radius: 20px;
    color: var(--light-grey);
    font-family: var(--font-body);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.feed-chip:hover { color: var(--off-white); border-color: var(--blue); }
.feed-chip.active {
    background: var(--blue-dim);
    border-color: var(--blue);
    color: var(--blue);
}

.feed-day {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.08em;
    color: var(--light-grey);
    margin: 1.25rem 0 0.5rem;
    padding-left: 0.25rem;
}
.feed-section:first-child .feed-day { margin-top: 0; }
.feed-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.feed-item {
    background: var(--dark-grey);
    border: 1px solid var(--medium-grey);
    border-left: 3px solid var(--medium-grey);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color 0.2s;
}
.feed-item[open] { border-color: rgba(91, 184, 255, 0.3); }
.feed-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
}
.feed-row::-webkit-details-marker { display: none; }
.feed-row:hover { background: rgba(255, 255, 255, 0.03); }
.feed-icon {
    font-size: 1.05rem;
    width: 1.6rem;
    text-align: center;
    flex-shrink: 0;
}
.feed-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.feed-title {
    font-size: 0.86rem;
    color: var(--off-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feed-subtitle {
    font-size: 0.72rem;
    color: var(--light-grey);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feed-time {
    font-size: 0.7rem;
    color: var(--light-grey);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.feed-detail {
    border-top: 1px solid var(--medium-grey);
    padding: 0.6rem 0.85rem 0.7rem;
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.feed-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}
.feed-detail-label {
    color: var(--light-grey);
    text-transform: none;
    letter-spacing: 0.04em;
    font-size: 0.66rem;
    flex-shrink: 0;
}
.feed-detail-value {
    color: var(--off-white);
    text-align: right;
    font-size: 0.78rem;
    word-break: break-word;
}
.feed-detail-link {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
}

/* category accent on the left border */
.feed-item.cat-money       { border-left-color: var(--green); }
.feed-item.cat-contract    { border-left-color: var(--blue); }
.feed-item.cat-lead        { border-left-color: var(--blue-glow); }
.feed-item.cat-appointment { border-left-color: var(--yellow); }
.feed-item.cat-client      { border-left-color: var(--blue); }
.feed-item.cat-ops         { border-left-color: var(--medium-grey); }
