/* FILE: /public/assets/css/app.css */
/* SawaFit — hand-written stylesheet. Brand: magenta #d81b8c, azure #1e9df1. */

:root {
    --primary: #d81b8c;
    --primary-dark: #b01573;
    --azure: #1e9df1;
    --sidebar-bg: #0b0f19;
    --sidebar-bg2: #111827;
    --bg: #f6f7fb;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --card: #ffffff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 9px;
    --ring: rgba(216, 27, 140, .15);
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 16px -6px rgba(16, 24, 40, .08);
    --shadow-lift: 0 2px 4px rgba(16, 24, 40, .06), 0 14px 30px -10px rgba(16, 24, 40, .16);
    --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    transition: background-color .2s ease, color .2s ease;
}
::selection { background: rgba(216, 27, 140, .22); }
/* thin, rounded scrollbars (dark variants in theme.css) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
    background: #c8cdd8; border-radius: 999px;
    border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #aab1c0; background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }
a { color: var(--azure); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
h3.form-section { margin: 1.2rem 0 .4rem; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
code { background: #f3f4f6; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }
.muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg2), var(--sidebar-bg));
    color: #cbd5e1;
    flex-shrink: 0;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    transition: transform .25s ease, width .25s ease;
    z-index: 40;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.1rem 1.2rem;
    color: #fff; font-weight: 700; font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-mark {
    background: var(--primary); color: #fff;
    border-radius: 8px; padding: .15rem .5rem; font-weight: 800;
}
.sidebar-nav { padding: .8rem .6rem 2rem; }
.nav-group { margin-top: .9rem; }
.nav-group-title {
    font-size: .66rem; text-transform: uppercase; letter-spacing: .11em; font-weight: 700;
    color: #64748b; padding: .35rem .75rem .25rem;
}
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    color: #cbd5e1; padding: .55rem .7rem; border-radius: 10px;
    margin: 2px 0; white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active {
    background: var(--primary); color: #fff;
    box-shadow: 0 6px 16px -4px rgba(216, 27, 140, .45);
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }

/* Collapsed sidebar (desktop) */
.app.sidebar-collapsed .sidebar { width: 64px; }
.app.sidebar-collapsed .brand-name,
.app.sidebar-collapsed .nav-item span,
.app.sidebar-collapsed .nav-group-title { display: none; }
.app.sidebar-collapsed .main { margin-left: 64px; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, .45); z-index: 35;
}

/* Main column */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
    display: flex; align-items: center; gap: .9rem;
    background: #fff; border-bottom: 1px solid var(--line);
    padding: .55rem 1.2rem; position: sticky; top: 0; z-index: 30;
}
.icon-btn {
    background: none; border: 0; cursor: pointer; color: var(--ink);
    padding: .45rem; border-radius: 8px; position: relative; display: inline-flex; align-items: center;
}
.icon-btn:hover { background: #f3f4f6; }
.icon-btn svg { width: 20px; height: 20px; }

.global-search { position: relative; flex: 1; max-width: 420px; display: flex; align-items: center; }
.global-search svg { width: 17px; height: 17px; position: absolute; left: .7rem; color: var(--muted); }
.global-search input {
    width: 100%; padding: .5rem .8rem .5rem 2.2rem;
    border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
}
.global-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); background: #fff; }
@keyframes sf-drop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.search-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lift); max-height: 380px; overflow-y: auto; z-index: 50;
    animation: sf-drop-in .14s ease;
}
.search-dropdown .sd-group { padding: .35rem .9rem .1rem; font-size: .7rem; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }
.search-dropdown .sd-item { display: block; padding: .5rem .9rem; color: var(--ink); }
.search-dropdown .sd-item:hover { background: var(--bg); text-decoration: none; }
.search-dropdown .sd-item small { color: var(--muted); margin-left: .4rem; }

.branch-selector select {
    padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

.notif-bell { position: relative; }
.badge {
    display: inline-block; min-width: 18px; padding: .16rem .55rem;
    font-size: .7rem; font-weight: 700; text-align: center; letter-spacing: .02em;
    border-radius: 999px; background: var(--danger); color: #fff;
    line-height: 1.35; white-space: nowrap;
}
#notifBadge { position: absolute; top: 0; right: 0; }
.notif-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); width: 320px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lift); max-height: 400px; overflow-y: auto; z-index: 50;
    animation: sf-drop-in .14s ease;
}
.notif-item { padding: .7rem .9rem; border-bottom: 1px solid var(--line); cursor: pointer; display: block; color: var(--ink); }
.notif-item:hover { background: var(--bg); text-decoration: none; }
.notif-item strong { display: block; font-size: .9rem; }
.notif-item small { color: var(--muted); }
.notif-empty { padding: 1rem; color: var(--muted); text-align: center; }

.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: .5rem; background: none; border: 0; cursor: pointer; padding: .3rem; border-radius: 8px; }
.user-menu-btn:hover { background: #f3f4f6; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lift); z-index: 50; overflow: hidden;
    animation: sf-drop-in .14s ease;
}
.user-dropdown-head { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.user-dropdown-head span { display: block; color: var(--muted); font-size: .8rem; }
.user-dropdown a { display: block; padding: .7rem 1rem; color: var(--ink); }
.user-dropdown a:hover { background: var(--bg); text-decoration: none; }

/* Content */
.content { padding: 1.4rem; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }

/* ---------- Cards / grids ---------- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1.2rem;
    transition: box-shadow .15s ease, border-color .15s ease, background-color .2s ease;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; gap: .8rem; flex-wrap: wrap; }
.card-head h2 {
    font-size: .82rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--muted);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.2rem; margin-bottom: 1.2rem; }
.kpi .kpi-label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi .kpi-value { font-size: 1.5rem; font-weight: 700; margin: .25rem 0; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { color: var(--muted); font-size: .82rem; }
/* primary stat card: brand accent bar */
.kpi-grid > .kpi:first-child { border-left: 4px solid var(--primary); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    text-align: left; padding: .6rem .75rem; color: var(--muted);
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    border-bottom: 2px solid var(--line);
}
.table td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background: #fafbfe; }
.table-sm th, .table-sm td { padding: .35rem .5rem; }
.table .actions { white-space: nowrap; text-align: right; }

/* Horizontal scroll container for wide tables (P6 W4): tables wider than
   their card scroll INSIDE the wrapper instead of scrolling the page. */
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 36px; padding: .35rem .95rem; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    font-size: .9rem; font-weight: 600; line-height: 1.25; cursor: pointer; text-align: center;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .12s ease, filter .15s ease;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-radius: 4px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--azure); border-color: var(--azure); color: #fff; }
.btn-secondary:hover { filter: brightness(.93); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.93); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); color: #fff; }
.btn-sm { min-height: 30px; padding: .2rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn-lg { min-height: 44px; padding: .55rem 1.25rem; font-size: 1rem; }
.btn-block { width: 100%; }
.inline-form { display: inline; }

/* ---------- Badges ---------- */
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-muted { background: #f3f4f6; color: var(--muted); }

/* ---------- Flash / toast ---------- */
.flash {
    padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem;
    border: 1px solid transparent; border-left-width: 4px; font-size: .92rem;
    box-shadow: var(--shadow);
    display: flex; align-items: flex-start; gap: .55rem;
    transition: opacity .3s ease, transform .3s ease, background-color .2s ease;
}
.flash::before { font-weight: 800; line-height: 1.45; flex: 0 0 auto; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-success::before { content: "✓"; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-error::before { content: "✕"; }
.flash-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash-warning::before { content: "!"; }
.flash.flash-hide { opacity: 0; transform: translateY(-4px); }

.toast-wrap { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
.toast {
    background: var(--ink); color: #fff; padding: .75rem 1.1rem;
    border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem;
    animation: toast-in .2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Forms ---------- */
.filter-bar { flex-wrap: wrap !important; align-items: flex-end; }
.filter-bar > .field { margin-bottom: 0; }
.form .field { display: block; margin-bottom: .9rem; }
.field > span, .field > label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .3rem; }
.field .help, .help { color: var(--muted); font-size: .8rem; font-weight: 400; }
.field input, .field select, .field textarea {
    width: 100%; min-height: 38px; padding: .5rem .7rem; font-size: .9rem;
    border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.field textarea { min-height: 0; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring);
}
.field input[type="checkbox"] { width: auto; min-height: 0; }
.checkbox { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; font-size: .92rem; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; }
fieldset.field { border: 0; padding: 0; margin: 0 0 .9rem; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(11, 15, 25, .55);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; z-index: 90;
}
@keyframes sf-modal-in { from { transform: scale(.95); opacity: .5; } to { transform: scale(1); opacity: 1; } }
.modal {
    background: var(--card); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
    width: min(560px, 94vw); max-height: 88vh; overflow-y: auto; padding: 1.3rem 1.4rem;
    animation: sf-modal-in .12s ease;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line);
}
.modal-close { background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--muted); border-radius: 8px; padding: 0 .35rem; }
.modal-close:hover { color: var(--ink); }
/* optional footer for modal actions (right-aligned) */
.modal-foot {
    display: flex; justify-content: flex-end; gap: .6rem;
    margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line);
}

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.page-link, .page-current {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; min-height: 32px; padding: .25rem .6rem;
    border-radius: 8px; border: 1px solid var(--line); font-size: .88rem; font-weight: 600;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.page-link:hover { background: #f3f4f6; text-decoration: none; border-color: #d1d5db; }
.page-current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Auth pages (split-screen) ---------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg2), var(--sidebar-bg));
    padding: 1rem;
}
/* Split-screen variant (login / forgot / reset) — plain .auth-body stays for error pages. */
.auth-has-split { display: block; padding: 0; background: #fff; }
.auth-split { display: flex; min-height: 100vh; }

/* Left brand panel */
.auth-panel {
    flex: 0 0 50%; max-width: 50%;
    background: linear-gradient(135deg, #d81b8c 0%, #a3166b 55%, #7c1d5e 100%);
    color: #fff; display: flex; align-items: center; padding: 3rem 3.5rem;
}
.auth-panel-inner { max-width: 480px; }
.auth-panel-brand { font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; gap: .5rem; margin-bottom: 3rem; }
.auth-panel-brand .brand-mark { background: rgba(255, 255, 255, .18); }
.auth-pill {
    display: inline-flex; align-items: center; gap: .45rem;
    background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px; padding: .3rem .9rem; font-size: .8rem; font-weight: 600;
    margin-bottom: 1.4rem;
}
.auth-pill-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.auth-headline { font-size: 2.4rem; font-weight: 800; line-height: 1.15; margin: 0 0 1rem; color: #fff; }
.auth-panel-sub { color: rgba(255, 255, 255, .82); font-size: 1.02rem; margin: 0 0 2rem; }
.auth-bullets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.auth-bullets li { display: flex; align-items: center; gap: .7rem; font-weight: 600; font-size: .98rem; }
.auth-check {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .35);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 800; color: #fff;
}

/* Right side: form card */
.auth-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: #fff; }
.auth-card {
    background: #fff; border: 1px solid var(--line); border-radius: 14px;
    padding: 2.2rem; width: min(420px, 100%);
    box-shadow: 0 20px 60px rgba(17, 24, 39, .12);
}
.auth-card-brand { margin-bottom: 1.2rem; }
.auth-card-brand .brand-mark { font-size: 1.05rem; padding: .3rem .65rem; border-radius: 10px; }
.auth-brand { font-weight: 800; font-size: 1.25rem; margin-bottom: 1.4rem; display: flex; align-items: center; gap: .5rem; }
.auth-title { font-size: 1.35rem; font-weight: 800; margin: 0; }
.auth-sub { color: var(--muted); margin: .25rem 0 1.4rem; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin: .2rem 0 1.1rem; font-size: .9rem; }
.auth-row .checkbox { margin: 0; }
.auth-links { margin: 1.1rem 0 0; text-align: center; font-size: .9rem; }

@media (max-width: 900px) {
    .auth-panel { display: none; }
    .auth-side { background: var(--bg); min-height: 100vh; }
}
.error-card { text-align: center; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); }

.audit-detail code { word-break: break-all; }

/* ---------- POS (shared pieces; pos.js builds the rest) ---------- */
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.pos-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .9rem; cursor: pointer; text-align: center;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pos-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.pos-card .pos-card-name { font-weight: 600; font-size: .9rem; }
.pos-card .pos-card-price { color: var(--primary); font-weight: 700; margin-top: .3rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); width: min(300px, 84vw); }
    .app.sidebar-open .sidebar { transform: none; box-shadow: 0 0 48px rgba(0, 0, 0, .35); }
    .app.sidebar-open .sidebar-overlay { display: block; }
    .main { margin-left: 0; }
    .app.sidebar-collapsed .main { margin-left: 0; }
    .user-name { display: none; }
    .global-search { max-width: none; }
    .topbar { gap: .5rem; padding: .5rem .8rem; }
    body.nav-locked { overflow: hidden; } /* scroll lock while off-canvas nav is open */
    /* KPI grids: 4 -> 2 columns (one more step to 1 column below 540px) */
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .8rem; }
    /* touch targets: >= 40px, inputs >= 16px font to prevent iOS auto-zoom */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 40px; }
    .icon-btn { min-width: 40px; min-height: 40px; justify-content: center; }
    .page-link, .page-current { min-width: 40px; min-height: 40px; }
    .field input, .field select, .field textarea { min-height: 42px; font-size: 16px; }
    .global-search input, .branch-selector select { min-height: 40px; font-size: 16px; }
    .notif-dropdown { width: min(320px, 86vw); }
    .nav-item { padding: .7rem .8rem; } /* ~44px touch target in the off-canvas nav */
}

/* Tables -> cards on small screens (fallback for tables WITHOUT a .table-wrap) */
@media (max-width: 720px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: .7rem; padding: .4rem .2rem; }
    .table td { border: 0; padding: .3rem .7rem; text-align: left !important; }
    .table td::before {
        content: attr(data-label);
        display: block; font-size: .7rem; text-transform: uppercase;
        color: var(--muted); letter-spacing: .05em;
    }
    .table td[data-label]::before { content: attr(data-label); }
    .kpi .kpi-value { font-size: 1.4rem; }
    .content { padding: .9rem; }

    /* P6 W4: tables inside a .table-wrap keep their real table layout and
       scroll horizontally within the card instead of card-ifying. */
    .table-wrap .table { display: table; width: 100%; }
    .table-wrap .table thead { display: table-header-group; }
    .table-wrap .table tbody { display: table-row-group; }
    .table-wrap .table tr { display: table-row; border: 0; border-radius: 0; margin: 0; padding: 0; }
    .table-wrap .table td {
        display: table-cell; width: auto;
        border-bottom: 1px solid var(--line); padding: .7rem .75rem;
        text-align: inherit !important;
    }
    .table-wrap .table.table-sm td { padding: .35rem .5rem; }
    .table-wrap .table td::before { content: none !important; display: none; }
    .table-wrap .table td.num, .table-wrap .table th.num { text-align: right !important; }
    .table-wrap .table td.actions, .table-wrap .table th.actions { text-align: right !important; }
}

/* ---------- Print: receipts (80mm / 58mm thermal) & A4 invoices ---------- */
.receipt { font-family: "Courier New", monospace; color: #000; }
.receipt.paper-80 { width: 76mm; }
.receipt.paper-58 { width: 54mm; font-size: 11px; }
.receipt.paper-a4 { width: 190mm; font-family: system-ui, sans-serif; }
.receipt h2 { text-align: center; margin: 0 0 2mm; }
.receipt .r-center { text-align: center; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td, .receipt th { padding: 1mm 0; vertical-align: top; }
.receipt .r-totals td { border-top: 1px dashed #000; }
.receipt hr { border: 0; border-top: 1px dashed #000; }

@media print {
    body * { visibility: hidden; }
    .receipt, .receipt * { visibility: visible; }
    .receipt { position: absolute; inset: 0 auto auto 0; }
    .sidebar, .topbar, .flash, .btn, .no-print { display: none !important; }
}
@page paper80 { size: 80mm auto; margin: 3mm; }
@page paper58 { size: 58mm auto; margin: 2mm; }
@page paperA4 { size: A4; margin: 12mm; }
.receipt.paper-80 { page: paper80; }
.receipt.paper-58 { page: paper58; }
.receipt.paper-a4 { page: paperA4; }

/* ==========================================================================
   P5c — refinement additions (registers page, micro-interactions)
   ========================================================================== */

/* smooth theme switching on the main surfaces */
.topbar, .card, .reg-card, .session-card, .flash, .modal {
    transition-property: background-color, border-color, box-shadow, transform;
    transition-duration: .2s, .2s, .15s, .15s;
    transition-timing-function: ease;
}
.icon-btn, .user-menu-btn { transition: background-color .15s ease, color .15s ease; }
.branch-selector select {
    transition: border-color .15s ease, box-shadow .15s ease, background-color .2s ease;
}
.branch-selector select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring);
}

/* ---------- Registers page (Mission: no horizontal scroll, ever) ---------- */
.reg-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem;
}
.reg-card {
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
    padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .8rem;
}
.reg-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.reg-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.reg-id { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.reg-name { font-weight: 700; font-size: .98rem; }
.reg-loc { font-size: .82rem; }
.reg-hint { font-size: .8rem; }
.reg-open-form { display: flex; align-items: flex-end; gap: .6rem; flex-wrap: wrap; }
.reg-open-label { flex: 1 1 130px; display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; }
.reg-open-label span, .session-close-form label span {
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.reg-open-form input {
    width: 100%; min-height: 36px; padding: .45rem .65rem; font-size: .9rem;
    border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.reg-open-form input:focus,
.session-close-form input:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring);
}

/* Sessions: stacked record cards at all widths */
.session-list {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(min(390px, 100%), 1fr));
}
.session-card {
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
    padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .8rem;
}
.session-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.session-id { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.session-title { font-weight: 700; font-size: .95rem; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem .9rem; margin: 0; }
.kv-item { min-width: 0; }
.kv-item dt {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted);
}
.kv-item dd { margin: .1rem 0 0; font-size: .92rem; }
.kv-item dd.num { text-align: left; font-variant-numeric: tabular-nums; }
.diff { font-weight: 700; }
.session-notes { font-size: .85rem; border-top: 1px dashed var(--line); padding-top: .6rem; }
.session-close-form {
    display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; align-items: end;
    border-top: 1px solid var(--line); padding-top: .8rem;
}
.session-close-form label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; }
.session-close-form input {
    width: 100%; min-height: 36px; padding: .45rem .65rem; border: 1px solid var(--line);
    border-radius: 8px; background: #fff; color: var(--ink); font-size: .9rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.session-close-form .btn { grid-column: 1 / -1; }
@media (max-width: 480px) {
    .kv { grid-template-columns: 1fr; }
    .session-close-form { grid-template-columns: 1fr; }
}

/* ==========================================================================
   P6 W4 — Mobile back-office (phones). All rules are media-scoped or use
   additive classes: desktop (>=1024px) rendering is unchanged.
   ========================================================================== */

/* Safety net: nothing should ever push the page itself sideways.
   overflow-x:clip does not create a scroll container, so the sticky
   topbar keeps working. */
html, body { overflow-x: clip; }

/* Page header: title + action buttons wrap on narrow screens */
.page-head { flex-wrap: wrap; gap: .6rem; }

@media (max-width: 640px) {
    /* Topbar: two rows — controls first, full-width search below */
    .topbar { flex-wrap: wrap; row-gap: .4rem; }
    .global-search { order: 10; flex: 1 1 100%; }
    .branch-selector select { max-width: 130px; }

    /* Filter bars (reports / inventory / products / …): stack vertically.
       !important is needed because some views still carry inline flex styles. */
    .filter-bar { flex-direction: column !important; align-items: stretch !important; }
    .filter-bar > .field, .filter-bar > label { min-width: 0 !important; width: 100%; flex: none !important; }
    .filter-bar > .form-actions { width: 100%; margin-top: 0; }

    /* Form action buttons: full-width, stacked */
    .form-actions { flex-wrap: wrap; }
    .form-actions .btn, .form-actions .inline-form { flex: 1 1 100%; }
    .form-actions .inline-form .btn { width: 100%; }

    /* Modals become near-fullscreen sheets */
    .modal-backdrop { padding: 6px; align-items: flex-end; }
    .modal {
        width: 100%; max-width: 100%; max-height: calc(100dvh - 12px);
        border-radius: 14px 14px 8px 8px; padding: 1rem 1rem 1.2rem;
    }
    .modal-foot { flex-wrap: wrap; }
    .modal-foot .btn { flex: 1 1 100%; }

    /* KPI grids: 2 -> 1 column */
    .kpi-grid { grid-template-columns: 1fr; }

    /* Auth pages: tighter card on phones */
    .auth-side { padding: 1.2rem .8rem; align-items: flex-start; padding-top: 8vh; }
    .auth-card { padding: 1.4rem 1.2rem; }
    .auth-body:not(.auth-has-split) { padding: .8rem; }
}
