/* ==========================================
   POS System - Modern Dark Theme
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #222639;
    --bg-card-hover: #2a2f45;
    --bg-input: #181b25;
    --bg-modal: rgba(0, 0, 0, 0.75);

    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b4;
    --text-muted: #636b7e;
    --text-white: #ffffff;

    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-dark: #4834d4;

    --success: #00cec9;
    --success-dark: #00b3ad;
    --warning: #fdcb6e;
    --danger: #ff6b6b;
    --danger-dark: #e55555;
    --info: #74b9ff;

    --gradient-accent: linear-gradient(135deg, #6c5ce7, #a29bfe);
    --gradient-success: linear-gradient(135deg, #00cec9, #55efc4);
    --gradient-danger: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    --gradient-card: linear-gradient(145deg, #222639, #2a2f45);

    --border-color: #2d3250;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.3);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--accent-light);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent);
}

img {
    max-width: 100%;
    height: auto;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ── Login Page ── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.15), transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.1), transparent 50%),
        var(--bg-primary);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .logo h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.login-card .logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
    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='%239ca3b4' 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 16px center;
    padding-right: 40px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    text-decoration: none;
    white-space: nowrap;
    min-height: 48px;
    user-select: none;
    -webkit-user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--gradient-accent);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 25px rgba(108, 92, 231, 0.5);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--gradient-success);
    color: #0a3d3c;
    box-shadow: 0 4px 15px rgba(0, 206, 201, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 25px rgba(0, 206, 201, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--gradient-danger);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 25px rgba(255, 107, 107, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.1);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-height: 36px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
    min-height: 56px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem;
}

/* ── Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand h2 {
    font-size: 1.4rem;
    font-weight: 800;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(108, 92, 231, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gradient-accent);
    color: var(--text-white);
    box-shadow: var(--shadow-glow);
}

.nav-item .nav-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
}

.user-details .user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-details .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    min-height: 100vh;
}

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-white);
}

.page-header .actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(108, 92, 231, 0.3);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.purple {
    background: rgba(108, 92, 231, 0.2);
    color: var(--accent-light);
}

.stat-icon.green {
    background: rgba(0, 206, 201, 0.2);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(253, 203, 110, 0.2);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(255, 107, 107, 0.2);
    color: var(--danger);
}

.stat-icon.blue {
    background: rgba(116, 185, 255, 0.2);
    color: var(--info);
}

.stat-info h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-info .stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-white);
}

.stat-info .stat-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover td {
    background: rgba(108, 92, 231, 0.05);
}

.product-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
}

/* ── POS Layout ── */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 20px;
    height: calc(100vh - 72px);
}

.pos-products {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-search {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
}

.pos-search .form-control {
    flex: 1;
}

.category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: nowrap;
}

.category-tab {
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.category-tab:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--gradient-accent);
    color: var(--text-white);
    border-color: transparent;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    overflow-y: auto;
    flex: 1;
    padding: 4px;
    align-content: flex-start;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

.product-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.product-card .prod-img {
    width: 100%;
    height: 120px;
    min-height: 120px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.product-card .prod-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card .prod-info {
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-card);
    flex: 1;
    z-index: 2;
    position: relative;
    width: 100%;
}

.product-card .prod-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffffff !important;
    line-height: 1.2;
    height: 2.4em;
    /* Show 2 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card .prod-price {
    font-size: 1rem;
    font-weight: 800;
    color: var(--success);
    margin: 2px 0;
}

.product-card .prod-stock {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
}

.product-card .prod-stock.low {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
}

/* Variant Selection */
.variant-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.variant-btn:hover {
    border-color: var(--accent);
}

.variant-btn.active {
    background: var(--gradient-accent);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-sm);
}

.product-card .prod-stock.low {
    color: var(--danger);
    font-weight: 600;
}

/* ── Thermal receipt printing (80mm roll) ── */
@media print {
    @page { size: 80mm auto; margin: 0; }
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }
    /* Hide the whole app, reveal only the receipt (works for sale & return receipts) */
    body * { visibility: hidden !important; }
    .receipt, .receipt * { visibility: visible !important; }
    .receipt {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 80mm !important;
        max-width: 80mm !important;
        margin: 0 !important;
        padding: 2mm 3mm !important;
        color: #000 !important;
        background: #fff !important;
        font-family: 'Courier New', 'Consolas', monospace !important;
        font-size: 12px !important;
        line-height: 1.35 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
    }
    .receipt .receipt-header { text-align: center !important; margin-bottom: 6px !important; padding-bottom: 6px !important; border-bottom: 1px dashed #000 !important; }
    .receipt .receipt-header h3 { font-size: 14px !important; color: #000 !important; margin: 0 0 2px !important; }
    .receipt .receipt-header p { color: #000 !important; margin: 1px 0 !important; }
    .receipt table { width: 100% !important; border-collapse: collapse !important; }
    .receipt table th, .receipt table td {
        color: #000 !important;
        padding: 1px 2px !important;
        border: none !important;
        border-bottom: 1px dotted #777 !important;
        font-size: 11px !important;
        vertical-align: top !important;
    }
    .receipt table th { border-bottom: 1px solid #000 !important; }
    .receipt .receipt-total { margin-top: 6px !important; padding-top: 6px !important; border-top: 1px dashed #000 !important; text-align: right !important; color: #000 !important; }
    .receipt .receipt-total p { margin: 1px 0 !important; }
    .receipt .receipt-footer { text-align: center !important; margin-top: 6px !important; padding-top: 6px !important; border-top: 1px dashed #000 !important; color: #000 !important; }
    /* keep any empty hidden duplicate out of the print */
    #printableReceipt:not(.receipt) { display: none !important; }
}

/* ── Cart Panel ── */
.pos-cart {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.cart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}

.cart-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.cart-customer {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cart-customer span {
    color: var(--accent-light);
    font-weight: 600;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.cart-items table {
    font-size: 0.82rem;
}

.cart-items table th {
    font-size: 0.72rem;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.cart-items table td {
    padding: 8px 12px;
}

.cart-items .cart-prod-img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-input);
}

.cart-items input {
    width: 70px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.82rem;
    text-align: center;
    outline: none;
    transition: var(--transition);
}

.cart-items input:focus {
    border-color: var(--accent);
}

.cart-items .qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cart-items .qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.cart-items .qty-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.cart-items .remove-btn {
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    background: none;
    border: none;
    padding: 4px;
}

.cart-items .remove-btn:hover {
    color: var(--danger-dark);
    transform: scale(1.2);
}

.discount-display {
    color: var(--warning);
    font-weight: 600;
    font-size: 0.78rem;
}

/* ── Cart Summary ── */
.cart-summary {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.summary-row.total {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-white);
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px solid var(--border-color);
}

.summary-row .discount-amount {
    color: var(--success);
}

/* ── Payment Buttons ── */
.payment-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.pay-btn {
    padding: 16px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.pay-btn:active {
    transform: scale(0.95);
}

.pay-btn.cash {
    background: linear-gradient(135deg, #00b894, #55efc4);
    color: #0a3d2f;
}

.pay-btn.upi {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
}

.pay-btn.card-pay {
    background: linear-gradient(135deg, #0984e3, #74b9ff);
    color: white;
}

.pay-btn .pay-icon {
    font-size: 1.3rem;
}

/* ── Empty Cart ── */
.cart-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 40px;
}

.cart-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.cart-empty p {
    font-size: 0.9rem;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success {
    background: rgba(0, 206, 201, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(253, 203, 110, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger);
}

.badge-info {
    background: rgba(116, 185, 255, 0.15);
    color: var(--info);
}

.badge-purple {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-white);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}

.toast-success {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: #0a3d3c;
}

.toast-error {
    background: linear-gradient(135deg, #e55555, #ff6b6b);
}

.toast-warning {
    background: linear-gradient(135deg, #f39c12, #fdcb6e);
    color: #3d2e00;
}

.toast-info {
    background: linear-gradient(135deg, #0984e3, #74b9ff);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ── Filters Bar ── */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar .form-control {
    width: auto;
    min-width: 140px;
}

/* ── Report Tabs ── */
.report-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 4px;
    border: 1px solid var(--border-color);
}

.report-tab {
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    border: none;
    background: none;
    font-family: var(--font-family);
}

.report-tab:hover {
    color: var(--text-primary);
}

.report-tab.active {
    background: var(--gradient-accent);
    color: var(--text-white);
    box-shadow: var(--shadow-sm);
}

/* ── Image Upload ── */
.image-upload {
    width: 120px;
    height: 120px;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.image-upload:hover {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
}

.image-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-upload .upload-icon {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.image-upload .upload-text {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.image-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ── Receipt Modal ── */
.receipt {
    background: white;
    color: #333;
    padding: 24px;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    max-width: 320px;
    margin: 0 auto;
}

.receipt .receipt-header {
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #ccc;
}

.receipt .receipt-header h3 {
    color: #333;
    font-size: 1.1rem;
}

.receipt table {
    width: 100%;
    font-size: 0.8rem;
}

.receipt table th {
    background: transparent;
    color: #666;
    border-bottom: 1px solid #ddd;
    padding: 6px 4px;
}

.receipt table td {
    padding: 6px 4px;
    border-bottom: 1px solid #eee;
    color: #333;
}

.receipt .receipt-total {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #ccc;
    text-align: right;
}

.receipt .receipt-footer {
    text-align: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed #ccc;
    color: #888;
    font-size: 0.78rem;
}

/* ── Hamburger (Mobile) ── */
.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--text-primary);
    transition: var(--transition);
}

/* ── Sidebar Overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

/* ── Loading Spinner ── */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Grid helpers ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-muted {
    color: var(--text-muted);
}

.fw-bold {
    font-weight: 700;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .pos-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .pos-cart {
        min-height: 50vh;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: 64px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .page-header h1 {
        font-size: 1.3rem;
    }

    .pos-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .pos-cart {
        min-height: auto;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }

    .product-card .prod-img {
        width: 60px;
        height: 60px;
    }

    .product-card .prod-name {
        font-size: 0.75rem;
    }

    .payment-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .filters-bar {
        flex-direction: column;
    }

    .filters-bar .form-control {
        width: 100%;
    }

    .report-tabs {
        flex-wrap: wrap;
    }
}

/* ── Print ── */
/* (thermal receipt print rules are consolidated in the 80mm block above) */
/* ==========================================================
   POS ENHANCEMENTS — barcode, card cart, stock top-up,
   returns, and mobile-first refinements (added)
   ========================================================== */

/* Never allow the page body to scroll sideways on any device */
html, body { max-width: 100%; overflow-x: hidden; }

/* ── Scan button in the POS search bar ── */
.pos-search { align-items: stretch; }
.btn-scan {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 18px; min-height: 46px;
    background: var(--gradient-accent); color: #fff;
    border: none; border-radius: var(--border-radius-sm);
    font-weight: 700; cursor: pointer; white-space: nowrap;
    transition: var(--transition);
}
.btn-scan:active { transform: scale(0.96); }
.btn-scan .scan-ico { font-size: 1.15rem; }

/* ── Product card: out of stock (kept tappable → Add Stock) ── */
.product-card.out { opacity: 0.6; }
.product-card.out .prod-stock { color: var(--danger); background: rgba(255,107,107,0.12); }

/* ── Variant size button: out of stock (still selectable) ── */
.variant-btn.out { opacity: 0.65; border-style: dashed; }

/* ── Cart rendered as touch-friendly cards ── */
.cart-list { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.cart-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cc-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); line-height: 1.25; word-break: break-word; }
.cc-variant {
    display: inline-block; margin-left: 6px;
    font-size: 0.68rem; font-weight: 600; color: var(--accent-light);
    background: rgba(108,92,231,0.15); padding: 1px 8px; border-radius: 20px;
    vertical-align: middle;
}
.cc-remove {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px;
    background: rgba(255,107,107,0.1); border: none; color: var(--danger);
    font-size: 0.95rem; cursor: pointer; transition: var(--transition);
}
.cc-remove:hover { background: rgba(255,107,107,0.22); }
.cc-mid { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cc-price-field { display: flex; align-items: center; gap: 6px; }
.cc-price-field label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.cc-price-field input {
    width: 94px; padding: 8px 10px; font-size: 0.9rem; text-align: right;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 8px; color: var(--text-primary); outline: none;
    font-family: var(--font-family);
}
.cc-price-field input:focus { border-color: var(--accent); }
.cc-meta { display: flex; align-items: center; gap: 10px; }
.cc-mrp { font-size: 0.75rem; color: var(--text-muted); text-decoration: line-through; }
.cc-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cc-qty { min-width: 30px; text-align: center; font-weight: 700; font-size: 1rem; }
.cc-total { font-size: 1rem; color: var(--success); }

/* Larger qty steppers for touch (applies to POS + returns) */
.qty-controls { display: flex; align-items: center; gap: 8px; }
.qty-btn {
    width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 9px; color: var(--text-primary); cursor: pointer;
    font-size: 1.25rem; font-weight: 700; transition: var(--transition); user-select: none;
    -webkit-user-select: none;
}
.qty-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.qty-btn:active { transform: scale(0.9); }

/* ── Scanner modal ── */
.scanner-view { width: 100%; min-height: 240px; border-radius: var(--border-radius-sm); overflow: hidden; background: #000; }
.scanner-view video { width: 100% !important; height: auto !important; border-radius: var(--border-radius-sm); }
.scanner-hint { margin-top: 12px; font-size: 0.82rem; color: var(--text-secondary); text-align: center; }

/* ── Add Stock modal ── */
.stock-modal-msg { font-size: 0.92rem; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.stock-modal-msg b { color: var(--text-primary); }
.stock-stepper { display: flex; align-items: center; gap: 10px; }
.stock-stepper input { flex: 1; text-align: center; font-size: 1.15rem; font-weight: 700; }

/* ── Mobile floating cart button (only shows on small screens with items) ── */
.mobile-cart-fab {
    display: none; position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
    z-index: 150; padding: 13px 26px; border: none; border-radius: 50px;
    background: var(--gradient-accent); color: #fff; font-size: 0.95rem; font-weight: 800;
    box-shadow: var(--shadow-lg); cursor: pointer; align-items: center; gap: 6px;
}
.mobile-cart-fab:active { transform: translateX(-50%) scale(0.96); }

/* ── Returns screen ── */
.returns-lookup .lookup-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.4px; }
.lookup-row { display: flex; gap: 10px; flex-wrap: wrap; }
.lookup-row .form-control { flex: 1; min-width: 180px; }
.lookup-row .btn { min-height: 46px; }
.section-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; color: var(--text-primary); }
.sale-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; }
.sale-info-grid > div { display: flex; flex-direction: column; gap: 2px; }
.si-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.si-value { font-size: 0.92rem; font-weight: 700; color: var(--text-primary); }
.return-items { display: flex; flex-direction: column; gap: 12px; }
.return-card { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--border-radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.return-card.done { opacity: 0.6; }
.rc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.rc-name { font-size: 0.92rem; font-weight: 700; word-break: break-word; }
.rc-price { font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.rc-info { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.8rem; color: var(--text-secondary); }
.rc-info b { color: var(--text-primary); }
.rc-returnable b { color: var(--success); }
.rc-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rc-all { padding: 6px 14px; min-height: 38px; }
.rc-refund { font-weight: 800; color: var(--success); font-size: 1rem; }
.rc-fully { color: var(--success); font-weight: 700; font-size: 0.9rem; }
.refund-summary { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border-color); font-size: 1rem; font-weight: 700; }
.refund-total { font-size: 1.5rem; font-weight: 800; color: var(--success); }

/* ── Mobile-first refinements ── */
@media (max-width: 768px) {
    .pos-layout { height: auto; }
    .pos-products { overflow: visible; }
    .product-grid { overflow-y: visible; }
    .cart-items { overflow-y: visible; }
    .btn-scan .scan-txt { display: none; }
    .btn-scan { padding: 0 15px; }
    .mobile-cart-fab.has-items { display: inline-flex; }
    .cc-price-field input { width: 86px; }
    .lookup-row .btn { width: 100%; }
    .modal { width: 94%; max-width: 94% !important; }
}

@media (min-width: 769px) {
    .mobile-cart-fab { display: none !important; }
}

/* ==========================================================
   MOBILE FIX — admin pages (dashboard, reports, products…)
   Stops stat cards / tables from overflowing the screen width
   ========================================================== */
.main-content { min-width: 0; }
.stats-grid { grid-template-columns: repeat(auto-fill, minmax(0, 240px)); }
.stat-info { min-width: 0; }
.stat-info .stat-value { overflow-wrap: anywhere; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .main-content { padding: 14px; padding-top: 64px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-icon { width: 42px; height: 42px; font-size: 1.15rem; }
    .stat-info h4 { font-size: 0.72rem; }
    .stat-info .stat-value { font-size: 1.35rem; }
    .stat-info .stat-sub { font-size: 0.72rem; }
    .card { padding: 16px; }
    .card-header h3 { font-size: 1rem; }
    .page-header h1 { font-size: 1.35rem; }
    table th, table td { padding: 10px 12px; font-size: 0.82rem; }
    .grid-2, .grid-3 { gap: 12px; }
}

@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
}
