/* =============================================
   JRG SMART ERP - MAIN STYLESHEET
   Brand Colors: #1a5276 (Primary Blue), #566573 (Gray), #f39c12 (Accent Gold)
   ============================================= */

/* ---- CSS VARIABLES / THEME ---- */
:root {
    --primary: #1a5276;
    --primary-light: #2471a3;
    --primary-dark: #0e3650;
    --primary-gradient: linear-gradient(135deg, #1a5276 0%, #2e86c1 100%);
    --accent: #f39c12;
    --accent-light: #f5b041;
    --accent-dark: #d68910;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --gray-50: #f8f9fa;
    --gray-100: #f0f2f5;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #0e1726;
    --bg-sidebar-hover: #1a2332;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -2px rgba(0, 0, 0, .05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -4px rgba(0, 0, 0, .04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --sidebar-width: 270px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
    --font-primary: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition-fast: 150ms cubic-bezier(.4, 0, .2, 1);
    --transition-normal: 250ms cubic-bezier(.4, 0, .2, 1);
    --transition-slow: 350ms cubic-bezier(.4, 0, .2, 1);
}

/* ---- RESET & BASE ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    height: auto;
}

/* ---- LAYOUT ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-normal);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

.content-area {
    flex: 1;
    padding: 24px;
}

/* ---- SIDEBAR ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 1050;
    transition: width var(--transition-normal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    height: var(--header-height);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    gap: 12px;
}

.sidebar-brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .sidebar-brand .brand-text {
    opacity: 0;
    width: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 4px;
}

.nav-section {
    padding: 8px 20px 4px;
}

.nav-section-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .3);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-collapsed .nav-section-title {
    opacity: 0;
}

.nav-item {
    position: relative;
    margin: 2px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    gap: 12px;
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
    font-size: .88rem;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(26, 82, 118, .4);
}

.nav-link .nav-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.15rem;
}

.nav-link .nav-text {
    overflow: hidden;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .nav-link .nav-text {
    opacity: 0;
    width: 0;
}

.nav-link .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .7rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-collapsed .nav-link .nav-badge {
    display: none;
}

/* Submenu */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.nav-submenu.open {
    max-height: 500px;
}

.nav-submenu .nav-link {
    padding-left: 48px;
    font-size: .82rem;
}

.nav-arrow {
    margin-left: auto;
    transition: transform var(--transition-fast);
    font-size: .75rem;
}

.nav-arrow.rotated {
    transform: rotate(90deg);
}

/* ---- HEADER / TOPBAR ---- */
.topbar {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: var(--shadow-sm);
}

.topbar-toggle {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    transition: all var(--transition-fast);
}

.topbar-toggle:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.topbar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    padding: 9px 16px 9px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--gray-50);
    font-size: .88rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 82, 118, .1);
}

.topbar-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.topbar-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.topbar-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.topbar-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.topbar-user:hover {
    background: var(--gray-50);
}

.topbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
}

.topbar-user-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.topbar-user-role {
    font-size: .72rem;
    color: var(--text-secondary);
}

/* Company Selector */
.company-selector {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.company-selector:hover {
    border-color: var(--primary);
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: rgba(26, 82, 118, .1);
    color: var(--primary);
}

.stat-icon.green {
    background: rgba(39, 174, 96, .1);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(243, 156, 18, .1);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(231, 76, 60, .1);
    color: var(--danger);
}

.stat-icon.purple {
    background: rgba(142, 68, 173, .1);
    color: #8e44ad;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-change {
    font-size: .75rem;
    font-weight: 600;
}

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

.stat-change.down {
    color: var(--danger);
}

/* ---- TABLES ---- */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-secondary);
    background: var(--gray-50);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: .88rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(26, 82, 118, .02);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: .88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.5;
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-light);
    color: #fff;
    box-shadow: 0 4px 12px rgba(26, 82, 118, .3);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: var(--accent-dark);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #219a52;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(26, 82, 118, .04);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: .8rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-icon.sm {
    width: 30px;
    height: 30px;
    font-size: .85rem;
}

/* ---- FORMS ---- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: .88rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-family: var(--font-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 82, 118, .1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control.error {
    border-color: var(--danger);
}

.form-error {
    font-size: .78rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: .88rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-family: var(--font-primary);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 82, 118, .1);
}

select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    gap: 16px;
}

.form-row.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.form-row.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-row.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ---- BADGES / STATUS ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.badge-success {
    background: rgba(39, 174, 96, .1);
    color: var(--success);
}

.badge-danger {
    background: rgba(231, 76, 60, .1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(243, 156, 18, .1);
    color: var(--accent-dark);
}

.badge-info {
    background: rgba(52, 152, 219, .1);
    color: var(--info);
}

.badge-primary {
    background: rgba(26, 82, 118, .1);
    color: var(--primary);
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--text-secondary);
}

/* ---- INVOICE PRINT STYLES ---- */
.invoice-container {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.invoice-header {
    background: var(--primary-gradient);
    color: #fff;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.invoice-header .company-info {
    flex: 1;
}

.invoice-header .company-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255, 255, 255, .15);
    padding: 8px;
}

.invoice-header .company-name {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.invoice-header .company-details {
    font-size: .82rem;
    opacity: .9;
    line-height: 1.6;
}

.invoice-type-badge {
    background: rgba(255, 255, 255, .2);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    backdrop-filter: blur(4px);
}

.invoice-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 24px 30px;
    border-bottom: 1px solid var(--border-color);
}

.invoice-meta .meta-block h4 {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.invoice-meta .meta-block p {
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
}

.invoice-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px 30px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-color);
}

.invoice-details .detail-item {
    text-align: center;
}

.invoice-details .detail-label {
    font-size: .72rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.invoice-details .detail-value {
    font-size: .95rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 2px;
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.invoice-items-table thead {
    background: var(--primary);
    color: #fff;
}

.invoice-items-table thead th {
    padding: 10px 16px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: left;
}

.invoice-items-table tbody td {
    padding: 10px 16px;
    font-size: .85rem;
    border-bottom: 1px solid var(--gray-100);
}

.invoice-items-table tbody tr:nth-child(even) {
    background: var(--gray-50);
}

.invoice-items-table .text-right {
    text-align: right;
}

.invoice-items-table .text-center {
    text-align: center;
}

.invoice-summary {
    display: flex;
    justify-content: flex-end;
    padding: 24px 30px;
    border-top: 2px solid var(--border-color);
}

.invoice-summary-table {
    min-width: 300px;
}

.invoice-summary-table .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: .88rem;
}

.invoice-summary-table .summary-row.total {
    border-top: 2px solid var(--primary);
    padding-top: 10px;
    margin-top: 4px;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
}

.invoice-amount-words {
    padding: 12px 30px;
    background: rgba(26, 82, 118, .03);
    font-size: .85rem;
    color: var(--text-secondary);
    font-style: italic;
    border-top: 1px solid var(--border-color);
}

.invoice-footer {
    padding: 24px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-top: 1px solid var(--border-color);
}

.invoice-footer .bank-details {
    font-size: .8rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.invoice-footer .signature-block {
    text-align: center;
}

.invoice-footer .signature-line {
    width: 150px;
    border-top: 1px solid var(--gray-400);
    margin-top: 50px;
    padding-top: 6px;
    font-size: .8rem;
    color: var(--text-secondary);
}

/* ---- THERMAL INVOICE ---- */
.thermal-invoice {
    width: 80mm;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 5mm;
}

.thermal-invoice .t-header {
    text-align: center;
    border-bottom: 1px dashed #000;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.thermal-invoice .t-company {
    font-size: 14px;
    font-weight: bold;
}

.thermal-invoice .t-row {
    display: flex;
    justify-content: space-between;
}

.thermal-invoice .t-divider {
    border-top: 1px dashed #000;
    margin: 4px 0;
}

.thermal-invoice .t-total {
    font-weight: bold;
    font-size: 14px;
}

/* ---- POS INTERFACE ---- */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    height: calc(100vh - var(--header-height));
}

.pos-products {
    padding: 16px;
    overflow-y: auto;
}

.pos-cart {
    background: #fff;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.pos-product-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pos-product-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pos-product-name {
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.pos-product-price {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
}

.pos-product-stock {
    font-size: .72rem;
    color: var(--text-secondary);
}

.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.pos-cart-total {
    background: var(--primary-gradient);
    color: #fff;
    padding: 20px;
    text-align: center;
}

.pos-cart-total .total-label {
    font-size: .82rem;
    opacity: .8;
}

.pos-cart-total .total-amount {
    font-size: 2rem;
    font-weight: 800;
}

/* ---- CUSTOM MODALS (JRG) ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
    z-index: 1060;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.jrg-custom-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 250ms ease;
    position: relative;
    z-index: 1061;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.jrg-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.jrg-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.jrg-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.jrg-modal-close:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.jrg-modal-body {
    padding: 24px;
}

.jrg-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---- ALERTS / TOASTS ---- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    font-size: .88rem;
}

.alert-success {
    background: rgba(39, 174, 96, .08);
    border: 1px solid rgba(39, 174, 96, .2);
    color: #1a7a3a;
}

.alert-danger {
    background: rgba(231, 76, 60, .08);
    border: 1px solid rgba(231, 76, 60, .2);
    color: #c0392b;
}

.alert-warning {
    background: rgba(243, 156, 18, .08);
    border: 1px solid rgba(243, 156, 18, .2);
    color: #b7791f;
}

.alert-info {
    background: rgba(52, 152, 219, .08);
    border: 1px solid rgba(52, 152, 219, .2);
    color: #1a6fb0;
}

.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 300ms ease;
    border-left: 4px solid var(--primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 1px solid transparent;
}

.page-link:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.page-link.active {
    background: var(--primary);
    color: #fff;
}

/* ---- TABS ---- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-link {
    padding: 10px 20px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
}

.tab-link:hover {
    color: var(--primary);
}

.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ---- DROPDOWN ---- */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 6px;
    z-index: 1050;
    display: none;
    animation: dropIn 150ms ease;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: .85rem;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ---- LOADING ---- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
}

/* ---- NOTIFICATION PANEL ---- */
.notification-panel {
    position: fixed;
    top: 0;
    right: -380px;
    width: 380px;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: var(--shadow-xl);
    z-index: 1055;
    transition: right var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.notification-panel.open {
    right: 0;
}

.notification-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.notification-item:hover {
    background: var(--gray-50);
}

.notification-item.unread {
    background: rgba(26, 82, 118, .03);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .05);
    top: -200px;
    right: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .03);
    bottom: -100px;
    left: -100px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 10;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo img {
    width: 100px;
    height: auto;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: .88rem;
    margin-bottom: 30px;
}

/* ---- GRID UTILS ---- */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

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

.grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* ---- FLEX UTILS ---- */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.items-end {
    align-items: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

.gap-5 {
    gap: 20px;
}

.gap-6 {
    gap: 24px;
}

/* ---- SPACING UTILS ---- */
.m-0 {
    margin: 0;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.mt-5 {
    margin-top: 20px;
}

.mb-1 {
    margin-bottom: 4px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mb-5 {
    margin-bottom: 20px;
}

.p-0 {
    padding: 0;
}

.p-1 {
    padding: 4px;
}

.p-2 {
    padding: 8px;
}

.p-3 {
    padding: 12px;
}

.p-4 {
    padding: 16px;
}

.p-5 {
    padding: 20px;
}

/* ---- TEXT UTILS ---- */
.text-primary {
    color: var(--primary) !important;
}

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

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

.text-warning {
    color: var(--warning) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-center {
    text-align: center;
}

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

.text-left {
    text-align: left;
}

.text-sm {
    font-size: .82rem;
}

.text-lg {
    font-size: 1.1rem;
}

.text-xl {
    font-size: 1.25rem;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- MISC ---- */
.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.rounded {
    border-radius: var(--radius-sm);
}

.rounded-lg {
    border-radius: var(--radius-lg);
}

.shadow {
    box-shadow: var(--shadow-md);
}

.border {
    border: 1px solid var(--border-color);
}

.hidden {
    display: none !important;
}

.visible {
    display: block;
}

.overflow-hidden {
    overflow: hidden;
}

.relative {
    position: relative;
}

.cursor-pointer {
    cursor: pointer;
}

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 16px rgba(26, 82, 118, 0.05);
}

.page-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .82rem;
    color: var(--text-secondary);
}

.page-breadcrumb a {
    color: var(--text-secondary);
}

.page-breadcrumb a:hover {
    color: var(--primary);
}

.page-breadcrumb .separator {
    color: var(--gray-300);
}

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

/* ---- CHARTS ---- */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 300px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    font-size: 3rem;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state .empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.empty-state .empty-text {
    font-size: .88rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ============================================================
   RESPONSIVE / MOBILE / TABLET — COMPREHENSIVE
   Covers: Sidebar, Topbar, Page Headers, KPI Cards, Forms,
   Tables, DataTables, Modals, POS, Invoices, Settings, Filters
   ============================================================ */

/* ---- TABLET (≤1024px) ---- */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-row.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .pos-layout {
        grid-template-columns: 1fr;
    }

    .pos-cart {
        height: 50vh;
    }

    .content-area {
        padding: 20px;
    }

    /* Page header: wrap actions */
    .page-header {
        gap: 10px;
    }

    .page-actions {
        flex-wrap: wrap;
    }

    /* Invoice row grid: tighter */
    .invoice-row {
        grid-template-columns: 30px 1.5fr 70px 70px 90px 70px 90px 30px;
        gap: 6px;
    }

    /* Settings tabs: scroll if needed */
    .settings-tab {
        padding: 8px 14px !important;
        font-size: 0.82rem !important;
    }

    /* KPI values slightly smaller */
    .kpi-value {
        font-size: 1.15rem;
        word-break: break-all;
    }

    .kpi-label {
        font-size: 0.7rem;
        line-height: 1.2;
        margin-bottom: 2px;
    }

    .kpi-card {
        padding: 12px;
    }

    /* Glass card padding */
    .glass-card {
        padding: 1rem 1.25rem;
    }

    .card-header-line {
        margin: -1rem -1.25rem 0.75rem;
        padding: 0.65rem 1.25rem;
    }
}

/* ---- MOBILE (≤768px) ---- */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    /* --- Sidebar: off-canvas --- */
    .sidebar {
        width: 270px;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .sidebar-collapsed .sidebar {
        width: 270px;
    }

    .sidebar-collapsed .main-content {
        margin-left: 0 !important;
    }

    /* --- Content area --- */
    .content-area {
        padding: 14px;
    }

    /* --- Topbar --- */
    .topbar {
        padding: 0 12px;
        gap: 8px;
    }

    .topbar-search {
        display: none;
    }

    .topbar-user-info {
        display: none;
    }

    .topbar-right {
        gap: 4px;
    }

    .company-selector {
        display: none !important;
    }

    .topbar-btn {
        width: 36px;
        height: 36px;
    }

    /* --- Grids: single column --- */
    .grid-2,
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6 {
        grid-template-columns: 1fr;
    }

    .form-row.cols-2,
    .form-row.cols-3,
    .form-row.cols-4 {
        grid-template-columns: 1fr;
    }

    /* --- Page Header --- */
    .page-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
        padding: 1rem !important;
    }

    .page-header .page-header-left {
        width: 100%;
    }

    .page-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .page-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .page-breadcrumb {
        font-size: 0.72rem;
    }

    /* --- KPI Cards --- */
    .kpi-card {
        padding: 0.9rem;
        gap: 0.75rem;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 1.1rem;
    }

    .kpi-value {
        font-size: 1.15rem;
    }

    .kpi-label {
        font-size: 0.68rem;
    }

    .stat-card {
        min-width: 0;
        padding: 14px;
        gap: 12px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    /* --- Glass card --- */
    .glass-card {
        padding: 0.85rem;
    }

    .glass-card .card-body {
        padding: 0.75rem;
    }

    .card-header-line {
        margin: -0.85rem -0.85rem 0.6rem;
        padding: 0.6rem 0.85rem;
    }

    .card-body {
        padding: 14px;
    }

    /* --- Forms: touch-friendly --- */
    .form-control,
    .form-select {
        min-height: 42px;
        font-size: 0.88rem;
        padding: 10px 12px;
    }

    .form-label {
        font-size: 0.78rem;
        margin-bottom: 4px;
    }

    textarea.form-control {
        min-height: 60px;
    }

    /* Bootstrap row cols override for mobile */
    .row.g-3>[class*="col-md-"],
    .row.g-3>[class*="col-lg-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Let row-cols-md-* fall back to single col on mobile */
    .row-cols-md-2>*,
    .row-cols-md-3>*,
    .row-cols-md-4>*,
    .row-cols-xl-4>* {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Fix input-group overflow on mobile */
    .input-group {
        flex-wrap: wrap;
    }

    .input-group>.form-control,
    .input-group>.form-select {
        flex: 1 1 150px !important;
        width: auto !important;
    }

    .input-group-text {
        flex-shrink: 0;
    }

    /* --- Tables: horizontal scroll --- */
    .table-container,
    .glass-card:has(.jrg-table),
    .glass-card:has(.data-table),
    .glass-card:has(.datatable-jrg) {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .jrg-table {
        min-width: 800px;
        /* Force scroll on small screens */
    }

    .datatable-jrg {
        min-width: 900px;
    }

    /* Print View Responsive (for screen viewing on mobile) */
    @media (max-width: 768px) {
        .page {
            width: 100% !important;
            max-width: 100% !important;
            margin: 0 !important;
            height: auto !important;
            min-height: auto !important;
            padding: 10px !important;
        }

        .inv-header,
        .inv-body {
            padding: 15px !important;
            flex-direction: column !important;
            align-items: flex-start !important;
        }

        .logo-box {
            margin-bottom: 15px;
        }

        .info-grid,
        .footer-grid,
        .totals-section {
            grid-template-columns: 1fr !important;
            display: flex !important;
            flex-direction: column !important;
            gap: 15px !important;
        }

        .totals-card {
            width: 100% !important;
        }

        .items-table {
            display: table !important;
            /* Keep as table but allow scroll */
            min-width: 600px !important;
        }

        .inv-body {
            overflow-x: auto;
        }
    }

    .jrg-table td:last-child,
    .data-table td:last-child {
        padding-right: 15px !important;
    }

    .action-btns {
        display: flex;
        gap: 4px;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .jrg-table tbody td,
    .data-table tbody td {
        padding: 8px 10px;
    }

    /* DataTables mobile */
    .dataTables_wrapper {
        padding: 4px 0;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        padding: 6px 8px;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 120px !important;
        margin-left: 4px !important;
    }

    .dataTables_wrapper .dataTables_length select {
        margin: 0 2px;
    }

    .dataTables_wrapper .dataTables_info {
        padding: 8px;
        font-size: 0.72rem !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        padding: 8px 4px;
        text-align: center;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 5px 8px !important;
        margin: 0 1px;
        font-size: 0.72rem !important;
    }

    .top-dt {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 0px !important;
        align-items: center !important;
    }

    /* Action buttons in tables */
    .action-btns {
        gap: 2px;
    }

    .action-btns .btn-icon,
    .btn-icon {
        width: 30px;
        height: 30px;
    }

    .d-flex.gap-1.justify-content-end {
        gap: 2px !important;
        flex-wrap: nowrap;
    }

    /* --- Modals: full-width mobile --- */
    .modal-dialog {
        margin: 8px !important;
        max-width: calc(100vw - 16px) !important;
    }

    .modal-dialog-centered {
        min-height: calc(100vh - 16px);
    }

    .modal-content {
        max-height: 92vh;
        overflow-y: auto;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }

    .jrg-modal-body {
        padding: 16px;
    }

    /* --- Invoice layouts --- */
    .invoice-meta {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .invoice-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px 16px;
    }

    .invoice-header {
        flex-direction: column;
        gap: 12px;
        padding: 20px;
    }

    .invoice-header .company-name {
        font-size: 1.2rem;
    }

    .invoice-type-badge {
        font-size: 0.85rem;
        padding: 6px 14px;
    }

    .invoice-summary {
        padding: 16px;
    }

    .invoice-summary-table {
        min-width: auto;
        width: 100%;
    }

    .invoice-container {
        border-radius: 0;
        margin: 0;
    }

    .invoice-footer {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .invoice-amount-words {
        padding: 10px 16px;
        font-size: 0.78rem;
    }

    /* Invoice row (create/edit) */
    .invoice-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px 0;
    }

    /* --- Filter bars --- */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .filter-bar .form-control {
        max-width: 100%;
    }

    /* --- Buttons: mobile sizing --- */
    .btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .btn-lg {
        padding: 10px 18px !important;
        font-size: 0.92rem !important;
    }

    .btn-sm {
        padding: 6px 10px !important;
        font-size: 0.76rem !important;
    }

    /* --- Notification panel --- */
    .notification-panel {
        width: 100%;
        right: -100%;
    }

    /* --- Dropdown menus --- */
    .dropdown-menu {
        min-width: 180px;
    }

    .dropdown-menu[style*="width: 320px"] {
        width: 280px !important;
    }

    /* --- Settings page tabs: horizontally scrollable --- */
    div:has(> .settings-tab) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
    }

    div:has(> .settings-tab)::-webkit-scrollbar {
        display: none;
    }

    .settings-tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
    }

    /* --- POS Terminal: stack layout --- */
    div[style*="grid-template-columns: 1fr 380px"] {
        grid-template-columns: 1fr !important;
    }

    .pos-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 12px;
        align-items: stretch;
    }

    .pos-header>div {
        flex-wrap: wrap;
    }

    .pos-header>div:first-child {
        justify-content: center;
    }

    .pos-header>div:last-child {
        justify-content: center;
    }

    .pos-header select {
        width: 100% !important;
    }

    .pos-product-card {
        padding: 8px;
    }

    .pos-product-card div[style*="font-size:0.78rem"] {
        font-size: 0.72rem !important;
    }

    .pos-cart-table {
        min-width: 400px !important;
    }

    /* POS quick add grid */
    div[style*="grid-template-columns: repeat(3,1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* --- Tax Estimator: GST rate reference grid --- */
    div[style*="grid-template-columns: repeat(5,1fr)"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* --- Select2 mobile --- */
    .select2-container {
        width: 100% !important;
    }

    .select2-container--default .select2-selection--single {
        min-height: 42px !important;
    }

    /* --- Charts --- */
    .chart-container {
        min-height: 220px;
    }

    div[style*="height:320px"] {
        height: 220px !important;
    }

    div[style*="height:250px"] {
        height: 200px !important;
    }

    /* --- Toast --- */
    .toast-container {
        right: 8px;
        left: 8px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    /* --- Login --- */
    .login-card {
        padding: 28px 20px;
        max-width: 100%;
    }

    .login-page {
        padding: 12px;
    }

    /* --- Empty state --- */
    .empty-state {
        padding: 40px 16px;
    }

    .empty-state .empty-icon {
        font-size: 2.5rem;
    }

    /* Ensure body never overflows horizontally */
    body {
        overflow-x: hidden;
    }

    html {
        overflow-x: hidden;
    }
}

/* ---- SMALL MOBILE (≤480px) ---- */
@media (max-width: 480px) {
    .content-area {
        padding: 10px;
    }

    /* KPI cards: single column */
    .row-cols-md-2>*,
    .row-cols-md-3>*,
    .row-cols-md-4>*,
    .row-cols-xl-4>* {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Page header */
    .page-header {
        padding: 0.75rem !important;
    }

    .page-title {
        font-size: 1rem;
    }

    .page-actions .btn {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    /* KPI even smaller */
    .kpi-card {
        padding: 0.75rem;
    }

    .kpi-value {
        font-size: 1rem;
    }

    .kpi-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 1rem;
    }

    /* Glass card */
    .glass-card {
        padding: 0.65rem;
        border-radius: 8px;
    }

    .card-header-line {
        margin: -0.65rem -0.65rem 0.5rem;
        padding: 0.5rem 0.65rem;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 0.85rem;
    }

    /* Buttons */
    .btn {
        padding: 7px 12px;
        font-size: 0.78rem;
    }

    .btn-lg {
        padding: 9px 16px !important;
        font-size: 0.88rem !important;
    }

    /* Invoice */
    .invoice-container {
        border-radius: 0;
    }

    .invoice-header {
        padding: 14px;
    }

    .invoice-header .company-name {
        font-size: 1rem;
    }

    .invoice-header .company-details {
        font-size: 0.75rem;
    }

    .invoice-items-table thead th,
    .invoice-items-table tbody td {
        padding: 5px 6px;
        font-size: 0.72rem;
    }

    .invoice-details {
        grid-template-columns: 1fr 1fr;
        padding: 10px 14px;
    }

    .invoice-details .detail-value {
        font-size: 0.82rem;
    }

    /* POS */
    .pos-product-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    div[style*="grid-template-columns: repeat(3,1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    div[style*="grid-template-columns: repeat(2,1fr)"] {
        gap: 4px !important;
    }

    /* Tax reference grid */
    div[style*="grid-template-columns: repeat(5,1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Tables */
    .jrg-table,
    .data-table {
        font-size: 0.75rem;
    }

    .jrg-table thead th,
    .data-table thead th {
        padding: 6px 8px;
        font-size: 0.65rem;
    }

    .jrg-table tbody td,
    .data-table tbody td {
        padding: 6px 8px;
    }

    /* Login */
    .login-card {
        padding: 20px 16px;
    }

    .login-title {
        font-size: 1.2rem;
    }

    .login-logo img {
        width: 70px;
    }

    /* Modals */
    .modal-dialog {
        margin: 4px !important;
    }

    .modal-body {
        padding: 12px;
    }

    .modal-header {
        padding: 12px;
    }

    .modal-footer {
        padding: 10px 12px;
    }

    /* Settings tabs */
    .settings-tab {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
    }

    .settings-tab i {
        display: none;
    }

    /* Dropdown */
    .dropdown-menu[style*="width: 320px"] {
        width: calc(100vw - 24px) !important;
    }

    /* --- Extra Utilities --- */
    .table-responsive-jrg {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        margin-bottom: 1rem;
    }

    .stack-on-mobile {
        flex-direction: column !important;
    }

    .hide-on-mobile {
        display: none !important;
    }

    .show-on-mobile {
        display: block !important;
    }

    /* Force form groups to stack properly */
    .form-row,
    .grid-2,
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Horizontal Scroll Hint */
    .scroll-hint::after {
        content: "Scroll horizontally to view more \2192";
        display: block;
        font-size: 0.7rem;
        color: var(--text-3);
        text-align: right;
        margin-top: 4px;
        font-style: italic;
    }
}

/* Restore for desktop */
@media (min-width: 769px) {
    .stack-on-mobile {
        flex-direction: row !important;
    }

    .show-on-mobile {
        display: none !important;
    }
}

/* ---- PRINT STYLES ---- */

@media print {
    body {
        background: #fff !important;
    }

    .sidebar,
    .topbar,
    .page-header,
    .page-actions,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-area {
        padding: 0 !important;
    }

    .invoice-container {
        box-shadow: none !important;
        border-radius: 0 !important;
        max-width: 100% !important;
    }

    .invoice-header {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .invoice-items-table thead {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
    }

    .btn {
        display: none !important;
    }

    @page {
        margin: 10mm;
        size: A4;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ---- ANIMATION KEYFRAMES ---- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.animate-fadeIn {
    animation: fadeIn 300ms ease;
}

.animate-slideUp {
    animation: slideUp 400ms ease;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* ---- SKELETON LOADING ---- */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 20px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ---- DARK OVERLAY FOR MOBILE SIDEBAR ---- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1049;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ---- NUMBER INPUT WITHOUT SPINNERS ---- */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ---- ACTION BUTTONS IN TABLE ---- */
.action-btns {
    display: flex;
    gap: 4px;
}

.action-btns .btn-icon {
    opacity: .6;
    transition: all var(--transition-fast);
}

.action-btns .btn-icon:hover {
    opacity: 1;
}

/* ---- INVOICE ITEM DYNAMIC ROW ---- */
.invoice-row {
    display: grid;
    grid-template-columns: 40px 2fr 80px 80px 100px 80px 100px 40px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.invoice-row .form-control {
    padding: 6px 8px;
    font-size: .85rem;
}

.invoice-row .remove-row {
    color: var(--danger);
    cursor: pointer;
    opacity: .5;
    transition: opacity var(--transition-fast);
}

.invoice-row .remove-row:hover {
    opacity: 1;
}

/* ---- FILTER BAR ---- */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.filter-bar .form-control {
    max-width: 200px;
    padding: 8px 12px;
}

/* ---- STEP INDICATOR ---- */
.steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 30px;
}

.step {
    flex: 1;
    text-align: center;
    position: relative;
}

.step::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--gray-200);
}

.step:last-child::after {
    display: none;
}

.step.active .step-number {
    background: var(--primary);
    color: #fff;
}

.step.completed .step-number {
    background: var(--success);
    color: #fff;
}

.step.completed::after {
    background: var(--success);
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.step-label {
    font-size: .78rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.step.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

/* ================================================================
   JRG GLASS DESIGN SYSTEM — PREMIUM EXTENSION
   All new glassmorphism components, JRG color tokens, and utilities
   ================================================================ */

/* ---- JRG COLOR TOKENS ---- */
:root {
    /* JRG Brand Blues */
    --jrg-blue: #1a5276;
    --jrg-blue-light: #2e86c1;
    --jrg-blue-dim: rgba(30, 80, 120, 0.15);
    --jrg-steel: #566573;
    --jrg-blue-rgb: 26, 82, 118;

    /* Surface & Background */
    --bg-surface: #f4f6f9;
    --bg-surface-2: #eef1f5;
    --bg-glass: rgba(255, 255, 255, 0.7);

    /* Text Hierarchy */
    --text: #1f2937;
    --text-2: #4b5563;
    --text-3: #9ca3af;

    /* Borders */
    --border: #e5e7eb;
    --border-2: rgba(26, 82, 118, 0.15);
    --border-light: rgba(0, 0, 0, 0.06);

    /* Radius */
    --radius: 10px;

    /* Accent Colors */
    --orange: #e67e22;
    --purple: #8e44ad;
    --teal: #16a085;
    --amber: #d97706;
    --green: #27ae60;
    --red: #e74c3c;
    --blue: #2e86c1;
}

/* ---- PAGE HEADER EXTENSIONS ---- */
.page-header-left {
    flex: 1;
}

.page-title-icon {
    margin-right: 10px;
    color: var(--jrg-blue-light);
    font-size: 1.3rem;
    vertical-align: middle;
}

.text-xs {
    font-size: 0.75rem;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

.text-jrg-blue {
    color: var(--jrg-blue-light) !important;
}

.fw-mono {
    font-family: 'JetBrains Mono', monospace;
}

.fw-medium {
    font-weight: 500;
}

.text-muted {
    color: var(--text-3) !important;
}

.opacity-25 {
    opacity: 0.25;
}

.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.h-100 {
    height: 100%;
}

.border-jrg {
    border: 1px solid var(--border-2) !important;
}

.hover-danger:hover {
    color: var(--red) !important;
}

/* ---- GLASS CARD ---- */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    box-shadow: 0 2px 16px rgba(26, 82, 118, 0.08);
    padding: 1.25rem 1.5rem;
    transition: box-shadow 0.2s ease;
}

.glass-card:hover {
    box-shadow: 0 4px 24px rgba(26, 82, 118, 0.12);
}

.glass-card .card-body {
    padding: 1rem 1.25rem;
}

/* Card header line inside glass-card */
.card-header-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    margin: -1.25rem -1.5rem 1rem;
}

.glass-card[style*="padding:0;"] .card-header-line,
.glass-card[style*="padding: 0;"] .card-header-line,
.glass-card[style*="padding: 0"] .card-header-line,
.glass-card.p-0 .card-header-line {
    margin: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-header-line .card-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    display: flex;
    align-items: center;
}

/* ---- KPI CARDS ---- */
.kpi-card {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 12px rgba(26, 82, 118, 0.07);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 82, 118, 0.14);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

.kpi-label {
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 2px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* KPI Color Variants */
.kpi-card.blue .kpi-icon {
    background: rgba(46, 134, 193, 0.12);
    color: var(--jrg-blue-light);
}

.kpi-card.green .kpi-icon {
    background: rgba(39, 174, 96, 0.12);
    color: var(--green);
}

.kpi-card.red .kpi-icon {
    background: rgba(231, 76, 60, 0.12);
    color: var(--red);
}

.kpi-card.orange .kpi-icon {
    background: rgba(230, 126, 34, 0.12);
    color: var(--orange);
}

.kpi-card.amber .kpi-icon {
    background: rgba(217, 119, 6, 0.12);
    color: var(--amber);
}

.kpi-card.purple .kpi-icon {
    background: rgba(142, 68, 173, 0.12);
    color: var(--purple);
}

.kpi-card.teal .kpi-icon {
    background: rgba(22, 160, 133, 0.12);
    color: var(--teal);
}

.jrg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.jrg-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    background: rgba(26, 82, 118, 0.02);
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
}

.jrg-table tbody td {
    padding: 14px 16px;
    font-size: 0.88rem;
    color: var(--text);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.jrg-table tbody tr {
    transition: background 0.15s ease;
}

.jrg-table tbody tr:hover {
    background: rgba(26, 82, 118, 0.03);
}

.jrg-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- NEW BUTTON STYLES ---- */
.btn-jrg-primary {
    background: linear-gradient(135deg, var(--jrg-blue) 0%, var(--jrg-blue-light) 100%);
    color: #fff !important;
    border: none;
    box-shadow: 0 2px 10px rgba(26, 82, 118, 0.25);
}

.btn-jrg-primary:hover {
    background: linear-gradient(135deg, #1a5276 0%, #2e86c1 100%);
    color: #fff !important;
    box-shadow: 0 4px 16px rgba(26, 82, 118, 0.38);
    transform: translateY(-1px);
}

.btn-outline-primary {
    background: transparent;
    border: 1.5px solid var(--jrg-blue-light);
    color: var(--jrg-blue-light);
}

.btn-outline-primary:hover {
    background: rgba(46, 134, 193, 0.08);
    border-color: var(--jrg-blue);
    color: var(--jrg-blue);
}

.btn-outline-light {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-2);
}

.btn-outline-light:hover {
    background: var(--bg-surface-2);
    border-color: var(--text-3);
    color: var(--text);
}

.btn-outline-success {
    background: transparent;
    border: 1.5px solid var(--green);
    color: var(--green);
}

.btn-outline-success:hover {
    background: rgba(39, 174, 96, 0.08);
}

.btn-outline-danger {
    background: transparent;
    border: 1.5px solid var(--red);
    color: var(--red);
}

.btn-outline-danger:hover {
    background: rgba(231, 76, 60, 0.08);
}

/* ---- NEW BADGE VARIANTS ---- */
.badge-green {
    background: rgba(39, 174, 96, 0.12);
    color: #1a7a3a;
}

.badge-red {
    background: rgba(231, 76, 60, 0.12);
    color: #c0392b;
}

.badge-blue {
    background: rgba(46, 134, 193, 0.12);
    color: #1a5276;
}

.badge-amber {
    background: rgba(217, 119, 6, 0.12);
    color: #92400e;
}

.badge-orange {
    background: rgba(230, 126, 34, 0.12);
    color: #9a3412;
}

.badge-purple {
    background: rgba(142, 68, 173, 0.12);
    color: #6b21a8;
}

.badge-teal {
    background: rgba(22, 160, 133, 0.12);
    color: #0f5132;
}

.badge-steel {
    background: rgba(86, 101, 115, 0.12);
    color: var(--jrg-steel);
}

/* Bootstrap-style size helpers for buttons */
.btn-sm {
    padding: 5px 12px !important;
    font-size: 0.78rem !important;
}

.btn-lg {
    padding: 11px 22px !important;
    font-size: 1rem !important;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0 !important;
}

/* ---- GLASSMORPHISM BODY (dark background support) ---- */
body.dark-erp {
    --bg-glass: rgba(15, 25, 40, 0.65);
    --text: #e2e8f0;
    --text-2: #94a3b8;
    --text-3: #64748b;
    --border-light: rgba(255, 255, 255, 0.07);
}

/* ---- DATATABLES GLASS THEME OVERRIDE ---- */
.dataTables_wrapper {
    padding: 5px 10px;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 10px;
    color: var(--text-2);
    font-size: 0.82rem;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid var(--border);
    border-radius: 50px;
    /* Pill shape for search */
    padding: 5px 16px;
    font-size: 0.82rem;
    outline: none;
    background: var(--bg-card, #fff);
    color: var(--text);
    margin-left: 8px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px var(--border-light);
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--jrg-blue-light);
    box-shadow: 0 0 0 3px var(--jrg-blue-dim);
}

.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 4px 24px 4px 10px;
    font-size: 0.82rem;
    appearance: none;
    background-color: var(--bg-card, #fff);
    color: var(--text);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 14px;
    margin: 0 4px;
    cursor: pointer;
}

.dataTables_wrapper .dataTables_info {
    padding: 15px 10px;
    font-size: 0.78rem;
    color: var(--text-2);
    font-weight: 500;
}

.dataTables_wrapper .dataTables_paginate {
    padding: 12px 10px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    color: var(--text-2) !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    cursor: pointer;
    margin: 0 2px;
    transition: all 0.2s;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--jrg-blue-dim) !important;
    color: var(--jrg-blue) !important;
    border: 1px solid var(--border-2) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
    background: var(--bg-surface-2) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* Ensure glass-card tables sit flush */
.glass-card .jrg-table {
    margin: 0;
}

/* ---- SELECT2 GLASS OVERRIDE ---- */
.select2-container--default .select2-selection--single {
    border: 1.5px solid var(--border) !important;
    border-radius: var(--radius) !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px !important;
    padding-left: 12px !important;
    font-size: 0.88rem;
    color: var(--text);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px !important;
}

.select2-dropdown {
    border: 1px solid var(--border-2) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}

/* ---- ANIMATE UTILITIES ---- */
.animate-fadeIn {
    animation: fadeIn 300ms ease;
}

/* (576px responsive rules merged into comprehensive responsive section above) */


/* ---- SELECT2 JRG THEME OVERRIDE ---- */
.select2-container--default .select2-selection--single,
.select2-container--bootstrap4 .select2-selection--single,
.select2-container .select2-selection--single {
    height: 42px !important;
    border: 1.5px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    background-color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 8px !important;
    transition: all var(--transition-fast) !important;
    box-shadow: none !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary) !important;
    line-height: normal !important;
    padding-left: 4px !important;
    font-size: 0.88rem !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow,
.select2-container .select2-selection--single .select2-selection__arrow {
    height: 40px !important;
    right: 10px !important;
}

.select2-container--open .select2-dropdown {
    border-color: var(--primary) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg) !important;
    z-index: 1060 !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary) !important;
}

/* ========================================================================
   PAGE SPECIFIC RESPONSIVE STYLES
   ======================================================================== */

/* --- Common Responsive Utilities --- */
.table-responsive-jrg {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fix for the white gap on the right in mobile */
@media (max-width: 991px) {
    .app-wrapper {
        display: block !important; /* Ensure main content is not constrained by flex sidebar */
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 100% !important;
        padding: 0 !important;
    }
    
    .topbar {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* ------------------------------------------------------------------------
   PAGE: SALES INVOICES (Tax Invoices & Create)
   ------------------------------------------------------------------------ */

/* Tablet (up to 991px) */
@media (max-width: 991px) {
    .table-responsive-jrg {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 1.5rem;
    }
}

/* Mobile (up to 768px) */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column !important;
        align-items: stretch !important; /* Changed from flex-start to stretch for full width */
        gap: 12px !important;
        margin-bottom: 1rem;
        width: 100% !important;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 12px !important;
    }

    .kpi-card {
        padding: 1rem !important;
        width: 100% !important;
    }

    .kpi-value {
        font-size: 1.25rem !important;
    }
    
    .jrg-table {
        min-width: 850px; /* Force horizontal scroll for data readability */
    }
    
    .glass-card {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Small Mobile (up to 480px) */
@media (max-width: 480px) {
    .page-title {
        font-size: 1.1rem !important;
    }
    
    .glass-card {
        padding: 0.75rem !important;
    }
    
    .kpi-card {
        gap: 0.75rem !important;
    }
    
    .content-area {
        padding: 8px !important;
    }
}