  /* ============ RESET & BASE ============ */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent; }

  :root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1c1c1c;
    --surface-3: #252525;
    --border: #2a2a2a;
    --border-strong: #3a3a3a;
    --text: #f5f5f4;
    --text-muted: #a3a3a3;
    --text-dim: #6b6b6b;
    --accent: #10b981;
    --accent-soft: rgba(16, 185, 129, 0.14);
    --accent-hover: #34d399;
    --danger: #ef4444;
    --success: #34d399;
    --tier-1: #60a5fa;
    --tier-2: #a78bfa;
    --tier-3: #f472b6;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 18px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-modal: 0 24px 80px rgba(0,0,0,0.6);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Typography — Inter is loaded from Google Fonts. The system fallbacks
       cover us if the network blocks Google Fonts (offline / corporate env). */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    --font-serif: var(--font-sans);  /* legacy alias — old rules still resolve */
    --font-mono: "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;

    /* Layout tokens */
    --sidebar-w: 240px;
    --sidebar-w-collapsed: 72px;
    --content-max: 1200px;
    --bp-desktop: 900px;
  }

  body.light {
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-2: #f5f5f4;
    --surface-3: #e7e5e4;
    --border: #e5e5e5;
    --border-strong: #d4d4d4;
    --text: #0a0a0a;
    --text-muted: #525252;
    --text-dim: #a3a3a3;
    --accent: #047857;
    --accent-soft: rgba(4, 120, 87, 0.1);
    --accent-hover: #065f46;
    --shadow: 0 8px 32px rgba(0,0,0,0.08);
    --shadow-modal: 0 24px 80px rgba(0,0,0,0.18);
  }

  body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01", "ss03";  /* Inter's nicer alt-glyphs */
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }

  button, input, select, textarea {
    font: inherit;
    color: inherit;
    border: none;
    background: none;
    outline: none;
  }
  button { cursor: pointer; }

  /* ============ APP SHELL ============ */
  /* Mobile-first: sidebar hidden, app fills the screen. */
  .app-shell {
    display: flex;
    min-height: 100vh;
  }
  .sidebar { display: none; }

  /* ============ LAYOUT ============ */
  .app {
    flex: 1;
    max-width: 720px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  /* ============ HEADER ============ */
  .header {
    position: sticky;
    top: var(--safe-top);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
  }
  .header-inner {
    padding: 14px 18px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .brand-logo {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: block;
    color: var(--accent);
  }
  .brand h1 {
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
  .brand h1::first-letter { color: var(--accent); }
  .brand-meta {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
  }
  .header-actions { display: flex; gap: 4px; }
  .icon-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
  }
  .icon-btn:hover, .icon-btn:active { background: var(--surface-2); color: var(--text); }
  .icon-btn svg { width: 20px; height: 20px; }

  /* ============ SEARCH & FILTERS ============ */
  .search-row {
    padding: 8px 18px 10px;
    display: flex;
    gap: 8px;
  }
  .search-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
  }
  .search-input:focus { border-color: var(--border-strong); }

  .chips {
    display: flex;
    gap: 6px;
    padding: 0 18px 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip {
    flex: none;
    padding: 7px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.15s;
  }
  .chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0a0a0a;
    font-weight: 600;
  }

  /* ============ CONTENT ============ */
  main {
    flex: 1;
    padding: 4px 18px 120px;
  }
  .empty {
    padding: 80px 20px;
    text-align: center;
    color: var(--text-dim);
  }
  .empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    opacity: 0.85;
  }
  .empty-icon::before {
    content: "";
    width: 22px;
    height: 22px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.35-4.35'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.35-4.35'/></svg>") center/contain no-repeat;
  }
  .empty-title {
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
  }
  .empty-text { font-size: 14px; max-width: 260px; margin: 0 auto; }

  /* Group sections */
  .group-section { margin-bottom: 22px; }
  .group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 2px 8px;
  }
  .group-name {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .group-count {
    font-size: 11px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
  }

  /* Product card */
  .product {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    position: relative;
    transition: transform 0.1s, border-color 0.15s;
  }
  .product:active { transform: scale(0.995); }
  .product-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
  }
  .product-name {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.01em;
    word-break: break-word;
  }
  .product-cost {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-top: 2px;
  }
  .product-cost-label {
    font-family: var(--font-sans);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-right: 4px;
  }
  .tiers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
  }
  .tier {
    text-align: center;
    padding: 6px 4px;
    border-radius: 8px;
    background: var(--surface-2);
  }
  .tier-label {
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 2px;
    font-weight: 600;
  }
  .tier:nth-child(1) .tier-label { color: var(--tier-1); }
  .tier:nth-child(2) .tier-label { color: var(--tier-2); }
  .tier:nth-child(3) .tier-label { color: var(--tier-3); }
  .tier-price {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
  }
  .tier-price.overridden::after {
    content: '•';
    color: var(--accent);
    margin-left: 3px;
  }
  .tier-margin {
    font-size: 9px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
  }

  /* ============ FAB ============ */
  .fab {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    right: 20px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #0a0a0a;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4), 0 2px 6px rgba(0,0,0,0.2);
    z-index: 20;
    transition: transform 0.15s;
  }
  .fab:active { transform: scale(0.92); }
  .fab svg { width: 26px; height: 26px; stroke-width: 2.5; }

  /* ============ MODAL ============ */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .modal-backdrop.open { opacity: 1; pointer-events: auto; }
  .modal {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 8px 18px calc(20px + var(--safe-bottom));
    max-height: 92vh;
    overflow-y: auto;
    z-index: 51;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    max-width: 720px;
    margin: 0 auto;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
  }
  .modal.open { transform: translateY(0); }
  .modal-handle {
    width: 36px; height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 8px auto 14px;
  }
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 2px;
  }
  .modal-title {
    font-family: var(--font-sans);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }
  .modal-close {
    color: var(--text-muted);
    font-size: 15px;
    padding: 6px 10px;
  }

  .form-group { margin-bottom: 16px; }
  .form-group label {
    display: block;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 600;
  }
  .form-group input, .form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .form-group input:focus, .form-group select:focus { border-color: var(--accent); }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

  .tier-override-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .tier-override-grid .form-group label { font-size: 10px; }
  .tier-override-grid input {
    padding: 10px 12px;
    font-size: 15px;
    text-align: center;
    font-family: var(--font-mono);
  }
  .tier-override-grid .form-group input::placeholder { font-family: var(--font-sans); font-size: 12px; color: var(--text-dim); }

  .btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #0a0a0a;
    font-weight: 600;
    font-size: 15px;
    border-radius: 12px;
    letter-spacing: 0.01em;
    transition: transform 0.1s, opacity 0.15s;
  }
  .btn:active { transform: scale(0.98); }
  .btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
  }
  .btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  }
  .btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
  .btn-stack > * + * { margin-top: 10px; }

  /* Settings groups */
  .settings-section { margin-bottom: 28px; }
  .settings-title {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-left: 2px;
  }
  .settings-card {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 4px;
  }
  .tier-config-row {
    display: grid;
    grid-template-columns: 1fr 90px 90px;
    gap: 8px;
    align-items: center;
    padding: 8px;
  }
  .tier-config-row input {
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
  }
  .tier-config-row input[type="number"] {
    text-align: center;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
  }
  .tier-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 8px;
  }

  .group-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  .group-row:last-child { border-bottom: none; }
  .group-row-name { flex: 1; font-size: 14px; }
  .group-row button {
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text-muted);
    border-radius: 6px;
  }
  .group-row button:hover { color: var(--danger); }
  .group-add-row { display: flex; gap: 8px; padding: 10px 4px 4px; }
  .group-add-row input {
    flex: 1;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
  }
  .group-add-row button {
    padding: 10px 16px;
    background: var(--accent);
    color: #0a0a0a;
    font-weight: 600;
    border-radius: 8px;
    font-size: 14px;
  }

  /* Footer stats */
  .footer-stats {
    padding: 20px 18px 8px;
    text-align: center;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    font-variant-numeric: tabular-nums;
  }

  /* Small helper */
  .divider-text {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 20px 0 14px;
  }

  /* Toast */
  .toast {
    position: fixed;
    bottom: calc(90px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface-3);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    border: 1px solid var(--border-strong);
    z-index: 100;
    opacity: 0;
    transition: all 0.25s;
    pointer-events: none;
    white-space: nowrap;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* In-app dialog (replaces native confirm/prompt) */
  .dialog-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
  }
  .dialog-backdrop.open { opacity: 1; pointer-events: auto; }
  .dialog {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 22px 22px 16px;
    width: calc(100% - 40px);
    max-width: 340px;
    z-index: 201;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }
  .dialog.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
  }
  .dialog-title {
    font-family: var(--font-serif);
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
  }
  .dialog-message {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 18px;
  }
  .dialog-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 18px;
    color: var(--text);
  }
  .dialog-input:focus { border-color: var(--accent); outline: none; }
  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .dialog-btn {
    padding: 11px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    border: 1px solid var(--border);
    transition: transform 0.1s;
  }
  .dialog-btn:active { transform: scale(0.97); }
  .dialog-btn-primary {
    background: var(--accent);
    color: #0a0a0a;
    border-color: var(--accent);
    font-weight: 600;
  }
  .dialog-btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    font-weight: 600;
  }

  /* SKU list in product modal */
  .sku-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
  }
  .sku-list:empty::before {
    content: 'No SKUs yet';
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
    padding: 14px 0;
    font-family: var(--font-sans);
  }
  .sku-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 8px 8px 14px;
  }
  .sku-row-code {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 0.03em;
    color: var(--text);
    word-break: break-all;
  }
  .sku-row-delete {
    width: 32px; height: 32px;
    border-radius: 8px;
    color: var(--text-dim);
    display: grid;
    place-items: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
  }
  .sku-row-delete:active { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
  .sku-row-delete svg { width: 16px; height: 16px; }

  .sku-add-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
  }
  .sku-add-row input {
    flex: 1;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
    min-width: 0;
  }
  .sku-add-row input:focus { border-color: var(--accent); }
  .sku-scan-btn {
    width: 44px;
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: 10px;
    color: var(--accent);
    display: grid;
    place-items: center;
    transition: transform 0.1s, background 0.15s;
    flex-shrink: 0;
  }
  .sku-scan-btn:active { transform: scale(0.94); }
  .sku-scan-btn svg { width: 20px; height: 20px; }
  .sku-add-btn {
    padding: 0 16px;
    background: var(--accent);
    color: #0a0a0a;
    font-weight: 600;
    font-size: 14px;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .sku-add-btn:active { transform: scale(0.97); }

  /* SKU count badge on product card */
  .product-sku-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    background: var(--surface-2);
    padding: 2px 7px;
    border-radius: 5px;
    margin-top: 4px;
    letter-spacing: 0.04em;
  }
  .product-sku-count svg { width: 10px; height: 10px; }

  /* Scanner overlay */
  .scanner-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 150;
    display: none;
    overflow: hidden;
  }
  .scanner-overlay.open { display: block; }
  #scannerVideo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .scanner-header {
    position: absolute;
    top: var(--safe-top);
    left: 0; right: 0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    z-index: 3;
  }
  .scanner-close {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    display: grid;
    place-items: center;
  }
  .scanner-close svg { width: 22px; height: 22px; }
  .scanner-title {
    color: white;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  }
  .scanner-frame {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(80vw, 320px);
    height: min(50vw, 200px);
    z-index: 2;
    pointer-events: none;
  }
  .scanner-corners {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  }
  .scanner-corners::before, .scanner-corners::after,
  .scanner-frame::before, .scanner-frame::after {
    content: '';
    position: absolute;
    width: 28px; height: 28px;
    border: 3px solid var(--accent);
  }
  .scanner-corners::before { top: -3px; left: -3px; border-right: none; border-bottom: none; border-radius: 12px 0 0 0; }
  .scanner-corners::after  { top: -3px; right: -3px; border-left: none; border-bottom: none; border-radius: 0 12px 0 0; }
  .scanner-frame::before   { bottom: -3px; left: -3px; border-right: none; border-top: none; border-radius: 0 0 0 12px; }
  .scanner-frame::after    { bottom: -3px; right: -3px; border-left: none; border-top: none; border-radius: 0 0 12px 0; }
  .scanner-line {
    position: absolute;
    left: 10%; right: 10%;
    top: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 12px var(--accent);
    animation: scannerScan 2s ease-in-out infinite;
  }
  @keyframes scannerScan {
    0%, 100% { top: 15%; opacity: 0.8; }
    50% { top: 85%; opacity: 1; }
  }
  .scanner-hint {
    position: absolute;
    bottom: calc(40px + var(--safe-bottom));
    left: 20px; right: 20px;
    text-align: center;
    color: white;
    font-size: 14px;
    padding: 12px 20px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    z-index: 3;
  }
  .scanner-hint.error { background: rgba(239, 68, 68, 0.85); }

  /* ============ BOTTOM TAB BAR ============ */
  .tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding-bottom: var(--safe-bottom);
    z-index: 15;
    max-width: 720px;
    margin: 0 auto;
  }
  .tab-btn {
    padding: 10px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
    transition: color 0.15s;
  }
  .tab-btn svg { width: 22px; height: 22px; stroke-width: 1.8; }
  .tab-btn.active { color: var(--accent); }
  .tab-btn.active svg { stroke-width: 2.2; }

  /* Adjust main padding + FAB for bottom tabbar */
  main { padding-bottom: 150px !important; }
  .fab { bottom: calc(80px + var(--safe-bottom)) !important; }

  /* ============ INVOICE VIEW ============ */
  .invoice-page { padding: 4px 18px 0; }

  /* Product dropdown on invoice page */
  .product-dropdown-wrap {
    position: relative;
    margin-bottom: 14px;
  }
  .product-dropdown {
    width: 100%;
    padding: 14px 42px 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--text);
    font-family: var(--font-sans);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .product-dropdown:focus { border-color: var(--accent); outline: none; }
  .product-dropdown:active { background: var(--surface-2); }
  .product-dropdown option { background: var(--surface); color: var(--text); }
  .product-dropdown option[disabled] { color: var(--text-dim); }
  .product-dropdown-caret {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    color: var(--accent);
    pointer-events: none;
  }

  /* Invoice "Add a product" trigger — looks like a search input but is a button.
     Clicking it opens the product picker modal (which has its own search input). */
  .invoice-add-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 13px 16px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
  }
  .invoice-add-trigger:hover {
    border-color: var(--border-strong);
    color: var(--text-muted);
  }
  .invoice-add-trigger:active {
    transform: scale(0.995);
    background: var(--surface-2);
  }
  .invoice-add-trigger svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
    flex-shrink: 0;
  }
  .invoice-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
  }
  .invoice-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
  }
  .invoice-field:last-child { border-bottom: none; }
  .invoice-field-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 600;
  }
  .invoice-field-value {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .invoice-field-value.muted { color: var(--text-dim); }
  .invoice-field-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 500;
  }
  .invoice-tier-pills {
    display: flex;
    gap: 6px;
    padding: 2px 0;
  }
  .invoice-tier-pill {
    flex: 1;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    transition: all 0.15s;
  }
  .invoice-tier-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0a0a0a;
    font-weight: 600;
  }

  .invoice-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
  }
  .invoice-line:last-child { border-bottom: none; }
  .invoice-line-name {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 3px;
  }
  .invoice-line-meta {
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
  }
  .invoice-line-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .qty-stepper {
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
  }
  .qty-btn {
    width: 30px; height: 30px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 600;
    transition: background 0.15s;
  }
  .qty-btn:active { background: var(--surface-3); }
  .qty-value {
    min-width: 28px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    font-weight: 600;
  }
  .invoice-line-price {
    font-family: var(--font-mono);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: -0.01em;
    min-width: 68px;
    text-align: right;
  }
  .invoice-line-delete {
    width: 28px; height: 28px;
    color: var(--text-dim);
    display: grid;
    place-items: center;
    border-radius: 6px;
  }
  .invoice-line-delete svg { width: 14px; height: 14px; }

  .invoice-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 18px 2px 8px;
    border-top: 2px solid var(--border-strong);
  }
  .invoice-total-label {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .invoice-total-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--accent);
  }

  .invoice-save-btn {
    width: 100%;
    margin-top: 16px;
    padding: 15px;
    background: var(--accent);
    color: #0a0a0a;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.02em;
  }
  .invoice-save-btn:active { transform: scale(0.99); }
  .invoice-save-btn:disabled { opacity: 0.4; pointer-events: none; }

  .invoice-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
  }
  .invoice-empty-title {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .invoice-empty-text { font-size: 13px; }

  /* ============ PICKER RESULTS ============ */
  .picker-results {
    max-height: 55vh;
    overflow-y: auto;
    margin: 0 -4px 10px;
  }
  .picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 6px;
    gap: 10px;
    transition: transform 0.1s;
  }
  .picker-item:active { transform: scale(0.99); }
  .picker-item-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 2px;
  }
  .picker-item-meta {
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
  }
  .picker-item-price {
    font-family: var(--font-mono);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
  }
  .picker-add-new {
    width: 100%;
    padding: 14px;
    background: var(--accent-soft);
    border: 1px dashed var(--accent);
    border-radius: 10px;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
  }
  .picker-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
  }

  /* Customer tier select row */
  .new-customer-form {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
  }
  .new-customer-form .form-group:last-child { margin-bottom: 0; }

  /* ============ REPORTS ============ */
  .reports-page { padding: 14px 18px 0; }
  .stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 18px;
  }
  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
  }
  .stat-card.wide { grid-column: 1 / -1; }
  .stat-label {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 6px;
  }
  .stat-value {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text);
  }
  .stat-value.accent { color: var(--accent); }
  .stat-sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
    font-family: var(--font-sans);
  }

  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 2px 10px;
    margin-top: 6px;
  }
  .section-header h2 {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .section-header-meta {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .list-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 18px;
  }
  .list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    transition: background 0.15s;
  }
  .list-row:last-child { border-bottom: none; }
  .list-row:active { background: var(--surface-2); }
  .list-row-main { flex: 1; min-width: 0; }
  .list-row-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .list-row-sub {
    font-size: 11px;
    color: var(--text-dim);
  }
  .list-row-right {
    font-family: var(--font-mono);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
  }
  .list-row-rank {
    width: 22px; height: 22px;
    background: var(--surface-2);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-right: 10px;
    flex-shrink: 0;
  }
  .list-row-rank.top { background: var(--accent); color: #0a0a0a; }

  .list-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    font-family: var(--font-sans);
  }

  /* Invoice detail lines */
  .idx-line {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
  }
  .idx-line:last-of-type { border-bottom: none; }
  .idx-line-left { flex: 1; min-width: 0; }
  .idx-line-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
  .idx-line-qty { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }
  .idx-line-price { font-family: var(--font-mono); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .idx-summary {
    padding: 14px 0 6px;
    margin-top: 6px;
    border-top: 2px solid var(--border-strong);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .idx-summary-label { font-family: var(--font-sans); font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.12em; text-transform: uppercase; }
  .idx-summary-value { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--accent); }
  .idx-meta {
    padding: 4px 0 16px;
    color: var(--text-dim);
    font-size: 12px;
  }


/* ============================================================
 * DESKTOP LAYOUT (≥ 900px)
 * ----------------------------------------------------------
 * Activates a persistent left sidebar with brand + nav + actions.
 * The bottom tab bar and per-tab header action buttons hide on
 * desktop since the sidebar already exposes those affordances.
 * ============================================================ */

/* ============ SIDEBAR ============ */
.sidebar {
  /* Hidden by default (mobile-first). The @media (min-width: 900px) block
     below flips display to `flex` for desktop. The earlier line-89
     `.sidebar { display: none }` rule was being overridden by source order
     when this rule had `display: flex` here — so on mobile both navs showed
     at once. Keeping default as `none` fixes the bug at its source. */
  display: none;
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 14px 18px;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 5;  /* must be below modal-backdrop (z:50) and modal (z:51) */
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 22px;
}
.sidebar-brand .brand-logo {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}
.sidebar-brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.005em;
  text-align: left;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg {
  opacity: 1;
}
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-align: left;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}
.sidebar-action svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.sidebar-action:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ============ DESKTOP MEDIA QUERY ============ */
@media (min-width: 900px) {

  /* Show sidebar */
  .sidebar { display: flex; }

  /* App pane: stretch to fill remaining width, max it at content-max for readability */
  .app {
    max-width: none;
    margin: 0;
  }

  /* Each tab-view becomes its own scroll container with its own padding */
  .tab-view {
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
  }

  /* Header tweaks — wider padding, header-actions on right (scan + theme/settings hidden) */
  .header-inner {
    padding: 18px 32px 14px;
  }
  /* The brand-logo+meta in the header is redundant once the sidebar shows the brand —
     keep just the meta text for context (item count / tier / etc) */
  .header .brand .brand-logo { display: none; }
  .brand-meta {
    font-size: 12px;
    letter-spacing: 0.1em;
  }
  /* Hide the per-tab theme + settings buttons on desktop. The sidebar owns those. */
  #themeBtn, #settingsBtn { display: none; }

  /* Search row: wider padding to match header */
  .search-row { padding: 10px 32px 12px; }
  .chips      { padding: 0 32px 14px; }

  /* Main content uses the new wider padding */
  main { padding: 6px 32px 80px; }
  .invoice-page  { padding: 8px 32px 80px; }
  .reports-page  { padding: 16px 32px 80px; }

  /* Bottom tab bar hides on desktop */
  .tabbar { display: none; }

  /* Restore default main padding (kill mobile-only tabbar offset) */
  main { padding-bottom: 80px !important; }
  .fab { bottom: calc(28px + var(--safe-bottom)) !important; right: 32px; }

  /* Reports stat grid expands to 4 columns on desktop for better use of space */
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .stat-card.wide { grid-column: span 2; }

  /* ============ MODALS ON DESKTOP ============
   * Bottom-sheet → centered dialog. Backdrop dims fully.
   * Hidden by default via opacity+pointer-events; shown when .open is added
   * (paired with a scale animation for polish). */
  .modal {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    border-radius: 16px;
    padding: 18px 22px calc(20px);
    max-width: 520px;
    width: calc(100% - 64px);
    max-height: 85vh;
    transform: translate(-50%, -50%) scale(0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
    box-shadow: var(--shadow-modal);
    margin: 0;
    border: 1px solid var(--border);
  }
  .modal.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
  }
  /* Hide the mobile drag-handle on desktop modals */
  .modal-handle { display: none; }
  /* Modal headers get a bottom border to feel more like a window. Also stick
     them to the top of the modal so the close button is always reachable
     when the body scrolls (settings, picker, etc. can be tall). */
  .modal-header {
    position: sticky;
    top: 0;
    background: var(--surface);
    margin: -8px -22px 18px;  /* extend full-width over modal padding */
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    z-index: 1;
  }

  /* Picker is a wider modal since it contains a search + scrollable list */
  #pickerModal, #customerModal {
    max-width: 540px;
  }

  /* Settings modal is the most content-heavy — let it be wider */
  #settingsModal {
    max-width: 600px;
  }

  /* Invoice detail modal — show the full detail comfortably */
  #invoiceDetailModal {
    max-width: 560px;
  }

  /* Hover states have meaning on desktop (no touch). Add subtle hovers to product cards. */
  .product:hover {
    border-color: var(--border-strong);
    cursor: pointer;
  }
  .picker-item:hover {
    background: var(--surface-3);
    cursor: pointer;
  }
  .list-row {
    cursor: pointer;
  }

  /* Buttons gain hover states */
  .btn:hover { filter: brightness(1.05); }
  .btn-secondary:hover { background: var(--surface-3); }
  .icon-btn:hover { background: var(--surface-2); }

  /* Picker results column doesn't need to be inside a tight 55vh on desktop */
  .picker-results { max-height: 50vh; }
}

/* Wider laptops & monitors get a little more breathing room */
@media (min-width: 1280px) {
  .sidebar { width: 260px; padding: 28px 18px 22px; }
  :root { --sidebar-w: 260px; }
  .header-inner, .search-row, .chips, main, .invoice-page, .reports-page {
    padding-left: 48px;
    padding-right: 48px;
  }
}

/* ============ LOGIN OVERLAY ============ */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.login-logo {
  width: 52px;
  height: 52px;
  color: var(--accent);
  margin-bottom: 4px;
}
.login-logo svg { width: 100%; height: 100%; }

.login-brand {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.login-back {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 4px 0;
  cursor: pointer;
}
.login-back:hover { color: var(--text); }

.login-select-wrap {
  width: 100%;
  max-width: 280px;
}
.login-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  appearance: auto;
}
.login-select:focus { border-color: var(--accent); outline: none; }

/* ============ PIN DOTS ============ */
.pin-dots {
  display: flex;
  gap: 16px;
  margin: 8px 0;
}
.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.pin-error {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  min-height: 18px;
}

/* ============ PIN KEYPAD ============ */
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(4, 64px);
  gap: 10px;
}
.pin-key {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.1s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.pin-key:active { background: var(--surface-3); transform: scale(0.94); }
.pin-key-back { font-size: 16px; color: var(--text-muted); }

@keyframes shake {
  0%  { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  35% { transform: translateX(8px); }
  55% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
  90% { transform: translateX(-3px); }
  100%{ transform: translateX(0); }
}
.pin-keypad.shake { animation: shake 0.45s ease; }

.login-forgot {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
}
.login-forgot:hover { color: var(--text-muted); }

.login-password-input {
  width: 100%;
  max-width: 280px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 17px;
  color: var(--text);
  letter-spacing: 0.08em;
}
.login-password-input:focus { border-color: var(--accent); outline: none; }

.login-forgot-msg {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  max-width: 280px;
}

/* ============ SIDEBAR LOGOUT + USER ============ */
.sidebar-user {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 0 4px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-action-danger { color: var(--danger) !important; }
.sidebar-action-danger:hover { background: rgba(239,68,68,0.08) !important; }

/* ============ EMPLOYEE ROWS IN SETTINGS ============ */
.employee-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.employee-row:last-child { border-bottom: none; }
.employee-row-name {
  font-size: 14px;
  font-weight: 500;
}
.employee-row-meta {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* PIN-only login additions: subhead under brand, "Owner login →" link below
   the keypad, and the forgot-PIN name picker list. */
.login-subhead {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 18px;
  text-align: center;
}
.login-owner-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  margin-top: 18px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s;
}
.login-owner-link:hover { color: var(--text-muted); }

.forgot-picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}
.forgot-picker-row {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.forgot-picker-row:hover {
  border-color: var(--accent);
  background: var(--surface);
}
.forgot-picker-row:active { transform: scale(0.99); }
.forgot-empty {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 16px;
}

/* Custom range picker row — appears below the chip row when "Custom" is tapped.
   Two date inputs and an Apply button. */
.custom-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}
.custom-range-input {
  flex: 1;
  min-width: 130px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  /* Firefox + Chromium agree on the date picker chrome appearance, but we
     normalize background/text color explicitly so it doesn't go white in dark mode */
  color-scheme: dark light;
}
.custom-range-input:focus {
  outline: none;
  border-color: var(--accent);
}
.custom-range-sep {
  color: var(--text-dim);
  font-size: 14px;
}
.custom-range-apply {
  padding: 8px 14px;
  font-size: 13px;
  white-space: nowrap;
}
@media (min-width: 900px) {
  .custom-range-row {
    padding: 0 32px 12px;
  }
}

/* --- "row-link", "row-meta-btn", "row-amount-btn" ---
   The Recent Invoices and Outstanding rows used to be one big <button>. Now
   they're <div> rows containing several smaller tappable buttons so we can
   route taps to different destinations (customer name → customer detail,
   anywhere else → invoice detail). These three classes style those inner
   buttons to look like the original list-row internals. */
.row-link {
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: color 0.15s, border-color 0.15s;
}
.row-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.row-meta-btn {
  display: block;
  background: none;
  border: none;
  padding: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.row-meta-btn:hover { color: var(--text-muted); }
.row-amount-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.row-amount-btn:hover { color: var(--accent); }

/* "by Sara" line under invoice header, shown only to owner */
.idx-meta-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

/* Customer-name link in invoice detail title (the big modal heading). It looks
   like normal heading text but with a subtle hover treatment. */
.title-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-bottom: 2px dashed transparent;
  transition: border-color 0.15s, color 0.15s;
}
.title-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Customer detail stats grid — appears at top of openCustomerDetail modal.
   Mobile: 2 columns. Desktop: still 2 columns, slightly wider. */
.customer-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 4px 0 16px;
}
.customer-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.customer-stat-wide { grid-column: span 2; }
.customer-stat-warn {
  border-color: var(--tier-3, #f59e0b);
}
.customer-stat-warn .customer-stat-value {
  color: var(--tier-3, #f59e0b);
}
.customer-stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.customer-stat-value {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.customer-stat-value-sm {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}
.customer-stat-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
}

/* Picker banner — appears when matching a scanned barcode to an existing product.
   Sits between the search row and the results list inside the picker modal. */
.picker-banner {
  margin: 0 16px 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}
