/* Minore Mobile-First Shared CSS */
:root {
    --primary: #0ea5e9;
    --primary-light: #38bdf8;
    --primary-dark: #0284c7;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-surface: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* MOBILE APP FRAME - forces mobile view in all browsers */
html, body {
    margin: 0; padding: 0;
    min-height: 100vh; min-height: 100dvh;
    background: #000;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

#app, .app-frame {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh; min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
    background: var(--bg-dark);
    box-shadow: 0 0 60px rgba(14,165,233,0.14);
}

/* SweetAlert mobile fix */
.swal-mobile { max-width: 340px !important; border-radius: 20px !important; font-size: 14px !important; }
.swal2-popup { font-family: inherit !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

/* Global mobile typography */
body { font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

/* Mobile header */
.mobile-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(15,23,42,0.92);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
    border-bottom: 1px solid rgba(148,163,184,0.1);
}

.mobile-header-title {
    font-size: 20px; font-weight: 700;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Bottom navigation */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px;
    background: rgba(15,23,42,0.95);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(148,163,184,0.1);
    display: flex; justify-content: space-around; align-items: center;
    padding: 8px 4px;
    padding-bottom: calc(8px + var(--safe-bottom));
    z-index: 100;
}

.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 6px 12px;
    color: var(--text-muted); font-size: 10px; font-weight: 500;
    cursor: pointer; border: none; background: none;
    transition: all 0.2s; border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active svg { filter: drop-shadow(0 0 8px rgba(14,165,233,0.45)); }

/* Mobile cards */
.m-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}
.m-card:active { transform: scale(0.98); }

/* Mobile stat cards */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px; text-align: center;
    border: 1px solid var(--border);
}
.stat-card .stat-value {
    font-size: 28px; font-weight: 800;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-card .stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Mobile buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer;
    border: none; transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
.btn-primary:active { transform: scale(0.96); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; }
.btn-success { background: linear-gradient(135deg, #16a34a, #22c55e); color: white; }
.btn-sm { padding: 8px 14px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; border-radius: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Mobile inputs */
.m-input, .m-select, .m-textarea {
    width: 100%; padding: 14px 16px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 15px; outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.m-input:focus, .m-select:focus, .m-textarea:focus { border-color: var(--primary); }
.m-input::placeholder { color: var(--text-muted); }
.m-textarea { resize: vertical; min-height: 80px; }
.m-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* Badge */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-error { background: rgba(239,68,68,0.15); color: #ef4444; }
.badge-info { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-primary { background: rgba(14,165,233,0.15); color: #0284c7; }

/* Page content area (with bottom nav padding) */
.page-content {
    padding: 16px;
    padding-bottom: calc(80px + var(--safe-bottom));
    min-height: calc(100vh - 130px);
}

/* Section titles */
.section-title {
    font-size: 16px; font-weight: 700; color: var(--text-primary);
    margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;
}

/* List items */
.list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px; cursor: pointer;
    transition: background 0.2s;
}
.list-item:active { background: var(--bg-surface); }

/* Avatar */
.avatar {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; color: white;
    flex-shrink: 0;
}

/* Tab bar */
.tab-bar {
    display: flex; gap: 6px; padding: 4px;
    background: var(--bg-card); border-radius: var(--radius);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab-item {
    flex: 1; padding: 10px 16px; text-align: center;
    border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    color: var(--text-muted); cursor: pointer; white-space: nowrap;
    border: none; background: none; transition: all 0.2s;
}
.tab-item.active { background: var(--primary); color: white; }

/* Empty state */
.empty-state {
    text-align: center; padding: 40px 20px;
}
.empty-state svg, .empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.empty-state .empty-text { font-size: 13px; color: var(--text-muted); }

/* Glassmorphism modals */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    background: var(--bg-dark);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px 16px;
    padding-bottom: calc(24px + var(--safe-bottom));
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-handle {
    width: 40px; height: 4px; background: var(--bg-surface);
    border-radius: 2px; margin: 0 auto 16px;
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; }

/* Floating action button */
.fab {
    position: fixed; bottom: 90px; right: calc(50% - 220px);
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(14,165,233,0.35);
    z-index: 90; transition: transform 0.2s;
}
.fab:active { transform: scale(0.9); }
.fab svg { width: 24px; height: 24px; }

/* Transitions */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Language toggle */
.lang-toggle {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 10px; border-radius: 20px;
    background: var(--bg-surface); border: 1px solid var(--border);
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    cursor: pointer;
}

/* Swipe actions */
.swipe-actions {
    display: flex; gap: 6px; margin-top: 8px;
}

/* Pull to refresh indicator */
.pull-indicator {
    text-align: center; padding: 8px; color: var(--text-muted); font-size: 12px;
}

/* Table mobile (horizontal scroll) */
.m-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.m-table { width: 100%; min-width: 400px; border-collapse: collapse; }
.m-table th { padding: 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--bg-card); text-align: left; white-space: nowrap; }
.m-table td { padding: 12px; font-size: 13px; color: var(--text-primary); border-bottom: 1px solid var(--border); }

/* Chip/tag */
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 500;
    background: var(--bg-surface); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.chip-remove { cursor: pointer; opacity: 0.6; }
.chip-remove:hover { opacity: 1; }

/* Search bar */
.search-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 4px 4px 4px 16px;
}
.search-bar input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text-primary); font-size: 15px;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar button {
    padding: 10px 16px; border-radius: var(--radius-sm);
    background: var(--primary); color: white; border: none;
    font-size: 13px; font-weight: 600; cursor: pointer;
}

/* Skeleton loading */
.skeleton { background: linear-gradient(90deg, var(--bg-surface) 25%, var(--border) 50%, var(--bg-surface) 75%); background-size: 200%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Light theme overrides for customer panel */
.theme-light {
    --bg-dark: #f8fafc;
    --bg-card: #ffffff;
    --bg-surface: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
}
.theme-light .mobile-header { background: rgba(248,250,252,0.92); }
.theme-light .bottom-nav { background: rgba(248,250,252,0.95); }
.theme-light .swal-mobile { background: #fff !important; color: #0f172a !important; }

/* Utility colors for logo/avatar classes used by API data */
.bg-blue-500 { background: #3b82f6 !important; }
.bg-purple-500 { background: #8b5cf6 !important; }
.bg-green-500 { background: #22c55e !important; }
.bg-red-500 { background: #ef4444 !important; }
.bg-orange-500 { background: #f97316 !important; }
.bg-cyan-500 { background: #06b6d4 !important; }
.bg-pink-500 { background: #ec4899 !important; }
.bg-indigo-500 { background: #6366f1 !important; }
.bg-teal-500 { background: #14b8a6 !important; }
.bg-gray-500 { background: #64748b !important; }

.text-success { color: var(--success) !important; }
.text-danger { color: var(--error) !important; }

/* App layout helpers */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

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

.header-actions {
    display: flex;
    gap: 8px;
}

.header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-search {
    margin-top: 10px;
}

.back-btn {
    min-width: 40px;
}

.page-gap {
    margin-top: 8px;
}

/* Card grids */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.kpi-icon {
    font-size: 18px;
}

.kpi-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-label {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Firm cards */
.firm-row {
    display: flex;
    gap: 10px;
}

.firm-main {
    flex: 1;
    min-width: 0;
}

.firm-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.firm-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.firm-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.firm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* Category and tools */
.category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.category-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    padding: 12px;
    text-align: left;
    color: var(--text-primary);
}

.category-icon {
    font-size: 20px;
}

.category-title {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
}

.category-count {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0;
}

.action-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px;
    text-align: left;
}

.action-icon {
    font-size: 20px;
}

.action-title {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 700;
}

.section-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Profile */
.profile-hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.profile-avatar {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.profile-main {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-mail {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-balance {
    text-align: right;
}

.profile-label {
    font-size: 10px;
    color: var(--text-muted);
}

.profile-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

/* Modal helpers */
.modal-inner-card {
    margin: 0 0 10px 0;
    padding: 12px;
}

.small-title {
    font-size: 14px;
    margin-bottom: 8px;
}

.qr-preview {
    width: 180px;
    height: 180px;
    display: block;
    margin: 0 auto 10px auto;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.review-item {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
}

.review-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.review-text {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}
