/* ====================================================================
   VELBOOKS BOOKER — MOBILE-FIRST PWA DESIGN
   Same palette tokens as the ERP. Optimised for field use.
==================================================================== */

/* ===== VEL DIALOG (Premium Alert/Confirm) ===== */
.vd-overlay {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0); backdrop-filter: blur(0px);
    transition: background 0.25s ease, backdrop-filter 0.25s ease;
    padding: 16px;
}
.vd-overlay.vd-visible {
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
}
.vd-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.05);
    max-width: 420px; width: 100%;
    padding: 28px 24px;
    text-align: center;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}
.vd-dialog.vd-enter {
    transform: scale(1) translateY(0);
    opacity: 1;
}
.vd-dialog.vd-exit {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.vd-icon-wrap {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
}
.vd-icon { width: 24px; height: 24px; }
.vd-icon svg { width: 100%; height: 100%; }
.vd-title {
    font-size: 17px; font-weight: 700; color: var(--text-primary);
    margin-bottom: 6px; line-height: 1.3;
}
.vd-message {
    font-size: 14px; color: var(--text-secondary);
    line-height: 1.6; margin-bottom: 24px;
    white-space: pre-line; word-break: break-word;
}
.vd-actions {
    display: flex; flex-direction: column-reverse; gap: 10px;
}
.vd-btn {
    padding: 10px; border-radius: 999px; font-size: 14px; font-weight: 600;
    border: none; cursor: pointer; transition: all 0.15s ease;
    width: 100%; letter-spacing: 0.01em;
}
.vd-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.vd-btn-primary {
    background: var(--accent); color: #fff;
}
.vd-btn-primary:hover { filter: brightness(1.1); }
.vd-btn-secondary {
    background: var(--bg-main); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.vd-btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.vd-btn-danger {
    background: #ef4444; color: #fff;
}
.vd-btn-danger:hover { background: #dc2626; }

:root {
    /* Light mode — Ice Effect base */
    --bg-app: #F2F2F7;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F5F5FA;
    --bg-input: #FFFFFF;
    --bg-sheet: #FFFFFF;

    --border: #D1D5DB;
    --border-light: #E5E7EB;

    --text-1: #111827;
    --text-2: #4B5563;
    --text-3: #9CA3AF;
    --text-4: #D1D5DB;

    --accent: #007AFF;
    --accent-hover: #0062CC;
    --accent-dim: rgba(0, 122, 255, 0.08);
    --accent-light: rgba(0, 122, 255, 0.12);
    --accent-text: #0055B3;

    --green: #10B981;
    --green-dim: rgba(16, 185, 129, 0.10);
    --green-text: #059669;

    --red: #EF4444;
    --red-dim: rgba(239, 68, 68, 0.08);
    --red-text: #DC2626;

    --amber: #F59E0B;
    --amber-dim: rgba(245, 158, 11, 0.08);
    --amber-text: #D97706;

    --shadow-sm: 0 1px 2px rgba(0, 43, 76, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 43, 76, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 43, 76, 0.08);

    --radius: 12px;
    --radius-sm: 8px;
    --nav-height: 64px;
    --header-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-app: #0F172A;
        --bg-card: #1E293B;
        --bg-card-hover: rgba(255, 255, 255, 0.04);
        --bg-input: #283548;
        --bg-sheet: #1E293B;
        --border: rgba(255, 255, 255, 0.10);
        --border-light: rgba(255, 255, 255, 0.06);
        --text-1: #F1F5F9;
        --text-2: #CBD5E1;
        --text-3: #94A3B8;
        --text-4: #64748B;
        --accent: #0A84FF;
        --accent-hover: #409CFF;
        --accent-dim: rgba(10, 132, 255, 0.15);
        --accent-light: rgba(10, 132, 255, 0.18);
        --accent-text: #64B5FF;
        --green: #34D399;
        --green-dim: rgba(52, 211, 153, 0.10);
        --green-text: #6EE7B7;
        --red: #F87171;
        --red-dim: rgba(248, 113, 113, 0.10);
        --red-text: #FCA5A5;
        --amber: #FBBF24;
        --amber-dim: rgba(251, 191, 36, 0.10);
        --amber-text: #FCD34D;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
        --shadow-md: 0 2px 8px rgba(0,0,0,0.25);
        --shadow-lg: 0 4px 16px rgba(0,0,0,0.3);
    }
}

[data-theme="dark"] {
    --bg-app: #0F172A;
    --bg-card: #1E293B;
    --bg-card-hover: rgba(255, 255, 255, 0.04);
    --bg-input: #283548;
    --bg-sheet: #1E293B;
    --border: rgba(255, 255, 255, 0.10);
    --border-light: rgba(255, 255, 255, 0.06);
    --text-1: #F1F5F9;
    --text-2: #CBD5E1;
    --text-3: #94A3B8;
    --text-4: #64748B;
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-dim: rgba(10, 132, 255, 0.15);
    --accent-light: rgba(10, 132, 255, 0.18);
    --accent-text: #64B5FF;
    --green: #34D399;
    --green-dim: rgba(52, 211, 153, 0.10);
    --green-text: #6EE7B7;
    --red: #F87171;
    --red-dim: rgba(248, 113, 113, 0.10);
    --red-text: #FCA5A5;
    --amber: #FBBF24;
    --amber-dim: rgba(251, 191, 36, 0.10);
    --amber-text: #FCD34D;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior-y: contain; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-app);
    color: var(--text-1);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ===== SPLASH ===== */
.splash {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #F8FAFC;
    color: #0F1B2D;
}
.splash-title { font-family: 'Outfit', 'Inter', sans-serif; font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.splash-sub { font-size: 14px; font-weight: 500; opacity: 0.5; margin-top: 4px; }

/* ===== LOGIN ===== */
.screen {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-app); padding: 24px;
}
.login-card { width: 100%; max-width: 360px; }
.login-title { text-align: center; font-family: 'Outfit', 'Inter', sans-serif; font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 13px; color: var(--text-3); margin-bottom: 24px; }
.login-error {
    background: var(--red-dim); color: var(--red-text); font-size: 13px;
    padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
}

/* ===== FIELDS ===== */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; font-weight: 600; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 8px 12px; font-size: 14px; font-family: inherit;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-input); color: var(--text-1);
    transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.select-field {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-input); cursor: pointer; font-size: 14px; color: var(--text-2);
}
.select-field.has-value { color: var(--text-1); font-weight: 500; }

/* ===== PASSWORD TOGGLE ===== */
.pass-toggle {
    position: absolute; right: 12px; top: 32px;
    width: 28px; height: 28px; border: none; background: none; cursor: pointer;
    color: var(--text-4); padding: 2px; border-radius: 4px;
}
.pass-toggle:active { color: var(--text-2); }
.pass-toggle svg { width: 100%; height: 100%; }

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 16px; font-size: 13px; font-weight: 600; font-family: inherit;
    background: var(--accent); color: #fff; border: none; border-radius: 999px;
    cursor: pointer; transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { opacity: 0.7; transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 16px; font-size: 13px; font-weight: 600; font-family: inherit;
    background: #d32f2f; color: #fff; border: none; border-radius: 999px;
    cursor: pointer; transition: opacity 0.15s; width: 100%; margin-top: 12px;
}
.btn-danger:hover { opacity: 0.85; }
.btn-danger:active { opacity: 0.7; transform: scale(0.97); }
.btn-full { width: 100%; }
.btn-lg { padding: 9px 18px; font-size: 14px; }
.btn-outline-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 16px; font-size: 13px; font-weight: 600; font-family: inherit;
    background: transparent; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px;
    cursor: pointer; transition: all 0.15s;
}
.btn-outline-primary:hover { border-color: var(--border-hover); color: var(--text-1); }
.btn-outline-primary:active { opacity: 0.7; transform: scale(0.97); }
.btn-outline-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 16px; font-size: 13px; font-weight: 600; font-family: inherit;
    background: transparent; color: var(--red-text); border: 1px solid var(--red); border-radius: 999px;
    cursor: pointer; transition: opacity 0.15s;
}
.btn-outline-danger:hover { opacity: 0.85; }
.btn-outline-danger:active { opacity: 0.7; transform: scale(0.97); }
.btn-text-danger { background: none; border: none; color: var(--red-text); font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; padding: 5px 8px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.spinner {
    width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== APP HEADER ===== */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    height: var(--header-height); padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
    background: #1C1917; border-bottom: none;
    box-shadow: none;
    color: #F5F5F4;
}
.app-header .header-name { color: #F5F5F4; }
.app-header .header-company { color: #A8A29E; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
    color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.header-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.header-company { font-size: 11px; color: var(--text-3); }
.header-right { display: flex; align-items: center; gap: 8px; }

.sync-indicator {
    display: flex; align-items: center; gap: 6px; padding: 4px 10px;
    border-radius: 20px; background: var(--green-dim); cursor: pointer; font-size: 11px; font-weight: 600; color: var(--green-text);
}
.sync-indicator.offline { background: var(--red-dim); color: var(--red-text); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.sync-dot.offline { background: var(--red); }
.sync-indicator.syncing { background: var(--amber-dim); color: var(--amber-text); }
.sync-indicator.syncing .sync-dot { background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ===== PAGE CONTAINER ===== */
.page-container {
    position: fixed;
    top: var(--header-height); bottom: calc(var(--nav-height) + var(--safe-bottom));
    left: 0; right: 0; overflow: hidden;
}
.page {
    position: absolute; inset: 0;
    display: none; overflow: hidden;
}
.page.active { display: flex; flex-direction: column; }
.page-scroll {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 14px 16px calc(14px + var(--safe-bottom));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}


/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: flex; align-items: center; justify-content: space-around;
    background: var(--bg-card); border-top: 1px solid var(--border-light);
    box-shadow: none;
}
.nav-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; background: none; border: none; cursor: pointer;
    color: var(--text-4); font-size: 10px; font-weight: 500; font-family: inherit;
    transition: color 0.15s;
}
.nav-tab svg { width: 22px; height: 22px; }
.nav-tab.active { color: var(--accent); }
.nav-tab.active svg { stroke: var(--accent); }
.nav-center { position: relative; }
.nav-fab {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.35);
    margin-top: -14px;
}
.nav-fab svg { width: 22px; height: 22px; stroke: #fff; }
.nav-center.active .nav-fab { background: var(--accent-hover); }

/* ===== DASHBOARD ===== */
.greeting { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.dash-date { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }
.stat-row { display: flex; gap: 10px; margin-bottom: 10px; }
.stat-card {
    flex: 1; padding: 12px; border-radius: 12px;
    background: var(--bg-card); border: 1px solid var(--border);
}
.stat-card.accent { background: var(--accent-dim); border-color: transparent; }
.stat-link { font: inherit; text-align: left; color: inherit; cursor: pointer; min-height: 72px; }
.stat-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.stat-link:active { filter: brightness(.95); }
.dashboard-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dashboard-detail-actions button { min-height: 44px; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green { background: var(--green-dim); border-color: transparent; }
.stat-card.green .stat-value { color: var(--green-text); }
.stat-value { font-size: 22px; font-weight: 800; line-height: 1; margin-bottom: 3px; }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }

.section-title {
    font-size: 12px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin: 16px 0 8px; display: flex; align-items: center; gap: 6px;
}
.badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px;
    background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
}

/* ===== CARDS & LISTS ===== */
.card-list { display: flex; flex-direction: column; gap: 8px; }
.card-item {
    padding: 12px; border-radius: var(--radius); background: var(--bg-card);
    border: 1px solid var(--border); cursor: pointer; transition: background 0.1s;
}
.card-item:active { background: var(--bg-card-hover); }
.card-row { display: flex; justify-content: space-between; align-items: center; }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-amount { font-size: 15px; font-weight: 700; text-align: right; }
.card-amount.danger { color: var(--red-text); }
.card-badge {
    display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px;
    border-radius: 4px; text-transform: uppercase;
}
.card-badge.pending { background: var(--amber-dim); color: var(--amber-text); }
.card-badge.confirmed { background: var(--green-dim); color: var(--green-text); }
.card-badge.invoiced { background: var(--accent-dim); color: var(--accent-text); }
.card-badge.cancelled { background: var(--red-dim); color: var(--red-text); }
.card-badge.synced { background: var(--green-dim); color: var(--green-text); }
.card-badge.queued { background: var(--amber-dim); color: var(--amber-text); }

/* ===== SEARCH ===== */
.search-bar {
    position: relative; margin-bottom: 12px;
}
.search-bar .search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--text-4); pointer-events: none;
}
.search-bar input {
    width: 100%; padding: 8px 14px 8px 38px; font-size: 14px; font-family: inherit;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); color: var(--text-1);
}
.search-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.list-count { font-size: 12px; color: var(--text-4); margin-bottom: 8px; }

/* ===== BACK BUTTON ===== */
.back-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: none; cursor: pointer;
    color: var(--accent); font-size: 14px; font-weight: 600; font-family: inherit;
    padding: 4px 0; margin-bottom: 12px;
}
.back-btn svg { width: 18px; height: 18px; }

.page-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.order-no { font-size: 12px; color: var(--text-3); margin: -12px 0 16px; font-weight: 600; }

/* ===== DETAIL PAGE ===== */
.detail-header { margin-bottom: 12px; }
.detail-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px;
}
.detail-stat {
    padding: 12px; border-radius: var(--radius-sm); background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}
.detail-stat-label { font-size: 10px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.5px; }
.detail-stat-value { font-size: 16px; font-weight: 700; margin-top: 2px; }
.detail-stat-value.danger { color: var(--red-text); }
.detail-stat-value.accent { color: var(--accent); }

/* Outstanding banner */
.cust-banner {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.cust-banner-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.cust-banner-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cust-banner-amount {
    font-size: 24px;
    font-weight: 800;
    color: var(--red-text);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}
.cust-banner-right { text-align: right; }
.cust-banner-invoices {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}
.cust-banner-oldest {
    font-size: 11px;
    color: var(--red-text);
    font-weight: 600;
    margin-top: 2px;
}
.cust-banner-clear {
    text-align: center;
    padding: 14px;
}
.cust-credit-bar {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    margin-bottom: 4px;
    overflow: hidden;
}
.cust-credit-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.cust-credit-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-4);
    font-weight: 600;
    margin-bottom: 12px;
}
.cust-credit-labels .danger { color: var(--red-text); }
.cust-aging-row {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}
.cust-aging-cell {
    flex: 1;
    text-align: center;
    padding: 6px 2px;
    background: var(--bg-app);
    border-radius: 6px;
}
.cust-aging-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.cust-aging-val {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}
.cust-aging-val.warn { color: var(--amber-text); }
.cust-aging-val.danger { color: var(--red-text); }
.cust-last-payment {
    font-size: 11px;
    color: var(--text-3);
    font-weight: 500;
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
}

/* Invoice outstanding list */
.inv-aging-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--accent-dim);
    color: var(--accent-text);
    margin-left: 4px;
}
.inv-aging-badge.overdue-med { background: rgba(245,158,11,0.1); color: var(--amber-text); }
.inv-aging-badge.overdue-high { background: rgba(244,63,94,0.08); color: var(--red-text); }
.inv-aging-badge.overdue-critical { background: rgba(244,63,94,0.15); color: var(--red-text); }
.inv-outstanding-card.overdue-critical { border-left: 3px solid var(--red-text); }
.inv-outstanding-card.overdue-high { border-left: 3px solid var(--amber-text); }

/* Visit notes */
.note-add-form {
    padding: 12px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border-light);
    margin-bottom: 12px;
}
.note-textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-app);
    color: var(--text-1);
    resize: vertical;
    min-height: 50px;
}
.note-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.note-card {
    padding: 12px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    margin-bottom: 8px;
}
.note-meta {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-4);
    margin-bottom: 4px;
}
.note-text {
    font-size: 13px;
    color: var(--text-1);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Form styles for new customer */
.form-group { margin-bottom: 12px; }
.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-1);
    transition: border-color 0.15s;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Pending approval badge */
.cust-pending-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(245,158,11,0.12);
    color: var(--amber-text);
    margin-left: 6px;
}

.detail-tabs {
    display: flex; gap: 4px; margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light); padding-bottom: 0;
}
.tab {
    flex: 1; padding: 10px 0; background: none; border: none; border-bottom: 2px solid transparent;
    font-size: 13px; font-weight: 600; color: var(--text-3); cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.detail-actions { display: flex; gap: 10px; margin-top: 20px; }
.detail-actions .btn-primary, .detail-actions .btn-outline-primary { flex: 1; font-size: 13px; padding: 8px; }

/* ===== ORDER / PRODUCT ===== */
.product-search-wrap { position: relative; margin-bottom: 8px; }
.product-search-wrap .search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--text-4); pointer-events: none;
}
.product-search-wrap input {
    width: 100%; padding: 11px 14px 11px 38px; font-size: 15px; font-family: inherit;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-card); color: var(--text-1);
}
.product-search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.product-dropdown {
    position: relative; max-height: 220px; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); margin-bottom: 8px;
}
.product-option {
    padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}
.product-option:last-child { border-bottom: none; }
.product-option:active { background: var(--accent-dim); }
.product-option-name { font-size: 14px; font-weight: 600; }
.product-option-info { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.product-option-stock { font-size: 11px; font-weight: 700; margin-left: 6px; }
.product-option-stock.in-stock { color: var(--green-text); }
.product-option-stock.out-stock { color: var(--red-text); }

.order-lines { display: flex; flex-direction: column; gap: 8px; }
.order-line {
    padding: 12px; border-radius: var(--radius-sm); background: var(--bg-card);
    box-shadow: var(--shadow-sm); position: relative;
}
.order-line-name { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding-right: 24px; }
.order-line-stock { font-size: 11px; font-weight: 700; margin-left: 6px; }
.order-line-stock.in-stock { color: var(--green-text); }
.order-line-stock.out-stock { color: var(--red-text); }
.order-line-fields { display: flex; gap: 8px; align-items: flex-end; }
.order-line-field { flex: 1; }
.order-line-field label { display: block; font-size: 10px; color: var(--text-4); margin-bottom: 3px; font-weight: 600; }
.order-line-field input {
    width: 100%; padding: 8px 10px; font-size: 14px; font-family: inherit;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-input); color: var(--text-1);
}
.order-line-field input:focus { outline: none; border-color: var(--accent); }
.order-line-field select {
    width: 100%; padding: 8px 6px; font-size: 14px; font-family: inherit;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-input); color: var(--text-1); appearance: auto;
}
.order-line-field select:focus { outline: none; border-color: var(--accent); }
.order-line-total { font-size: 13px; font-weight: 700; color: var(--accent); text-align: right; margin-top: 6px; }
.order-line-remove {
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--red-dim); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.order-line-remove svg { width: 14px; height: 14px; stroke: var(--red-text); }

.empty-state {
    padding: 40px 20px; text-align: center; color: var(--text-4); font-size: 14px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}

/* ===== ORDER TOTALS ===== */
.order-totals {
    margin-top: 12px; padding: 14px;
    border-radius: var(--radius-sm); background: var(--bg-card); box-shadow: var(--shadow-sm);
}
.total-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); padding: 4px 0; }
.total-row.total-net { font-size: 16px; font-weight: 700; color: var(--text-1); border-top: 1px solid var(--border-light); padding-top: 8px; margin-top: 4px; }

.bottom-action { margin-top: 16px; padding-bottom: 8px; }

/* ===== COLLECTION ===== */
.alloc-toggle { display: flex; gap: 4px; margin-bottom: 14px; background: var(--bg-card); border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--border); }
.alloc-btn {
    flex: 1; padding: 10px; font-size: 13px; font-weight: 600; font-family: inherit;
    border: none; border-radius: 6px; cursor: pointer;
    background: transparent; color: var(--text-3); transition: all 0.15s;
}
.alloc-btn.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }

.invoice-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.invoice-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; border-radius: var(--radius-sm); background: var(--bg-card); box-shadow: var(--shadow-sm);
}
.invoice-check { flex-shrink: 0; }
.invoice-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.invoice-info { flex: 1; min-width: 0; }
.invoice-no { font-size: 13px; font-weight: 600; }
.invoice-date { font-size: 11px; color: var(--text-4); }
.invoice-amt { text-align: right; flex-shrink: 0; }
.invoice-amt-total { font-size: 12px; color: var(--text-3); }
.invoice-amt-input { width: 90px; }
.invoice-amt-input input {
    width: 100%; padding: 6px 8px; font-size: 13px; font-family: inherit; text-align: right;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-input); color: var(--text-1);
}
.invoice-amt-input input:focus { outline: none; border-color: var(--accent); }

.alloc-summary {
    display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3);
    padding: 8px 0; border-top: 1px solid var(--border-light);
}

/* ===== SYNC PAGE ===== */
.sync-status-card {
    padding: 24px; text-align: center; border-radius: var(--radius);
    background: var(--bg-card); box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.sync-status-icon { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--green); }
.sync-status-icon svg { width: 100%; height: 100%; }
.sync-status-icon.pending { color: var(--amber); }
.sync-status-icon.error { color: var(--red); }
.sync-status-text { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.sync-last { font-size: 12px; color: var(--text-4); }

.cache-info {
    font-size: 13px; color: var(--text-2);
    background: var(--bg-card); border-radius: var(--radius-sm); padding: 12px;
    box-shadow: var(--shadow-sm);
}
.cache-row { display: flex; justify-content: space-between; padding: 4px 0; }

/* ===== MODAL / PICKER ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.4); display: none;
}
.modal-overlay.is-open { display: block; }
.modal-sheet {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 201;
    overflow: hidden;
    background: var(--bg-sheet);
    padding: calc(var(--safe-top, 0px) + 8px) 16px calc(16px + var(--safe-bottom));
    box-shadow: var(--shadow-lg);
    transform: translateY(100%); transition: transform 0.25s ease-out;
    display: flex; flex-direction: column;
}
.modal-sheet.is-open { transform: translateY(0); }
.sheet-handle {
    width: 36px; height: 4px; border-radius: 2px; background: var(--border);
    margin: 4px auto 12px;
}
.picker-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light);
}
.picker-title { font-size: 17px; font-weight: 700; color: var(--text-1); }
.picker-close {
    background: none; border: none; cursor: pointer; padding: 4px;
    color: var(--text-3); border-radius: 50%;
}
.picker-close:active { background: var(--bg-card-hover); }
.picker-list { flex: 1; overflow-y: auto; }
.picker-item {
    padding: 14px 12px; border-bottom: 1px solid var(--border-light);
    cursor: pointer; transition: background 0.1s;
}
.picker-item:active { background: var(--accent-dim); }
.picker-item-name { font-size: 15px; font-weight: 600; }
.picker-item-info { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.picker-item-right { float: right; text-align: right; }
.picker-item-amount { font-size: 14px; font-weight: 700; color: var(--red-text); }

.pending-search-wrap { margin-bottom: 8px; }
.pending-search-input {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface-2);
    color: var(--text-1); font-size: 13px; outline: none;
    box-sizing: border-box;
}
.pending-search-input:focus { border-color: var(--accent); }
.pending-list { display: flex; flex-direction: column; gap: 6px; }
.pending-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--amber-dim); font-size: 13px;
}
.pending-item-type { font-weight: 600; }

/* ===== TOAST ===== */
.toast {
    position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    left: 50%; transform: translateX(-50%) translateY(100px);
    padding: 12px 20px; border-radius: var(--radius-sm);
    background: var(--text-1); color: var(--bg-app);
    font-size: 14px; font-weight: 600; z-index: 9000;
    box-shadow: var(--shadow-lg); transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    pointer-events: none; white-space: nowrap; opacity: 0;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.hiding { opacity: 0; transform: translateX(-50%) translateY(20px); }

/* ===== HEADER ICON BTN ===== */
.header-icon-btn {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-dim); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent); transition: background 0.15s;
}
.header-icon-btn:active { background: var(--accent-light); }
.header-icon-btn svg { width: 18px; height: 18px; }

/* ===== SUCCESS OVERLAY ===== */
.success-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center;
    padding: 24px;
}
.success-overlay.show { display: flex; }
.success-card {
    width: 100%; max-width: 320px;
    background: var(--bg-card); border-radius: var(--radius);
    padding: 32px 24px 24px; text-align: center;
    box-shadow: var(--shadow-lg);
    animation: successPop 0.3s ease-out;
}
@keyframes successPop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.success-icon { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--green); }
.success-icon svg { width: 100%; height: 100%; }
.success-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.success-amount { font-size: 28px; font-weight: 800; color: var(--accent); margin-bottom: 8px; }
.success-detail { font-size: 13px; color: var(--text-3); margin-bottom: 20px; }
.success-actions { display: flex; flex-direction: column; gap: 8px; }

/* ===== DETAIL VIEW ===== */
.detail-card {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow-sm); margin-bottom: 12px;
}
.detail-card-title { font-size: 11px; font-weight: 700; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.detail-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.detail-row-label { color: var(--text-3); }
.detail-row-value { font-weight: 600; text-align: right; }
.detail-item {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 10px 0; border-bottom: 1px solid var(--border-light);
}
.detail-item:last-child { border-bottom: none; }
.detail-item-name { font-size: 14px; font-weight: 600; }
.detail-item-info { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.detail-item-amount { font-size: 14px; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* ===== DASHBOARD ACTIONS ===== */
.dash-actions { display: flex; gap: 8px; margin: 16px 0 8px; flex-wrap: wrap; }
.dash-action-card {
    flex: 1 1 calc(33.33% - 6px); min-width: 90px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 8px; border-radius: var(--radius);
    background: var(--bg-card); box-shadow: var(--shadow-sm);
    border: none; cursor: pointer; font-family: inherit;
    font-size: 11px; font-weight: 600; color: var(--text-2);
    transition: background 0.1s;
}
.dash-action-card:active { background: var(--bg-card-hover); }
.dash-action-card svg { color: var(--accent); }

.dash-pending-banner {
    display: flex; align-items: center; gap: 10px;
    background: var(--warning-bg, #fef3c7); color: var(--warning-text, #b45309);
    padding: 12px 14px; border-radius: var(--radius); cursor: pointer;
    font-size: 13px; font-weight: 600; margin: 8px 0 4px;
}
.dash-pending-banner svg:last-child { margin-left: auto; opacity: 0.5; }

.orders-sync-bar {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
}
.orders-sync-info { font-size: 13px; font-weight: 600; color: var(--text-2); flex: 1; }
.orders-sync-bar .btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; font-size: 13px; white-space: nowrap; width: auto;
}

@keyframes spin-sync { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin-icon { animation: spin-sync 1s linear infinite; }

/* ===== DATE FILTER ===== */
.date-filter-row { display: flex; gap: 8px; margin-bottom: 10px; }
.date-filter-field { flex: 1; }
.date-filter-field label { display: block; font-size: 10px; font-weight: 600; color: var(--text-4); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.date-filter-field input {
    width: 100%; padding: 8px 10px; font-size: 13px; font-family: inherit;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-input); color: var(--text-1);
}
.date-filter-field input:focus { outline: none; border-color: var(--accent); }

/* ===== HISTORY SUMMARY ===== */
.history-summary {
    display: flex; gap: 8px; margin-bottom: 10px;
    padding: 10px; border-radius: var(--radius-sm);
    background: var(--bg-card); box-shadow: var(--shadow-sm);
}
.history-stat { flex: 1; text-align: center; }
.history-stat-val { display: block; font-size: 14px; font-weight: 700; color: var(--text-1); }
.history-stat-lbl { display: block; font-size: 10px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }

/* ===== PRODUCT CATALOG ===== */
.catalog-sort {
    display: flex; align-items: center; gap: 4px;
    padding: 10px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg-card);
    font-size: 12px; font-weight: 600; color: var(--text-2);
    cursor: pointer; font-family: inherit; white-space: nowrap;
}
.catalog-sort:active { background: var(--bg-card-hover); }
.catalog-sort svg { color: var(--accent); flex-shrink: 0; }

.catalog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.product-card {
    padding: 12px; border-radius: var(--radius-sm);
    background: var(--bg-card); box-shadow: var(--shadow-sm);
    cursor: pointer; transition: background 0.1s;
}
.product-card:active { background: var(--bg-card-hover); }
.product-card-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.product-card-code { font-size: 11px; color: var(--text-4); margin-bottom: 6px; }
.product-card-price { font-size: 15px; font-weight: 700; color: var(--accent); }
.product-card-meta { font-size: 10px; color: var(--text-3); margin-top: 4px; }
.product-card-stock { font-size: 11px; font-weight: 700; margin-top: 4px; }
.product-card-stock.in-stock { color: var(--green-text); }
.product-card-stock.out-stock { color: var(--red-text); }
.in-stock { color: var(--green-text); }
.out-stock { color: var(--red-text); }

/* ===== FILTER ROW ===== */
.filter-row { margin-bottom: 10px; }
.filter-row select {
    width: 100%; padding: 8px 12px; font-size: 13px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-input); color: var(--text-1);
    appearance: auto; cursor: pointer;
}

/* ===== DAY SUMMARY ===== */
.summary-section { margin-top: 16px; }
.summary-section-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 700; color: var(--text-2);
    margin-bottom: 8px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}
.summary-section-title svg { color: var(--accent); flex-shrink: 0; }
.summary-total-row {
    text-align: right; font-size: 13px; font-weight: 700;
    color: var(--accent); padding: 8px 0 4px;
    border-top: 1px solid var(--border-light); margin-top: 4px;
}

/* ===== CASH HANDOVER ===== */
.handover-summary {
    padding: 13px 14px; border-radius: var(--radius);
    background: var(--bg-card); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.handover-summary .summary-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 8px 0; color: var(--text-3); font-size: 13px;
}
.handover-summary .summary-row + .summary-row { border-top: 1px solid var(--border-light); }
.handover-summary .summary-row strong { color: var(--text-1); text-align: right; }

/* ===== DESKTOP ===== */
@media (min-width: 600px) {
    .page-container { max-width: 480px; margin: 0 auto; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
    .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
    .app-header { max-width: 480px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
    .modal-sheet { max-width: 480px; left: 50%; transform: translateX(-50%) translateY(100%); right: auto; width: 100%; top: 0; bottom: 0; }
    .modal-sheet.is-open { transform: translateX(-50%) translateY(0); }
    .toast { max-width: 400px; }
}
