/* ==========================================================================
   POS System - Shared Application Stylesheet
   Full-screen layout: fixed sidebar + top bar + content, used by
   dashboard / POS / reports. Login page uses a separate centered layout
   further down this file.
   ========================================================================== */

:root {
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-header-start: #0f172a;
    --color-header-end: #1e293b;

    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-secondary: #4f46e5;
    --color-success: #059669;
    --color-success-dark: #047857;
    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-warning: #d97706;

    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-text-faint: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;
    --color-bg-muted: #f8fafc;

    --sidebar-width: 236px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', 'Noto Sans Lao', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------------
   App shell: sidebar + main area, fills the full viewport
   ------------------------------------------------------------------------ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--color-header-start) 0%, var(--color-header-end) 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 22px 20px;
    font-size: 16.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: -0.01em;
}

.sidebar-brand i {
    background: var(--color-primary);
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-section-label {
    color: rgba(255, 255, 255, 0.35);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 14px 6px;
}

.sidebar-link {
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s ease, color 0.15s ease;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-link i {
    width: 16px;
    text-align: center;
    font-size: 13.5px;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar-link.active {
    background: var(--color-primary);
    color: #ffffff;
}

.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-user {
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #ffffff;
    flex-shrink: 0;
}

.sidebar-user-info {
    min-width: 0;
}

.sidebar-user-name {
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    text-transform: capitalize;
}

.sidebar-link.logout {
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-link.logout:hover {
    background: rgba(220, 38, 38, 0.18);
    color: #fecaca;
}

/* Mobile sidebar toggle (hidden on desktop) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 150;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-header-end);
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
}

.sidebar-backdrop.visible { display: block; }

/* ------------------------------------------------------------------------
   Main area: top bar + content + footer
   ------------------------------------------------------------------------ */
.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 16px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.topbar h1 i {
    color: var(--color-primary);
    font-size: 16px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.main-content,
.content-wrapper {
    flex: 1;
    padding: 26px 30px;
    width: 100%;
    max-width: 1500px;
}

/* ------------------------------------------------------------------------
   Stat / summary cards
   ------------------------------------------------------------------------ */
.stats-grid,
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.stat-card,
.summary-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

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

.stat-card::before,
.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-primary);
}

.stat-card.today::before,
.summary-card.transactions::before { background: var(--color-danger); }
.stat-card.month::before,
.summary-card.items::before { background: var(--color-warning); }
.summary-card.revenue::before { background: var(--color-success); }

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.stat-icon,
.card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: #ffffff;
    background: var(--color-primary);
    flex-shrink: 0;
}

.stat-card.today .stat-icon { background: var(--color-danger); }
.stat-card.month .stat-icon { background: var(--color-warning); }
.summary-card.transactions .card-icon { background: var(--color-danger); }
.summary-card.items .card-icon { background: var(--color-warning); }
.summary-card.revenue .card-icon { background: var(--color-success); }

.stat-value,
.card-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.stat-label,
.card-label {
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
}

.card-value.currency { color: var(--color-success-dark); }

/* ------------------------------------------------------------------------
   Sections (Recent Sales, Low Stock, report blocks, POS table wrapper)
   ------------------------------------------------------------------------ */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.password-form-wrap {
    max-width: 480px;
}

.password-form-wrap .btn {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

.section,
.report-section,
.table-container {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
    margin-bottom: 20px;
}

.content-grid .section { margin-bottom: 0; }

.section-header,
.table-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.section-header h3,
.table-header h3,
.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header i,
.table-header i,
.filter-title i {
    color: var(--color-primary);
    font-size: 14px;
}

.section-content,
.filter-section {
    padding: 20px 22px;
}

.date-range-badge {
    background: var(--color-primary);
    color: #ffffff;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

/* ------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------ */
table,
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrapper {
    overflow-x: auto;
}

th,
.data-table th {
    background: var(--color-bg-muted);
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

td,
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 13.5px;
    vertical-align: middle;
}

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

tr:hover,
.data-table tbody tr:hover {
    background: var(--color-bg-muted);
}

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

.amount,
.currency {
    font-weight: 600;
    color: var(--color-success-dark);
    font-variant-numeric: tabular-nums;
}

.bill-no {
    font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
    font-weight: 600;
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    color: var(--color-primary-dark);
    font-size: 12.5px;
}

.low-stock,
.stock-display {
    display: inline-block;
    background: #fef2f2;
    color: var(--color-danger);
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
    min-width: 32px;
    text-align: center;
}

.stock-low { background: #fef2f2; color: var(--color-danger); }
.stock-medium { background: #fffbeb; color: var(--color-warning); }
.stock-good { background: #ecfdf5; color: var(--color-success-dark); }

/* ------------------------------------------------------------------------
   Empty states
   ------------------------------------------------------------------------ */
.no-data {
    text-align: center;
    color: var(--color-text-muted);
    padding: 44px 20px;
    background: var(--color-bg-muted);
    border-radius: var(--radius-md);
}

.no-data i {
    font-size: 34px;
    margin-bottom: 12px;
    color: var(--color-border-strong);
    display: block;
}

/* ------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------ */
.footer,
.footer-info {
    text-align: center;
    padding: 14px 30px;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 12.5px;
    background: var(--color-surface);
}

/* ------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------ */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover {
    box-shadow: var(--shadow-sm);
}

.btn-primary { background: var(--color-primary); color: #ffffff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-success { background: var(--color-success); color: #ffffff; }
.btn-success:hover { background: var(--color-success-dark); }

.btn-danger {
    background: var(--color-danger);
    color: #ffffff;
    padding: 8px 12px;
    font-size: 12px;
}
.btn-danger:hover { background: var(--color-danger-dark); }

.btn-muted { background: #64748b; color: #ffffff; }
.btn-muted:hover { background: #475569; }

.filter-btn {
    padding: 10px 20px;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
}
.filter-btn:hover { background: var(--color-primary-dark); }

.action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 18px;
    padding: 16px;
    background: var(--color-bg-muted);
    border-radius: var(--radius-md);
}

/* ------------------------------------------------------------------------
   Messages (success / error banners)
   ------------------------------------------------------------------------ */
.message {
    padding: 13px 18px;
    margin-bottom: 18px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message.success {
    background: #ecfdf5;
    color: var(--color-success-dark);
    border: 1px solid #a7f3d0;
}

.message.error {
    background: #fef2f2;
    color: var(--color-danger-dark);
    border: 1px solid #fecaca;
}

/* ------------------------------------------------------------------------
   Forms (filter bar, POS product rows)
   ------------------------------------------------------------------------ */
.filter-form {
    display: flex;
    gap: 18px;
    align-items: end;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.filter-form label,
.form-group label {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 12.5px;
}

.filter-form input {
    padding: 10px 13px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    min-width: 150px;
    font-family: inherit;
    color: var(--color-text);
}

.filter-form select {
    padding: 10px 13px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    min-width: 150px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
}

.filter-form input:focus,
.filter-form select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.report-note {
    margin: -8px 0 18px;
    color: var(--color-text-muted);
    font-size: 12.5px;
}

.sale-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.sale-status-active {
    background: #ecfdf5;
    color: #047857;
}

.sale-status-deleted {
    background: #fef2f2;
    color: #b91c1c;
}

.sale-status-meta {
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: 11px;
}

.filter-form input[type="date"] {
    color-scheme: light;
    cursor: pointer;
}

.filter-form input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 4px;
    margin-left: 4px;
    border-radius: var(--radius-sm);
    opacity: 0.65;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.filter-form input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background: var(--color-bg-muted);
}

input[type="text"], input[type="number"], input[type="password"] {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    background: var(--color-surface);
    font-family: inherit;
    color: var(--color-text);
}

input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[readonly] {
    background: var(--color-bg-muted);
    color: var(--color-text-muted);
}

/* Autocomplete */
.autocomplete-container {
    position: relative;
    width: 100%;
    min-width: 240px;
}

.autocomplete-input {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
}

.autocomplete-input:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.autocomplete-suggestions {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 99999;
    display: none;
    box-shadow: var(--shadow-lg);
}

.autocomplete-suggestion {
    padding: 11px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
}

.autocomplete-suggestion:hover { background: var(--color-bg-muted); }

.autocomplete-suggestion.active {
    background: var(--color-primary);
    color: #ffffff;
}

.suggestion-name {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 3px;
    font-size: 13.5px;
}

.active .suggestion-name { color: #ffffff; }

.suggestion-details {
    font-size: 11.5px;
    color: var(--color-text-muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.active .suggestion-details { color: rgba(255, 255, 255, 0.9); }

.detail-item {
    background: var(--color-bg-muted);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
}

.active .detail-item { background: rgba(255, 255, 255, 0.2); }

/* ------------------------------------------------------------------------
   POS layout: cart (left) + sticky order-summary panel (right)
   ------------------------------------------------------------------------ */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

.pos-summary-card {
    position: sticky;
    top: 82px;
}

.pos-summary-card .section-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    color: var(--color-text-muted);
}

.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 14px 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.summary-total-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-total-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-success-dark);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.pos-summary-card .btn-success {
    width: 100%;
    justify-content: center;
    padding: 13px;
    font-size: 14.5px;
}

.pos-summary-card .btn-muted {
    width: 100%;
    justify-content: center;
}

/* Touch-friendly qty stepper inside the cart */
.qty-stepper {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.qty-stepper button {
    width: 25px;
    height: 25px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    padding: 0;
}

.qty-stepper button:hover { background: var(--color-bg-muted); }

.qty-stepper input {
    width: 42px;
    text-align: center;
    padding: 5px 4px;
}

@media (max-width: 1024px) {
    .pos-layout { grid-template-columns: 1fr; }
    .pos-summary-card { position: static; }
}

.loading {
    padding: 12px 16px;
    text-align: center;
    color: var(--color-text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading i { animation: spin 1s linear infinite; }

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

.product-row.completed { background: #f0fdf4; }
.product-row.error { background: #fef2f2; }

/* ------------------------------------------------------------------------
   Login page (separate centered layout, not part of the app shell)
   ------------------------------------------------------------------------ */
body.auth-body {
    min-height: 100vh;
    background: var(--color-bg);
}

.auth-shell {
    display: flex;
    min-height: 100vh;
}

.auth-brand-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 48px;
    background: linear-gradient(135deg, var(--color-header-start) 0%, #1e3a5f 55%, var(--color-primary) 130%);
}

.auth-brand-content { max-width: 380px; color: #ffffff; }

.auth-brand-content .brand-icon {
    width: 58px;
    height: 58px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 22px;
}

.auth-brand-content h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

.auth-brand-content p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 14.5px;
    line-height: 1.6;
    margin-bottom: 28px;
}

.auth-feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-feature-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
    color: rgba(255, 255, 255, 0.85);
}

.auth-feature-list li i {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.auth-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    padding: 40px 24px;
}

.login-container {
    width: 100%;
    max-width: 380px;
}

.login-header { text-align: left; margin-bottom: 2rem; }

.login-header h2 {
    color: var(--color-text);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    letter-spacing: -0.01em;
}

.login-header p { color: var(--color-text-muted); font-size: 0.9rem; }

.login-container .form-group { margin-bottom: 1.25rem; }

.login-container label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background-color: var(--color-bg-muted);
}

.login-container input[type="text"]:focus,
.login-container input[type="password"]:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--color-surface);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-container .btn {
    width: 100%;
    justify-content: center;
    padding: 0.85rem;
    background: var(--color-primary);
    color: #ffffff;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.login-container .btn:hover { background: var(--color-primary-dark); }

.login-container .error {
    color: var(--color-danger-dark);
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.88rem;
    text-align: center;
}

.form-footer {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.form-footer p { color: var(--color-text-faint); font-size: 0.82rem; }

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid transparent;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------ */
@media (max-width: 1024px) {
    .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-lg);
    }

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

    .sidebar-toggle {
        display: inline-flex;
    }

    .main-wrapper { width: 100%; }
}

@media (max-width: 768px) {
    .topbar { padding: 14px 18px; }
    .main-content, .content-wrapper { padding: 18px; }
    .stats-grid, .summary-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .action-buttons { flex-direction: column; align-items: stretch; }
    .btn { justify-content: center; }
    .footer, .footer-info { padding: 14px 18px; }

    .auth-shell { flex-direction: column; }
    .auth-brand-panel { flex: none; padding: 32px 24px; }
    .auth-feature-list { display: none; }
    .auth-form-panel { padding: 32px 20px; }

    /* Products page: stack the toolbar and let the search box take full width */
    .products-toolbar { flex-direction: column; align-items: stretch; }
    .products-toolbar .search-box { max-width: none; }
    .products-toolbar .toolbar-actions { justify-content: flex-start; }

    /* Modal forms: two-column field pairs become one column so labels and
       number inputs (e.g. "Cost Price (K)") aren't squeezed on a phone. */
    .modal-form .form-row { grid-template-columns: 1fr; }
    .modal-box { padding: 20px; }
    .modal-actions { flex-wrap: wrap; }

    /* Cart quantity stepper and receipt toolbar stay usable at narrow widths */
    .qty-stepper input { width: 36px; }
}

@media (max-width: 480px) {
    .receipt-toolbar .btn { flex: 1 1 calc(50% - 5px); }
}

/* ------------------------------------------------------------------------
   Modal dialog (replaces native confirm()/alert() popups)
   ------------------------------------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: modalFadeIn 0.15s ease;
}

/* Force-hidden whenever the "hidden" attribute is set, regardless of the
   display:flex rule above. Without this, a persistently-in-the-DOM modal
   (toggled via el.hidden in JS, as on the Products page) can stay visibly
   rendered even after being "closed". */
.modal-overlay[hidden] {
    display: none !important;
}

.modal-box {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
    max-width: 400px;
    width: 100%;
    padding: 24px;
    animation: modalPop 0.15s ease;
}

.modal-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: #ffffff;
    background: var(--color-primary);
    margin-bottom: 14px;
}

.modal-icon.danger { background: var(--color-danger); }

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
}

.modal-message {
    font-size: 13.5px;
    color: var(--color-text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions .btn { padding: 9px 18px; }

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* Wider modal variant that holds a real form (Add/Edit/Adjust Stock/Upload) */
.modal-box.modal-form {
    max-width: 480px;
    text-align: left;
}

.modal-form .modal-subtitle {
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin-bottom: 18px;
    margin-top: -4px;
}

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

.modal-form .form-group { margin-bottom: 14px; }
.modal-form .form-hint { font-size: 11.5px; color: var(--color-text-muted); margin-top: -8px; margin-bottom: 14px; }

/* ------------------------------------------------------------------------
   Products page: toolbar, pagination, compact row actions
   ------------------------------------------------------------------------ */
.products-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.products-toolbar .search-box { flex: 1; min-width: 220px; max-width: 360px; }
.products-toolbar .toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.action-icons {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-icons .btn { padding: 6px 10px; font-size: 12px; }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.pagination a, .pagination span.page-current, .pagination span.page-ellipsis {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong);
    font-size: 13px;
    color: var(--color-text);
    text-decoration: none;
}

.pagination a:hover { background: var(--color-bg-muted); }
.pagination span.page-current { background: var(--color-primary); border-color: var(--color-primary); color: #ffffff; font-weight: 600; }
.pagination span.page-ellipsis { border: none; color: var(--color-text-muted); padding: 7px 4px; }

/* ------------------------------------------------------------------------
   Receipt (receipt.php - shared by "Print Bill" and report reprints)
   ------------------------------------------------------------------------ */
.receipt-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 16px;
}

.receipt-toolbar {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.receipt-toolbar .btn { flex: 1; justify-content: center; }

.receipt {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px 22px;
    width: 100%;
    max-width: 340px;
    font-family: 'SFMono-Regular', Consolas, 'Courier New', 'Noto Sans Lao', monospace;
    color: var(--color-text);
}

.receipt-header {
    text-align: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--color-border-strong);
}

.receipt-header .receipt-brand {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.receipt-header .receipt-subtitle {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.receipt-meta {
    font-size: 11.5px;
    color: var(--color-text-muted);
    margin-bottom: 14px;
    line-height: 1.6;
}

.receipt-meta strong { color: var(--color-text); }

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    margin-bottom: 12px;
}

.receipt-table th {
    text-align: left;
    padding: 0 0 6px;
    border-bottom: 1px dashed var(--color-border-strong);
    font-weight: 600;
    color: var(--color-text-muted);
}

.receipt-table th:last-child, .receipt-table td:last-child { text-align: right; }
.receipt-table th:nth-child(2), .receipt-table td:nth-child(2) { text-align: center; }

.receipt-table td { padding: 5px 0; vertical-align: top; }

.receipt-totals {
    border-top: 1px dashed var(--color-border-strong);
    padding-top: 10px;
    margin-bottom: 14px;
}

.receipt-totals .receipt-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
}

.receipt-totals .receipt-total-row.grand {
    font-size: 14px;
    font-weight: 700;
    margin-top: 6px;
}

.receipt-footer {
    text-align: center;
    font-size: 11px;
    color: var(--color-text-muted);
}

.receipt-not-found {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}

/* ------------------------------------------------------------------------
   Print (Reports page)
   ------------------------------------------------------------------------ */
.print-only { display: none; }

@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }

    * { -webkit-print-color-adjust: exact !important; color-adjust: exact !important; }

    body { background: #ffffff !important; }
    .app-shell { display: block !important; }
    .sidebar { display: none !important; }

    .main-content, .content-wrapper {
        padding: 0 !important;
        max-width: 100% !important;
    }

    .print-header {
        text-align: center;
        margin-bottom: 24pt;
        border-bottom: 2pt solid var(--color-text);
        padding-bottom: 12pt;
    }

    .print-header h1 { font-size: 22pt !important; color: var(--color-text) !important; margin-bottom: 4pt !important; }
    .print-header .company-info { font-size: 10pt !important; color: #666 !important; margin-bottom: 4pt !important; }
    .print-date-range { font-size: 11pt !important; font-weight: bold !important; }

    .summary-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 12pt !important; page-break-inside: avoid !important; }
    .summary-card { border: 1pt solid #ddd !important; box-shadow: none !important; }
    .summary-card::before, .card-icon { display: none !important; }

    .report-section { page-break-inside: avoid !important; border: 1pt solid #ddd !important; box-shadow: none !important; }
    .date-range-badge { background: none !important; color: #666 !important; padding: 0 !important; }

    .data-table th { background: #f0f0f0 !important; border: 1pt solid #ccc !important; }
    .data-table td { border: 1pt solid #ddd !important; }

    .print-footer {
        margin-top: 24pt !important;
        padding-top: 12pt !important;
        border-top: 1pt solid #ddd !important;
        text-align: center !important;
        font-size: 9pt !important;
        color: #666 !important;
    }

    @page {
        size: 80mm auto;
        margin: 4mm;
    }

    .receipt-page { padding: 0 !important; display: block !important; }
    .receipt-toolbar { display: none !important; }
    .receipt { box-shadow: none !important; border: none !important; max-width: 100% !important; margin: 0 !important; }
}
