/* =========================================================
   BuildWithAdithya CRM - Stylesheet
   Mobile-first, dark UI, minimal gradient accents.
   No external framework dependency.
   ========================================================= */

:root {
    --bg: #0b0f19;
    --surface: #131a29;
    --surface-2: #1a2233;
    --surface-3: #212b40;
    --border: #262f45;
    --text: #e7eaf3;
    --text-muted: #94a0bd;
    --text-faint: #5c6688;

    --primary: #6366f1;
    --primary-2: #22d3ee;
    --primary-soft: #6366f11a;
    --gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 45%, #22d3ee 100%);

    --danger: #ef4444;
    --danger-soft: #ef444422;
    --success: #22c55e;
    --success-soft: #22c55e22;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow: 0 8px 24px rgba(0,0,0,0.35);

    --c-slate: #64748b;
    --c-blue: #3b82f6;
    --c-amber: #f59e0b;
    --c-violet: #8b5cf6;
    --c-cyan: #06b6d4;
    --c-orange: #f97316;
    --c-green: #22c55e;
    --c-red: #ef4444;

    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
ul { list-style: none; margin: 0; padding: 0; }
code { background: var(--surface-3); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

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

.sidebar {
    display: none;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(11,15,25,0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-logo { width: 30px; height: 30px; border-radius: 8px; }
.topbar-name { font-weight: 700; font-size: 15px; }
.topbar-add { display: none; }

.app-content {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 16px 96px;
}

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 18px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,0.35); }
.btn-primary:hover { opacity: 0.92; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger-ghost { background: var(--danger-soft); color: #fca5a5; }
.btn-danger-ghost:hover { background: #ef444433; }
.btn-sm { padding: 9px 14px; min-height: 42px; font-size: 13.5px; }
.btn-lg { padding: 14px 18px; min-height: 50px; font-size: 15.5px; }
.btn-block { width: 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-actions .btn { flex: 1; }

/* ---------------------------------------------------------
   Forms
   --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field-wide { grid-column: 1 / -1; }
input, select, textarea {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 15px;
    min-height: 44px;
    width: 100%;
    font-family: inherit;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field-error { color: #fca5a5; font-size: 12.5px; }
.field-hint { color: var(--text-muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.checkbox-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; }
.checkbox-item input { width: 18px; height: 18px; min-height: unset; flex-shrink: 0; }

.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.form-section summary { padding: 14px 16px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.form-section summary::-webkit-details-marker { display: none; }
.form-section summary::after { content: '+'; color: var(--text-muted); font-size: 18px; }
.form-section[open] summary::after { content: '−'; }
.form-section .form-grid { padding: 0 16px 16px; }

/* ---------------------------------------------------------
   Cards / Sections
   --------------------------------------------------------- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; }
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 0; }
.page-header-action { flex-shrink: 0; }

.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.detail-card-won { border-color: #22c55e55; }
.detail-card-lost { border-color: #ef444455; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.section-header h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.section-count { background: var(--surface-3); color: var(--text-muted); font-size: 12px; padding: 2px 8px; border-radius: 20px; }
.section-link { font-size: 13px; color: var(--primary-2); font-weight: 600; }

.dash-section { margin-bottom: 22px; }
.dash-section-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }

.detail-kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.detail-kv-compact { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.detail-kv div { display: flex; flex-direction: column; gap: 3px; }
.detail-kv span { font-size: 12px; color: var(--text-muted); }
.detail-kv strong { font-size: 14.5px; font-weight: 600; word-break: break-word; }
.detail-text { color: var(--text); font-size: 14px; line-height: 1.6; white-space: pre-line; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 12px; font-size: 12.5px; color: var(--text); }
.lead-settings-group { margin-bottom: 14px; }
.lead-settings-group .quickfact-label { display: block; margin-bottom: 8px; }

/* ---------------------------------------------------------
   Badges / Status Colors
   --------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px;
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    white-space: nowrap;
}
.badge-lg { padding: 6px 14px; font-size: 12.5px; }
.badge-slate  { background: #64748b26; color: #94a3b8; }
.badge-blue   { background: #3b82f626; color: #60a5fa; }
.badge-amber  { background: #f59e0b26; color: #fbbf24; }
.badge-violet { background: #8b5cf626; color: #a78bfa; }
.badge-cyan   { background: #06b6d426; color: #22d3ee; }
.badge-orange { background: #f9731626; color: #fb923c; }
.badge-green  { background: #22c55e26; color: #4ade80; }
.badge-red    { background: #ef444426; color: #f87171; }

.text-danger { color: #f87171; }

/* ---------------------------------------------------------
   KPI grid
   --------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 22px; }
.kpi-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.kpi-tile-wide { grid-column: 1 / -1; }
.kpi-tile-accent { border-color: #6366f155; background: linear-gradient(160deg, #6366f11a, transparent); }
.kpi-tile-alert { border-color: #f59e0b55; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-value-money { font-size: 20px; }
.kpi-note { font-size: 11.5px; color: #fbbf24; font-weight: 600; }

/* ---------------------------------------------------------
   Pipeline
   --------------------------------------------------------- */
.pipeline { display: flex; flex-direction: column; gap: 10px; }
.pipeline-row { display: grid; grid-template-columns: 92px 1fr 28px; align-items: center; gap: 10px; }
.pipeline-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.pipeline-bar-track { background: var(--surface-2); border-radius: 20px; height: 10px; overflow: hidden; }
.pipeline-bar-fill { height: 100%; border-radius: 20px; background: var(--c-slate); }
.pipeline-bar-fill.badge-slate  { background: var(--c-slate); }
.pipeline-bar-fill.badge-blue   { background: var(--c-blue); }
.pipeline-bar-fill.badge-amber  { background: var(--c-amber); }
.pipeline-bar-fill.badge-violet { background: var(--c-violet); }
.pipeline-bar-fill.badge-cyan   { background: var(--c-cyan); }
.pipeline-bar-fill.badge-orange { background: var(--c-orange); }
.pipeline-bar-fill.badge-green  { background: var(--c-green); }
.pipeline-bar-fill.badge-red    { background: var(--c-red); }
.pipeline-count { font-size: 13px; font-weight: 700; text-align: right; }

/* Bar chart (Analytics - Lead by Source) */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 30px; align-items: center; gap: 10px; }
.bar-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 20px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; background: var(--gradient); }
.bar-count { font-size: 13px; font-weight: 700; text-align: right; }

/* ---------------------------------------------------------
   Follow-up mini cards (dashboard)
   --------------------------------------------------------- */
.followup-list { display: flex; flex-direction: column; gap: 10px; }
.followup-mini-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.followup-mini-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.followup-mini-value { font-size: 13.5px; font-weight: 700; color: var(--primary-2); }
.followup-mini-action { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* Recent lists */
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.recent-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-item-main strong { font-size: 13.5px; }
.recent-item-main span { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------
   Lead cards (list page + follow up page)
   --------------------------------------------------------- */
.lead-cards-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 14px; }
.lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.lead-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.lead-card-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lead-card-title strong { font-size: 15.5px; }
.lead-card-industry { font-size: 12px; color: var(--text-muted); }
.lead-card-services { font-size: 12.5px; color: var(--text-muted); }
.lead-card-value { font-size: 17px; font-weight: 800; color: var(--primary-2); }
.lead-card-followup { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.lead-card-followup.is-overdue { background: var(--danger-soft); }
.lead-card-followup-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.lead-card-followup.is-overdue .lead-card-followup-label { color: #fca5a5; }
.lead-card-followup-date { font-size: 13.5px; font-weight: 600; }
.lead-card-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }

.leads-table-wrap { display: none; }
.leads-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.leads-table th, .leads-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.leads-table th { color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 700; }
.leads-table tr:last-child td { border-bottom: none; }
.table-sub { font-size: 12px; color: var(--text-muted); }

/* Follow-up page cards */
.followup-cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.followup-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.followup-card.is-overdue { border-color: #ef444455; }
.followup-card-link { display: block; }
.followup-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.followup-card-value { font-size: 14.5px; font-weight: 700; color: var(--primary-2); }
.followup-card-date { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.followup-card.is-overdue .followup-card-date { color: #fca5a5; font-weight: 600; }
.followup-card-action { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.followup-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.followup-card-actions form { flex-shrink: 0; }

/* ---------------------------------------------------------
   Toolbar / Filters / Search
   --------------------------------------------------------- */
.leads-toolbar, .analytics-filter { margin-bottom: 16px; }
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-input { flex: 1; }
.filter-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.filter-panel summary { padding: 12px 16px; font-weight: 600; font-size: 13.5px; cursor: pointer; list-style: none; color: var(--text-muted); display: flex; justify-content: space-between; }
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel summary::after { content: '▾'; }
.filter-panel[open] summary::after { content: '▴'; }
.filter-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; padding: 0 16px; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }
.result-count { font-size: 12.5px; color: var(--text-muted); margin: 0 0 12px; }

.analytics-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.analytics-filter .field { margin-bottom: 0; min-width: 150px; }
.analytics-custom-range { display: flex; gap: 10px; }
.analytics-range-label { font-size: 12.5px; color: var(--text-muted); margin-left: auto; }

.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 10px; }
.pg-btn { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.pg-btn.is-disabled { opacity: 0.4; pointer-events: none; }
.pg-info { font-size: 12.5px; color: var(--text-muted); }

/* ---------------------------------------------------------
   Detail page specific
   --------------------------------------------------------- */
.detail-header { align-items: flex-start; }
.detail-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-quickfacts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.quickfact { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.quickfact-wide { grid-column: 1 / -1; }
.quickfact-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.quickfact-value { font-size: 15px; font-weight: 700; }
.detail-wa-btn { margin-bottom: 14px; }
.status-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.status-form .field { min-width: 160px; margin-bottom: 0; flex: 1; }
.status-extra { display: flex; gap: 12px; flex-wrap: wrap; width: 100%; }
.status-extra .field { flex: 1; min-width: 140px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-date { font-size: 12px; color: var(--text-muted); padding-top: 2px; }
.timeline-body p { margin: 6px 0 0; font-size: 13.5px; color: var(--text); line-height: 1.5; }

/* Media gallery (lampiran aktivitas) */
.media-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.media-thumb {
    display: flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; flex-shrink: 0;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb-file { font-size: 10px; color: var(--text-muted); text-align: center; line-height: 1.4; }

/* ---------------------------------------------------------
   Staff / Team
   --------------------------------------------------------- */
.staff-list { display: flex; flex-direction: column; gap: 10px; }
.staff-card {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.staff-card.is-inactive { opacity: 0.6; }
.staff-card-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.staff-card-info strong { font-size: 14.5px; }
.staff-card-email { font-size: 12.5px; color: var(--text-muted); }
.staff-card-badges { display: flex; gap: 6px; margin-top: 2px; }
.staff-card-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------------------------------------------------------
   Empty states
   --------------------------------------------------------- */
.empty-state { text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-muted); }
.empty-state p { margin: 0 0 12px; }
.empty-state .btn { margin-top: 4px; }
.empty-state-compact { padding: 24px 16px; }
.empty-state-compact p { margin: 0; }

/* ---------------------------------------------------------
   Flash messages
   --------------------------------------------------------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.flash { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--success-soft); color: #86efac; border: 1px solid #22c55e40; }
.flash-error { background: var(--danger-soft); color: #fca5a5; border: 1px solid #ef444440; }
.flash-close { background: none; border: none; color: inherit; font-size: 18px; cursor: pointer; line-height: 1; padding: 10px; margin: -10px; }

/* ---------------------------------------------------------
   Modal / Bottom Sheet (Add Activity)
   --------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-radius: 20px 20px 0 0;
    border: 1px solid var(--border); border-bottom: none;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    max-height: 88vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h3 { font-size: 17px; }
.modal-close { background: var(--surface-2); border: none; color: var(--text); width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.modal-form .field:last-of-type { margin-bottom: 16px; }

/* ---------------------------------------------------------
   Bottom Navigation (mobile)
   --------------------------------------------------------- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: grid; grid-template-columns: 1fr 1fr 64px 1fr 1fr;
    align-items: end;
    background: rgba(19,26,41,0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.bn-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; border-radius: 10px; font-size: 10.5px; color: var(--text-muted);
    font-weight: 600; background: none; border: none; cursor: pointer;
}
.bn-item.is-active { color: var(--primary-2); }
.bn-icon { font-size: 19px; line-height: 1; }
.bn-add {
    display: flex; align-items: center; justify-content: center;
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--gradient); color: #fff; font-size: 28px; font-weight: 400;
    margin: -22px auto 0; box-shadow: 0 6px 18px rgba(99,102,241,0.5);
    border: 4px solid var(--bg);
}

.more-sheet { position: fixed; inset: 0; z-index: 90; display: none; }
.more-sheet.is-open { display: block; }
.more-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.more-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-radius: 20px 20px 0 0;
    border: 1px solid var(--border); border-bottom: none;
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 4px;
}
.more-sheet-link { padding: 14px 10px; font-size: 15px; font-weight: 600; border-radius: var(--radius-sm); background: none; border: none; text-align: left; color: var(--text); cursor: pointer; }
.more-sheet-link:hover { background: var(--surface-2); }
.more-sheet-logout { color: #f87171; }
.more-sheet-cancel { color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 4px; padding-top: 16px; }

/* ---------------------------------------------------------
   Auth pages (login / change password / errors)
   --------------------------------------------------------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card, .error-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 26px; text-align: center; box-shadow: var(--shadow); }
.auth-logo img { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 16px; }
.auth-title { font-size: 21px; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }
.auth-form { text-align: left; }
.auth-hint { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 18px; line-height: 1.6; }
.auth-hint-link { display: block; color: var(--primary-2); font-weight: 600; text-decoration: none; }

.error-code { font-size: 52px; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-title { font-size: 19px; margin: 6px 0 8px; }
.error-text { color: var(--text-muted); font-size: 13.5px; margin: 0 0 20px; }

/* ---------------------------------------------------------
   Responsive: Tablet (>= 640px)
   --------------------------------------------------------- */
@media (min-width: 640px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .lead-cards-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
    .followup-cards { grid-template-columns: repeat(2, 1fr); }
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
    .modal-panel { max-width: 480px; left: 50%; right: auto; transform: translateX(-50%); bottom: 24px; border-radius: 20px; border-bottom: 1px solid var(--border); }
    .more-sheet-panel { max-width: 320px; left: auto; right: 24px; bottom: 90px; border-radius: 16px; border-bottom: 1px solid var(--border); }
}

/* ---------------------------------------------------------
   Responsive: Desktop (>= 900px) - sidebar layout kicks in
   --------------------------------------------------------- */
@media (min-width: 900px) {
    .sidebar {
        display: flex; flex-direction: column;
        width: 240px; flex-shrink: 0; min-height: 100vh; max-height: 100vh; overflow-y: auto;
        background: var(--surface); border-right: 1px solid var(--border);
        padding: 20px 14px; position: sticky; top: 0; align-self: flex-start;
    }
    .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
    .sidebar-logo { width: 36px; height: 36px; border-radius: 10px; }
    .sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
    .sidebar-brand-text strong { font-size: 14px; }
    .sidebar-brand-text span { font-size: 11.5px; color: var(--text-muted); }
    .sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
    .sidebar-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--text-muted); }
    .sidebar-link:hover { background: var(--surface-2); color: var(--text); }
    .sidebar-link.is-active { background: var(--primary-soft); color: var(--primary-2); }
    .sidebar-icon { font-size: 16px; width: 20px; text-align: center; }
    .sidebar-footer { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
    .sidebar-logout { color: #f87171; }

    .topbar { display: none; }
    .app-content { padding: 32px 32px 48px; }
    .bottom-nav, .more-sheet { display: none !important; }

    .page-header-action, .topbar-add { display: inline-flex; }

    .lead-cards-grid { display: none; }
    .leads-table-wrap { display: block; overflow-x: auto; }

    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .dash-section-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-quickfacts { grid-template-columns: repeat(4, 1fr); }
    .followup-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1100px) {
    .lead-cards-grid { grid-template-columns: repeat(3, 1fr); }
}
