:root {
    /* Filtron Multipack Brand */
    --primary: #F58220;
    --primary-dark: #D96E10;
    --primary-light: #FF9500;
    --accent: #FFD200;
    --brand-black: #000000;
    --brand-dark: #111111;
    --success: #10b981;
    --warning: #FFD200;
    --danger: #ef4444;
    --info: #06b6d4;

    --sidebar-width: 270px;
    --sidebar-bg: #ffffff;
    --sidebar-brand-bg: #000000;
    --sidebar-border: #ebe6e0;
    --sidebar-text: #4b5563;
    --sidebar-text-muted: #9ca3af;
    --body-bg: #f5f5f5;
    --surface: #ffffff;
    --text: #111111;
    --text-muted: #6b7280;
    --border: #ebe6e0;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
    --gradient: linear-gradient(135deg, #F58220 0%, #FF9500 45%, #FFD200 100%);
    --gradient-dark: linear-gradient(180deg, #111111 0%, #000000 100%);
    --gradient-soft: linear-gradient(135deg, rgba(245, 130, 32, 0.1) 0%, rgba(255, 210, 0, 0.08) 100%);
    --glow-orange: 0 8px 24px rgba(245, 130, 32, 0.35);
}

* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    touch-action: pan-y;
}

body {
    touch-action: pan-y;
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--body-bg);
    background-image:
        radial-gradient(ellipse at 0% 0%, rgba(245, 130, 32, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(255, 210, 0, 0.05) 0%, transparent 50%);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: pan-y;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show { display: block; opacity: 1; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 12px;
    border-bottom: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
}

.brand-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    width: 100%;
}

.brand-fm {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    box-shadow: var(--glow-orange);
}

.brand-fm-text {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.brand-logo-wrap:hover .brand-fm {
    transform: scale(1.04);
    transition: transform 0.2s ease;
}

.brand-logo-wrap:hover .brand-logo-img {
    transform: scale(1.02);
}

.brand-icon {
    width: 46px;
    height: 46px;
    background: var(--gradient);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    box-shadow: var(--glow-orange);
}

.sidebar-brand h1 {
    margin: 0;
    font-size: 1.15rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-brand span {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-nav {
    padding: 8px 14px;
    flex: 1;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
    opacity: 0.75;
    padding: 16px 14px 8px;
    margin: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    opacity: 0.85;
    color: var(--primary);
}

.sidebar-nav .nav-link:hover {
    background: rgba(245, 130, 32, 0.08);
    color: var(--primary-dark);
    transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
    background: var(--gradient);
    color: #fff;
    box-shadow: var(--glow-orange);
}

.sidebar-nav .nav-link.active i {
    opacity: 1;
    color: #fff;
}

.sidebar-footer {
    padding: 20px 22px;
    border-top: 1px solid var(--sidebar-border);
    font-size: 0.75rem;
    color: var(--sidebar-text-muted);
    background: #fafafa;
}

.sidebar-footer strong {
    color: var(--text);
    display: block;
    margin-bottom: 2px;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Topbar ─── */
.topbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 14px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    color: var(--text) !important;
    text-decoration: none !important;
    padding: 8px !important;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.sidebar-toggle:hover { background: var(--gradient-soft); }

.topbar-title h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.topbar-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 2px 0 0;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--gradient-soft);
    border-radius: 999px;
    font-weight: 500;
}

.topbar-fy {
    font-size: 0.8rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(245, 130, 32, 0.12);
    border: 1px solid rgba(245, 130, 32, 0.25);
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border) !important;
    border-radius: 999px !important;
    padding: 6px 16px 6px 6px !important;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--surface) !important;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.user-menu:hover {
    border-color: var(--primary-light) !important;
    box-shadow: var(--shadow-sm);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 8px;
}

.dropdown-item {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.875rem;
}

.app-content {
    padding: 28px 32px 40px;
    flex: 1;
}

/* ─── Cards ─── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border);
    padding: 18px 24px;
    font-weight: 600;
}

.card-header h5 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card-body { padding: 24px; }

.filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
}

.filter-card .card-body { padding: 20px 24px; }

/* ─── Tables ─── */
.table-responsive {
    border-radius: var(--radius);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    white-space: nowrap;
}

.table tbody td {
    font-size: 0.875rem;
    vertical-align: middle;
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text);
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover { background: #fafbff; }

.table tbody tr:last-child td { border-bottom: none; }

.card-footer {
    background: #fafbfc !important;
    border-top: 1px solid var(--border);
    padding: 14px 20px;
}

/* ─── Stat cards ─── */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.stat-primary::before { background: var(--gradient); }
.stat-success::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-info::before { background: linear-gradient(90deg, #06b6d4, #22d3ee); }
.stat-warning::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-primary .stat-icon { background: rgba(245, 130, 32, 0.12); color: var(--primary); }
.stat-success .stat-icon { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.stat-info .stat-icon { background: rgba(6, 182, 212, 0.12); color: var(--info); }
.stat-warning .stat-icon { background: rgba(245, 158, 11, 0.12); color: var(--warning); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-info h3 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1;
}

/* ─── Dashboard ─── */
.welcome-banner {
    background: var(--gradient);
    border-radius: var(--radius);
    padding: 28px 32px;
    color: #fff;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--glow-orange);
}

.welcome-banner::after {
    content: '';
    position: absolute;
    right: -40px;
    top: -40px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.welcome-banner h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.welcome-banner p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

.metric-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    background: var(--surface);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s ease;
    background: var(--surface);
}

.quick-action-btn i {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: transform 0.2s;
}

.quick-action-btn:hover {
    border-color: var(--primary-light);
    background: var(--gradient-soft);
    color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.quick-action-btn:hover i { transform: scale(1.08); }

.qa-invoice i { background: rgba(245, 130, 32, 0.12); color: var(--primary); }
.qa-payment i { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.qa-customer i { background: rgba(6, 182, 212, 0.12); color: var(--info); }
.qa-product i { background: rgba(255, 210, 0, 0.15); color: #c99200; }
.qa-ledger i { background: rgba(15, 23, 42, 0.08); color: var(--text); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 10px 20px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.btn:active {
    transform: scale(0.97) !important;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    border: none;
    box-shadow: var(--glow-orange);
}

.btn-primary:hover {
    color: #fff;
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 130, 32, 0.35);
}

.btn-outline-primary {
    border-color: var(--primary-light);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--gradient-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-light {
    background: #f8fafc;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-light:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--text);
    transform: translateY(-1px);
}

.btn-sm { 
    padding: 6px 14px; 
    font-size: 0.8rem; 
    border-radius: 8px; 
    gap: 6px;
}

/* ─── Forms ─── */
.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--surface);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(245, 130, 32, 0.15);
}

.input-group-text {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-color: var(--border);
    background: #f8fafc;
    color: var(--text-muted);
}

.input-group .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ─── Badges ─── */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

/* ─── Alerts & Toasts ─── */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.toast-container {
    z-index: 1090;
    max-width: min(420px, calc(100vw - 24px));
}

.app-toast {
    border: none;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
    min-width: 320px;
}

.app-toast .toast-header {
    border-bottom: none;
    padding: 14px 16px 6px;
    background: transparent;
    font-weight: 700;
}

.app-toast .toast-body {
    padding: 4px 16px 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.app-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-right: 10px;
    font-size: 0.95rem;
}

.app-toast-success {
    background: #ffffff;
    border-left: 4px solid var(--success);
}

.app-toast-success .toast-header {
    color: #065f46;
}

.app-toast-success .app-toast-icon {
    background: #ecfdf5;
    color: var(--success);
}

.app-toast-error {
    background: #ffffff;
    border-left: 4px solid var(--danger);
}

.app-toast-error .toast-header {
    color: #991b1b;
}

.app-toast-error .app-toast-icon {
    background: #fef2f2;
    color: var(--danger);
}

.app-confirm-modal {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
}

.app-confirm-modal .modal-header {
    padding: 24px 24px 0;
}

.app-confirm-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fef3c7;
    color: #d97706;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.app-confirm-modal .modal-body {
    padding: 12px 24px 8px;
}

.app-confirm-modal .modal-footer {
    padding: 8px 24px 24px;
    gap: 8px;
}

/* ─── Page header ─── */
.page-header .btn-primary {
    box-shadow: var(--glow-orange);
}

/* ─── Invoice totals ─── */
.invoice-totals {
    background: var(--gradient-soft);
    border: 1px solid rgba(245, 130, 32, 0.2);
    border-radius: var(--radius-sm);
    padding: 20px;
}

/* ─── Pagination ─── */
.pagination .page-link {
    border-radius: 8px !important;
    margin: 0 2px;
    border-color: var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
}

.pagination .page-item.active .page-link {
    background: var(--gradient);
    border-color: transparent;
}

/* ─── Login ─── */
.auth-body {
    min-height: 100vh;
    display: flex;
    margin: 0;
    background: #f0f0f0;
}

.login-page {
    display: flex;
    width: 100%;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.login-form-panel {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: #f0f0f0;
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 12px 40px rgba(0, 0, 0, 0.06);
    border: 1px solid #e8e8e8;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo-wrap {
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-fm {
    width: 72px;
    height: 72px;
    background: var(--gradient);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.9rem;
    letter-spacing: 0.02em;
    box-shadow: var(--glow-orange);
}

.login-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0;
    color: #000000;
    letter-spacing: -0.02em;
}

.login-header p {
    color: #888888;
    margin: 6px 0 0;
    font-size: 0.9rem;
}

.input-group-brand {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group-brand .input-group-text {
    background: #fafafa;
    border: none;
    color: #F58220;
    padding-left: 14px;
}

.input-group-brand .form-control {
    border: none;
    background: #fafafa;
    padding: 12px 14px;
    font-size: 0.9rem;
}

.input-group-brand .form-control:focus {
    background: #fff;
    box-shadow: none;
}

.input-group-brand:focus-within {
    border-color: #F58220;
    box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.12);
}

.input-group-brand:focus-within .input-group-text,
.input-group-brand:focus-within .form-control {
    background: #fff;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid #f0f0f0;
}

.login-form .btn-primary {
    padding: 13px;
    font-size: 0.95rem;
    border-radius: 10px;
    font-weight: 700;
}

/* ─── Code ─── */
code {
    background: var(--gradient-soft);
    color: var(--primary-dark);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}

/* ─── Responsive ─── */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-bar .btn { flex-shrink: 0; }

.action-bar-ledger {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.action-bar-ledger .btn {
    width: 100%;
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
}

.ledger-filter-toggle {
    border: 1px solid var(--border);
    font-weight: 600;
    min-height: 48px;
}

.list-filter-toggle {
    border: 1px solid var(--border);
    font-weight: 600;
    min-height: 48px;
}

.list-filter-toggle .badge,
.ledger-filter-toggle .badge {
    max-width: 45%;
    flex-shrink: 1;
}

.ledger-fy-trigger {
    cursor: pointer;
    background-color: var(--surface);
    color: var(--text);
}

.ledger-fy-trigger::after {
    float: right;
    margin-top: 2px;
}

.ledger-fy-modal .list-group-item {
    padding: 14px 18px;
    font-weight: 600;
    border: none;
    border-bottom: 1px solid var(--border);
}

.ledger-fy-modal .list-group-item.active {
    background: var(--gradient-soft);
    color: var(--primary-dark);
    border-color: var(--border);
}

.ledger-balance-badges .badge.fs-6 {
    white-space: normal;
    line-height: 1.4;
    text-align: left;
}

tr.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

tr.clickable-row:hover {
    background-color: rgba(37, 99, 235, 0.06) !important;
}

tr.clickable-row:hover .hover-link {
    text-decoration: underline !important;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-mobile-cards { width: 100%; }

.invoice-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}

@media (min-width: 992px) {
    .topbar-date { display: flex; }
    .w-lg-auto { width: auto !important; }
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        touch-action: pan-y;
    }
    .app-content {
        padding: 16px 14px 28px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        touch-action: pan-y;
    }
    .topbar {
        padding: 10px 14px;
        gap: 10px;
        flex-wrap: wrap;
    }
    .topbar-title { min-width: 0; flex: 1; }
    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
        gap: 8px;
    }
    .card-body { padding: 18px 16px; }
    .card-header { padding: 14px 16px; }
    .filter-card .card-body { padding: 16px; }
    .filter-actions { width: 100%; }
    .filter-actions .btn { flex: 1; }
    .page-header {
        flex-direction: column;
        align-items: stretch !important;
    }
    .page-header .btn-primary { width: 100%; justify-content: center; }
}

@media (min-width: 768px) {
    #ledgerFilters.collapse,
    #listFilters.collapse {
        display: block;
        height: auto !important;
        visibility: visible;
    }
    .ledger-filter-toggle,
    .list-filter-toggle { display: none !important; }
}

@media (max-width: 767.98px) {
    .topbar-subtitle { display: none; }
    .topbar-title h2 { font-size: 1.1rem; }
    .topbar-fy {
        font-size: 0.72rem;
        padding: 6px 10px;
    }
    .topbar-fy i { display: none; }
    .user-menu { padding: 4px 10px 4px 4px !important; }
    .welcome-banner {
        padding: 20px 18px;
        margin-bottom: 20px;
    }
    .welcome-banner h3 { font-size: 1.15rem; }
    .stat-card { padding: 16px; }
    .stat-info h3 { font-size: 1.35rem; }
    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.15rem;
    }
    .metric-card { padding: 16px; }
    .metric-card h4 { font-size: 1.1rem; }
    .quick-action-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .quick-action-btn { padding: 16px 10px; font-size: 0.78rem; }
    .card-footer {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
        text-align: center;
    }
    .card-footer .pagination { justify-content: center !important; }
    .invoice-totals { margin-top: 16px; }
    .table-responsive-cards { overflow: visible; }
    .table-responsive:not(.table-responsive-cards) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
    }

    /* Mobile card tables */
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards tbody tr {
        display: block;
        margin-bottom: 12px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }
    .table-mobile-cards tbody tr:hover { background: var(--surface); }
    .table-mobile-cards tbody tr:last-child { margin-bottom: 0; }
    .table-mobile-cards tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border: none;
        text-align: right !important;
    }
    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }
    .table-mobile-cards tbody td.cell-empty::before { display: none; }
    .table-mobile-cards tbody td.cell-title {
        display: block;
        padding-top: 0;
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--border);
        text-align: left !important;
    }
    .table-mobile-cards tbody td.cell-title::before { display: none; }
    .table-mobile-cards tbody td.cell-title strong { font-size: 1rem; }
    .table-mobile-cards tbody td.cell-actions {
        justify-content: flex-end;
        padding-top: 12px;
        margin-top: 4px;
        border-top: 1px solid var(--border);
    }
    .table-mobile-cards tbody td.cell-actions::before { display: none; }
    .table-mobile-cards tbody tr td[colspan] {
        display: block;
        text-align: center !important;
    }
    .table-mobile-cards tbody tr td[colspan]::before { display: none; }

    .form-control, .form-select, .ts-control input {
        min-height: 44px;
        font-size: 16px !important;
    }
    .btn {
        min-height: 44px;
        font-size: 0.875rem !important;
    }
    .btn-sm {
        min-height: 38px;
        min-width: 38px;
        padding: 8px 10px;
        font-size: 0.82rem !important;
    }

    .action-bar, .action-bar-ledger {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px;
        width: 100%;
        max-width: 100%;
    }
    .action-bar .btn, .action-bar-ledger .btn {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: 120px !important;
        justify-content: center;
        margin: 0 !important;
    }

    .form-actions {
        flex-direction: row;
        gap: 10px;
    }
    .form-actions .btn {
        width: auto;
    }

    .invoice-items-header {
        flex-direction: column;
        align-items: stretch;
    }
    .invoice-items-header #addItemRow {
        width: 100%;
        min-height: 44px;
    }

    /* Invoice form item rows → stacked cards */
    #invoiceItemsTable.table-bordered { border: none; }
    #invoiceItemsTable thead { display: none; }
    #invoiceItemsTable tbody tr {
        display: block;
        margin-bottom: 12px;
        padding: 14px;
        border: 1px solid var(--border) !important;
        border-radius: var(--radius-sm);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }
    #invoiceItemsTable tbody td {
        display: block;
        padding: 8px 0;
        border: none !important;
    }
    #invoiceItemsTable tbody td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        margin-bottom: 6px;
    }
    #invoiceItemsTable tbody td:last-child {
        text-align: right;
        padding-top: 12px;
        margin-top: 4px;
        border-top: 1px solid var(--border) !important;
    }
    #invoiceItemsTable tbody td:last-child::before { display: none; }

    .invoice-detail-table tfoot tr {
        display: block;
        padding: 8px 14px;
        border-top: 1px solid var(--border);
    }
    .invoice-detail-table tfoot td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border: none;
        text-align: right !important;
    }
    .invoice-detail-table tfoot td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
    }
    .invoice-detail-table tfoot td[colspan] {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .app-content { padding: 12px 12px 24px; }
    .topbar-actions { justify-content: space-between; }
    .login-form-panel { padding: 24px 16px; }
    .login-card { padding: 28px 22px; border-radius: 14px; }
    .login-header h1 { font-size: 1.4rem; }
    .login-fm {
        width: 64px;
        height: 64px;
        font-size: 1.6rem;
    }
    .user-menu > span:not(.user-avatar) { display: none; }
    .user-menu { padding: 4px !important; }
    .quick-action-grid { grid-template-columns: 1fr 1fr; }
    .badge.fs-6 {
        font-size: 0.75rem !important;
        display: inline-block;
        width: fit-content;
        max-width: 100%;
        margin-bottom: 6px;
        white-space: normal;
        line-height: 1.4;
    }
    .ledger-filter-toggle .badge {
        max-width: 45%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .list-filter-toggle .badge {
        max-width: 45%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #invoiceForm .row.justify-content-end > .col-md-4 {
        width: 100%;
        max-width: 100%;
    }
}

@supports (padding: max(0px)) {
    .app-content {
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
    .topbar {
        padding-top: max(10px, env(safe-area-inset-top));
    }
}

/* ─── Tom Select Premium Styling ─── */
.ts-wrapper {
    width: 100% !important;
}

.ts-wrapper .ts-control {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 14px !important;
    font-size: 0.875rem !important;
    font-family: inherit !important;
    background-color: var(--surface) !important;
    color: var(--text) !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(245, 130, 32, 0.25) !important;
}

.ts-dropdown {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    background-color: var(--surface) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
    margin-top: 4px !important;
    padding: 6px !important;
    z-index: 9999 !important;
}

.ts-dropdown .option {
    padding: 10px 14px !important;
    border-radius: 6px !important;
    color: var(--text) !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
    transition: background 0.15s ease, color 0.15s ease !important;
}

.ts-dropdown .active {
    background-color: var(--gradient-soft) !important;
    color: var(--primary-dark) !important;
}

.ts-dropdown .create {
    display: none !important;
}

/* Mobile responsive fixes for Tom Select inside flex columns */
@media (max-width: 767.98px) {
    #invoiceItemsTable tbody td[data-label="Product"] {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    #invoiceItemsTable tbody td[data-label="Product"]::before {
        align-self: flex-start;
    }
}
