@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-gradient: radial-gradient(circle at 50% 50%, #0d1224 0%, #05070f 100%);
    --panel-bg: rgba(13, 20, 38, 0.45);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-highlight: rgba(255, 255, 255, 0.15);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.4);
    --primary-light: #818cf8;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.25);
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.25);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    --shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 30px 0 rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px 0 rgba(0, 0, 0, 0.5);
    --shadow-inset: inset 0 2px 4px 0 rgba(0, 0, 0, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    padding: 12px;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1440px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Header Section */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px var(--primary-glow));
}

.brand h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #f3f4f6, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gps-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition-normal);
}

.gps-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.gps-dot.connected {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
    animation: pulse 2s infinite;
}

.gps-dot.searching {
    background-color: var(--warning);
    animation: flash 1s infinite alternate;
}

.gps-dot.error {
    background-color: var(--danger);
    box-shadow: 0 0 10px var(--danger-glow);
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 12px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.main-column, .sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Glassmorphic Panel Styles */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Stats Cards */
.stats-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

@media (max-width: 768px) {
    .stats-strip {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
}

.stat-change {
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive {
    color: var(--success);
}

/* Inputs & Form styling */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input, textarea, select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    background: rgba(0, 0, 0, 0.3);
}

textarea {
    resize: vertical;
    min-height: 70px;
}

/* Quick entry interface with ghost text autocomplete */
.quick-entry-container {
    position: relative;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--panel-highlight);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.quick-entry-container:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    background: rgba(0, 0, 0, 0.3);
}

.quick-entry-input {
    width: 100%;
    border: none !important;
    background: transparent !important;
    color: var(--text-primary);
    position: relative;
    z-index: 2;
    padding-right: 48px;
    outline: none !important;
    box-shadow: none !important;
}

.quick-entry-ghost {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.22); /* Faded inline suggestion */
    pointer-events: none;
    z-index: 1;
    white-space: pre;
    background: transparent;
    display: flex;
    align-items: center;
}

.quick-entry-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: color var(--transition-fast);
}

.quick-entry-clear:hover {
    color: var(--text-primary);
}

/* Category Quick Pills Buttons */
.category-quick-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.category-pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.category-pill:hover {
    background: rgba(79, 70, 229, 0.15);
    border-color: var(--primary);
    color: #ffffff;
    transform: translateY(-1px);
}

.category-pill:active {
    transform: translateY(0);
}

/* Parser Live Preview Badge */
.parser-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--panel-border);
    border-radius: var(--radius-sm);
}

.preview-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.preview-badge strong {
    color: var(--text-primary);
}

.preview-badge.ready {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.05);
}

/* Payment Type Selector */
.payment-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.payment-option {
    position: relative;
}

.payment-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.payment-label {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    user-select: none;
}

.payment-option input[type="radio"]:checked + .payment-label {
    background: rgba(79, 70, 229, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(79, 70, 229, 0.2);
    color: #ffffff;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
    background: linear-gradient(135deg, #818cf8, #4f46e5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Modal Onboarding Setup Dialog styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-highlight);
    border-radius: var(--radius-md);
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #ffffff;
    text-align: center;
}

/* Charts Containers */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 640px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-container {
    position: relative;
    height: 220px;
    width: 100%;
}

/* Map Container */
.map-panel {
    min-height: 300px;
}

#map {
    height: 280px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--panel-border);
    background-color: #0c0f1d;
    z-index: 1;
}

/* Tables Styling */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.15);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

th, td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--panel-border);
}

th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.col-serial {
    font-weight: 700;
    color: var(--primary-light);
}

.col-amount {
    font-family: var(--font-heading);
    font-weight: 600;
    color: #ffffff;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-cash {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-cc {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.badge-bank {
    background: rgba(6, 182, 212, 0.12);
    color: #22d3ee;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-resolved {
    background: rgba(245, 158, 11, 0.08);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.15);
    margin-left: 4px;
    font-size: 0.6rem;
    padding: 2px 4px;
}

.actions-cell {
    display: flex;
    gap: 6px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    cursor: pointer;
    font-size: 1rem;
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    transition: all var(--transition-fast);
}

.action-btn.edit {
    color: var(--primary-light);
}

.action-btn.edit:hover {
    background: rgba(79, 70, 229, 0.15);
    border-color: var(--primary-light);
}

.action-btn.delete {
    color: #f87171;
}

.action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #f87171;
}

/* Search Bar and Filters */
.search-bar-container {
    display: flex;
    gap: 8px;
    margin-bottom: 0px;
    flex-wrap: wrap;
    flex-grow: 1;
    justify-content: flex-end;
}

.search-input {
    flex-grow: 1;
    max-width: 250px;
    background: rgba(0, 0, 0, 0.15);
}

@media (max-width: 576px) {
    .search-bar-container {
        justify-content: stretch;
    }
    .search-input {
        max-width: 100%;
    }
    .search-bar-container select {
        width: 100% !important;
    }
}

/* Backups and Settings Row */
.settings-bar {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

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

/* Screen Toggle Utilities */
.screen-view {
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes flash {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 320px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(13, 20, 38, 0.95);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: toastSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--danger);
}

.toast-info {
    border-left: 3px solid var(--primary-light);
}

.toast-hide {
    opacity: 0;
    transform: translateX(20px);
}

@keyframes toastSlide {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 576px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Mobile Friendly Overrides */
@media (max-width: 768px) {

    body {
        padding: 8px;
    }
    
    header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 12px;
    }
    
    .panel {
        padding: 12px;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    #map {
        height: 220px;
    }

    /* Stack Table as Touch-Friendly Cards on Mobile */
    table thead {
        display: none;
    }
    
    table, tbody, tr, td {
        display: block;
        width: 100%;
    }
    
    tr {
        margin-bottom: 12px;
        background: rgba(255, 255, 255, 0.015);
        border: 1px solid var(--panel-border);
        border-radius: var(--radius-sm);
        padding: 10px;
    }
    
    td {
        text-align: right;
        padding: 8px;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 40px;
    }
    
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.75rem;
        text-transform: uppercase;
    }
    
    td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        gap: 8px;
        padding-top: 10px;
    }
    
    .actions-cell {
        width: 100%;
        justify-content: center;
    }
    
    .action-btn {
        flex-grow: 1;
        max-width: 150px;
    }
}
