/* =====================================================
   Landbot CRM - Modern Clean UI
   ===================================================== */

:root {
    /* Deep blue palette (change these tokens to re-theme) */
    --primary: #1f3a93;
    --primary-dark: #172c70;
    --primary-light: #3d5fd0;
    --primary-soft: #e4eafb;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --page-bg: #f5f7fc;
    --sidebar-bg: #0c1330;
    --sidebar-hover: #1b2550;
    --sidebar-width: 206px;
    --header-height: 56px;
    --card-radius: 14px;
    --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-lg: 0 12px 32px rgba(15,23,42,0.10);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ---------- Login / Auth Pages ---------- */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1f3a93 0%, #2d4bb0 40%, #16296b 100%);
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.login-card {
    display: flex;
    max-width: 920px;
    width: 100%;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
}

.login-left {
    width: 42%;
    background: linear-gradient(160deg, #1f3a93 0%, #16296b 100%);
    color: #fff;
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.login-brand .logo {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.login-brand h1 {
    font-size: 22px;
    font-weight: 700;
}

.login-brand span {
    font-size: 12px;
    opacity: 0.6;
    display: block;
}

.login-left h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.login-left p {
    opacity: 0.7;
    font-size: 14px;
    margin-bottom: 28px;
}

.feature-list {
    list-style: none;
}

.feature-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 14px;
    opacity: 0.85;
}

.feature-list li::before {
    content: '✓';
    width: 22px;
    height: 22px;
    background: rgba(255,255,255,0.18);
    color: #c3d0f7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}
.login-left-foot {
    font-size: 12px;
    opacity: 0.45;
    margin-top: 28px;
}

.login-right {
    width: 58%;
    padding: 48px 48px;
}

.login-right h2 {
    font-size: 24px;
    margin-bottom: 6px;
}

.login-right .subtitle {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s;
    background: #f8fafc;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(31,58,147,0.18);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
    cursor: pointer;
    line-height: 1.25;
    white-space: nowrap;
}

.btn i.fa {
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(31,58,147, 0.25);
}

.btn-info {
    background: var(--info);
    color: #fff;
    border-color: var(--info);
}

.btn-info:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 7px;
}

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-right: 1px solid #1e293b;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
}

.sidebar-header {
    padding: 14px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header .logo {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-header .brand-text h2 {
    font-size: 14px;
    font-weight: 700;
    color: #f8fafc;
}

.sidebar-header .brand-text span {
    font-size: 11px;
    opacity: 0.5;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Sidebar submenu visibility fix: the navigation itself owns the scroll, so
   expanded groups can never be clipped by the viewport/footer. */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.55); border-radius: 10px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sb-group.open { scroll-margin-top: 10px; scroll-margin-bottom: 14px; }
.sb-subcards { max-height: none; overflow: visible; }

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8;
    padding: 0 10px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-ico { font-size: 15px; width: 20px; text-align: center; }

/* Dropdown */
.nav-dropdown { margin-bottom: 2px; }
.nav-drop-btn { position: relative; }
.nav-arrow {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.7;
    transition: transform 0.2s;
}
.nav-dropdown.open .nav-arrow { transform: rotate(180deg); }
.nav-drop-menu {
    display: none;
    padding: 2px 0 4px 12px;
}
.nav-dropdown.open .nav-drop-menu { display: block; }
.nav-sub {
    display: block;
    padding: 7px 12px;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 12.5px;
    font-weight: 500;
    margin-bottom: 1px;
    transition: all 0.12s;
}
.nav-sub:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-sub.active {
    background: rgba(31,58,147, 0.35);
    color: #b4c4f8;
    font-weight: 600;
}

.nav-item .badge {
    margin-left: auto;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
}

.nav-item.active .badge {
    background: rgba(255,255,255,0.25);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.user-info .role {
    font-size: 11px;
    opacity: 0.5;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.topbar {
    min-height: var(--header-height);
    height: auto;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    /* Keep page content from sliding under sticky header */
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.topbar-left h1 {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-left span {
    font-size: 13px;
    color: #64748b;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    row-gap: 8px;
    justify-content: flex-end;
}

.btn-outline {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    color: #475569;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-logout {
    background: #fef2f2;
    border: 1.5px solid #fecaca;
    color: #dc2626;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #b91c1c;
}

.content-area {
    padding: 28px;
}

/* KPI Cards — compact */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: #fff;
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    border: 1px solid #f1f5f9;
    transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.kpi-card .label {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-card .value {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.kpi-card .sub {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
}

.kpi-card.blue { border-left: 4px solid #3b82f6; }
.kpi-card.green { border-left: 4px solid #10b981; }
.kpi-card.yellow { border-left: 4px solid #f59e0b; }
.kpi-card.red { border-left: 4px solid #ef4444; }
.kpi-card.purple { border-left: 4px solid #8b5cf6; }
.kpi-card.cyan { border-left: 4px solid #06b6d4; }

/* Cards */
.card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    border: 1px solid #f1f5f9;
    margin-bottom: 24px;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 22px;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #64748b;
    font-weight: 600;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

/* Sticky table headers inside scrollable areas */
.table-responsive thead th,
.card .table-responsive thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f1f5f9;
    box-shadow: 0 1px 0 #e2e8f0;
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

tr:hover td {
    background: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #047857; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Search bar */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar input {
    flex: 1;
    min-width: 220px;
    padding: 11px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row.three {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 768px) {
    .main-content { margin-left: 0; }
    .login-card { flex-direction: column; }
    .login-left, .login-right { width: 100%; }
    .form-row, .form-row.three { grid-template-columns: 1fr; }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #94a3b8;
}

.empty-state h4 {
    font-size: 16px;
    color: #64748b;
    margin-bottom: 8px;
}

/* Action buttons in table */
.action-btns {
    display: flex;
    gap: 6px;
}

.action-btns a, .action-btns button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: 14px;
    transition: all 0.15s;
}

.action-btns a:hover, .action-btns button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}


/* Delete action */
.btn-del {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
}
.btn-del:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.action-btns form { display: inline; }

/* =========================================================
   Card sidebar – professional clear contrast
   ========================================================= */
.sidebar {
    background: #0f172a !important;
    color: #e2e8f0 !important;
}
.sidebar * {
    box-sizing: border-box;
}
.sidebar-header {
    background: #0f172a !important;
    border-bottom: 1px solid #1e293b !important;
    padding: 12px 10px !important;
}
.sidebar-header .logo {
    background: transparent !important;
    color: #fff !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 12px !important;
}
.sidebar-header img.logo {
    background: transparent !important;
}
.sidebar-header .brand-text h2 {
    color: #f8fafc !important;
    font-size: 13px !important;
}
.sidebar-header .brand-text span {
    color: #94a3b8 !important;
    opacity: 1 !important;
    font-size: 10px !important;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px 0 12px !important;
    background: #0f172a;
}

.sidebar-footer {
    flex-shrink: 0;
    background: #0f172a !important;
    border-top: 1px solid #1e293b !important;
    padding: 10px 8px !important;
}
.sidebar-footer .user-info {
    background: #1e293b !important;
    border: 1px solid #334155;
    padding: 8px !important;
    gap: 8px !important;
}
.sidebar-footer .name { color: #f1f5f9 !important; }
.sidebar-footer .role { color: #94a3b8 !important; opacity: 1 !important; }
.user-avatar {
    background: #1f3a93 !important;
    color: #fff !important;
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
}
.sidebar-footer .name {
    font-size: 12px !important;
}
.sidebar-footer .role {
    font-size: 10px !important;
}

.sb-logout {
    display: block;
    margin-top: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #fecaca !important;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #7f1d1d;
    background: #450a0a;
}
.sb-logout:hover { background: #7f1d1d; color: #fff !important; }

.sb-section-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8 !important;
    padding: 8px 10px 4px;
}

.sb-divider {
    height: 1px;
    background: #334155;
    margin: 8px 10px;
    border: none;
}

.sb-top-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 8px 8px;
}

/* Clear white cards on dark sidebar */
.sb-card-btn {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 9px 10px !important;
    border-radius: 10px !important;
    text-decoration: none !important;
    color: #0f172a !important;
    font-weight: 600 !important;
    font-size: 12.5px !important;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12) !important;
    transition: all 0.15s ease;
    line-height: 1.3;
    cursor: pointer;
}
.sb-card-btn:hover {
    background: #f5f7fc !important;
    border-color: #1f3a93 !important;
    color: #1f3a93 !important;
}
.sb-card-btn.active {
    background: #1f3a93 !important;
    border-color: #2d4bb0 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 3px 10px rgba(31,58,147, 0.35) !important;
}
.sb-card-btn .sb-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.sb-card-btn .sb-text,
.sb-card-btn span:not(.sb-icon) {
    color: inherit !important;
}

/* Group dropdown */
.sb-group {
    margin: 8px 0;
}
.sb-group-btn {
    width: calc(100% - 16px) !important;
    margin: 0 8px !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    font-family: inherit !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    padding: 10px 10px !important;
    cursor: pointer !important;
    text-align: left;
    border-radius: 10px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
}
.sb-group-btn:hover {
    background: #f8fafc !important;
    border-color: #1f3a93 !important;
}
.sb-group.open > .sb-group-btn {
    background: #1f3a93 !important;
    border-color: #2d4bb0 !important;
    color: #ffffff !important;
    border-radius: 10px 10px 0 0 !important;
    box-shadow: 0 3px 10px rgba(31,58,147, 0.3) !important;
}
.sb-group.open > .sb-group-btn .sb-text,
.sb-group.open > .sb-group-btn .sb-group-left,
.sb-group.open > .sb-group-btn .sb-icon {
    color: #ffffff !important;
}
.sb-group-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sb-caret {
    font-size: 14px;
    color: #64748b !important;
    transition: transform 0.2s ease;
}
.sb-group.open .sb-caret {
    transform: rotate(180deg);
    color: #ffffff !important;
}

/* Sub dropdown panel */
.sb-subcards {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 8px !important;
    margin: 0 8px 8px !important;
    background: #ffffff !important;
    border: 1px solid #1f3a93 !important;
    border-top: none !important;
    border-radius: 0 0 10px 10px !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12) !important;
}
.sb-group.open > .sb-subcards {
    display: flex !important;
}
.sb-subcards[hidden] {
    display: none !important;
}
.sb-subcards .sb-card-btn {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: #0f172a !important;
    box-shadow: none !important;
    font-size: 12px !important;
    padding: 8px 10px !important;
}
.sb-subcards .sb-card-btn:hover {
    background: #f5f7fc !important;
    border-color: #1f3a93 !important;
    color: #1f3a93 !important;
}
.sb-subcards .sb-card-btn.active {
    background: #1f3a93 !important;
    border-color: #2d4bb0 !important;
    color: #ffffff !important;
}

/* Page content */
body {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}
.main-content {
    background: #f1f5f9;
}
.content-area {
    color: #0f172a;
}
.card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}


/* ---------- Form cards & alignment (Add/Edit Lead) ---------- */
.form-card {
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
}
.form-card .card-header {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.form-card .card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}
.form-card .card-body {
    padding: 16px;
}
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    text-transform: none;
    letter-spacing: 0;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    background: #fff;
    min-height: 40px;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(31,58,147, 0.12);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
    align-items: start;
}
.form-row.three {
    grid-template-columns: 1fr 1fr 1fr;
}
.form-row > .form-group {
    margin-bottom: 0;
}
.form-hint {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 12px;
}
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 0 24px;
}
.form-actions .btn-primary {
    width: auto;
    min-width: 140px;
}

/* ---------- Document checklist ---------- */
.docs-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.docs-toolbar .docs-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #64748b;
}
.docs-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.docs-legend .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.docs-legend .dot.ok { background: #059669; }
.docs-legend .dot.pending { background: #dc2626; }
.docs-toolbar .docs-actions {
    display: flex;
    gap: 6px;
}
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}
label.doc-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #0f172a;
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
    margin: 0;
    user-select: none;
    min-height: 44px;
}
label.doc-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #1f3a93;
    flex-shrink: 0;
    cursor: pointer;
}
label.doc-check:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}
label.doc-check.is-collected {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}
label.doc-check.is-pending {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}
label.doc-check span {
    line-height: 1.3;
}

@media (max-width: 768px) {
    .form-row, .form-row.three { grid-template-columns: 1fr; }
    .docs-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   Mobile app-like CRM — interactive, non-blocking
   ========================================================= */
.mobile-menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: #f1f5f9;
  font-size: 20px;
  cursor: pointer;
  margin-right: 8px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-close {
  display: none;
  margin-left: auto;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 8px 10px;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
  pointer-events: none;
}
.sidebar-backdrop.show {
  display: block;
  pointer-events: auto;
}
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 80;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(15,23,42,0.08);
  pointer-events: auto;
}
.mobile-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 10px;
  min-width: 56px;
  min-height: 48px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}
.mobile-bottom-nav a span { font-size: 20px; line-height: 1; }
.mobile-bottom-nav a.active {
  color: #1f3a93;
  background: #f5f7fc;
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: inline-flex !important; }
  .mobile-nav-close { display: block !important; }
  .desktop-only { display: none !important; }

  /* Drawer: off-screen + no hit testing until open */
  .sidebar {
    display: flex !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    z-index: 100;
    width: min(280px, 85vw) !important;
    max-width: 280px;
    transform: translateX(-110%) !important;
    transition: transform 0.25s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.2);
    pointer-events: none !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
    pointer-events: auto !important;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: 80px !important;
    position: relative;
    z-index: 1;
    pointer-events: auto !important;
  }
  .content-area {
    padding: 12px !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: auto !important;
    min-height: var(--header-height) !important;
    padding: 10px 12px !important;
    pointer-events: auto !important;
    flex-wrap: nowrap !important; /* keep the bar itself to one row: title left, 1-2 actions right */
    align-items: center !important;
  }
  .topbar h1,
  .topbar-left h1 {
    font-size: 15px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .topbar-left {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .topbar-right {
    flex-wrap: nowrap !important;
    gap: 6px !important;
    flex-shrink: 0;
  }
  /* Prevent content from sitting under sticky header on mobile */
  .content-area {
    padding-top: 14px !important;
  }
  /* Language chips, theme toggle, Support/System dropdowns, Loan Files & New File quick
     links, and Logout duplicate what's already reachable from the sidebar drawer (☰) and
     bottom nav on phones — hiding them here is what stops the topbar from wrapping onto
     several rows and covering the page title / welcome banner underneath it. */
  .topbar-desktop-only { display: none !important; }

  .mobile-bottom-nav { display: flex !important; }
  body.nav-open { overflow: hidden; }
  body.nav-open .main-content { pointer-events: none; }

  .card { border-radius: 14px; }
  .btn, .form-control, select.form-control {
    min-height: 44px;
    font-size: 15px !important;
  }
  select, input, button, a, textarea, label {
    pointer-events: auto !important;
  }
  /* Don't shrink action buttons to icon-only on mobile forms */
  .action-btns a, .action-btns button {
    width: auto !important;
    height: auto !important;
    min-height: 40px;
    min-width: 40px;
    padding: 8px 12px !important;
  }
  table { font-size: 13px; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
}

/* ===== Installed-app (PWA) polish ===== */
@media (display-mode: standalone) {
  /* status bar is translucent on iOS: keep the top bar clear of the notch/clock.
     Use min-height (not fixed height) so the bar can still grow if needed. */
  .topbar {
    height: auto !important;
    min-height: calc(var(--header-height) + env(safe-area-inset-top, 0px)) !important;
    padding-top: max(10px, env(safe-area-inset-top, 0px)) !important;
  }
  body { overscroll-behavior-y: none; }          /* no rubber-band bounce that looks like a web page */
  html { scroll-padding-top: calc(var(--header-height) + env(safe-area-inset-top, 0px)); }
}

/* =========================================================
   Wallet & Subscription pages
   (desktop values = what used to be inline styles; phone layout in the media query below)
   ========================================================= */
.wl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; margin-bottom: 20px; }
.wl-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.wl-acct { font-size: 18px; font-weight: 700; font-family: ui-monospace, monospace; letter-spacing: .06em; color: #0f172a; margin-bottom: 16px; }
.wl-bal { font-size: 32px; font-weight: 800; color: #1f3a93; }
.wl-note { font-size: 12px; color: #94a3b8; margin: 10px 0 0; }
.wl-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.wl-topup { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.wl-topup .form-group { margin: 0; flex: 1; min-width: 140px; }

.sub-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; align-items: start; }
.sub-col .card { margin-bottom: 16px; }
.sub-col .card:last-child { margin-bottom: 0; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.plan-card { border: 2px solid #e2e8f0; border-radius: 14px; padding: 18px; background: #fff; position: relative; }
.plan-card.best { border-color: #1f3a93; background: #f5f7fc; }
.plan-name { font-size: 13px; font-weight: 700; color: #64748b; text-transform: uppercase; }
.plan-price { font-size: 28px; font-weight: 800; color: #0f172a; margin: 8px 0 4px; }
.plan-list { font-size: 13px; color: #475569; margin: 12px 0 16px; padding-left: 18px; line-height: 1.6; }
.sub-mobile-only { display: none; }

@media (max-width: 768px) {
  /* ---- Wallet ---- */
  .wl-grid { grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
  .wl-grid .card { margin-bottom: 0; }

  /* balance first, big, on the brand colour; account number underneath */
  .card.wl-hero { background: var(--primary) !important; border-color: var(--primary); }   /* .card sets background !important */
  .wl-hero .card-header { display: none; }
  .wl-hero .card-body { display: flex; flex-direction: column; padding: 20px; }
  .wl-hero .card-body > :nth-child(3) { order: 1; }   /* "Balance" label */
  .wl-hero .card-body > :nth-child(4) { order: 2; }   /* amount */
  .wl-hero .card-body > :nth-child(1) { order: 3; }   /* "Account Number" label */
  .wl-hero .card-body > :nth-child(2) { order: 4; }   /* number */
  .wl-hero .wl-label { color: rgba(255,255,255,.78); text-transform: none; letter-spacing: 0; font-size: 13px; }
  .wl-hero .wl-bal { color: #fff; font-size: 38px; line-height: 1.1; margin-bottom: 18px; }
  .wl-hero .wl-acct { color: #fff; font-size: 16px; margin-bottom: 0; }
  .wl-idnote { display: none; }

  /* top-up: presets in one row, full-width amount + button */
  .wl-presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
  .wl-topup { flex-direction: column; align-items: stretch; gap: 12px; }
  .wl-topup .form-group { min-width: 0; width: 100%; }
  .wl-topup .form-control { font-size: 18px !important; font-weight: 600; }
  .wl-topup .btn { width: 100%; }

  /* ---- Subscription ---- */
  .sub-help { padding: 12px !important; gap: 10px !important; }
  .sub-help-contact { display: none; }               /* the two buttons already do this */
  .sub-help-btns { width: 100%; }
  .sub-help-btns .btn { flex: 1; }

  /* single column, current plan first */
  .sub-grid { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
  .sub-col { display: contents; }
  .sub-col .card { margin-bottom: 0; }
  .sub-current { order: 1; }
  .sub-plans { order: 2; }
  .sub-balance { order: 3; }
  .sub-txns { order: 4; }
  .sub-walletlink { display: none; }                 /* replaced by the button inside the balance card */
  .sub-mobile-only { display: inline-flex; width: 100%; margin-top: 12px; }
  .sub-current .card-body > div { display: flex; justify-content: space-between; gap: 12px; }

  .plan-grid { grid-template-columns: 1fr; gap: 12px; }
  .plan-card { padding: 16px; }
  .plan-price { font-size: 26px; }
  .plan-list { margin: 10px 0 14px; }

  /* ---- Transactions (both pages): one small card per row instead of a wide table ---- */
  .txn-table, .txn-table tbody { display: block; }
  .txn-table thead { display: none; }
  .txn-table tr {
    display: grid; grid-template-columns: auto auto 1fr auto; column-gap: 8px; row-gap: 4px; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid #f1f5f9;
  }
  .txn-table tr:last-child { border-bottom: 0; }
  .txn-table td { display: block; padding: 0; border: 0; font-size: 13px; }
  .txn-table tr:hover td { background: transparent; }
  .txn-table .tx-purpose { grid-column: 1 / 4; grid-row: 1; font-size: 14px; font-weight: 600; color: #0f172a; overflow-wrap: anywhere; }
  .txn-table .tx-amt { grid-column: 4; grid-row: 1; text-align: right; font-size: 15px; font-weight: 700; white-space: nowrap; }
  .txn-table .tx-amt.credit { color: #047857; }
  .txn-table .tx-amt.debit { color: #b91c1c; }
  .txn-table .tx-date { grid-column: 1; grid-row: 2; font-size: 12px; color: #64748b; }
  .txn-table .tx-type { grid-column: 2; grid-row: 2; }
  .txn-table .tx-bal { grid-column: 4; grid-row: 2; text-align: right; font-size: 12px; color: #94a3b8; white-space: nowrap; }
  .txn-table .tx-bal::before { content: 'Balance '; }
  .txn-table .tx-note { grid-column: 1 / -1; grid-row: 3; font-size: 12px; overflow-wrap: anywhere; }
  .txn-table .tx-note:empty { display: none; }
  .txn-table td.empty-state { grid-column: 1 / -1; padding: 32px 16px; }
}


/* =========================================================
   Auth UX — back btn, tabs, password toggle, mobile polish
   ========================================================= */
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 14px;
    padding: 6px 0;
    -webkit-tap-highlight-color: transparent;
}
.auth-back:hover { color: var(--primary-dark); text-decoration: underline; }

.auth-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
}
.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    transition: all 0.15s;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}
.auth-tab:hover:not(.active) { color: var(--text); }

.btn-block {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
}

.remember-row {
    margin: 4px 0 18px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.auth-links {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
    color: #64748b;
}
.auth-links a {
    color: var(--primary);
    font-weight: 600;
}
.auth-links a:hover { text-decoration: underline; }
.auth-links .dot { margin: 0 6px; opacity: 0.5; }

.input-with-toggle {
    position: relative;
}
.input-with-toggle .form-control {
    padding-right: 48px;
}
.pwd-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 18px;
    padding: 6px 8px;
    line-height: 1;
    opacity: 0.7;
    cursor: pointer;
    border-radius: 8px;
}
.pwd-toggle:hover { opacity: 1; background: #f1f5f9; }

.channel-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.channel-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    user-select: none;
}
.channel-pill:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
}
.channel-pill input { width: 16px; height: 16px; accent-color: var(--primary); }

.otp-input {
    letter-spacing: 6px;
    font-size: 22px !important;
    font-weight: 700;
    text-align: center;
}
.otp-code {
    letter-spacing: 3px;
    font-size: 18px;
}

.auth-done {
    text-align: center;
    padding: 12px 0 8px;
}
.auth-done-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #d1fae5;
    color: #059669;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-done p {
    color: #64748b;
    margin-bottom: 18px;
    font-size: 15px;
}

.login-right h2 {
    font-size: 22px;
    margin-bottom: 4px;
    color: #0f172a;
}
.login-right .subtitle {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 18px;
}

.login-brand .logo {
    background: rgba(255,255,255,0.2) !important;
    color: #fff;
}

@media (max-width: 768px) {
    .login-page {
        padding: 12px;
        align-items: flex-start;
        padding-top: max(20px, env(safe-area-inset-top));
    }
    .login-card {
        flex-direction: column;
        border-radius: 16px;
        max-width: 440px;
        margin: 0 auto;
    }
    .login-left {
        width: 100%;
        padding: 24px 22px 18px;
    }
    .login-left h2 { font-size: 20px; margin-bottom: 6px; }
    .login-left p { margin-bottom: 14px; font-size: 13px; }
    .feature-list { display: none; } /* keep card compact on phone */
    .login-left-foot { display: none; }
    .login-right {
        width: 100%;
        padding: 24px 20px 28px;
    }
    .login-brand { margin-bottom: 12px; }
    .login-brand h1 { font-size: 18px; }
    .auth-tabs { margin-bottom: 16px; }
    .form-group { margin-bottom: 16px; }
    .btn-block { min-height: 50px; font-size: 16px; }
}

.field-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
}

.req {
    color: #dc2626;
    font-weight: 700;
}


/* ---- Topbar chips / dropdowns / back buttons ---- */
.topbar-chip.is-active {
  background: #1f3a93 !important;
  border-color: #1f3a93 !important;
  color: #fff !important;
}
.topbar-drop-item {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  text-decoration: none;
}
.topbar-drop-item:hover {
  background: #f1f5f9;
  color: #1f3a93;
}
.page-back-bar {
  margin-bottom: 12px;
}
.page-back-btn,
a.page-back-btn.btn-outline {
  background: #0f172a !important;
  border-color: #0f172a !important;
  color: #fff !important;
  font-weight: 700 !important;
}
.page-back-btn:hover,
a.page-back-btn.btn-outline:hover {
  background: #1e293b !important;
  border-color: #1e293b !important;
  color: #fff !important;
}
.sidebar-footer {
  flex-shrink: 0;
  margin-bottom: 0 !important;
  padding-bottom: 12px !important;
}


/* ---- Desktop top bar — neat & tight (phones keep their own compact bar above) ---- */
@media (min-width: 769px) {
  :root { --header-height: 46px; }
  .topbar { padding: 5px 16px; min-height: 46px; row-gap: 4px; }
  .topbar-left h1 { font-size: 16px; line-height: 1.2; }
  .topbar-right { gap: 5px; row-gap: 4px; }
  .topbar-right .btn,
  .topbar-right .btn-sm,
  .topbar-right .btn-logout {
    padding: 5px 10px; font-size: 12px; line-height: 1.3; border-radius: 7px; white-space: nowrap; gap: 4px;
  }
  .topbar-right .topbar-chip { padding: 5px 8px; min-width: 0; }
  /* EN | मराठी as one joined pair */
  .topbar-right .topbar-chip + .topbar-chip { margin-left: -6px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
  .topbar-right .topbar-chip:has(+ .topbar-chip) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
  .content-area { padding: 14px 18px; }
}
/* Wide screens: keep the whole bar on ONE row */
@media (min-width: 1280px) {
  .topbar { flex-wrap: nowrap; }
  .topbar-right { flex-wrap: nowrap; }
}

/* Landbot logo image — clear display on web + mobile */
img.logo,
.sidebar-header img.logo,
.login-brand img.logo {
    background: transparent !important;
    padding: 0 !important;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
    image-rendering: -webkit-optimize-contrast;
}
.sidebar-header img.logo {
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.login-brand img.logo {
    width: 52px !important;
    height: 52px !important;
    border-radius: 12px;
}
@media (max-width: 768px) {
    .sidebar-header img.logo {
        width: 44px !important;
        height: 44px !important;
        border-radius: 11px;
    }
}

/* ── Smoothness ── */
html{scroll-behavior:smooth;-webkit-tap-highlight-color:transparent}
a,button,select,input,label,.btn{touch-action:manipulation}
.btn,button,.dh-chip,.fu-btn,.mobile-bottom-nav a,.cb-act{transition:transform .12s ease,background-color .2s ease,box-shadow .2s ease,opacity .2s ease}
.btn:active,button:active,.dh-chip:active,.fu-btn:active,.mobile-bottom-nav a:active,.cb-act:active{transform:scale(.96)}
@keyframes sm-fade{from{opacity:0}to{opacity:1}}
@keyframes sm-pop{from{opacity:0;transform:translateY(14px) scale(.98)}to{opacity:1;transform:none}}
#followupModal[style*="flex"],#addLeadModal[style*="flex"],#editLeadModal[style*="flex"]{animation:sm-fade .18s ease}
#followupModal[style*="flex"]>div,#addLeadModal[style*="flex"]>div,#editLeadModal[style*="flex"]>div{animation:sm-pop .22s ease}
.cb-mcard,.fu-table tr{transition:background-color .2s ease,box-shadow .2s ease}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}

/* =========================================================
   LAND FLOW MOBILE UX FINAL PATCH
   Touch-first layout, no page shake, safe-area aware.
   ========================================================= */
@media (max-width: 768px) {
  html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
  }
  body {
    min-height: 100dvh;
    -webkit-text-size-adjust: 100%;
  }
  .crm-app {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100dvh !important;
    overflow-x: clip !important;
  }
  .main-content {
    min-width: 0 !important;
    overflow-x: clip !important;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .content-area {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: clip !important;
    padding: 10px !important;
  }
  .topbar {
    width: 100% !important;
    min-width: 0 !important;
    padding: 8px 10px !important;
    min-height: 52px !important;
    padding-top: max(8px, env(safe-area-inset-top, 0px)) !important;
  }
  .topbar-left, .topbar-right { min-width: 0 !important; }
  .topbar-right { overflow: hidden; }
  .topbar-right > * { flex-shrink: 0; }

  /* Cards / grids */
  .card, .panel, .form-card, .stat-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  .card-body, .form-card .card-body { min-width: 0 !important; }
  .form-row, .form-row.three, .wl-grid, .sub-grid, .plan-grid {
    grid-template-columns: 1fr !important;
  }
  .form-row > *, .form-row.three > * { min-width: 0 !important; }

  /* Long data tables: only the table scrolls, never the whole page. */
  .table-wrap, .table-responsive, .data-table-wrap, .responsive-table {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }
  .table-wrap table, .table-responsive table, .data-table-wrap table, .responsive-table table {
    min-width: 680px;
  }
  table { width: 100%; }

  /* Buttons become easy to tap without forcing huge toolbars. */
  .btn, button, .fu-btn, .cb-act {
    min-height: 44px;
  }
  .form-actions, .docs-toolbar, .docs-actions {
    width: 100%;
    gap: 8px;
  }
  .form-actions .btn, .docs-actions .btn {
    flex: 1 1 auto;
  }

  /* Modals fit the viewport and scroll inside the modal only. */
  .modal, [role="dialog"] {
    padding: max(8px, env(safe-area-inset-top, 0px)) 8px max(8px, env(safe-area-inset-bottom, 0px)) !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .modal-content, .modal > div, [role="dialog"] > div {
    width: min(100%, 560px) !important;
    max-width: 560px !important;
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    margin: 8px auto !important;
    border-radius: 14px !important;
  }

  /* Sidebar drawer never changes document width. */
  .sidebar { max-height: 100dvh !important; height: 100dvh !important; }
  .sidebar-nav { overflow-y: auto !important; overscroll-behavior: contain; }
  .sidebar-footer { padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important; }

  /* Bottom navigation stays above the phone home indicator. */
  .mobile-bottom-nav {
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px)) !important;
    min-height: calc(58px + env(safe-area-inset-bottom, 0px));
  }

  /* Chatbot: full-width mobile sheet, stable input area. */
  .chatbot-container, .chat-container, .cb-shell, .cb-modal {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  .chat-messages, .cb-messages, .chatbot-messages {
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .chat-input, .cb-input, .chatbot-input {
    position: sticky;
    bottom: 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    background: inherit;
  }
  .chat-input input, .cb-input input, .chatbot-input input {
    min-height: 46px !important;
    font-size: 16px !important; /* prevents iOS zoom */
  }

  /* Follow-up cards: stack controls instead of squeezing them. */
  .fu-toolbar, .followup-toolbar, .filters, .filter-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .fu-toolbar > *, .followup-toolbar > *, .filters > *, .filter-row > * {
    flex: 1 1 140px;
    min-width: 0 !important;
  }
  .fu-card, .followup-card, .fu-mcard, .cb-mcard {
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  .action-btns { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; }

  /* Avoid fixed-width inline panels creating horizontal page movement. */
  [style*="width:"], [style*="min-width:"] { max-width: 100%; }
  img, video, iframe { max-width: 100%; }
  iframe { border: 0; width: 100%; }
}

@media (max-width: 390px) {
  .content-area { padding: 8px !important; }
  .topbar { padding-left: 8px !important; padding-right: 8px !important; }
  .topbar-left h1 { font-size: 14px !important; }
  .mobile-menu-btn { width: 40px; height: 40px; }
  .mobile-bottom-nav a { min-width: 50px; padding-left: 5px; padding-right: 5px; }
}
