/* EyeFlow — Optical SaaS Management System */
/* Primary: #1E3A8A | Secondary: #10B981 */

:root {
    --primary:       #1E3A8A;
    --primary-light: #3B5CB8;
    --primary-dark:  #152C6B;
    --secondary:     #10B981;
    --secondary-dark:#059669;
    --bg:            #F8FAFC;
    --surface:       #FFFFFF;
    --border:        #E2E8F0;
    --text:          #1E293B;
    --text-muted:    #64748B;
    --danger:        #EF4444;
    --warning:       #F59E0B;
    --sidebar-w:     260px;
    --topbar-h:      60px;
    --radius:        8px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:     0 4px 12px rgba(0,0,0,.1);
    --transition:    .2s ease;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.font-lao {
    font-family: 'Noto Sans Lao', 'Inter', sans-serif;
}

.font-latin {
    font-family: 'Inter', 'Roboto', sans-serif;
}

/* Form controls don't inherit font in most browsers — set explicitly */
html.font-lao,
html.font-lao body,
.font-lao input,
.font-lao textarea,
.font-lao select,
.font-lao button,
.font-lao .btn,
.font-lao label,
.font-lao .lang-btn,
.font-lao h1,
.font-lao h2,
.font-lao h3,
.font-lao p,
.font-lao span {
    font-family: 'Noto Sans Lao', 'Inter', sans-serif;
}

.font-latin input,
.font-latin textarea,
.font-latin select,
.font-latin button,
.font-latin .btn,
.font-latin label,
.font-latin .lang-btn {
    font-family: 'Inter', 'Roboto', sans-serif;
}

.font-lao input::placeholder,
.font-lao textarea::placeholder {
    font-family: 'Noto Sans Lao', 'Inter', sans-serif;
    color: #94A3B8;
}

a:not(.btn):not(.nav-item):not(.lang-btn):not(.package-badge):not(.tab-filter):not(.sidebar-package-link) { color: var(--primary); text-decoration: none; }
a:not(.btn):not(.nav-item):not(.lang-btn):not(.package-badge):not(.tab-filter):not(.sidebar-package-link):hover { color: var(--primary-light); }

/* ── Layout ─────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-icon {
    font-size: 28px;
    background: rgba(255,255,255,.15);
    border-radius: 10px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
}

.brand-logo {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 58px;
    object-fit: contain;
    display: block;
}

.brand-name { font-size: 18px; font-weight: 700; }
.brand-sub  { font-size: 11px; opacity: .7; line-height: 1.3; }

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: rgba(255,255,255,.9) !important;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,.15);
    color: #fff !important;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 0;
}

.sidebar-package-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 1;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    color: rgba(255,255,255,.92) !important;
    border: 1px solid rgba(251, 191, 36, 0.45);
    background: rgba(251, 191, 36, 0.12);
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.sidebar-package-link:hover,
.sidebar-package-link.active {
    background: rgba(251, 191, 36, 0.22);
    border-color: #FBBF24;
    color: #fff !important;
}

.sidebar-package-icon {
    flex-shrink: 0;
    color: #FBBF24;
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.45));
}

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

.sidebar-footer-lang {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.lang-btn {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,.7);
    border: 1px solid rgba(255,255,255,.3);
    transition: all var(--transition);
}

.lang-btn.active, .lang-btn:hover {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}

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

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 22px; height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.branch-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg);
    cursor: pointer;
    max-width: 180px;
}

.branch-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    color: var(--primary);
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-danger-text { color: var(--danger) !important; }
.btn-danger-text:hover { background: #FEE2E2 !important; color: #991B1B !important; }


/* Topbar package badge */
.topbar-package { display: flex; align-items: center; }

.package-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border: 1px solid #BFDBFE;
    color: var(--primary);
    text-decoration: none;
    transition: all var(--transition);
    max-width: 220px;
}

.package-badge:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    color: var(--primary);
}

.package-badge.expired {
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    border-color: #FECACA;
    color: #991B1B;
}

.package-badge-icon { font-size: 18px; flex-shrink: 0; }

.package-badge-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.package-badge-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.package-badge-exp {
    font-size: 10px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.package-badge.package-beginner { border-left: 3px solid #64748B; }
.package-badge.package-professional { border-left: 3px solid var(--primary); }
.package-badge.package-enterprise { border-left: 3px solid var(--secondary); }

/* Subscription page */
.pkg-badge-lg {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

.row-current-pkg { background: #EFF6FF; }
.row-current-pkg td { font-weight: 500; }

@media (max-width: 768px) {
    .package-badge { max-width: 140px; padding: 4px 8px; }
    .package-badge-exp { display: none; }
    .branch-select { max-width: 120px; font-size: 12px; }
}

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

/* ── Cards & Stats ──────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

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

.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}

.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

a.btn { text-decoration: none; }

.btn-primary  { background: var(--secondary); color: #fff; }
.btn-primary:hover { background: var(--secondary-dark); color: #fff; }
.btn-secondary{ background: var(--primary); color: #fff; }
.btn-secondary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline  { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #EFF6FF; }
.btn-ghost    { background: #F1F5F9; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: #E2E8F0; }

/* Action button variants */
.btn-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }
.btn-info:hover { background: #BFDBFE; color: #1E3A8A; }
.btn-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.btn-warning:hover { background: #FDE68A; color: #78350F; }
.btn-neutral { background: #F1F5F9; color: #475569; border: 1px solid #CBD5E1; }
.btn-neutral:hover { background: #E2E8F0; color: #1E293B; }
.btn-success { background: var(--secondary); color: #fff; border: 1px solid var(--secondary-dark); }
.btn-success:hover { background: var(--secondary-dark); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; border: 1px solid #DC2626; }
.btn-danger:hover { background: #DC2626; color: #fff; }

.btn-sm  { padding: 5px 10px; font-size: 13px; }
.btn-lg  { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}

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

.form-control::placeholder {
    color: #94A3B8;
    opacity: 1;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    transition: opacity 0.28s ease, transform 0.28s ease, max-height 0.28s ease, margin 0.28s ease, padding 0.28s ease;
    overflow: hidden;
}

.alert.alert-dismissed {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
}

.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }

/* ── Login Page ─────────────────────────────────────────── */
.login-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 40px 32px;
    box-shadow: var(--shadow-md);
}

.login-brand { text-align: center; margin-bottom: 32px; }
.brand-icon-lg { display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.login-logo {
    display: block;
    margin: 0 auto 20px;
    width: min(100%, 280px);
    height: auto;
    object-fit: contain;
}
.login-brand h1 { font-size: 28px; font-weight: 700; color: var(--primary); }
.login-brand p  { font-size: 13px; color: var(--text-muted); margin-top: 6px; line-height: 1.7; }

.password-input-wrap {
    position: relative;
}

.password-input-wrap .form-control {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.password-toggle:hover {
    color: var(--primary);
    background: var(--bg);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.login-form .form-group { margin-bottom: 18px; }

.login-form .form-control {
    padding: 12px 14px;
    font-size: 15px;
}

.login-lang {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.login-lang .lang-btn {
    color: var(--text-muted);
    border-color: var(--border);
}

.login-lang .lang-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.login-credit {
    margin: 16px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── POS Layout ─────────────────────────────────────────── */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    height: calc(100vh - var(--topbar-h) - 48px);
}

.pos-products, .pos-cart {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-search-bar {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.pos-barcode-input.scan-miss {
    animation: scan-miss-flash 0.5s ease;
}
@keyframes scan-miss-flash {
    0%, 100% { border-color: var(--border); }
    50% { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2); }
}

.product-category-tabs,
.job-product-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.product-category-tab,
.job-product-tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.product-category-tab:hover,
.product-category-tab.active,
.job-product-tab:hover,
.job-product-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.job-order-fields {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
}

.job-order-fields-compact {
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    flex-shrink: 0;
}

.job-order-fields-compact .job-notes-row {
    grid-column: 1 / -1;
}

.job-order-fields-compact .form-group {
    margin-bottom: 0;
}

.job-order-fields .form-group,
.job-order-fields-compact .form-group {
    margin-bottom: 8px;
}

.job-order-fields-compact .form-group {
    margin-bottom: 0;
}

.job-order-fields label,
.job-order-fields-compact label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.job-cart-panel .cart-items {
    flex: 1;
    min-height: 100px;
}

.job-cart-panel .cart-summary.job-cart-summary {
    padding: 6px 12px;
}

.job-cart-panel .cart-summary .summary-row {
    padding: 3px 0;
    font-size: 13px;
}

.job-cart-panel .cart-pay-panel {
    flex-shrink: 0;
}

.job-cart-panel .cart-pay-fields .summary-row {
    padding: 3px 0;
}

.job-cart-panel .cart-actions .btn-primary {
    width: 100%;
}

.job-slot-tag {
    color: var(--primary);
    font-weight: 600;
}

.product-grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    align-content: start;
}

.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.cart-header h2 { font-size: 16px; font-weight: 600; }

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

.customer-picker-field .pos-customer-picker {
    position: relative;
}

.cart-customer {
    padding: 12px 16px 0;
    border-top: 1px solid var(--border);
}

.cart-customer-top {
    padding: 10px 12px;
    border-top: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.cart-customer label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.pos-customer-picker {
    position: relative;
}

.pos-customer-search-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.pos-customer-search-row .form-control {
    flex: 1;
    min-width: 0;
}

.pos-customer-search-row .btn {
    flex-shrink: 0;
    padding: 0 10px;
    white-space: nowrap;
}

.pos-customer-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 50;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.pos-customer-results li {
    margin: 0;
}

.pos-customer-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
}

.pos-customer-option:hover,
.pos-customer-option:focus {
    background: var(--bg);
}

.pos-customer-option-name {
    display: block;
    font-weight: 600;
}

.pos-customer-option-meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.pos-customer-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.pos-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pos-modal[hidden] {
    display: none;
}

.pos-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.pos-modal-box {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.pos-modal-box.pos-modal-lg {
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.pos-modal-box .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.pos-modal-box .form-row .form-group {
    flex: 1;
    min-width: 140px;
}

.pos-modal-box h3 {
    margin: 0 0 16px;
    font-size: 18px;
}

.pos-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.purchase-total {
    font-size: 16px;
    margin-bottom: 12px;
}

.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-page {
    font-size: 13px;
    color: var(--text-muted);
    padding: 0 4px;
}

.cart-summary {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 4px 0;
    color: var(--text-muted);
}

.summary-row.total {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 10px;
}

.summary-row.secondary-currency {
    font-size: 13px;
    color: var(--secondary);
}

.cart-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.cart-actions .btn-primary { flex: 1; min-width: 120px; }
.cart-actions #parkedListBtn { flex: 1; min-width: 0; }
.cart-actions #parkBillBtn { flex: 0 1 auto; }

.parked-badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.pos-parked-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    max-height: 360px;
    overflow-y: auto;
}

.pos-parked-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.pos-parked-item:last-child { border-bottom: none; }

.pos-parked-info {
    flex: 1;
    min-width: 0;
}

.pos-parked-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.pos-parked-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.pos-parked-actions {
    display: flex;
    flex-shrink: 0;
    gap: 4px;
}

.pos-parked-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 12px;
    font-size: 14px;
}

.pos-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 14px;
    grid-column: 1 / -1;
}

.pos-tabs { display: none; }

.cart-badge {
    background: var(--secondary);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
}

/* ── Utilities ──────────────────────────────────────────── */
.mt-4       { margin-top: 16px; }
.text-muted { color: var(--text-muted); }

/* ── Admin: Tables, Forms, Badges ──────────────────────── */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 400px;
}

.search-form .form-control { flex: 1; }

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.data-table tbody tr:hover { background: #F1F5F9; }

.job-parts-cell {
    max-width: 220px;
    font-size: 13px;
    line-height: 1.4;
}

.job-status-form {
    margin: 0;
    min-width: 140px;
}

.job-status-select {
    width: 100%;
    min-width: 130px;
    padding: 5px 8px;
    font-size: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
}

.job-status-select:focus {
    outline: none;
    border-color: var(--primary);
}

.actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.actions-cell .btn-sm {
    min-height: 30px;
}

.inline-form { display: inline; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-muted   { background: #F1F5F9; color: #64748B; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }

.admin-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.admin-form .form-row .form-group-full {
    grid-column: 1 / -1;
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.form-section-title:first-child { margin-top: 0; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

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

select.form-control { cursor: pointer; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.detail-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    font-size: 14px;
}

.detail-list dt {
    color: var(--text-muted);
    font-weight: 500;
}

.detail-list dd { margin: 0; }

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.quick-link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 500;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.quick-link-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.quick-icon { font-size: 24px; }

.p-0  { padding: 0 !important; }
.p-4  { padding: 16px !important; }

.form-group-btn { display: flex; flex-direction: column; justify-content: flex-end; }

.card-body.p-0 .table-wrap:last-child .data-table tr:last-child td { border-bottom: none; }

/* Product cards (POS) */
.product-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition);
}
.product-card:hover { border-color: var(--primary); background: #EFF6FF; }
.product-card-img {
    width: 100%; height: 80px; object-fit: cover;
    border-radius: 6px; margin-bottom: 8px; background: #F1F5F9;
}
.product-card-img-placeholder {
    width: 100%; height: 80px; display: flex; align-items: center; justify-content: center;
    font-size: 28px; background: #F1F5F9; border-radius: 6px; margin-bottom: 8px;
}
.product-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; line-height: 1.3; }
.product-price { font-size: 14px; font-weight: 700; color: var(--primary); }
.product-stock { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.product-card-out-of-stock { opacity: 0.65; }
.product-card-out-of-stock .product-stock { color: var(--danger); font-weight: 600; }

.stock-receipt-cart-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px;
}
.stock-receipt-notes { padding: 0 4px; }
.stock-cart-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.stock-cart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.stock-cart-meta { font-size: 12px; margin: 4px 0 8px; }
.stock-cart-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.stock-field span {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.stock-field .form-control { padding: 6px 8px; font-size: 14px; }
.stock-field-readonly .stock-cost-value {
    padding: 6px 8px;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.stock-receipt-meta {
    padding: 0 4px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.stock-receipt-meta .form-group { margin-bottom: 8px; }
.stock-receipt-pay-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.stock-cart-line-total {
    text-align: right;
    font-weight: 600;
    font-size: 13px;
    margin-top: 6px;
    color: var(--primary);
}

.cart-item-row {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.cart-item-main { flex: 1; min-width: 0; }
.cart-item-title {
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 2px;
    word-break: break-word;
}
.cart-item-calc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}
.cart-item-calc strong { color: var(--primary); font-weight: 700; }
.cart-item-name { flex: 1; min-width: 0; }
.cart-item-price { white-space: nowrap; font-weight: 500; }
.cart-qty-inline {
    display: inline-flex;
    vertical-align: middle;
    margin: 0 2px;
}
.cart-qty-inline .cart-qty-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
}
.cart-qty-control {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.cart-qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
}
.cart-qty-btn:hover { background: var(--surface); border-color: var(--primary); }
.cart-qty-value {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
}
.cart-remove {
    background: none; border: none; color: var(--danger);
    font-size: 18px; cursor: pointer; padding: 0 4px;
}
.cart-pay-panel { border-top: 1px solid var(--border); }
.cart-pay-options { display: flex; gap: 8px; padding: 8px 16px 4px; }
.cart-pay-fields { padding: 4px 16px 8px; }
.cart-pay-fields .summary-row { padding: 4px 0; align-items: center; }
.cart-pay-fields .pay-input {
    width: 120px;
    max-width: 45%;
    margin-left: auto;
    text-align: right;
}
.cart-pay-fields .discount-input-row {
    gap: 6px;
}
.cart-pay-fields .pay-discount-type {
    width: 72px;
    flex-shrink: 0;
    padding: 4px 6px;
}
.pay-change-row strong.text-success { color: var(--secondary); }
.pay-balance-row strong.text-warning { color: #D97706; }

/* Rx form */
.rx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rx-eye-block h4 { font-size: 13px; color: var(--primary); margin-bottom: 8px; }
.rx-fields { grid-template-columns: repeat(4, 1fr) !important; }

/* Job status badges */
.badge-job-pending { background: #FEF3C7; color: #92400E; }
.badge-job-in_progress { background: #DBEAFE; color: #1E40AF; }
.badge-job-ready { background: #D1FAE5; color: #065F46; }
.badge-job-delivered { background: #F1F5F9; color: #64748B; }

.tab-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-filter {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.tab-filter:hover,
.tab-filter.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

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

@media (max-width: 768px) {
    .rx-grid { grid-template-columns: 1fr; }
    .rx-fields { grid-template-columns: 1fr 1fr !important; }
}

/* Product image & barcode input */
.product-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.product-thumb-placeholder { font-size: 24px; opacity: 0.5; }
.product-thumb-cell { width: 50px; }
.product-image-preview {
    max-width: 200px; max-height: 150px; border-radius: var(--radius);
    border: 1px solid var(--border); margin-bottom: 8px; display: block;
}
.image-preview-wrap { margin-bottom: 8px; }
.input-with-btn { display: flex; gap: 8px; align-items: stretch; }
.input-with-btn .form-control { flex: 1; }
.input-with-btn .btn { white-space: nowrap; flex-shrink: 0; }

/* ── Sidebar overlay (mobile) ─────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 150;
}

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

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
    .pos-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .pos-cart { display: none; }
    .pos-cart.active { display: flex; }
    .pos-products.hidden { display: none; }

    .pos-tabs {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 100;
    }

    .pos-tab {
        flex: 1;
        padding: 12px;
        background: none;
        border: none;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        color: var(--text-muted);
        font-family: inherit;
    }

    .pos-tab.active {
        color: var(--primary);
        border-top: 2px solid var(--primary);
    }

    .page-content { padding-bottom: 60px; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .hamburger { display: flex; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}

/* Reports */
.report-toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.report-toolbar-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 1px solid var(--border);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.report-toolbar-nav::-webkit-scrollbar {
    height: 4px;
}

.report-toolbar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.report-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.report-nav-item:hover,
.report-nav-item.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.report-nav-icon { font-size: 14px; line-height: 1; flex-shrink: 0; }

.report-toolbar-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.report-toolbar-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
}

.report-toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    flex-shrink: 0;
}

.report-toolbar-actions {
    flex-shrink: 0;
    margin-left: auto;
}

.tab-filters-inline {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    flex-shrink: 0;
}

.tab-filters-inline .tab-filter {
    white-space: nowrap;
    font-size: 12px;
    padding: 5px 12px;
}

.report-date-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.report-date-form .form-control-sm {
    width: auto;
    min-width: 130px;
    padding: 5px 8px;
    font-size: 12px;
}

.report-date-sep { color: var(--text-muted); flex-shrink: 0; }

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

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

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

.stats-grid-reports .stat-card {
    padding: 14px 16px;
}

.stats-grid-reports .stat-label {
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-grid-reports .stat-value {
    font-size: 22px;
}

.report-kv-table th {
    width: 42%;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--bg);
}

.report-kv-table td {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

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

@media (max-width: 1200px) {
    .stats-grid-reports {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

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

    .report-kv-table th {
        white-space: normal;
        font-size: 12px;
    }
}

.report-hub {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.report-hub-card {
    display: block;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.report-hub-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.report-hub-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.report-hub-card h3 { margin: 0 0 6px; font-size: 1rem; color: var(--text); }
.report-hub-card p { margin: 0; font-size: 0.8125rem; color: var(--text-muted); }

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 200px;
}

.report-table th:last-child,
.report-table td:last-child { min-width: 180px; }

.text-success { color: var(--success, #16a34a); }
.text-danger { color: var(--danger, #dc2626); }

/* Dashboard */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.dashboard-heading {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.dashboard-sub {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.dashboard-kpis.stats-grid-reports {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.dashboard-kpis .stat-card {
    padding: 12px 14px;
}

.dashboard-kpis .stat-label {
    font-size: 11px;
    margin-bottom: 2px;
}

.dashboard-kpis .stat-value {
    font-size: 20px;
    line-height: 1.2;
}

.dashboard-kpis .stat-sub {
    margin-top: 2px;
    font-size: 11px;
}

.stat-card-accent {
    border-left-color: var(--secondary);
}

.stat-card-accent .stat-value {
    color: var(--secondary-dark);
}

.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: stretch;
}

.dashboard-charts-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    min-height: 0;
    align-items: stretch;
}

.dashboard-chart-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.dashboard-chart-card .card-header {
    padding: 10px 14px;
}

.dashboard-chart-card .card-header h2 {
    font-size: 13px;
}

.dashboard-chart-card .card-body {
    padding: 8px 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 230px;
    flex: 1;
    min-height: 230px;
}

.chart-wrap-donut {
    height: 230px;
    min-height: 230px;
}

.dashboard-lists.detail-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: stretch;
}

.dashboard-lists .card {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dashboard-lists .card-body {
    flex: 1;
}

.dashboard-lists .card-header {
    padding: 10px 14px;
}

.dashboard-lists .card-header h2 {
    font-size: 14px;
}

.dashboard-lists .card-body.p-0 .text-muted {
    padding: 14px !important;
    margin: 0;
    font-size: 13px;
}

@media (max-width: 1200px) {
    .dashboard-kpis.stats-grid-reports {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-charts {
        grid-template-columns: 1fr;
    }

    .dashboard-charts-side {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-kpis.stats-grid-reports {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-charts-side {
        grid-template-columns: 1fr;
    }

    .dashboard-lists.detail-grid {
        grid-template-columns: 1fr;
    }

    .chart-wrap,
    .chart-wrap-donut {
        min-height: 200px;
    }
}
