/* ============================================================
   SmartStock POS — custom stylesheet
   1. Variables         2. Reset/base
   3. Buttons           4. Alerts
   5. Auth (login)      6. App layout + sidebar
   7. Topbar            8. Page head
   8b. Section headings  9. Cards + KPI grid
   10. Panels + quick actions
   11. Empty state     12. Mobile responsive
   ============================================================ */

/* 1. Variables ----------------------------------------------- */
:root {
    --color-brand:       #2563eb;
    --color-brand-dark:  #1d4ed8;
    --color-brand-soft:  #dbeafe;

    --color-bg:          #f4f6fa;
    --color-surface:     #ffffff;
    --color-border:      #e3e8ef;

    --color-text:        #1e293b;
    --color-text-muted:  #64748b;
    --color-text-faint:  #94a3b8;

    --color-success:     #16a34a;
    --color-success-bg:  #dcfce7;
    --color-danger:      #dc2626;
    --color-danger-bg:   #fee2e2;
    --color-warn:        #d97706;
    --color-warn-bg:     #fef3c7;

    --sidebar-bg:        #0f1b2d;
    --sidebar-text:      #aebad0;
    --sidebar-text-active:#ffffff;
    --sidebar-active-bg: #1d2c47;

    --radius:            10px;
    --radius-sm:         6px;
    --shadow-sm:         0 1px 2px rgba(15, 27, 45, 0.06);
    --shadow-md:         0 8px 24px rgba(15, 27, 45, 0.08);

    --sidebar-width:     264px;
    --topbar-height:     64px;

    --font:              "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

/* 2. Reset/base ---------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

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

img, svg { display: block; max-width: 100%; }

input, button, select, textarea {
    font: inherit;
    color: inherit;
}

a { color: var(--color-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--color-brand-soft); }

/* 3. Buttons -------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--color-brand);
    color: #fff;
}
.btn-primary:hover {
    background: var(--color-brand-dark);
    text-decoration: none;
}
.btn-primary:focus-visible {
    outline: 3px solid var(--color-brand-soft);
    outline-offset: 1px;
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover { border-color: var(--color-text-faint); text-decoration: none; }

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { background: #b91c1c; text-decoration: none; }

.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: rgba(15, 27, 45, 0.06); color: var(--color-text); }
.icon-btn svg { width: 20px; height: 20px; }

/* 4. Alerts --------------------------------------------------- */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.alert-success { background: var(--color-success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--color-danger-bg);  color: #991b1b; border: 1px solid #fecaca; }

/* 5. Auth (login) -------------------------------------------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 500px at 85% -10%, rgba(37, 99, 235, 0.10), transparent 60%),
        var(--color-bg);
}

.auth-shell { width: 100%; max-width: 420px; }

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 36px 32px 28px;
}

.auth-brand { text-align: center; margin-bottom: 26px; }

.auth-mark {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--color-brand), #7c3aed);
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.auth-subtitle { color: var(--color-text-muted); font-size: 14px; margin-top: 4px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--color-text); }

.input {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-soft);
}
.input::placeholder { color: var(--color-text-faint); }
.input.input-error { border-color: var(--color-danger); box-shadow: 0 0 0 3px var(--color-danger-bg); }

.auth-hint {
    margin-top: 18px;
    text-align: center;
    font-size: 12.5px;
    color: var(--color-text-muted);
    background: var(--color-warn-bg);
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.auth-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--color-text-faint);
}

.error-card { text-align: center; }
.error-code {
    display: inline-block;
    font-size: 56px;
    font-weight: 800;
    color: var(--color-brand);
    line-height: 1;
}
.error-title { font-size: 20px; margin: 8px 0 6px; }
.error-message { color: var(--color-text-muted); margin-bottom: 20px; }

/* 6. App layout + sidebar ------------------------------------ */
.app-body { background: var(--color-bg); }

.app-layout { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform .22s ease;
}

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

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--color-brand), #7c3aed);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; color: #fff; font-size: 16px; }
.brand-sub { font-size: 11.5px; color: var(--sidebar-text); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
    text-decoration: none;
}
.nav-link:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); text-decoration: none; }

.nav-link.is-active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    box-shadow: inset 3px 0 0 var(--color-brand);
}

.nav-icon { display: inline-grid; place-items: center; flex-shrink: 0; }
.nav-icon svg { width: 19px; height: 19px; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.version-badge {
    font-size: 11.5px;
    color: var(--sidebar-text);
    background: var(--sidebar-active-bg);
    padding: 4px 10px;
    border-radius: 99px;
}

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

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 27, 45, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.app-content {
    flex: 1;
    padding: 24px;
    max-width: 1360px;
    width: 100%;
}

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

.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-left .sidebar-toggle { display: none; }
.topbar-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 6px;
    border-radius: 99px;
}

.user-avatar {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-brand);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-size: 13.5px; font-weight: 600; }
.user-role { font-size: 11.5px; color: var(--color-text-muted); }

.logout-form { margin: 0; display: inline-flex; }

/* 8. Page head ------------------------------------------------ */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.page-subtitle { color: var(--color-text-muted); font-size: 14.5px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; }

/* 9. Section headings ---------------------------------------- */
.section-heading {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    border-left: 4px solid var(--color-brand);
    padding-left: 10px;
    margin: 0 0 12px;
    line-height: 1.3;
}

.page-section { margin-bottom: 28px; }
.page-section:last-child { margin-bottom: 0; }

/* 9a. Cards + card grid -------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 20px 24px;
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.cards-grid > .card { margin: 0; }

/* 9b. KPI cards ---------------------------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    min-height: 120px;
    padding: 20px 24px;
    background: var(--color-surface);
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.kpi-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.kpi-icon {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
}
.kpi-icon svg { width: 20px; height: 20px; }
.kpi-icon-brand  { background: var(--color-brand-soft); color: var(--color-brand); }
.kpi-icon-green  { background: var(--color-success-bg); color: var(--color-success); }
.kpi-icon-purple { background: #ede9fe;                 color: #6d28d9; }
.kpi-icon-amber  { background: var(--color-warn-bg);    color: var(--color-warn); }

.kpi-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.kpi-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: #1a1a2e;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.kpi-change { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); }
.kpi-change-up   { color: var(--color-success); }
.kpi-change-down { color: var(--color-danger); }

.kpi-spark {
    margin: auto -24px -20px;
    height: 44px;
}
.kpi-sparkline { width: 100%; height: 44px; display: block; }
.kpi-sparkline polyline {
    fill: none;
    stroke: var(--color-brand);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.45;
}

/* 10. Panels + quick actions ---------------------------------- */
.panel {
    background: var(--color-surface);
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 0 16px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 16px;
}
.panel-title { font-size: 16px; font-weight: 700; }

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

.card .quick-grid { padding: 0; }

.quick-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text);
    transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.quick-card:hover { border-color: var(--color-brand); box-shadow: var(--shadow-md); text-decoration: none; }
.quick-card:active { transform: translateY(1px); }

.quick-icon {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-bottom: 8px;
}
.quick-icon-blue   { background: var(--color-brand-soft);  color: var(--color-brand); }
.quick-icon-green  { background: #dcfce7;                 color: #15803d; }
.quick-icon-purple { background: #ede9fe;                 color: #6d28d9; }
.quick-icon-amber  { background: var(--color-warn-bg);    color: var(--color-warn); }

.quick-label { font-weight: 700; font-size: 14.5px; }
.quick-meta { font-size: 12.5px; color: var(--color-text-muted); }

/* 11. Empty state --------------------------------------------- */
.empty-state {
    background: var(--color-surface);
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 56px 24px;
    text-align: center;
    max-width: 560px;
}
.empty-icon {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--color-brand-soft);
    color: var(--color-brand);
    margin-bottom: 16px;
}
.empty-title { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.empty-text { color: var(--color-text-muted); font-size: 14.5px; margin-bottom: 22px; }

/* 12. Mobile responsive ---------------------------------------- */
@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .app-main { margin-left: 0; }
    .topbar-left .sidebar-toggle { display: inline-flex; }
    .app-content { padding: 20px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .cards-grid { grid-template-columns: 1fr; }

    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-md); }
    body.sidebar-open .sidebar-overlay { opacity: 1; visibility: visible; }
}

@media (max-width: 640px) {
    .app-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .user-meta { display: none; }
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 22px; }
    .kpi-grid, .cards-grid { gap: 14px; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .auth-body { padding: 16px; }
    .auth-card { padding: 28px 20px 22px; }
}

@media (max-width: 400px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ============================================================
   Phase 2 — Sales history (filters, table, modal, pagination)
   ============================================================ */
.filter-bar { margin-bottom: 20px; }
.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    padding: 0;
}
.filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.filter-field label { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); }
.filter-field .input { min-width: 150px; height: 38px; }
.filter-actions { flex-direction: row; align-items: center; gap: 8px; margin-left: auto; }

.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th {
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: #f8fafc;
    padding: 11px 14px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

.table .sale-code { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-brand); }
.table .sale-date { white-space: nowrap; color: var(--color-text-muted); font-size: 13px; }
.table .total-cell { font-weight: 700; }
.table-empty {
    text-align: center;
    color: var(--color-text-faint);
    padding: 34px 14px !important;
}

.ta-right { text-align: right; }
.ta-center { text-align: center; }
.sku-inline { color: var(--color-text-faint); font-size: 11.5px; font-weight: 500; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 14px;
    border-top: 1px solid var(--color-border);
}
.pagination-info { font-size: 13px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.pagination a[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* Sale detail modal */
.sale-modal { max-width: 560px; text-align: left; padding: 0; overflow: hidden; }
.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--color-border);
}
.modal-title-sm { font-size: 17px; font-weight: 800; }
.modal-sub { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }

.sale-modal-body { padding: 6px 20px 0; }
.sale-table-wrap { overflow-x: auto; }
.table.table-sm { font-size: 13px; }
.table-sm th { padding: 8px 8px; }
.table-sm td { padding: 8px; }

.sale-modal-totals { padding: 12px 0 18px; }
.sale-total-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 13.5px;
    color: var(--color-text-muted);
}
.sale-total-row.sale-total-grand {
    border-top: 1px dashed var(--color-border);
    margin-top: 6px;
    padding-top: 8px;
    font-size: 16px;
    font-weight: 800;
    color: var(--color-text);
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--color-border);
}

@media (max-width: 640px) {
    .filter-row { align-items: stretch; }
    .filter-field, .filter-field .input { min-width: 100%; width: 100%; }
    .filter-actions { margin-left: 0; }
}

[hidden] { display: none !important; }

/* =====================================================================
   Phase 3 — Inventory & Barcode Labels
   ===================================================================== */
.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; font-size: 14px; font-weight: 600;
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    background: transparent; color: var(--color-text); cursor: pointer;
    text-decoration: none;
}
.btn-ghost:hover { background: var(--color-bg); border-color: var(--color-text-faint); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.req { color: var(--color-danger); }
.hint { color: var(--color-text-faint); font-weight: 500; font-size: 12px; }

.stock {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; white-space: nowrap;
}
.stock::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stock-ok   { color: var(--color-success); background: var(--color-success-bg); }
.stock-low  { color: var(--color-warn);    background: var(--color-warn-bg); }
.stock-out  { color: var(--color-danger);  background: var(--color-danger-bg); }

.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag-success { color: var(--color-success); background: var(--color-success-bg); }
.tag-neutral { color: var(--color-text-muted); background: var(--color-bg); }

.mv-up, .mv-down { font-weight: 700; font-variant-numeric: tabular-nums; }
.mv-up   { color: var(--color-success); }
.mv-down { color: var(--color-danger); }

.inventory-toolbar { margin: 0 0 16px; }
.inventory-search { min-width: 280px; }

.view-toggle {
    display: inline-flex; gap: 4px; padding: 3px; margin: 0 0 14px;
    background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 999px;
}
.view-toggle-btn {
    border: none; background: transparent; padding: 6px 16px; border-radius: 999px;
    font-size: 13px; font-weight: 600; color: var(--color-text-muted); cursor: pointer;
}
.view-toggle-btn.is-active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

.bulk-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 0 0 14px; padding: 0;
}
.bulk-bar[hidden] { display: none !important; }
.bulk-label { font-size: 13.5px; font-weight: 700; }
.bulk-actions { display: flex; gap: 8px; }

.prod-thumb {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    object-fit: cover; display: inline-flex; align-items: center; justify-content: center;
    background: var(--color-bg); border: 1px solid var(--color-border);
}
.prod-thumb-empty { font-weight: 800; color: var(--color-brand); font-size: 15px; }
.prod-name-link { font-weight: 700; color: var(--color-brand); text-decoration: none; }
.prod-name-link:hover { text-decoration: underline; }
.sku-code { background: var(--color-bg); border: 1px solid var(--color-border); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.sku-inline { display: block; font-size: 12px; color: var(--color-text-faint); margin-top: 2px; }

.qty-inline {
    border: 1px dashed var(--color-border); background: transparent;
    border-radius: var(--radius-sm); padding: 4px 10px; font-weight: 700; cursor: pointer;
}
.qty-inline:hover { border-color: var(--color-brand); color: var(--color-brand); }
.qty-inline-input { width: 72px; text-align: center; font-weight: 700; }

.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.inv-grid[hidden] { display: none; }
.inv-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; }
.inv-card-row { display: flex; align-items: center; justify-content: space-between; }
.inv-card-img .prod-thumb { width: 100%; height: 120px; display: flex; font-size: 26px; }
.inv-card-name { font-weight: 700; text-decoration: none; color: var(--color-text); }
.inv-card-name:hover { color: var(--color-brand); text-decoration: underline; }
.inv-card-cat { font-size: 12.5px; color: var(--color-text-muted); }
.inv-card-price { font-weight: 800; }
.inv-card-qty { font-size: 12.5px; color: var(--color-text-faint); }

.table-empty { padding: 22px; text-align: center; color: var(--color-text-muted); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0 4px; }
.pagination-info { font-size: 13px; color: var(--color-text-muted); font-weight: 600; }

/* product detail */
.prod-detail { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .prod-detail { grid-template-columns: 1fr; } }
.prod-detail-main { display: flex; flex-direction: column; gap: 16px; }
.prod-detail-img {
    width: 100%; max-height: 300px; object-fit: contain;
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; font-size: 64px; font-weight: 800; color: var(--color-brand);
}
.prod-detail-img-empty { height: 200px; }
.prod-facts { display: grid; grid-template-columns: 140px 1fr; row-gap: 10px; column-gap: 14px; margin: 0; }
.prod-facts dt { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.prod-facts dd { margin: 0; font-size: 14px; font-weight: 600; }
.prod-fact-strong { font-size: 18px !important; font-weight: 800; }
.prod-detail-desc { padding: 0; }
.prod-desc-text { margin: 0; line-height: 1.6; color: var(--color-text-muted); }

.restock-form { display: flex; flex-direction: column; gap: 12px; }

/* form page */
.inv-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .inv-form-grid { grid-template-columns: 1fr; } }
.inv-form-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.inv-form-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .inv-form-split { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--color-text); }
.form-field .input { width: 100%; }
.field-error { color: var(--color-danger); font-size: 12.5px; min-height: 1em; }
.form-preview { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px; text-align: center; }
.form-preview-img { max-width: 100%; max-height: 220px; border-radius: var(--radius-sm); }
.form-preview-label { display: block; margin-top: 8px; font-size: 12px; color: var(--color-text-muted); }
.inv-form-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 0 0; border-top: 1px solid var(--color-border); margin-top: 20px;
}
.inv-form-error { color: var(--color-danger); font-size: 13.5px; font-weight: 600; }

/* categories */
.cat-add { margin-bottom: 16px; }
.cat-name-cell { font-weight: 700; }

/* labels */
.labels-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .labels-layout { grid-template-columns: 1fr; } }
.labels-controls, .labels-niimbot { display: flex; flex-direction: column; gap: 14px; }
.niimbot-hint { margin: 0; font-size: 13px; color: var(--color-text-muted); line-height: 1.5; }
.niimbot-caveat { font-size: 12px; }
.niimbot-status { font-size: 13px; font-weight: 600; align-self: center; }
.labels-preview-panel { margin-top: 18px; }

.labels-sheet { display: flex; flex-wrap: wrap; gap: 4mm; padding: 10mm; background: var(--color-bg); border-radius: var(--radius); }
.labels-sheet[data-size="40x30"] { gap: 4mm; }
.label {
    width: 50mm; height: 30mm;
    background: #fff; color: #000;
    padding: 2mm 3mm;
    display: flex; flex-direction: column; justify-content: space-between;
    box-sizing: border-box; overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-family: var(--font);
}
.label-margin { margin-right: 3mm; }
.labels-sheet[data-size="40x30"] .label { width: 40mm; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 2mm; }
.label-name { font-size: 10px; font-weight: 700; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.label-price { font-size: 12px; font-weight: 800; white-space: nowrap; }
.label-barcode { display: flex; align-items: center; justify-content: center; }
.label-barcode svg { max-width: 100%; height: auto; display: block; }
.labels-sheet[data-size="40x30"] .label-barcode svg { max-width: 32mm; }
.label-nobc { font-family: monospace; font-size: 9px; letter-spacing: 2px; }
.label-sku { font-size: 8px; color: #333; letter-spacing: 1px; text-transform: uppercase; }

@media print {
    @page { size: 50mm 30mm; margin: 0; }
    body * { visibility: hidden; }
    [data-label-sheet], [data-label-sheet] * { visibility: visible; }
    .labels-preview-panel { display: block !important; margin: 0; padding: 0; box-shadow: none; border: none; }
    .labels-sheet {
        display: flex; flex-wrap: wrap; gap: 0;
        margin: 0; padding: 0; background: #fff; border-radius: 0;
        position: absolute; top: 0; left: 0;
    }
    .label {
        width: 50mm; height: 30mm; margin: 0; box-sizing: border-box;
        page-break-inside: avoid; box-shadow: none;
    }
    .labels-sheet[data-size="40x30"] .label { width: 40mm; height: 30mm; }
    .label-margin + .label-margin { margin-left: 2mm; }
}

/* dashboard low-stock banner */
.stock-alert {
    display: flex; align-items: flex-start; gap: 12px;
    margin-bottom: 18px; padding: 12px 16px;
    border: 1px solid #fde68a; border-left: 4px solid var(--color-warn);
    background: var(--color-warn-bg); border-radius: var(--radius);
}
.stock-alert-icon {
    flex: 0 0 22px; height: 22px; border-radius: 50%;
    background: var(--color-warn); color: #fff; font-weight: 800; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.stock-alert-title { font-weight: 800; font-size: 14px; }
.stock-alert-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }
.stock-alert-list a { color: var(--color-text); font-weight: 600; }
.stock-alert-dismiss {
    margin-left: auto; border: none; background: transparent; cursor: pointer;
    font-size: 20px; line-height: 1; color: var(--color-warn);
}
.stock-alert-dismiss:hover { color: var(--color-danger); }
/* 14. Analytics (Phase 4) --------------------------------------- */
.section-heading.analytics-accent { border-left-color: #e94560; }

.page-section-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.page-section-tools .section-heading { margin: 0; }

.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.seg-btn {
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
}
.seg-btn.is-active { background: #e94560; border-color: #e94560; color: #fff; }

.chart-card { padding: 20px 24px; }
.chart-card-wide { grid-column: 1 / -1; }
.chart-box { position: relative; height: 300px; }
.chart-box-tall { height: 340px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

.chart-skeleton {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: #eef1f5;
}
.skeleton-pulse { animation: skeleton-pulse 1.4s ease-in-out infinite; }
@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.table-card { padding: 0; overflow: hidden; }
.text-right { text-align: right; }

.alerts-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid #f0f0f0;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.alert-banner-icon {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    display: inline-grid; place-items: center;
    border-radius: 50%;
    font-weight: 800; font-size: 13px;
}
.alert-banner-danger { border-left: 4px solid #dc2626; }
.alert-banner-danger .alert-banner-icon { background: #fee2e2; color: #dc2626; }
.alert-banner-warn { border-left: 4px solid #d97706; }
.alert-banner-warn .alert-banner-icon { background: #fef3c7; color: #d97706; }
.alert-banner-info { border-left: 4px solid #2563eb; }
.alert-banner-info .alert-banner-icon { background: #dbeafe; color: #2563eb; }
.alert-banner-x {
    margin-left: auto;
    border: none; background: none;
    font-size: 18px; line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
}

.report-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}
.report-field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.report-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.report-output { margin-top: 20px; }
.report-output-head { margin-bottom: 8px; }

@media (max-width: 720px) {
    .report-grid { grid-template-columns: 1fr; }
    .chart-box { height: 260px; }
    .page-section-tools { flex-direction: column; align-items: flex-start; }
}

/* 16. AI Widget (Phase 5) ---------------------------------------- */
.ai-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: inherit;
}

.ai-widget-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #e94560;
    color: #fff;
    border: none;
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-widget-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(233, 69, 96, 0.5);
}

.ai-widget-trigger:focus-visible {
    outline: 3px solid rgba(233, 69, 96, 0.4);
    outline-offset: 3px;
}

.ai-widget-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
}

.ai-widget-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: calc(100vh - 120px);
    height: auto;
    min-height: 400px;
    max-height: 600px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #1a1a2e;
}

.ai-widget-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e94560;
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-widget-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    flex: 1;
}

.ai-widget-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-widget-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.ai-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-widget-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-items: flex-start;
}

.ai-widget-message-left {
    align-self: flex-start;
}

.ai-widget-message-right {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-widget-message-left .ai-widget-avatar {
    background: #1a1a2e;
}

.ai-widget-message-right .ai-widget-avatar {
    background: #e94560;
}

.ai-widget-message-body {
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    max-width: 100%;
    word-wrap: break-word;
}

.ai-widget-message-left .ai-widget-message-body {
    background: #f5f5f5;
    color: #1a1a2e;
    border-radius: 12px 12px 12px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-widget-message-right .ai-widget-message-body {
    background: #e94560;
    color: #fff;
    border-radius: 12px 12px 0 12px;
}

.ai-widget-message-body p {
    margin: 0 0 8px 0;
}
.ai-widget-message-body p:last-child { margin-bottom: 0; }
.ai-widget-message-body ul, .ai-widget-message-body ol {
    margin: 8px 0;
    padding-left: 18px;
}
.ai-widget-message-body li { margin: 4px 0; }
.ai-widget-message-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 8px 0;
}
.ai-widget-message-body th, .ai-widget-message-body td {
    border: 1px solid #e2e8f0;
    padding: 6px 8px;
    text-align: left;
}
.ai-widget-message-body th { background: #f8fafc; font-weight: 600; }

.ai-widget-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 16px;
}

.ai-widget-typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.ai-widget-typing-dots span {
    width: 7px;
    height: 7px;
    background: #64748b;
    border-radius: 50%;
    display: inline-block;
    animation: typingDelay 1.4s infinite ease-in-out both;
}
.ai-widget-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-widget-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDelay {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.ai-widget-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
}

.ai-widget-prompt {
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ai-widget-prompt:hover {
    background: #f8fafc;
    border-color: #e94560;
    color: #e94560;
}

.ai-widget-input-form {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.ai-widget-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
}

.ai-widget-input-wrapper:focus-within {
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

#aiWidgetInput {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 13.5px;
    color: #1e293b;
    min-height: 20px;
}

.ai-widget-send {
    border: none;
    background: none;
    color: #e94560;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: transform 0.1s ease;
}

.ai-widget-send:hover {
    transform: scale(1.1);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .ai-widget-panel {
        width: 100vw;
        right: 0;
        bottom: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
    }
    .ai-widget-trigger {
        bottom: 16px;
        right: 16px;
    }
}

@media (max-width: 768px) {
    .ai-widget-panel {
        right: 0;
    }
}

/* Generic Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal[hidden] { display: none; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.modal-content form {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

/* Printing toast */
.toast-printing {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-left: 4px solid #d97706;
    color: #92400e;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.toast-printing .toast-view {
    background: #d97706;
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 8px;
}

.toast-printing .toast-view:hover {
    background: #b45309;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* 17. Settings Page (Phase 5+) ----------------------------------- */
.settings-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h2.section-heading {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.form-group .input {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group .input:focus {
    outline: none;
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

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

.form-hint {
    font-size: 12px;
    color: #6b7280;
    margin: 4px 0 0 0;
}

.form-group.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

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

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #e94560;
}

.logo-upload-group {
    grid-column: 1 / -1;
}

.logo-upload {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.logo-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.logo-preview img {
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.logo-preview .remove-logo {
    margin-left: auto;
    padding: 4px 8px;
    font-size: 18px;
    line-height: 1;
    color: #6b7280;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
}

.logo-preview .remove-logo:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #ef4444;
}

.section-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    margin-top: 8px;
}

.settings-section h2 {
    margin-bottom: 20px;
}

.settings-section .settings-grid {
    margin-bottom: 20px;
}

/* Toast improvements */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    padding: 12px 16px;
    border-radius: 8px;
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease-out;
}

.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-printing { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; display: flex; align-items: center; gap: 12px; border-left: 4px solid #d97706; }

.toast-printing .toast-view {
    background: #d97706;
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* AI Widget improved mobile */
@media (max-width: 480px) {
    .ai-widget-panel {
        width: 100vw;
        right: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
    }
    .ai-widget-trigger {
        bottom: 16px;
        right: 16px;
    }
    .ai-widget-messages {
        padding: 12px;
    }
    .ai-widget-header {
        padding: 12px;
    }
    .ai-widget-quick-prompts {
        padding: 0 12px 8px;
    }
    .ai-widget-input-form {
        padding: 10px 12px;
    }
    .ai-widget-input-wrapper {
        padding: 8px 12px;
    }
}

@media (max-width: 768px) {
    .ai-widget-panel {
        width: calc(100vw - 32px);
        right: 16px;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Settings page responsive */
@media (max-width: 640px) {
    .settings-section {
        padding: 16px;
    }
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .form-group .input {
        padding: 12px 14px;
    }
}

/* Sidebar brand logo */
.brand-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    flex: 0 0 auto;
}

/* Modal backdrop (sale detail, POS success) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
}
.modal-backdrop[hidden] { display: none; }

/* Receipt table alignment helpers */
.ta-r { text-align: right; }
.ta-c { text-align: center; }

/* Dialog card inside a backdrop (history detail, POS success).
   Must override the generic .modal overlay rules above. */
.modal-backdrop .modal {
    position: relative;
    inset: auto;
    z-index: auto;
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    max-height: calc(100vh - 60px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    padding: 0;
    overflow: hidden;
    animation: modalIn 0.18s ease-out;
}
