/* ============================================================
   BiasharaFlow Phase 1A — Complete Mobile-First CSS
   Font: DM Sans (Google Fonts)
   Palette: Deep Forest Green + Gold Accent
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    /* Brand */
    --primary:       #0B6B3A;
    --primary-dk:    #0B2D20;
    --primary-lt:    #E8F5EE;
    --accent:        #C9930A;
    --accent-lt:     #FFF8E6;

    /* Semantic */
    --green:         #16A34A;
    --green-dk:      #166534;
    --red:           #DC2626;
    --red-lt:        #FEF2F2;
    --orange:        #D97706;
    --orange-lt:     #FFFBEB;
    --blue:          #2563EB;
    --blue-lt:       #EFF6FF;
    --purple:        #7C3AED;
    --purple-lt:     #F5F3FF;
    --gold:          #B45309;
    --gold-lt:       #FEFCE8;
    --wa-green:      #25D366;

    /* Neutral */
    --bg:            #F2F5F2;
    --card-bg:       #FFFFFF;
    --text:          #111827;
    --text-2:        #4B5563;
    --text-3:        #9CA3AF;
    --border:        #E5E7E5;
    --muted:         #6B7280;

    /* Shadows */
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:        0 4px 16px rgba(0,0,0,0.09);
    --shadow-lg:     0 8px 32px rgba(0,0,0,0.14);

    /* Layout */
    --radius:        14px;
    --radius-sm:     8px;
    --radius-lg:     20px;
    --nav-h:         58px;
    --bottom-h:      68px;

    /* Font */
    --font:          'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:     'DM Mono', 'Courier New', monospace;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--primary-dk) 0%, #143D2B 55%, #1A5C38 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.auth-wrap { width: 100%; max-width: 440px; }
.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
}
.auth-card-lg { max-width: 480px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-mark { font-size: 52px; margin-bottom: 6px; }
.auth-brand { font-size: 28px; font-weight: 800; color: var(--primary-dk); letter-spacing: -1px; }
.auth-tagline { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.auth-alt { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-2); }
.auth-alt a { color: var(--primary); font-weight: 600; }
.demo-hint {
    text-align: center; margin-top: 16px;
    padding: 12px; background: var(--primary-lt);
    border-radius: var(--radius-sm);
    font-size: 13px; color: var(--primary-dk);
}
.demo-hint code {
    background: rgba(11,45,32,0.1); padding: 2px 6px;
    border-radius: 4px; font-size: 12px;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--primary-dk);
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-menu-btn {
    background: none; border: none;
    display: flex; flex-direction: column;
    gap: 5px; padding: 6px; border-radius: 6px;
}
.nav-menu-btn span {
    display: block; width: 22px; height: 2px;
    background: #fff; border-radius: 2px;
    transition: 0.2s ease;
}
.nav-biz-name {
    font-size: 15px; font-weight: 700; color: #fff;
    max-width: 200px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.nav-logo-link {
    font-size: 22px; text-decoration: none;
    color: var(--accent);
    line-height: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: 280px; height: 100dvh;
    background: var(--primary-dk);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    overflow-y: auto; overflow-x: hidden;
    box-shadow: var(--shadow-lg);
    -webkit-overflow-scrolling: touch;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150; display: none;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }
.sidebar-header {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { font-size: 17px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.sidebar-close {
    background: none; border: none;
    color: rgba(255,255,255,0.7); font-size: 26px;
    line-height: 1; padding: 4px 8px;
    border-radius: 6px;
}
.sidebar-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.sidebar-user {
    display: flex; align-items: center; gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-avatar {
    width: 40px; height: 40px;
    background: var(--accent); color: var(--primary-dk);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800; flex-shrink: 0;
}
.sidebar-user-name { font-weight: 600; color: #fff; font-size: 14px; }
.sidebar-user-phone { font-size: 12px; color: rgba(255,255,255,0.6); }
.sidebar-nav { padding: 8px 0; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 15px; font-weight: 500;
    border-left: 3px solid transparent;
    transition: 0.15s ease;
    text-decoration: none;
}
.nav-link:hover, .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--accent);
}
.nav-link-danger { color: rgba(255,120,120,0.8); }
.nav-link-danger:hover { color: #ff9999; background: rgba(220,38,38,0.1); border-left-color: var(--red); }
.nav-link-admin { color: var(--accent) !important; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-divider { border-top: 1px solid rgba(255,255,255,0.1); margin: 8px 16px; }

/* ── Bottom Nav ─────────────────────────────────────────────── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottom-h);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex; align-items: flex-start;
    padding-top: 6px;
    z-index: 90;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.07);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bn-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; gap: 3px;
    padding: 6px 4px;
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.15s ease;
    position: relative;
}
.bn-item.active { color: var(--primary); }
.bn-item.active::before {
    content: '';
    position: absolute; top: -6px;
    width: 30px; height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}
.bn-icon { font-size: 20px; line-height: 1; }
.bn-label { font-size: 10px; font-weight: 600; letter-spacing: 0.2px; }

/* ── Subscription Banner ────────────────────────────────────── */
.sub-banner {
    position: fixed; top: var(--nav-h);
    left: 0; right: 0;
    padding: 10px 16px;
    font-size: 13px; font-weight: 600;
    text-align: center; z-index: 80;
}
.sub-banner-warning { background: #FEF3C7; color: #92400E; }
.sub-banner-danger  { background: #FEE2E2; color: #991B1B; }

/* ── Flash Messages ─────────────────────────────────────────── */
.flash {
    position: fixed; top: calc(var(--nav-h) + 8px);
    left: 50%; transform: translateX(-50%);
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600;
    z-index: 1000; max-width: 92vw; width: max-content;
    display: flex; align-items: center; gap: 10px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
}
.flash-success { background: var(--green); color: #fff; }
.flash-danger  { background: var(--red);   color: #fff; }
.flash-warning { background: var(--orange); color: #fff; }
.flash-close {
    background: none; border: none;
    color: inherit; font-size: 20px;
    line-height: 1; opacity: 0.8; padding: 0 2px;
}
@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-16px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
    margin-top: var(--nav-h);
    padding: 18px 15px;
    padding-bottom: calc(var(--bottom-h) + 20px);
    max-width: 700px;
    margin-left: auto; margin-right: auto;
}
/* Extra top padding when subscription banner is visible */
.has-sub-banner .main-content { margin-top: calc(var(--nav-h) + 38px); }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: flex-start;
    justify-content: space-between; gap: 10px;
    margin-bottom: 18px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.page-sub   { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.card-warning { border-color: #FDE68A; background: #FFFBEB; }
.card-wa-highlight { border-left: 5px solid var(--wa-green); }
.card-title {
    font-size: 15px; font-weight: 700;
    color: var(--text); margin-bottom: 14px;
}
.card-header-row {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 12px;
}
.mb-0 { margin-bottom: 0 !important; }
.link-sm { font-size: 13px; font-weight: 600; color: var(--primary); }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px; margin-bottom: 14px;
}
.stats-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.stat-card {
    border-radius: var(--radius);
    padding: 16px 14px;
    box-shadow: var(--shadow-sm);
    color: #fff;
}
.stat-green      { background: linear-gradient(135deg, #0B6B3A, #0D8048); }
.stat-green-dark { background: linear-gradient(135deg, #166534, #15803D); }
.stat-red        { background: linear-gradient(135deg, #B91C1C, #DC2626); }
.stat-orange     { background: linear-gradient(135deg, #B45309, #D97706); }
.stat-blue       { background: linear-gradient(135deg, #1D4ED8, #2563EB); }
.stat-card:not([class*="stat-"]) { background: linear-gradient(135deg, #374151, #4B5563); }
.stat-label { font-size: 11px; font-weight: 700; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 20px; font-weight: 800; margin: 5px 0 2px; font-family: var(--font-mono); letter-spacing: -0.5px; }
.stat-sub   { font-size: 11px; opacity: 0.8; }

/* ── Period Summary ─────────────────────────────────────────── */
.period-grid { display: grid; grid-template-columns: 1fr 1px 1fr; gap: 14px; }
.period-sep  { background: var(--border); }
.period-head { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.period-row  { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.period-total { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 4px; font-weight: 700; }

/* ── Quick Actions ──────────────────────────────────────────── */
.quick-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.quick-grid-4 { grid-template-columns: repeat(4,1fr); }
.qa {
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    padding: 14px 8px; border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600; text-align: center;
    text-decoration: none; transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: none;
}
.qa:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.qa span:first-child { font-size: 22px; }
.qa-green  { background: var(--primary-lt);  color: var(--primary-dk); }
.qa-red    { background: var(--red-lt);       color: var(--red);       }
.qa-blue   { background: var(--blue-lt);      color: var(--blue);      }
.qa-wa     { background: #DCFCE7;             color: #166534;          }
.qa-purple { background: var(--purple-lt);    color: var(--purple);    }
.qa-gold   { background: var(--gold-lt);      color: var(--gold);      }

/* ── Lists ──────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-warn { background: linear-gradient(90deg, #FEF9C3 0%, transparent 100%); margin: 0 -18px; padding: 13px 18px; }
.list-item-avatar {
    width: 38px; height: 38px;
    background: var(--primary-lt); color: var(--primary-dk);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 800; flex-shrink: 0;
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.list-item-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.li-title { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub   { font-size: 12px; color: var(--text-2); margin-top: 2px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.li-amount    { font-size: 15px; font-weight: 700; font-family: var(--font-mono); }
.li-amount-sm { font-size: 12px; font-weight: 600; font-family: var(--font-mono); }
.list-total   { padding: 10px 0; text-align: right; font-size: 14px; font-weight: 600; color: var(--text-2); border-top: 2px solid var(--border); }

/* ── Debt Progress Bar ──────────────────────────────────────── */
.debt-bar { height: 5px; background: var(--border); border-radius: 3px; margin: 5px 0 3px; overflow: hidden; }
.debt-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px; border-radius: 30px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.3px;
    white-space: nowrap;
}
.bdg-paid      { background: #DCFCE7; color: #15803D; }
.bdg-unpaid    { background: #FEE2E2; color: #B91C1C; }
.bdg-partial   { background: #FEF3C7; color: #B45309; }
.bdg-active    { background: #DCFCE7; color: #15803D; }
.bdg-trial     { background: #DBEAFE; color: #1D4ED8; }
.bdg-overdue   { background: #FEE2E2; color: #B91C1C; }
.bdg-suspended { background: #F3F4F6; color: #374151; }
.bdg-cancelled { background: #F3F4F6; color: #6B7280; }
.bdg-cash      { background: #F3F4F6; color: #374151; }
.bdg-mpesa     { background: #DCFCE7; color: #15803D; }
.bdg-credit    { background: #FEF3C7; color: #B45309; }
.bdg-other     { background: #F3F4F6; color: #4B5563; }
.bdg-danger    { background: #FEE2E2; color: #B91C1C; }
.bdg-ref       { background: #EEF2FF; color: #4338CA; }
.bdg-unknown   { background: #F3F4F6; color: #6B7280; }

/* ── Filter Tabs ────────────────────────────────────────────── */
.filter-tabs {
    display: flex; gap: 6px; margin-bottom: 14px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.ftab {
    padding: 7px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 600; white-space: nowrap;
    background: var(--card-bg); border: 2px solid var(--border);
    color: var(--text-2); transition: 0.15s ease;
    text-decoration: none;
}
.ftab.ftab-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.ftab:hover:not(.ftab-active) { border-color: var(--primary); color: var(--primary); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-hint  { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.form-input {
    width: 100%; padding: 11px 13px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px; color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.15s ease;
    -webkit-appearance: none; appearance: none;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11,107,58,0.1);
}
textarea.form-input { resize: vertical; min-height: 76px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-row   { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-inline{ display: flex; gap: 8px; align-items: center; }
.search-wrap{ margin-bottom: 14px; }
.search-input { border-radius: 40px !important; padding-left: 16px !important; }
.input-eye  { position: relative; }
.eye-btn {
    position: absolute; right: 12px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    font-size: 16px; color: var(--text-3);
    padding: 4px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center;
    justify-content: center; gap: 6px;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600;
    border: none; transition: 0.15s ease;
    cursor: pointer; white-space: nowrap;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #0D8048; color: #fff; transform: translateY(-1px); }
.btn-ghost {
    background: transparent; color: var(--text-2);
    border: 2px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-wa { background: var(--wa-green); color: #fff; }
.btn-wa:hover { background: #1ebe5e; color: #fff; }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn-icon {
    background: none; border: none; padding: 6px 7px;
    font-size: 16px; border-radius: var(--radius-sm);
    transition: background 0.15s ease;
    display: inline-flex; align-items: center;
}
.btn-icon:hover { background: var(--primary-lt); }
.btn-icon-red:hover { background: var(--red-lt); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 12px 14px; border-radius: var(--radius-sm);
    font-size: 14px; margin-bottom: 12px; border: 1px solid;
}
.alert-danger  { background: var(--red-lt);    color: #991B1B; border-color: #FECACA; }
.alert-success { background: #F0FFF4;           color: #166534; border-color: #BBF7D0; }
.alert-warning { background: var(--orange-lt);  color: #92400E; border-color: #FDE68A; }
.alert-info    { background: var(--blue-lt);    color: #1E40AF; border-color: #BFDBFE; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-icon  { font-size: 44px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { margin-bottom: 14px; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0;
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 500;
}
.modal-bg {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
}
.modal-box {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%; max-width: 560px;
    max-height: 92dvh; overflow-y: auto;
    animation: slideUp 0.25s ease;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.modal-hdr {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 18px 20px 0;
}
.modal-hdr h3 { font-size: 17px; font-weight: 700; }
.modal-x {
    background: none; border: none;
    font-size: 26px; color: var(--text-2);
    line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.modal-x:hover { background: var(--bg); }
.modal-bd { padding: 16px 20px; }
.modal-cust { font-weight: 600; color: var(--primary); margin-bottom: 14px; font-size: 14px; }
.modal-ft {
    display: flex; gap: 10px;
    padding: 12px 20px 20px;
    border-top: 1px solid var(--border);
}

/* ── WhatsApp Preview ───────────────────────────────────────── */
.wa-preview {
    background: #ECE5DD;
    padding: 14px 15px;
    border-radius: var(--radius-sm);
    font-size: 14px; line-height: 1.6;
    color: #1A1A1A; margin: 12px 0;
    white-space: pre-wrap; word-break: break-word;
    border-left: 4px solid var(--wa-green);
    min-height: 60px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    background: var(--bg); padding: 9px 12px;
    text-align: left; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-2); border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.tfoot-total { background: var(--primary-lt); }
.tfoot-total td { font-size: 14px; }
.tr-warn td { background: #FFFBEB; }
.tr-danger td { background: #FEF2F2; }

/* ── Category Bars ──────────────────────────────────────────── */
.cat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.cat-label { width: 140px; flex-shrink: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar-wrap { flex: 1; height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.cat-bar-fill { height: 100%; background: var(--accent); border-radius: 5px; transition: width 0.4s ease; }
.cat-amt { white-space: nowrap; font-weight: 600; font-size: 12px; color: var(--text-2); }

/* ── Admin specific ─────────────────────────────────────────── */
.admin-user-header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.admin-user-biz { font-size: 16px; font-weight: 700; color: var(--text); }
.admin-user-name { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.admin-user-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.admin-sub-info { font-size: 13px; color: var(--text-2); margin-bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ── Subscription payment note ──────────────────────────────── */
.sub-payment-note { margin-top: 12px; padding: 12px; background: var(--primary-lt); border-radius: var(--radius-sm); font-size: 13px; color: var(--primary-dk); }
.sub-payment-note p { margin-bottom: 4px; }

/* ── Utilities ──────────────────────────────────────────────── */
.c-g    { color: var(--green)  !important; }
.c-r    { color: var(--red)    !important; }
.c-muted{ color: var(--muted)  !important; }
code    { font-family: var(--font-mono); font-size: 0.9em; background: var(--bg); padding: 2px 6px; border-radius: 4px; }

/* ── Desktop ────────────────────────────────────────────────── */
@media (min-width: 600px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .quick-grid { grid-template-columns: repeat(6, 1fr); }
    .quick-grid-4 { grid-template-columns: repeat(4, 1fr); }
    .main-content { padding: 22px 20px calc(var(--bottom-h) + 22px); }
}
@media (min-width: 900px) {
    .sidebar { position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); transform: none; }
    .bottom-nav { display: none; }
    .main-content { padding-bottom: 30px; }
}

/* ── Language Switchers ───────────────────────────────────── */
.auth-lang-switcher {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.auth-lang-switcher select,
.sidebar-lang-switcher select {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.sidebar-lang-switcher {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: grid;
    gap: 8px;
}

.sidebar-lang-switcher label {
    color: rgba(255,255,255,0.78);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.sidebar-lang-switcher select {
    width: 100%;
    border-color: rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-lang-switcher option {
    color: var(--text);
}

/* ============================================================
   Phase 1B.3 Layout Correction
   Fixes excessive top whitespace on logged-in app/admin pages.
   ============================================================ */
body:not(.auth-body) .main-content {
    margin-top: 0 !important;
    padding-top: calc(var(--nav-h) + 16px) !important;
    padding-bottom: calc(var(--bottom-h) + 24px) !important;
    min-height: auto !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
}

body:not(.auth-body).has-sub-banner .main-content {
    padding-top: calc(var(--nav-h) + 52px) !important;
}

body:not(.auth-body) .page-header {
    margin-top: 0 !important;
}

@media (min-width: 900px) {
    body:not(.auth-body) .main-content {
        max-width: 1040px !important;
        padding-left: 28px !important;
        padding-right: 28px !important;
    }
}

/* ============================================================
   Phase 1B.4 Dashboard Graph + Non-Dashboard Topspace Control
   ============================================================ */

/* Non-dashboard pages should start high and clean */
body:not(.auth-body):not(.page-dashboard):not(.admin-mode.page-index) .main-content {
    padding-top: calc(var(--nav-h) + 8px) !important;
}

/* Dashboard pages get comfortable executive spacing */
body.page-dashboard .main-content,
body.admin-mode.page-index .main-content {
    padding-top: calc(var(--nav-h) + 14px) !important;
}

/* If subscription banner exists, protect space for it */
body.has-sub-banner:not(.auth-body):not(.page-dashboard):not(.admin-mode.page-index) .main-content {
    padding-top: calc(var(--nav-h) + 44px) !important;
}

body.has-sub-banner.page-dashboard .main-content,
body.has-sub-banner.admin-mode.page-index .main-content {
    padding-top: calc(var(--nav-h) + 52px) !important;
}

.dashboard-hero-card {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 22px;
    align-items: stretch;
    background:
        radial-gradient(circle at 18% 0%, rgba(201,147,10,.22), transparent 30%),
        linear-gradient(135deg, #0B2D20 0%, #0B6B3A 58%, #0E3A2A 100%);
    border-radius: 24px;
    padding: 24px;
    margin: 0 0 18px;
    color: #fff;
    box-shadow: 0 18px 44px rgba(11,45,32,.22);
}

.dashboard-hero-card::after {
    content: "";
    position: absolute;
    right: -80px;
    top: -80px;
    width: 220px;
    height: 220px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
}

.admin-hero-card {
    background:
        radial-gradient(circle at 18% 0%, rgba(201,147,10,.22), transparent 30%),
        linear-gradient(135deg, #111827 0%, #0B2D20 52%, #14532D 100%);
}

.hero-copy,
.bf-chart-wrap {
    position: relative;
    z-index: 1;
}

.hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #FDE68A;
    margin-bottom: 8px;
}

.hero-copy h2 {
    font-size: clamp(22px, 4vw, 34px);
    line-height: 1.05;
    letter-spacing: -.04em;
    margin: 0 0 10px;
}

.hero-copy p {
    max-width: 560px;
    color: rgba(255,255,255,.82);
    font-size: 14px;
    margin: 0 0 14px;
}

.hero-mini-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hero-mini-stats span {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    padding: 8px 11px;
    font-size: 12px;
    color: rgba(255,255,255,.88);
}

.hero-mini-stats strong {
    color: #fff;
}

.bf-chart-wrap {
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 20px;
    padding: 14px;
    min-height: 210px;
    display: grid;
    align-content: space-between;
}

.bf-chart-legend {
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    margin-bottom: 10px;
    color: rgba(255,255,255,.82);
    font-size: 12px;
    font-weight: 800;
}

.legend-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    margin-right: 5px;
}

.legend-sales {
    background: #FDE68A;
}

.legend-expenses {
    background: #FCA5A5;
}

.bf-mini-chart {
    height: 155px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    align-items: end;
}

.admin-mini-chart {
    grid-template-columns: repeat(5, 1fr);
}

.bf-chart-day {
    height: 100%;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 8px;
    text-align: center;
    color: rgba(255,255,255,.82);
    font-size: 11px;
    font-weight: 800;
}

.bf-bars {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 4px;
    height: 100%;
    min-height: 110px;
}

.bf-bars.single-bar .bf-bar {
    width: 24px;
}

.bf-bar {
    display: block;
    width: 12px;
    min-height: 8px;
    border-radius: 999px 999px 4px 4px;
    box-shadow: 0 10px 18px rgba(0,0,0,.16);
}

.bf-bar-sales {
    background: linear-gradient(180deg, #FDE68A, #C9930A);
}

.bf-bar-expenses {
    background: linear-gradient(180deg, #FCA5A5, #DC2626);
}

.bf-bar-trial {
    background: linear-gradient(180deg, #93C5FD, #2563EB);
}

.bf-bar-danger {
    background: linear-gradient(180deg, #FCA5A5, #991B1B);
}

.bf-bar-muted {
    background: linear-gradient(180deg, #D1D5DB, #6B7280);
}

@media (max-width: 760px) {
    .dashboard-hero-card {
        grid-template-columns: 1fr;
        padding: 20px;
        border-radius: 22px;
    }

    .bf-chart-wrap {
        min-height: 190px;
    }

    .bf-mini-chart {
        height: 140px;
        gap: 7px;
    }

    .hero-copy h2 {
        font-size: 24px;
    }
}

/* ============================================================
   Phase 1B.5 — Dashboard Space + Sidebar Overlay Fix
   Fixes:
   1. Dashboard hero should occupy the top space.
   2. Sidebar should not cover dashboard wording on desktop.
   3. Other pages should start closer to the top.
   ============================================================ */

/* Hide old page header only on dashboard pages because the graph is now the header */
body.page-dashboard .page-header,
body.admin-mode.page-index .page-header {
    display: none !important;
}

/* Dashboard graph should sit immediately below navbar */
body.page-dashboard .main-content,
body.admin-mode.page-index .main-content {
    padding-top: calc(var(--nav-h) + 10px) !important;
}

/* Other pages should not have dashboard-style whitespace */
body:not(.auth-body):not(.page-dashboard):not(.admin-mode.page-index) .main-content {
    padding-top: calc(var(--nav-h) + 8px) !important;
}

/* If subscription banner is present, preserve only necessary space */
body.has-sub-banner.page-dashboard .main-content,
body.has-sub-banner.admin-mode.page-index .main-content {
    padding-top: calc(var(--nav-h) + 44px) !important;
}

body.has-sub-banner:not(.auth-body):not(.page-dashboard):not(.admin-mode.page-index) .main-content {
    padding-top: calc(var(--nav-h) + 42px) !important;
}

/* Desktop sidebar should push content, not cover it */
@media (min-width: 900px) {
    .sidebar.open ~ .sidebar-overlay {
        display: none !important;
        pointer-events: none !important;
    }

    .sidebar.open ~ .main-content {
        width: calc(100% - 280px) !important;
        max-width: calc(100% - 280px) !important;
        margin-left: 280px !important;
        margin-right: 0 !important;
        padding-left: 24px !important;
        padding-right: 24px !important;
    }

    .sidebar.open ~ .main-content .dashboard-hero-card,
    .sidebar.open ~ .main-content .card,
    .sidebar.open ~ .main-content .stats-grid {
        max-width: 1120px !important;
    }
}

/* Make dashboard hero readable on narrower screens */
.dashboard-hero-card {
    width: 100% !important;
}

.dashboard-hero-card .hero-copy h2 {
    overflow-wrap: anywhere;
}

.dashboard-hero-card .hero-copy p {
    overflow-wrap: anywhere;
}

/* Prevent chart labels from being squeezed unreadably */
.bf-chart-day small {
    line-height: 1.25 !important;
    word-break: normal !important;
}

/* Mobile keeps sidebar as overlay */
@media (max-width: 899px) {
    .sidebar.open ~ .main-content {
        margin-left: auto !important;
        margin-right: auto !important;
        width: auto !important;
        max-width: 700px !important;
    }
}
