/* ==========================================================================
   MOST POS — Master stylesheet
   Phases 3–11 cumulative. Append-only convention preserved.
   Modern design tokens, consistent spacing, refined typography.
   ========================================================================== */

/* ==========================================================================
   Phase 10.9 — Design tokens & reset (loaded first, applies everywhere)
   ========================================================================== */
:root {
    --brand-primary: #1D5925;
    --brand-primary-dark: #174a1e;
    --brand-primary-light: #e8f2ea;
    --brand-secondary: #F58112;
    --brand-secondary-dark: #d96b04;
    --brand-danger: #DC3545;
    --brand-danger-light: #fde8ea;

    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-soft: #9ca3af;
    --text-inverse: #ffffff;

    --border-default: #e5e7eb;
    --border-strong: #d1d5db;
    --border-soft: #eef0f2;

    --bg-page: #f5f7f8;
    --bg-surface: #ffffff;
    --bg-subtle: #f7f8fa;
    --bg-hover: #fafbfc;
    --bg-tint: #f0f6f1;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;

    /* Rounded Corners - Increased for a softer UI */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(16,24,40,.04);
    --shadow-sm: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
    --shadow-md: 0 4px 12px -2px rgba(16,24,40,.08), 0 2px 6px -2px rgba(16,24,40,.04);
    --shadow-lg: 0 12px 24px -4px rgba(16,24,40,.10), 0 4px 8px -4px rgba(16,24,40,.04);
    --shadow-focus: 0 0 0 4px rgba(29,89,37,.15);
    --shadow-focus-danger: 0 0 0 4px rgba(220,53,69,.15);

    --font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --transition-fast: 120ms cubic-bezier(.4,0,.2,1);
    --transition-base: 200ms cubic-bezier(.4,0,.2,1);
}

/* ==========================================================================
   Base reset & typography
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-3);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

p { margin: 0 0 var(--space-3); }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--brand-primary-light); color: var(--brand-primary-dark); }

:focus-visible {
    outline: 2px solid transparent;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}

/* Scrollbar (Webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: var(--radius-pill);
    border: 2px solid var(--bg-surface);
}
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ==========================================================================
   POS terminal styles
   ========================================================================== */
body.pos-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    background: var(--bg-page);
    font-size: 14px;
}

.pos-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--brand-primary);
    color: #fff;
    padding: 10px 18px;
    font-size: 14px;
    flex: 0 0 auto;
    box-shadow: var(--shadow-sm);
}
.pos-top-left,
.pos-top-center,
.pos-top-right { display: flex; align-items: center; gap: 12px; }
.pos-brand { font-weight: 700; letter-spacing: -0.01em; font-size: 15px; }
.pos-branch { opacity: .9; }
.pos-branch-select {
    background: rgba(255,255,255,.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 13px;
}
.pos-branch-select option { color: #111; }
.pos-clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.pos-user { opacity: .9; }
.pos-shift-badge {
    background: var(--brand-secondary);
    color: #1a1a1a;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}
.pos-shift-none { background: #c0392b; color: #fff; }
.pos-logout { margin: 0; }
.pos-link-btn {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
    transition: background var(--transition-fast);
}
.pos-link-btn:hover { background: rgba(255,255,255,.15); }

.pos-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    flex: 1 1 auto;
    min-height: 0;
}
.pos-left,
.pos-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.pos-left { padding: 16px; }
.pos-right {
    background: #fff;
    border-left: 1px solid var(--border-default);
    padding: 16px 16px 0 16px;
}

.pos-search-bar { display: flex; gap: 8px; margin-bottom: 12px; position: relative; }
#pos-search {
    flex: 1;
    padding: 12px 36px 12px 16px;
    font-size: 15px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
#pos-search:focus { border-color: var(--brand-primary); box-shadow: var(--shadow-focus); }
.pos-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 6px;
}

.pos-cat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pos-chip {
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    padding: 8px 16px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.pos-chip:hover { background: var(--bg-subtle); }
.pos-chip.active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.pos-products {
    flex: 1 1 auto;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
    padding-right: 6px;
    align-content: start;
}
.pos-prod {
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 14px;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 80px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    font: inherit;
    box-shadow: var(--shadow-xs);
}
.pos-prod:hover { border-color: var(--brand-primary); box-shadow: var(--shadow-md); }
.pos-prod:active { transform: scale(.98); }
.pos-prod-zero { opacity: .55; }
.pos-prod-name { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.pos-prod-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.pos-prod-price { color: var(--brand-primary); font-weight: 600; }
.pos-products-none { grid-column: 1 / -1; padding: 32px; text-align: center; color: var(--text-muted); }
.pos-product-status { font-size: 12px; color: var(--text-muted); padding: 4px 2px 0 2px; min-height: 18px; }

.pos-customer-bar { margin-bottom: 12px; }
.pos-customer-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font: inherit;
    transition: background var(--transition-fast);
}
.pos-customer-btn:hover { background: var(--bg-hover); }
.pos-customer-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.pos-customer-name { font-weight: 600; }

.pos-cart {
    flex: 1 1 auto;
    overflow-y: auto;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    min-height: 120px;
    box-shadow: var(--shadow-xs);
}
.pos-cart-empty { padding: 32px 16px; text-align: center; color: var(--text-muted); }
.pos-cart-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pos-cart-table th,
.pos-cart-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.pos-cart-table th {
    text-align: left;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    position: sticky;
    top: 0;
    background: var(--bg-subtle);
    z-index: 1;
    font-weight: 600;
}
.pos-cart-table tr:last-child td { border-bottom: none; }
.pos-cart-table .pos-col-item { max-width: 160px; }
.pos-cart-table .pos-col-qty { width: 130px; white-space: nowrap; }
.pos-cart-table .pos-col-price { width: 90px; text-align: right; }
.pos-cart-table .pos-col-total { width: 100px; text-align: right; font-weight: 600; }
.pos-cart-table .pos-col-act { width: 60px; white-space: nowrap; text-align: right; }
.pos-cart-table .q-inp {
    width: 44px;
    text-align: center;
    padding: 6px 4px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font: inherit;
}
.pos-cart-table .q-dec,
.pos-cart-table .q-inc {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-default);
    background: #fff;
    border-radius: var(--radius-md);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    transition: background var(--transition-fast);
}
.pos-cart-table .q-dec:hover,
.pos-cart-table .q-inc:hover { background: var(--bg-subtle); }
.pos-cart-table .l-del,
.pos-cart-table .l-disc {
    width: 26px; height: 26px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 15px;
    padding: 0 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.pos-cart-table .l-del:hover { color: var(--brand-danger); background: var(--brand-danger-light); }
.pos-cart-table .l-disc:hover { color: var(--brand-secondary); background: #fff3cd; }

.pos-totals { padding: 10px 4px; }
.pos-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.pos-totals-total {
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-primary);
    border-top: 2px dashed var(--border-default);
    margin-top: 8px;
    padding-top: 12px;
}

.pos-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.pos-btn {
    padding: 12px 8px;
    border: 1px solid var(--border-default);
    background: #fff;
    border-radius: var(--radius-lg);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.pos-btn:hover { background: var(--bg-subtle); box-shadow: var(--shadow-sm); }

.pos-charge-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: calc(100% + 32px);
    margin: 0 -16px 0 -16px;
    padding: 20px 12px;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: 0;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    letter-spacing: .02em;
    transition: background var(--transition-fast);
}
.pos-charge-btn:hover:not(:disabled) { background: var(--brand-primary-dark); }
.pos-charge-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.pos-charge-total { font-size: 16px; font-weight: 500; opacity: .95; }
.pos-charge-hint { font-size: 11px; opacity: .75; letter-spacing: .12em; }

.pos-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.pos-modal[hidden] { display: none; }
.pos-modal-card {
    background: #fff;
    border-radius: var(--radius-xl);
    width: min(560px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.pos-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-default);
}
.pos-modal-head h3 { margin: 0; font-size: 16px; }
.pos-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 8px;
    border-radius: var(--radius-md);
}
.pos-modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.pos-modal-body { padding: 16px 20px; overflow-y: auto; }
.pos-modal-foot { padding: 16px 20px; border-top: 1px solid var(--border-default); background: var(--bg-subtle); }

.pos-customer-list,
.pos-held-list { list-style: none; margin: 12px 0 0; padding: 0; }
.pos-customer-list li,
.pos-held-list li { margin: 0 0 8px; }
.pos-customer-pick,
.pos-held-pick {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font: inherit;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.pos-customer-pick:hover,
.pos-held-pick:hover { background: var(--bg-hover); border-color: var(--brand-primary); box-shadow: var(--shadow-sm); }

.pos-offline-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--brand-danger);
    color: #fff;
    text-align: center;
    padding: 12px;
    font-weight: 600;
    z-index: 900;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.pos-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    backdrop-filter: blur(4px);
}
.pos-overlay-card {
    background: #fff;
    padding: 32px;
    border-radius: var(--radius-xl);
    width: min(420px, 92vw);
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.pos-overlay-card h2 { margin: 0 0 12px; color: var(--brand-primary); }
.pos-inline-field { display: block; text-align: left; margin: 16px 0; font-size: 13px; color: var(--text-secondary); }
.pos-inline-field input {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    margin-top: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
}
.pos-error { color: var(--brand-danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

body.checkout-body .checkout-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 480px;
    flex: 1 1 auto;
    min-height: 0;
}
.checkout-left,
.checkout-right { padding: 24px; overflow-y: auto; background: #fff; }
.checkout-left { border-right: 1px solid var(--border-default); }
.checkout-right h2,
.checkout-left h2 { margin: 0 0 16px; font-size: 16px; }

.checkout-payments { margin-bottom: 16px; }
.checkout-add-payment { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.checkout-summary { padding: 12px 0; border-top: 1px dashed var(--border-default); }

@media (max-width: 900px) {
    .pos-main { grid-template-columns: 1fr; }
    .pos-right { border-left: none; border-top: 1px solid var(--border-default); }
    body.checkout-body .checkout-main { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Admin shell — header, nav, main, footer (shared by all admin modules)
   ========================================================================== */
.app-body {
    background: var(--bg-page);
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    background: var(--brand-primary);
    color: #fff;
    padding: 0 var(--space-5);
    min-height: 60px;
    box-shadow: var(--shadow-sm);
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header-left,
.app-header-right { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }

.app-header-right { flex-shrink: 0; }

.app-brand {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    letter-spacing: -0.01em;
    padding: 8px 0;
    white-space: nowrap;
    flex-shrink: 0;
}
.app-brand:hover { text-decoration: none; opacity: .92; }

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.app-nav a {
    color: #fff;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    opacity: .85;
    transition: background var(--transition-fast), opacity var(--transition-fast);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.app-nav a:hover { background: rgba(255,255,255,.12); opacity: 1; text-decoration: none; }
.app-nav a.active { background: rgba(255,255,255,.20); opacity: 1; font-weight: 600; }

.app-user {
    font-size: 13px;
    opacity: .92;
    text-decoration: none;
    color: #fff;
    white-space: nowrap;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}
.app-user:hover { background: rgba(255,255,255,.10); text-decoration: none; }

.app-main {
    flex: 1 1 auto;
    padding: var(--space-6) var(--space-6) var(--space-7);
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-5);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.app-footer {
    flex: 0 0 auto;
    padding: var(--space-5) var(--space-6);
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    border-top: 1px solid var(--border-default);
    margin-top: var(--space-6);
    background: var(--bg-surface);
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.card h2,
.card-title {
    margin: 0 0 var(--space-4);
    font-size: 16px;
    font-weight: 600;
    color: var(--brand-primary);
    letter-spacing: -0.005em;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--bg-subtle); border-color: #b8bfc9; text-decoration: none; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); box-shadow: none; }

.btn-primary { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); }

.btn-danger { background: var(--brand-danger); border-color: var(--brand-danger); color: #fff; }
.btn-danger:hover { background: #b02a37; border-color: #b02a37; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-primary); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-subtle); border-color: var(--border-default); box-shadow: none; }

.btn-secondary { background: #fff; border-color: var(--border-strong); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-subtle); }

.btn-sm { min-height: 32px; padding: 6px 14px; font-size: 13px; border-radius: var(--radius-sm); }

.btn-block { display: flex; width: 100%; }

.btn:disabled,
.btn[disabled] { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ==========================================================================
   Data tables (canonical style)
   ========================================================================== */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    margin-bottom: var(--space-4);
}

.data-table th,
.data-table td {
    padding: 14px 18px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-soft);
    line-height: 1.4;
}

.data-table thead th {
    background: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: var(--bg-hover); }
.data-table tbody tr:hover { background: var(--bg-tint); }

.data-table .num,
.data-table td.num,
.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.data-table .strong { font-weight: 600; }

.data-table td.danger,
.data-table .danger { color: var(--brand-danger); font-weight: 500; }

.data-table .empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-style: italic;
}

.data-table.compact th,
.data-table.compact td { padding: 10px 14px; font-size: 13px; }

/* Alias: pages that emit class="table" (Phase 4 inventory) */
.table,
.table-compact {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    margin-bottom: var(--space-4);
}
.table th,
.table td,
.table-compact th,
.table-compact td {
    padding: 14px 18px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-soft);
    line-height: 1.4;
}
.table thead th,
.table-compact thead th {
    background: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}
.table tbody tr:last-child td,
.table-compact tbody tr:last-child td { border-bottom: none; }
.table tbody tr:nth-child(even),
.table-compact tbody tr:nth-child(even) { background: var(--bg-hover); }
.table tbody tr:hover,
.table-compact tbody tr:hover { background: var(--bg-tint); }
.table .num,
.table td.num,
.table th.num,
.table-compact .num,
.table-compact td.num,
.table-compact th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong,
.table-compact .strong { font-weight: 600; }
.table .muted,
.table-compact .muted { color: var(--text-muted); }
.table .danger,
.table-compact .danger { color: var(--brand-danger); font-weight: 500; }
.table .empty,
.table-compact .empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-style: italic;
}

/* ==========================================================================
   Forms — canonical grids and inputs
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-5) var(--space-5);
    margin-bottom: var(--space-5);
    align-items: start;
}

.form-grid > .full,
.form-grid > .grid-2-span { grid-column: 1 / -1; }

.form-grid > label,
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-grid input[type="text"],
.form-grid input[type="email"],
.form-grid input[type="password"],
.form-grid input[type="number"],
.form-grid input[type="tel"],
.form-grid input[type="url"],
.form-grid input[type="search"],
.form-grid input[type="date"],
.form-grid input[type="time"],
.form-grid input[type="datetime-local"],
.form-grid input[type="month"],
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 12px 16px;
    min-height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    font: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: #fff;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-sizing: border-box;
    box-shadow: var(--shadow-xs);
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}

.form-grid input:disabled,
.form-grid select:disabled,
.form-grid textarea:disabled {
    background: var(--bg-subtle);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.form-grid input[type="checkbox"],
.form-grid input[type="radio"] {
    min-height: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--brand-primary);
    margin: 0;
    border-radius: 4px;
}

.form-grid label.check {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.form-grid textarea { min-height: 100px; resize: vertical; }

/* Standalone .field wrapper */
.field { display: block; margin-bottom: var(--space-4); font-size: 13px; }
.field .field-label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.field input,
.field select,
.field textarea {
    display: block;
    width: 100%;
    padding: 12px 16px;
    min-height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    font: inherit;
    font-size: 14px;
    background: #fff;
    box-sizing: border-box;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}

/* Global input polish */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
select,
textarea {
    font-family: var(--font-sans);
    color: var(--text-primary);
}

input::placeholder,
textarea::placeholder { color: var(--text-soft); opacity: 1; }

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand-primary);
    width: 18px;
    height: 18px;
    vertical-align: middle;
    border-radius: 4px;
}

input[type="number"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    align-items: center;
    margin-top: var(--space-3);
    flex-wrap: wrap;
}
.form-actions.full { grid-column: 1 / -1; }

/* Toolbars */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.toolbar-form {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-wrap: wrap;
}

/* Filter bars */
.filter-bar,
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-end;
    margin-bottom: var(--space-5);
    padding: var(--space-4) var(--space-5);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.filter-bar label,
.toolbar-form label,
.filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-bar input,
.filter-bar select,
.toolbar-form input,
.toolbar-form select,
.filters input,
.filters select {
    padding: 10px 14px;
    min-height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 13.5px;
    background: #fff;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.filter-bar input:focus,
.filter-bar select:focus,
.toolbar-form input:focus,
.toolbar-form select:focus,
.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}

/* ==========================================================================
   Alerts / flash
   ========================================================================== */
.alert,
.flash {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    font-size: 14px;
    border: 1px solid transparent;
    line-height: 1.45;
    box-shadow: var(--shadow-xs);
}

.alert ul { margin: 0; padding-left: 24px; }

.flash-success,
.alert-success { background: #e6f4ea; color: #14532d; border-color: #bfe0c6; }
.flash-error,
.alert-danger { background: var(--brand-danger-light); color: #842029; border-color: #f5b8be; }
.flash-info,
.alert-info { background: #eaf3fb; color: #1a4b7a; border-color: #bcd8ef; }
.alert-warning { background: #fff3cd; color: #664d03; border-color: #f6e3a8; }

/* ==========================================================================
   Pills / badges
   ========================================================================== */
.pill,
.badge,
.pill-ok,
.pill-off,
.pill-warn,
.badge-draft,
.badge-approved,
.badge-received,
.badge-cancelled,
.badge-posted,
.badge-paid,
.badge-partially_paid,
.badge-partially_received,
.badge-partially_received {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: .01em;
    white-space: nowrap;
}

.pill-ok    { background: #e6f4ea; color: #14532d; }
.pill-off   { background: #f3f4f6; color: #4b5563; }
.pill-warn  { background: #FEF3C7; color: #92400E; }

.badge-draft              { background: #e9ecef; color: #495057; }
.badge-approved           { background: #cfe2ff; color: #084298; }
.badge-partially_received { background: #fff3cd; color: #664d03; }
.badge-received           { background: #d1e7dd; color: #0a3622; }
.badge-cancelled          { background: #f8d7da; color: #842029; }
.badge-posted             { background: #d1e7dd; color: #0a3622; }
.badge-partially_paid     { background: #fff3cd; color: #664d03; }
.badge-paid               { background: #cfe2ff; color: #084298; }

/* ==========================================================================
   Pager
   ========================================================================== */
.pager {
    display: flex;
    gap: 6px;
    margin-top: var(--space-5);
    flex-wrap: wrap;
}
.pager a {
    padding: 8px 14px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13.5px;
    background: #fff;
    min-width: 40px;
    text-align: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.pager a:hover { background: var(--bg-subtle); border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow-sm); }
.pager a.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); box-shadow: none; }

/* ==========================================================================
   Key/value list
   ========================================================================== */
.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-3) var(--space-6);
    margin: 0 0 var(--space-5);
    font-size: 14px;
}
.kv dt,
.kv .muted { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.kv dd { margin: 0; font-weight: 500; color: var(--text-primary); }

/* ==========================================================================
   Tiles
   ========================================================================== */
.tile {
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.tile:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-2px); }
.tile-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 8px;
    font-weight: 600;
}
.tile-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: -0.015em;
    line-height: 1.2;
}

/* ==========================================================================
   Grids
   ========================================================================== */
.grid      { display: grid; gap: var(--space-5); }
.grid-2    { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-5); }
.grid-3    { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--space-5); }
.grid-4    { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--space-5); }
.grid-2-span { grid-column: span 2; }
.mt-3      { margin-top: var(--space-5); }

/* ==========================================================================
   Utility classes
   ========================================================================== */
.right   { text-align: right; }
.strong  { font-weight: 600; }
.num     { text-align: right; font-variant-numeric: tabular-nums; }
.inline  { display: inline-flex; gap: 8px; align-items: center; }
.muted   { color: var(--text-muted); }
.mono    { font-family: var(--font-mono); font-size: .85rem; }
.full    { grid-column: 1 / -1; }

.cost, .vat, .qty {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.count-input {
    width: 100px;
    text-align: right;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    box-shadow: var(--shadow-xs);
}
.count-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}

.variance-cell { font-variant-numeric: tabular-nums; font-weight: 600; }

.is-active {
    background: var(--brand-primary) !important;
    color: #fff !important;
}

/* ==========================================================================
   Login page
   ========================================================================== */
.login-page {
    background: linear-gradient(135deg, #f5f7f8 0%, #e6f0e7 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 48px 36px;
    width: min(420px, 100%);
    box-shadow: var(--shadow-lg);
}
.login-brand {
    margin: 0 0 8px;
    color: var(--brand-primary);
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.02em;
}
.login-sub {
    margin: 0 0 28px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}
.login-help {
    margin-top: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ==========================================================================
   Setup wizard
   ========================================================================== */
.setup-page,
.setup-card {
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    max-width: 720px;
    margin: var(--space-6) auto;
    box-shadow: var(--shadow-md);
}
.setup-sub { color: var(--text-muted); font-size: 14px; margin-bottom: var(--space-4); }
.setup-actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-5); }
.setup-ok  { color: var(--brand-primary); font-weight: 600; }
.setup-fail { color: var(--brand-danger); font-weight: 600; }
.setup-table { width: 100%; border-collapse: collapse; margin: var(--space-4) 0; }
.setup-table th,
.setup-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); text-align: left; font-size: 13.5px; }

/* ==========================================================================
   Procurement legacy shell (temporary — awaiting layout rewrite)
   ========================================================================== */
.admin-body { background: var(--bg-page); margin: 0; font-family: var(--font-sans); color: var(--text-primary); }
.admin-header { background: var(--brand-primary); color: #fff; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.admin-brand { color: #fff; font-weight: 700; text-decoration: none; }
.admin-user { color: #fff; font-size: 13px; opacity: .92; margin-left: auto; }
.admin-link { color: #fff; text-decoration: none; font-size: 13px; opacity: .92; }
.admin-shell { max-width: 1440px; margin: 0 auto; padding: var(--space-6) var(--space-6) var(--space-7); }
.admin-main { padding: 0; }

/* ==========================================================================
   Procurement tabs
   ========================================================================== */
.procurement-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: var(--space-5);
}
.procurement-tabs a {
    padding: 10px 20px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    text-decoration: none;
    color: var(--brand-primary);
    font-weight: 600;
    font-size: 14px;
    transition: background var(--transition-fast);
}
.procurement-tabs a.active,
.procurement-tabs a:hover {
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    text-decoration: none;
}

/* ==========================================================================
   HR sidebar shell
   ========================================================================== */
.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}
.app-sidebar {
    background: var(--brand-primary);
    color: #fff;
    padding: var(--space-6) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.app-sidebar .brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    margin-bottom: var(--space-5);
    color: #fff;
}
.app-sidebar .brand small {
    display: block;
    color: var(--brand-secondary);
    font-size: .75rem;
    font-weight: 500;
    letter-spacing: .05em;
    margin-top: 4px;
}
.app-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.app-sidebar nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: #fff;
    text-decoration: none;
    font-size: .95rem;
    opacity: .85;
    transition: background var(--transition-fast), opacity var(--transition-fast);
}
.app-sidebar nav a.nav-link:hover {
    background: rgba(255,255,255,.12);
    opacity: 1;
    text-decoration: none;
}
.app-sidebar nav a.nav-link.active {
    background: rgba(255,255,255,.20);
    opacity: 1;
    font-weight: 600;
}
.app-sidebar nav a.nav-link i { width: 20px; text-align: center; }
.app-sidebar .sidebar-foot {
    margin-top: auto;
    padding-top: var(--space-5);
    border-top: 1px solid rgba(255,255,255,.15);
    font-size: .85rem;
    opacity: .9;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.app-sidebar .sidebar-foot a { color: var(--brand-secondary); text-decoration: none; }

@media (max-width: 820px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        padding: var(--space-4);
        gap: var(--space-4);
        align-items: center;
    }
    .app-sidebar .brand { margin: 0; }
    .app-sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .app-sidebar .sidebar-foot {
        margin: 0;
        padding: 0;
        border: none;
        flex-direction: row;
    }
}

/* ==========================================================================
   HR helpers
   ========================================================================== */
.hr-empty { text-align: center; color: var(--text-muted); padding: var(--space-5); }

.att-time   { width: 100px; }
.att-hours  { width: 70px; }
.att-status { width: 130px; }
.att-notes  { width: 180px; }

.hr-selftest-summary {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    font-size: 1rem;
    border: 1px solid transparent;
}
.hr-selftest-summary.ok  { background: #e6f4ea; color: var(--brand-primary); border-color: #bfe0c6; }
.hr-selftest-summary.bad { background: var(--brand-danger-light); color: var(--brand-danger); border-color: #f5b8be; }

/* ==========================================================================
   Details/summary
   ========================================================================== */
details > summary {
    cursor: pointer;
    padding: 8px 0;
    font-weight: 600;
    color: var(--brand-primary);
}
details pre {
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    font-size: .85rem;
    overflow: auto;
}

/* ==========================================================================
   Selftest
   ========================================================================== */
.selftest-summary {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    font-size: 1rem;
}
.selftest-summary.ok  { background: #e6f4ea; color: var(--brand-primary); }
.selftest-summary.bad { background: var(--brand-danger-light); color: var(--brand-danger); }
.row-ok  td { background: #f7fcf8; }
.row-bad td { background: #fdf3f4; }

/* ==========================================================================
   Finance
   ========================================================================== */
.finance-journal-line-row td { vertical-align: top; }
.finance-journal-line-row input.mono { text-align: right; width: 120px; }
.finance-totals-row th.mono { text-align: right; }
.finance-summary-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.finance-summary-tile .tile-value { font-size: 1.2rem; }
.finance-status-pill.posted   { color: var(--brand-primary); }
.finance-status-pill.reversed { color: var(--brand-secondary); }
.finance-status-pill.closed   { color: var(--text-muted); }
.finance-source-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: .75rem;
    background: #f1f3f5;
    color: #333;
    font-weight: 500;
}
.finance-memo-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finance-ledger-running { font-weight: 600; }
.finance-coa-immutable { color: var(--text-muted); font-size: .85rem; }
.finance-period-closed-alert { border-left: 4px solid var(--brand-danger); border-radius: var(--radius-sm); }
.finance-tb-balanced { color: var(--brand-primary); font-weight: 600; }
.finance-tb-imbalanced { color: var(--brand-danger); font-weight: 600; }
.finance-manual-lines tbody input { width: 100%; box-sizing: border-box; }
.finance-manual-lines tfoot th { background: var(--bg-subtle); }

/* ==========================================================================
   Expenses
   ========================================================================== */
.expense-subnav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.expense-filter .form-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.expense-filter label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}
.expense-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
}
.expense-actions .inline {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin: 0;
}
.expense-reject-form input[type="text"] { min-width: 240px; }
.expense-reject-form {
    border-left: 4px solid var(--brand-danger);
    padding-left: 16px;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Manual-entry / form-as-grid fixes
   ========================================================================== */
#manual-journal-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-5) var(--space-5);
    align-items: start;
    margin-bottom: var(--space-5);
}

#manual-journal-form > label { grid-column: auto; }

#manual-journal-form > table,
#manual-journal-form > #lines-table,
#manual-journal-form > .form-actions,
#manual-journal-form > .alert,
#manual-journal-form > input[type="hidden"] { grid-column: 1 / -1; }

#lines-table { width: 100%; table-layout: auto; margin-top: 8px; margin-bottom: 0; }
#lines-table thead th:nth-child(1) { width: 34%; }
#lines-table thead th:nth-child(2) { width: 30%; }
#lines-table thead th:nth-child(3) { width: 15%; }
#lines-table thead th:nth-child(4) { width: 15%; }
#lines-table thead th:nth-child(5) { width: 60px; }

#lines-table td select,
#lines-table td input[type="text"] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
#lines-table td input.mono,
#lines-table td select.mono { text-align: right; font-variant-numeric: tabular-nums; }
#lines-table th.mono,
#lines-table td.mono { text-align: right; }
#lines-table tfoot th {
    background: var(--bg-subtle);
    font-weight: 600;
    font-size: 13px;
    padding: 14px 18px;
    border-top: 1px solid var(--border-default);
}

#manual-journal-form > .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: var(--space-3);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-soft);
    flex-wrap: wrap;
}

/* Line-item rows inside tables (general) */
.journal-line td { vertical-align: middle; }
.journal-line input,
.journal-line select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 13.5px;
    box-shadow: var(--shadow-xs);
}
.journal-line input:focus,
.journal-line select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}
.line-total { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }

.remove-line,
.remove-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid #f5b8be;
    background: var(--brand-danger-light);
    color: var(--brand-danger);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast);
}
.remove-line:hover,
.remove-row:hover { background: #f8d7da; }

/* Custom chevron for selects (in card contexts) */
.card select,
.form-grid select,
.field select,
.filter-bar select,
.filters select,
.toolbar-form select,
#lines-table select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #6b7280 50%),
        linear-gradient(135deg, #6b7280 50%, transparent 50%);
    background-position:
        calc(100% - 20px) calc(50% - 2px),
        calc(100% - 15px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 40px !important;
}
select::-ms-expand { display: none; }

/* ==========================================================================
   POS additions
   ========================================================================== */
.pos-btn-secondary { background: #fff; border: 1px solid var(--border-default); color: var(--text-primary); }
.pos-btn-secondary:hover { background: var(--bg-subtle); }
.pos-prod-stock {
    font-size: 11.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Phase 11 — Users / Permissions / Audit
   ========================================================================== */

.user-name-cell {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .01em;
    text-transform: uppercase;
    box-shadow: var(--shadow-sm);
}

.user-name-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}
.user-name-text .user-name-primary {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-name-text .user-name-secondary {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 12.5px;
    color: var(--text-muted);
}
.user-status-inline .pill { margin: 0; }

.user-form-section {
    grid-column: 1 / -1;
    margin: var(--space-5) 0 var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--border-soft);
}
.user-form-section h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--brand-primary);
}

.user-branch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
}
.user-branch-grid label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.user-branch-grid label:hover { background: rgba(29,89,37,.06); }
.user-branch-grid input[type="checkbox"] { flex-shrink: 0; }

.user-detail-card .kv {
    grid-template-columns: max-content 1fr;
    gap: var(--space-3) var(--space-6);
}
.user-detail-card .kv dt { white-space: nowrap; }

.user-actions-card hr {
    border: none;
    border-top: 1px solid var(--border-soft);
    margin: var(--space-5) 0;
}
.user-actions-card .form-grid {
    margin-bottom: 0;
    gap: var(--space-4) var(--space-4);
}
.user-actions-card .form-actions {
    justify-content: flex-start;
}
.user-actions-card form + form { margin-top: var(--space-4); }

.user-role-system {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.user-perm-group {
    margin-bottom: var(--space-5);
}
.user-perm-group-title {
    margin: 0 0 var(--space-3);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--brand-primary);
    padding-bottom: var(--space-1);
    border-bottom: 2px solid var(--border-soft);
}
.user-perm-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-2) var(--space-5);
}
.user-perm-item {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    padding: 4px 0;
    font-size: 13.5px;
    min-width: 0;
}
.user-perm-item code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-primary);
    background: var(--bg-subtle);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.user-perm-item .user-perm-name {
    color: var(--text-muted);
    font-size: 13px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-perm-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.user-perm-roles .pill {
    font-size: 11.5px;
    padding: 3px 10px;
}

.user-role-perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}
.user-role-perm-group {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    background: var(--bg-surface);
    box-shadow: var(--shadow-xs);
}
.user-role-perm-group h4 {
    margin: 0 0 var(--space-3);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--brand-primary);
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 8px;
}
.user-role-perm-group label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0;
    font-size: 13.5px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.user-role-perm-group label:hover { background: var(--bg-subtle); }
.user-role-perm-group label input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.user-role-perm-group label code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
}
.user-role-perm-group label span.user-perm-name {
    color: var(--text-muted);
    font-size: 12.5px;
}
.user-role-perm-group input[type="checkbox"]:disabled + code,
.user-role-perm-group input[type="checkbox"]:disabled ~ span {
    opacity: .6;
}

.audit-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-4);
    align-items: flex-end;
    padding: var(--space-5);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
}
.audit-filter-bar .audit-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.audit-filter-bar input,
.audit-filter-bar select {
    padding: 10px 14px;
    min-height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 14px;
    background: #fff;
    box-shadow: var(--shadow-xs);
}
.audit-filter-bar input:focus,
.audit-filter-bar select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}
.audit-filter-bar .audit-filter-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    margin-left: auto;
}

.audit-action-code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-subtle);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    display: inline-block;
}

.audit-entity-cell {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13.5px;
}
.audit-entity-cell .audit-entity-type {
    color: var(--text-secondary);
}
.audit-entity-cell .audit-entity-id {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-muted);
}
.audit-entity-cell .audit-entity-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-size: 12.5px;
    opacity: .7;
}
.audit-entity-cell .audit-entity-link:hover { opacity: 1; text-decoration: underline; }

.audit-ip {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-muted);
}
.audit-request-id {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-soft);
}

.audit-detail-dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-3) var(--space-5);
    font-size: 14px;
    margin: 0 0 var(--space-5);
}
.audit-detail-dl dt {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.audit-detail-dl dd {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-primary);
    word-break: break-word;
}

.audit-json {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow: auto;
    color: var(--text-primary);
    margin: 0;
}

.audit-attempt-success { color: var(--brand-primary); font-weight: 600; }
.audit-attempt-fail    { color: var(--brand-danger);  font-weight: 600; }
.audit-useragent {
    max-width: 380px;
    font-size: 12.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-selftest-summary {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    font-size: 1rem;
    border: 1px solid transparent;
}
.user-selftest-summary.ok  {
    background: #e6f4ea;
    color: var(--brand-primary);
    border-color: #bfe0c6;
}
.user-selftest-summary.bad {
    background: var(--brand-danger-light);
    color: var(--brand-danger);
    border-color: #f5b8be;
}

@media (max-width: 900px) {
    .user-role-perm-grid { grid-template-columns: 1fr; }
    .user-perm-list      { grid-template-columns: 1fr; }
    .audit-filter-bar    { padding: var(--space-4); }
    .audit-filter-bar .audit-filter-actions { margin-left: 0; width: 100%; }
    .audit-useragent     { max-width: 200px; }
    .audit-detail-dl     { grid-template-columns: 1fr; gap: 4px var(--space-4); }
    .audit-detail-dl dt  { margin-top: var(--space-2); }
}

@media (max-width: 600px) {
    .user-branch-grid    { grid-template-columns: 1fr; }
    .user-avatar         { width: 32px; height: 32px; font-size: 12px; }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    .app-header, .app-footer, .toolbar, .toolbar-form, .filter-bar,
    .filters, .pager, .btn, .form-actions, .expense-subnav,
    .app-nav, .app-user {
        display: none !important;
    }
    .app-main { padding: 0; max-width: none; }
    .card { border: none; padding: 0; box-shadow: none; }
    .data-table, .table { border: 1px solid #999; box-shadow: none; border-radius: 0; }
    .data-table th, .data-table td,
    .table th, .table td { font-size: 11px; padding: 8px 10px; border: 1px solid #999; }
    .data-table thead th, .table thead th { background: #f0f0f0; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
    .app-main { padding: var(--space-5) var(--space-5) var(--space-6); }
}

@media (max-width: 900px) {
    .app-main { padding: var(--space-4) var(--space-4) var(--space-5); }
    .app-nav { flex-wrap: wrap; gap: 4px; }
    .app-nav a { padding: 8px 12px; font-size: 13.5px; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid > .full,
    .form-grid > .grid-2-span { grid-column: auto; }
    .data-table th, .data-table td { padding: 12px 14px; }
    .table th, .table td { padding: 12px 14px; }
    #manual-journal-form { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .page-title { font-size: 20px; }
    .card { padding: var(--space-4); border-radius: var(--radius-lg); }
    .app-header { padding: 0 var(--space-4); }
    .app-header-left, .app-header-right { gap: var(--space-3); }
    .app-user { display: none; }
    .filter-bar, .filters { padding: var(--space-4); }
}

/* ==========================================================================
   Phase 12 — Reports
   ========================================================================== */

.report-subtitle {
    font-size: 0.9rem;
    margin: 0;
}

.report-range-chip {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: rgba(29, 89, 37, 0.08);
    color: #1D5925;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.report-csv-link {
    white-space: nowrap;
}

.report-totals-row td {
    background: rgba(29, 89, 37, 0.06);
    border-top: 2px solid rgba(29, 89, 37, 0.25);
}

.report-totals-row strong {
    font-weight: 700;
}

.filter-bar label.check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    font-weight: 500;
}

.filter-bar label.check input[type="checkbox"] {
    margin: 0;
}

.report-hub-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.5rem 1.25rem;
}

.report-hub-list li a {
    display: block;
    padding: 0.5rem 0;
    color: #1D5925;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    font-weight: 500;
    transition: border-color 0.1s ease;
}

.report-hub-list li a:hover {
    border-bottom-color: #1D5925;
}

@media print {
    .app-header,
    .app-footer,
    .filter-bar,
    .toolbar .form-actions,
    .report-csv-link {
        display: none !important;
    }
    .app-main {
        padding: 0;
        margin: 0;
    }
    .data-table {
        font-size: 11px;
    }
    .report-totals-row td {
        background: transparent !important;
        border-top: 2px solid #000;
    }
}

/* ==========================================================================
   Phase 15 - Admin shell + dashboard
   ========================================================================== */

.shell-wrap {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
}

.shell-main {
    min-width: 0;
    max-width: none;
    margin: 0;
}

.shell-sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    padding: var(--space-5) var(--space-4);
    overflow-y: auto;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    box-sizing: border-box;
}

.shell-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.shell-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.shell-group-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 var(--space-2) var(--space-1);
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: var(--space-2);
}

.shell-group-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.shell-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.shell-link:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    text-decoration: none;
}

.shell-link.is-active {
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    font-weight: 600;
}

.shell-link i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    opacity: .85;
    flex-shrink: 0;
}

.shell-link.is-active i {
    opacity: 1;
}

.shell-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: rgba(255,255,255,.10);
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.shell-sidebar-toggle:hover {
    background: rgba(255,255,255,.20);
}

.shell-signout {
    background: transparent;
    border: none;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dash-section-title {
    margin: var(--space-6) 0 var(--space-4);
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--border-soft);
}

.dash-section-title:first-of-type {
    margin-top: var(--space-4);
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.dash-tile {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-6);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 110px;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.dash-tile:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.dash-tile-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}

.dash-tile-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: -0.015em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.dash-tile-foot {
    margin-top: auto;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.dash-tile-foot a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
}

.dash-tile-foot a:hover {
    text-decoration: underline;
}

.dash-tile-pay .dash-tile-value {
    font-size: 18px;
}

.dash-tile-warn {
    border-color: var(--brand-secondary);
    background: #fffaf2;
}

.dash-tile-warn .dash-tile-value {
    color: var(--brand-secondary-dark);
}

.dash-tile-badge-warn {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--brand-danger-light);
    color: var(--brand-danger);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .01em;
}

@media (max-width: 1100px) {
    .shell-wrap {
        grid-template-columns: 240px minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .shell-wrap {
        grid-template-columns: 1fr;
    }
    .shell-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-default);
        max-height: 360px;
    }
    .shell-sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-4);
    }
    .shell-group {
        min-width: 200px;
    }
    .shell-sidebar-toggle {
        display: inline-flex;
    }
    .dash-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 600px) {
    .shell-sidebar {
        max-height: 300px;
        padding: var(--space-4) var(--space-3);
    }
    .shell-group {
        min-width: 150px;
    }
    .dash-grid {
        grid-template-columns: 1fr;
    }
    .dash-tile {
        min-height: 90px;
        padding: var(--space-4) var(--space-5);
        border-radius: var(--radius-lg);
    }
    .dash-tile-value {
        font-size: 20px;
    }
}

@media print {
    .shell-sidebar,
    .shell-sidebar-toggle {
        display: none !important;
    }
    .shell-wrap {
        display: block;
    }
    .dash-tile {
        border: 1px solid #999;
        box-shadow: none;
    }
}

/* ==========================================================================
   Phase 15.1 - Admin shell: independent column scroll
   ========================================================================== */

.shell-wrap {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    height: calc(100vh - 60px);
    min-height: 0;
    overflow: hidden;
}

.shell-sidebar {
    position: static;
    top: auto;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--border-default);
    background: var(--bg-surface);
    padding: var(--space-5) var(--space-4);
    box-sizing: border-box;
}

.shell-main {
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
}

.shell-wrap + .app-footer,
.app-body > .app-footer {
    display: none;
}

@media (max-width: 900px) {
    .shell-wrap {
        height: auto;
        overflow: visible;
        grid-template-columns: 1fr;
    }
    .shell-sidebar {
        height: auto;
        max-height: 360px;
        overflow-y: auto;
    }
    .shell-main {
        height: auto;
        max-height: none;
        overflow-y: visible;
    }
    .app-body > .app-footer {
        display: block;
    }
}

/* ==========================================================================
   Phase 15.2 - Settings page
   ========================================================================== */

.settings-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
}

.settings-rail {
    position: sticky;
    top: var(--space-6);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.settings-rail nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-rail-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 10px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.settings-rail-link:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    text-decoration: none;
}

.settings-rail-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-rail-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    flex-shrink: 0;
}

.settings-rail-badge.muted {
    background: #f3f4f6;
    color: #4b5563;
}

.settings-sections {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    min-width: 0;
}

.settings-section {
    scroll-margin-top: var(--space-6);
}

.settings-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.settings-section-head .card-title {
    margin-bottom: 4px;
}

.settings-note {
    margin: 0;
    font-size: 13px;
}

.settings-form .settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-5) var(--space-5);
    margin-bottom: var(--space-5);
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    min-width: 0;
}

.settings-field-bool {
    gap: 6px;
}

.settings-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.settings-field input[type="text"],
.settings-field input[type="number"],
.settings-field input[type="password"],
.settings-field textarea {
    width: 100%;
    padding: 12px 16px;
    min-height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    font: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: #fff;
    box-sizing: border-box;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-xs);
}

.settings-field textarea {
    font-family: var(--font-mono);
    font-size: 13px;
    resize: vertical;
    min-height: 100px;
}

.settings-field input:focus,
.settings-field textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}

.settings-field input:disabled,
.settings-field textarea:disabled {
    background: var(--bg-subtle);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.settings-field .settings-help {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
}

.settings-field .settings-help code {
    font-family: var(--font-mono);
    font-size: 11.5px;
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.set-bool {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.set-bool input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--brand-primary);
    margin: 0;
    flex-shrink: 0;
    border-radius: 4px;
}

.settings-readonly-wrap {
    width: 100%;
    overflow-x: auto;
}

.settings-readonly {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    margin: 0;
    table-layout: fixed;
}

.settings-readonly th,
.settings-readonly td {
    padding: 12px 16px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-soft);
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.settings-readonly thead th {
    background: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.settings-readonly tbody tr:last-child td {
    border-bottom: none;
}

.settings-readonly tbody tr:nth-child(even) {
    background: var(--bg-hover);
}

.settings-readonly col.col-key   { width: 34%; }
.settings-readonly col.col-value { width: 24%; }
.settings-readonly col.col-type  { width: 10%; }
.settings-readonly col.col-desc  { width: 32%; }

.settings-readonly .cell-key {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    white-space: normal;
}

.settings-readonly .cell-value {
    font-variant-numeric: tabular-nums;
}

.settings-readonly .cell-value.is-empty {
    color: var(--text-muted);
    font-style: italic;
}

.settings-readonly .cell-value.is-secret {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
}

.settings-readonly .cell-type {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.settings-readonly .cell-desc {
    color: var(--text-muted);
    font-size: 13px;
}

@media (max-width: 900px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }
    .settings-rail {
        position: static;
    }
    .settings-rail nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    .settings-rail-link {
        padding: 8px 12px;
        background: var(--bg-subtle);
    }
    .settings-readonly col.col-key   { width: 40%; }
    .settings-readonly col.col-value { width: 30%; }
    .settings-readonly col.col-type  { width: 12%; }
    .settings-readonly col.col-desc  { width: 18%; }
}

@media (max-width: 600px) {
    .settings-readonly {
        font-size: 13px;
        table-layout: auto;
    }
    .settings-readonly th,
    .settings-readonly td {
        padding: 10px 12px;
    }
}

@media print {
    .settings-rail {
        display: none !important;
    }
    .settings-layout {
        display: block;
    }
    .settings-field input,
    .settings-field textarea {
        border: none;
        padding: 0;
        background: transparent;
    }
    .settings-readonly {
        border: 1px solid #999;
        box-shadow: none;
        border-radius: 0;
    }
    .settings-readonly th,
    .settings-readonly td {
        border: 1px solid #999;
    }
    .settings-readonly thead th {
        background: #f0f0f0;
    }
}

/* ==========================================================================
   Phase 16.1 - POS shift actions (top bar)
   ========================================================================== */

.pos-shift-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,.35);
    transition: background var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
}

.pos-shift-close {
    background: transparent;
    color: #fff;
}

.pos-shift-close:hover {
    background: rgba(255,255,255,.15);
    text-decoration: none;
    color: #fff;
}

.pos-shift-open {
    background: var(--brand-secondary);
    color: #1a1a1a;
    border-color: var(--brand-secondary);
}

.pos-shift-open:hover {
    background: var(--brand-secondary-dark);
    border-color: var(--brand-secondary-dark);
}

.pos-shift-badge.pos-shift-optional {
    background: rgba(255,255,255,.15);
    color: #fff;
}

/* ==========================================================================
   Phase 19 - Visual POS (three-column layout)
   ========================================================================== */

.pos-main-visual {
    grid-template-columns: minmax(0, 1fr) 440px;
}

.posv-left {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 16px;
}

.posv-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
}

.posv-preview {
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
    box-shadow: var(--shadow-sm);
}

.posv-preview-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 16px;
}
.posv-preview-idle i { font-size: 48px; opacity: .35; }
.posv-preview-idle p { margin: 0; font-size: 14px; }

.posv-preview-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: var(--bg-subtle);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
}

.posv-preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    color: var(--text-soft);
    background: var(--bg-subtle);
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
}

.posv-preview-name {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
    line-height: 1.25;
    margin-top: 8px;
}

.posv-preview-sku { font-family: var(--font-mono); font-size: 12.5px; }

.posv-preview-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.015em;
}

.posv-preview-stock { font-size: 13px; }

.posv-preview-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.posv-preview-actions .q-dec,
.posv-preview-actions .q-inc {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-default);
    background: #fff;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 700;
    font-size: 16px;
    box-shadow: var(--shadow-xs);
}

.posv-preview-actions .q-dec:hover,
.posv-preview-actions .q-inc:hover { background: var(--bg-subtle); }

.posv-q-inp {
    width: 60px;
    height: 36px;
    text-align: center;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 15px;
    box-shadow: var(--shadow-xs);
}

.posv-add-btn {
    margin-top: 8px;
    width: 100%;
}

.posv-similar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    align-content: start;
    overflow-y: auto;
    padding-right: 6px;
    min-height: 0;
}

.posv-tiles-none {
    grid-column: 1 / -1;
    padding: 40px;
    text-align: center;
}

.posv-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    min-height: 220px;
    box-shadow: var(--shadow-xs);
}

.posv-tile:hover { border-color: var(--brand-primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.posv-tile:active { transform: scale(.98); }
.posv-tile-active { border-color: var(--brand-primary); box-shadow: var(--shadow-md); }

.posv-tile-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    flex-shrink: 0;
}

.posv-tile-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: var(--brand-primary);
    background: var(--brand-primary-light);
    border: 1px solid var(--border-soft);
}

.posv-tile-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.posv-tile-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-primary);
    font-variant-numeric: tabular-nums;
    margin-top: auto;
}

.inv-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    display: block;
}

.inv-thumb-ph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    font-weight: 700;
    font-size: 18px;
    border: 1px solid var(--border-soft);
}

@media (max-width: 1100px) {
    .posv-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
    .posv-similar { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 900px) {
    .pos-main-visual { grid-template-columns: 1fr; }
    .posv-layout { grid-template-columns: 1fr; }
    .posv-preview { max-height: 360px; }
    .posv-preview-image { aspect-ratio: 16 / 9; }
    .posv-similar { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ==========================================================================
   Phase 15.3 - Dashboard two-column shell with right chart rail
   ========================================================================== */

.dash-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--space-6);
    align-items: start;
}

.dash-shell-main {
    min-width: 0;
}

.dash-shell-rail {
    position: sticky;
    top: var(--space-6);
    min-width: 0;
    max-width: 360px;
}

.dash-shell-rail .dash-section-title {
    margin-top: 0;
}

.dash-chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-4) var(--space-5);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-4);
}

.dash-chart-title {
    margin: 0 0 var(--space-3);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.dash-chart-card .chart-svg {
    display: block;
    width: 100%;
    height: auto;
}

@media (max-width: 1200px) {
    .dash-shell {
        grid-template-columns: minmax(0, 1fr);
    }
    .dash-shell-rail {
        position: static;
        max-width: none;
    }
    .dash-shell-rail .dash-chart-card {
        margin-bottom: var(--space-5);
    }
}

@media (max-width: 900px) {
    .dash-chart-card .chart-svg {
        width: 100%;
        max-width: 100%;
    }
}

/* ==========================================================================
   MOBILE RESPONSIVE SHELL (Hamburger Menu)
   ========================================================================== */

/* Hide the mobile-specific elements on desktop */
.shell-sidebar-header,
.shell-sidebar-overlay {
    display: none !important;
}

@media (max-width: 992px) {
    /* 1. Hide the horizontal top nav to save space */
    .app-nav {
        display: none !important;
    }

    /* 2. Make the top bar hamburger button look nice */
    .shell-sidebar-toggle {
        display: block;
        background: transparent;
        border: none;
        color: inherit;
        font-size: 1.25rem;
        cursor: pointer;
        margin-right: 10px;
    }

    /* 3. Transform the sidebar into an off-canvas drawer */
    .shell-sidebar {
        position: fixed !important;
        top: 0;
        left: -280px; /* Hide it off-screen to the left */
        width: 280px;
        height: 100vh; 
        height: 100dvh; 
        max-height: 100dvh !important; 
        z-index: 9999; 
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        background-color: #fff; 
        
        /* Flexbox setup so the header stays fixed and the list scrolls */
        display: flex !important; 
        flex-direction: column; 
        overflow: hidden; 
    }

    /* 4. Class added by JS to slide it in */
    .shell-sidebar.is-open {
        left: 0;
    }

    /* 5. Sidebar Header (Fixed at the top of the drawer) */
    .shell-sidebar-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        border-bottom: 1px solid var(--border-default);
        flex-shrink: 0; 
    }

    .shell-sidebar-brand {
        font-weight: 700;
        font-size: 1.2rem;
        color: var(--brand-primary); 
    }

    .shell-sidebar-close {
        background: transparent;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--text-muted);
        padding: 0 8px;
        border-radius: var(--radius-md);
    }

    /* 6. Sidebar Nav (Scrollable list) */
    .shell-sidebar-nav {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 20px 16px;
    }

    /* 7. The dark overlay */
    .shell-sidebar-overlay {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998; 
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    }

    .shell-sidebar-overlay.is-active {
        opacity: 1;
        visibility: visible;
    }

    /* 8. Make sure the main content takes full width */
    .shell-wrap {
        display: block !important;
    }

    .shell-main {
        margin-left: 0 !important;
        padding: 20px;
    }
}

/* ==========================================================================
   Mobile Dashboard Action Buttons
   ========================================================================== */
.dash-actions-wrap {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    /* Force a 2-column grid on mobile */
    .dash-actions-wrap {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px;
        width: 100%;
        margin-top: 20px;
    }
    
    /* Make sure all buttons fill their grid cell */
    .dash-actions-wrap .btn {
        width: 100% !important;
        padding: 14px 8px;
        font-size: 14px;
        justify-content: center;
        text-align: center;
        border-radius: var(--radius-lg);
    }
    
    /* If there is an odd number of buttons (like 3), make the last one span the full width */
    .dash-actions-wrap .btn:last-child:nth-child(odd) {
        grid-column: 1 / -1 !important; 
    }
}

/* ==========================================================================
   Mobile Card Layout for Data Tables
   ========================================================================== */
@media (max-width: 768px) {
    /* Force the table to act like a block container */
    .mobile-stack-table thead {
        display: none; /* Hide the headers on mobile */
    }
    
    .mobile-stack-table, 
    .mobile-stack-table tbody, 
    .mobile-stack-table tr, 
    .mobile-stack-table td {
        display: block;
        width: 100%;
    }
    
    .mobile-stack-table tr {
        margin-bottom: 16px;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-lg);
        background: #fff;
        padding: 16px;
        box-shadow: var(--shadow-sm);
    }
    
    .mobile-stack-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        border-bottom: 1px solid var(--border-soft);
        padding: 12px 0;
        text-align: right;
    }
    
    .mobile-stack-table td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        padding-top: 16px;
    }

    /* Add labels before inputs so the user knows what they are typing */
    .mobile-stack-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-align: left;
        margin-right: 16px;
    }
    
    /* Make the inputs and selects take up the remaining space */
    .mobile-stack-table td input,
    .mobile-stack-table td select {
        width: 60% !important;
        text-align: right;
        padding: 10px 14px;
        border-radius: var(--radius-md);
    }
}

/* Custom File Upload Styling */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}
.file-upload-input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}
.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: var(--bg-subtle);
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    box-sizing: border-box;
}
.file-upload-label:hover {
    background: var(--bg-hover);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* ==========================================================================
   Global Rounded Inputs Override
   Forces all inputs to use soft rounded corners regardless of container
   ========================================================================== */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
select,
textarea,
.q-inp,
.count-input {
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-strong);
    padding: 10px 14px;
    box-shadow: var(--shadow-xs) !important;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* Ensure they still glow green when clicked */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand-primary) !important;
    box-shadow: var(--shadow-focus) !important;
}

/* Specifically targets the table inputs to ensure they don't get squished */
.data-table input,
.data-table select,
.mobile-stack-table input,
.mobile-stack-table select {
    border-radius: var(--radius-md) !important;
    padding: 10px 12px !important;
    min-height: 42px;
}