/* Ported verbatim from the original portal so the list is pixel-identical.
   Recipe-specific styles are deliberately excluded; those get rebuilt.
   Source: hensonfamilygrocery/portal/index.html lines 21-1134. */

    :root {
      --paper: #f7f5f0;
      --paper-dark: #eeeae2;
      --paper-edge: #d8d3c7;
      --bosch-blue: #005a9c;
      --bosch-blue-dark: #003d6b;
      --bosch-blue-light: #0077c8;
      --bosch-blue-soft: #e8f1f8;
      --ink: #191c1e;
      --ink-medium: #45494d;
      --ink-light: #74797e;
      --danger: #ba1a1a;
      --danger-soft: #ffdad6;
      --success: #206c2f;
      --success-soft: #d3f0d2;
      --surface: #ffffff;
      --radius-sm: 8px;
      --radius: 14px;
      --radius-lg: 20px;
      --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
      --shadow: 0 4px 14px rgba(0,0,0,0.07);
      --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    }

    * {
      box-sizing: border-box;
      -webkit-tap-highlight-color: transparent;
    }

    html, body {
      overscroll-behavior-y: contain;
    }

    body {
      background-color: var(--paper);
      color: var(--ink);
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      margin: 0;
      padding: 0;
      padding-bottom: 100px;
      user-select: none;
      -webkit-user-select: none;
    }

    /* Pull-to-Refresh Container */
    .ptr-container {
      width: 100%;
      height: 0px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--paper-dark);
      border-bottom: 1px solid var(--paper-edge);
      transition: height 0.15s ease, opacity 0.15s ease;
      opacity: 0;
    }

    .ptr-container.active {
      opacity: 1;
    }

    .ptr-container.refreshing {
      height: 52px !important;
      opacity: 1;
    }

    .ptr-content {
      display: flex;
      align-items: center;
      gap: 10px;
      color: var(--bosch-blue);
      font-size: 0.84rem;
      font-weight: 600;
    }

    .ptr-icon {
      width: 22px;
      height: 22px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.2s ease;
    }

    .ptr-icon svg {
      width: 20px;
      height: 20px;
      fill: none;
      stroke: var(--bosch-blue);
      stroke-width: 2.5;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .ptr-container.refreshing .ptr-icon svg {
      animation: ptr-spin 0.75s linear infinite;
    }

    @keyframes ptr-spin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }

    /* Header */
    header {
      position: sticky;
      top: 0;
      z-index: 100;
      background: rgba(247, 245, 240, 0.94);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      border-bottom: 1px solid var(--paper-edge);
      padding: 10px 14px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 6px;
      min-height: 50px;
      box-sizing: border-box;
    }

    .brand-title {
      font-size: clamp(0.92rem, 4vw, 1.15rem);
      font-weight: 700;
      color: var(--bosch-blue);
      display: flex;
      align-items: center;
      gap: 6px;
      letter-spacing: -0.01em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      min-width: 0;
      flex-shrink: 1;
      cursor: pointer;
    }

    .header-stats {
      font-size: 0.8rem;
      font-weight: 500;
      color: var(--ink-medium);
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }

    #statsLabel {
      white-space: nowrap;
      font-size: 0.78rem;
    }

    @media (max-width: 370px) {
      #statsLabel {
        display: none;
      }
    }

    .live-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: #4caf50;
      display: inline-block;
      box-shadow: 0 0 5px rgba(76, 175, 80, 0.7);
      transition: background 0.3s, box-shadow 0.3s;
      flex-shrink: 0;
    }
    .live-dot.offline {
      background: #f44336;
      box-shadow: none;
    }

    /* Store Filter Pill Bar */
    .filter-bar {
      display: flex;
      gap: 6px;
      overflow-x: auto;
      padding: 10px 16px 2px 16px;
      max-width: 650px;
      margin: 0 auto;
      scrollbar-width: none;
    }
    .filter-bar::-webkit-scrollbar {
      display: none;
    }

    .filter-chip {
      background: var(--surface);
      border: 1px solid var(--paper-edge);
      color: var(--ink-medium);
      padding: 5px 12px;
      border-radius: 16px;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
      transition: all 0.15s ease;
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .filter-chip.active {
      background: var(--bosch-blue);
      color: #ffffff;
      border-color: var(--bosch-blue);
      box-shadow: 0 2px 6px rgba(0,90,156,0.25);
    }

    /* Main Container */
    main {
      max-width: 650px;
      margin: 0 auto;
      padding: 8px 16px;
    }

    /* Category Group Card */
    .category-group {
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px solid var(--paper-edge);
      box-shadow: var(--shadow-sm);
      margin-bottom: 12px;
      overflow: hidden;
      transition: box-shadow 0.2s ease;
    }

    .category-header {
      background: #faf8f5;
      border-bottom: 1px solid var(--paper-edge);
      padding: 10px 14px;
      font-size: 0.86rem;
      font-weight: 700;
      color: var(--bosch-blue-dark);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .category-count {
      background: var(--paper-dark);
      color: var(--ink-medium);
      font-size: 0.72rem;
      padding: 2px 7px;
      border-radius: 10px;
      font-weight: 600;
    }

    /* Item Row */
    .item-list {
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .item-row {
      display: flex;
      align-items: center;
      padding: 10px 14px;
      border-bottom: 1px solid #f2eee8;
      transition: background 0.12s ease;
    }

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

    .item-row:active {
      background: #faf8f4;
    }

    .checkbox-touch-area {
      padding: 6px;
      margin: -6px 6px -6px -6px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .checkbox-custom {
      width: 22px;
      height: 22px;
      border-radius: 6px;
      border: 2px solid var(--bosch-blue);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      transition: all 0.15s ease;
    }

    .item-row.bought .checkbox-custom {
      background: var(--success);
      border-color: var(--success);
    }

    .checkbox-custom svg {
      display: none;
      width: 14px;
      height: 14px;
      stroke: #ffffff;
      stroke-width: 3;
      fill: none;
    }

    .item-row.bought .checkbox-custom svg {
      display: block;
    }

    .item-content {
      flex: 1;
      min-width: 0;
      cursor: pointer;
      padding: 2px 6px;
      border-radius: 6px;
    }
    .item-content:hover {
      background: rgba(0,0,0,0.02);
    }

    .item-title {
      font-size: 0.96rem;
      font-weight: 500;
      color: var(--ink);
      word-break: break-word;
      transition: all 0.2s ease;
      line-height: 1.35;
    }

    .item-row.bought .item-title {
      text-decoration: line-through;
      color: var(--ink-light);
    }

    .item-meta {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 5px;
      margin-top: 3px;
      font-size: 0.74rem;
      color: var(--ink-light);
    }

    .qty-badge {
      background: var(--bosch-blue-soft);
      color: var(--bosch-blue-dark);
      padding: 1px 7px;
      border-radius: 5px;
      font-weight: 600;
    }

    .store-badge {
      background: #fdf3e7;
      color: #935300;
      padding: 1px 6px;
      border-radius: 5px;
      font-weight: 600;
    }

    .author-badge {
      color: var(--ink-light);
    }

    .notes-preview {
      display: block;
      width: 100%;
      font-style: italic;
      color: var(--ink-medium);
      margin-top: 2px;
      font-size: 0.72rem;
    }

    .item-actions {
      display: flex;
      align-items: center;
      gap: 2px;
    }

    .edit-btn, .delete-btn {
      background: none;
      border: none;
      padding: 6px;
      color: #9e978c;
      cursor: pointer;
      width: 34px;
      height: 34px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color 0.15s, background 0.15s;
    }

    .edit-btn {
      font-size: 1.05rem;
    }

    .delete-btn {
      font-size: 1.45rem;
      line-height: 1;
      font-weight: 400;
    }

    .edit-btn:hover {
      color: var(--bosch-blue);
      background: var(--bosch-blue-soft);
    }

    .delete-btn:hover {
      color: var(--danger);
      background: var(--danger-soft);
    }

    /* Bought Section Drawer */
    .bought-section {
      margin-top: 18px;
    }

    .bought-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 4px;
      font-size: 0.84rem;
      font-weight: 600;
      color: var(--ink-light);
      cursor: pointer;
    }

    .clear-btn {
      background: none;
      border: 1px solid var(--paper-edge);
      padding: 4px 10px;
      border-radius: 6px;
      color: var(--ink-medium);
      font-size: 0.76rem;
      cursor: pointer;
      transition: all 0.15s;
    }

    .clear-btn:active {
      background: var(--paper-dark);
    }

    /* Empty State */
    .empty-state {
      text-align: center;
      padding: 45px 20px;
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px dashed var(--paper-edge);
      margin-top: 10px;
    }

    .empty-icon {
      font-size: 2.8rem;
      margin-bottom: 8px;
    }

    .empty-title {
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--ink);
    }

    .empty-subtitle {
      font-size: 0.85rem;
      color: var(--ink-light);
      margin-top: 4px;
    }

    /* Bottom Quick-Add Bar */
    .bottom-bar {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: rgba(255, 255, 255, 0.94);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      border-top: 1px solid var(--paper-edge);
      padding: 8px 10px;
      padding-bottom: max(8px, env(safe-area-inset-bottom));
      display: flex;
      justify-content: center;
      z-index: 200;
      box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
      box-sizing: border-box;
    }

    .add-form {
      max-width: 650px;
      width: 100%;
      display: flex;
      align-items: center;
      gap: 6px;
      box-sizing: border-box;
    }

    .add-input {
      flex: 1;
      min-width: 0; /* Ensures flex child doesn't overflow container */
      height: 40px;
      background: var(--paper);
      border: 1px solid var(--paper-edge);
      border-radius: 20px;
      padding: 0 12px;
      font-size: 0.92rem;
      color: var(--ink);
      outline: none;
      transition: border 0.15s, background 0.15s;
      box-sizing: border-box;
    }

    .add-input:focus {
      border-color: var(--bosch-blue);
      background: #ffffff;
    }

    .gear-btn {
      background: none; border: none; font-size: 1.05rem; line-height: 1;
      padding: 4px 2px 4px 8px; cursor: pointer; opacity: 0.75;
    }
    .gear-btn:active { opacity: 0.4; }

    .store-row {
      display: flex; align-items: center; gap: 8px;
      padding: 9px 2px; border-bottom: 1px solid var(--paper-edge);
    }
    .store-row:last-of-type { border-bottom: none; }
    .store-emoji, .store-name {
      background: var(--paper); border: 1px solid var(--paper-edge);
      border-radius: 8px; font-family: inherit; font-size: 0.92rem;
      color: inherit; padding: 7px 9px;
    }
    .store-emoji { width: 52px; text-align: center; flex-shrink: 0; }
    .store-name { flex: 1; min-width: 0; }
    .store-count {
      font-size: 0.72rem; opacity: 0.6; white-space: nowrap;
      min-width: 44px; text-align: right;
    }
    .store-btn {
      background: none; border: none; font-size: 0.95rem;
      cursor: pointer; padding: 5px 3px; opacity: 0.7;
    }
    .store-btn:disabled { opacity: 0.2; cursor: default; }
    .store-add { display: flex; gap: 8px; padding-top: 12px; }
    .store-scroll { max-height: 46vh; overflow-y: auto; }

    .toast {
      position: fixed;
      left: 50%;
      bottom: 92px;
      transform: translateX(-50%) translateY(12px);
      z-index: 10000;
      max-width: 88vw;
      padding: 11px 18px;
      border-radius: 22px;
      background: var(--ink, #1d1d1f);
      color: #ffffff;
      font-size: 0.9rem;
      text-align: center;
      box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease, transform 0.2s ease;
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
    @media (prefers-reduced-motion: reduce) {
      .toast { transition: none; }
    }

    .photo-btn {
      height: 40px;
      width: 40px;
      background: var(--paper);
      color: inherit;
      border: 1px solid var(--paper-edge);
      border-radius: 20px;
      font-size: 1.1rem;
      line-height: 1;
      cursor: pointer;
      flex-shrink: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      transition: background 0.15s, opacity 0.15s;
      box-sizing: border-box;
    }
    .photo-btn:active { opacity: 0.6; }
    .photo-btn:disabled { opacity: 0.45; cursor: default; }

    .draft-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 11px 4px;
      border-bottom: 1px solid var(--paper-edge);
      cursor: pointer;
      user-select: none;
    }
    .draft-row:last-of-type { border-bottom: none; }
    .draft-check {
      width: 22px;
      height: 22px;
      flex-shrink: 0;
      accent-color: var(--bosch-blue);
      pointer-events: none;
    }
    .draft-name { flex: 1; font-size: 0.95rem; }
    .draft-name.off { opacity: 0.45; text-decoration: line-through; }
    .draft-qty { font-size: 0.8rem; opacity: 0.65; white-space: nowrap; }
    .draft-scroll { max-height: 46vh; overflow-y: auto; margin: 4px 0 14px; }
    .draft-tools {
      display: flex;
      gap: 14px;
      padding: 2px 4px 10px;
      font-size: 0.85rem;
    }
    .draft-tools button {
      background: none;
      border: none;
      color: var(--bosch-blue);
      font-size: 0.85rem;
      cursor: pointer;
      padding: 0;
    }

    .add-btn {
      height: 40px;
      padding: 0 14px;
      background: var(--bosch-blue);
      color: #ffffff;
      border: none;
      border-radius: 20px;
      font-size: 0.92rem;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 4px;
      transition: background 0.15s;
      flex-shrink: 0;
      white-space: nowrap;
      box-sizing: border-box;
    }

    .add-btn:active {
      background: var(--bosch-blue-dark);
    }

    .add-btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    /* ---------------- Edit Modal / Bottom Sheet ---------------- */
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.45);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      z-index: 500;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease;
    }

    .modal-overlay.open {
      opacity: 1;
      pointer-events: auto;
    }

    .modal-sheet {
      background: var(--surface);
      width: 100%;
      max-width: 600px;
      border-radius: var(--radius-lg) var(--radius-lg) 0 0;
      box-shadow: var(--shadow-lg);
      padding: 20px 20px max(24px, env(safe-area-inset-bottom));
      transform: translateY(100%);
      transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
      max-height: 90vh;
      overflow-y: auto;
    }

    @media (min-width: 650px) {
      .modal-overlay {
        align-items: center;
      }
      .modal-sheet {
        border-radius: var(--radius-lg);
        transform: translateY(20px) scale(0.96);
        transition: transform 0.22s ease, opacity 0.22s ease;
      }
      .modal-overlay.open .modal-sheet {
        transform: translateY(0) scale(1);
      }
    }

    .modal-overlay.open .modal-sheet {
      transform: translateY(0);
    }

    .sheet-handle {
      width: 36px;
      height: 4px;
      background: var(--paper-edge);
      border-radius: 2px;
      margin: -6px auto 14px auto;
    }

    @media (min-width: 650px) {
      .sheet-handle {
        display: none;
      }
    }

    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;
    }

    .modal-title {
      font-size: 1.15rem;
      font-weight: 700;
      color: var(--ink);
    }

    .modal-close {
      background: none;
      border: none;
      font-size: 1.4rem;
      color: var(--ink-light);
      cursor: pointer;
      padding: 4px;
      line-height: 1;
    }

    .form-group {
      margin-bottom: 14px;
    }

    .form-label {
      display: block;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--ink-medium);
      margin-bottom: 5px;
      text-transform: uppercase;
      letter-spacing: 0.03em;
    }

    .form-control {
      width: 100%;
      height: 42px;
      background: var(--paper);
      border: 1px solid var(--paper-edge);
      border-radius: var(--radius-sm);
      padding: 0 12px;
      font-size: 0.95rem;
      color: var(--ink);
      outline: none;
      transition: border 0.15s, background 0.15s;
    }

    .form-control:focus {
      border-color: var(--bosch-blue);
      background: #ffffff;
    }

    /* Stepper Quantity Control */
    .quantity-row {
      display: flex;
      gap: 8px;
      align-items: center;
    }

    .stepper-btn {
      width: 42px;
      height: 42px;
      background: var(--paper-dark);
      border: 1px solid var(--paper-edge);
      border-radius: var(--radius-sm);
      font-size: 1.2rem;
      font-weight: 600;
      color: var(--ink);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: background 0.12s;
      flex-shrink: 0;
    }
    .stepper-btn:active {
      background: var(--paper-edge);
    }

    .quick-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 6px;
    }

    .chip-btn {
      background: var(--paper);
      border: 1px solid var(--paper-edge);
      border-radius: 12px;
      padding: 4px 9px;
      font-size: 0.74rem;
      font-weight: 500;
      color: var(--ink-medium);
      cursor: pointer;
      transition: all 0.12s;
    }

    .chip-btn:hover, .chip-btn.selected {
      background: var(--bosch-blue-soft);
      border-color: var(--bosch-blue);
      color: var(--bosch-blue-dark);
    }

    /* Modal Action Buttons */
    .modal-actions {
      display: flex;
      gap: 10px;
      margin-top: 20px;
    }

    .btn-save {
      flex: 1;
      height: 44px;
      background: var(--bosch-blue);
      color: #ffffff;
      border: none;
      border-radius: var(--radius-sm);
      font-size: 0.95rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s;
    }
    .btn-save:active {
      background: var(--bosch-blue-dark);
    }

    .btn-delete-modal {
      height: 44px;
      padding: 0 16px;
      background: var(--danger-soft);
      color: var(--danger);
      border: none;
      border-radius: var(--radius-sm);
      font-size: 0.9rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s;
    }
    .btn-delete-modal:active {
      background: #f8b8b0;
    }

    /* Preferences Toggles */
    .settings-section-title {
      font-size: 0.8rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--ink-light);
      margin: 16px 0 8px 0;
      padding-top: 12px;
      border-top: 1px solid var(--paper-edge);
    }
    .pref-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 0;
      border-bottom: 1px solid var(--paper-dark);
    }
    .pref-row:last-child {
      border-bottom: none;
    }
    .pref-info {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding-right: 12px;
    }
    .pref-title {
      font-size: 0.95rem;
      font-weight: 600;
      color: var(--ink);
    }
    .pref-desc {
      font-size: 0.78rem;
      color: var(--ink-light);
      line-height: 1.3;
    }
    .toggle-switch {
      position: relative;
      display: inline-block;
      width: 46px;
      height: 28px;
      flex-shrink: 0;
    }
    .toggle-switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }
    .toggle-slider {
      position: absolute;
      cursor: pointer;
      top: 0; left: 0; right: 0; bottom: 0;
      background-color: var(--paper-edge);
      transition: .22s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: 28px;
    }
    .toggle-slider:before {
      position: absolute;
      content: "";
      height: 22px;
      width: 22px;
      left: 3px;
      bottom: 3px;
      background-color: white;
      transition: .22s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: 50%;
      box-shadow: 0 1px 4px rgba(0,0,0,0.22);
    }
    .toggle-switch input:checked + .toggle-slider {
      background-color: var(--bosch-blue);
    }
    .toggle-switch input:checked + .toggle-slider:before {
      transform: translateX(18px);
    }

    /* Staples Restock Shelf */
    .staples-shelf {
      margin-bottom: 14px;
      background: var(--surface);
      border: 1px solid var(--paper-edge);
      border-radius: var(--radius);
      padding: 10px 12px;
      box-shadow: var(--shadow-sm);
    }
    .staples-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 0.76rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--ink-light);
      margin-bottom: 8px;
    }
    .staples-chips {
      display: flex;
      flex-wrap: nowrap;
      overflow-x: auto;
      gap: 6px;
      padding-bottom: 3px;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .staples-chips::-webkit-scrollbar { display: none; }
    .staple-chip {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 5px 12px;
      background: var(--paper);
      border: 1px solid var(--paper-edge);
      border-radius: 20px;
      font-size: 0.84rem;
      font-weight: 500;
      color: var(--ink);
      white-space: nowrap;
      cursor: pointer;
      flex-shrink: 0;
      transition: background 0.15s, border-color 0.15s, transform 0.1s;
    }
    .staple-chip:active {
      transform: scale(0.95);
      background: var(--bosch-blue-soft);
      border-color: var(--bosch-blue-light);
      color: var(--bosch-blue);
    }

    /* Barcode Scanner */
    .barcode-sheet {
      max-height: 92vh;
      display: flex;
      flex-direction: column;
    }
    .barcode-viewport-wrap {
      position: relative;
      width: 100%;
      height: 280px;
      background: #000000;
      border-radius: var(--radius);
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 12px;
    }
    #barcodeVideo {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .scanner-viewfinder {
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: none;
    }
    .viewfinder-box {
      width: 78%;
      height: 140px;
      border: 2px solid rgba(255, 255, 255, 0.85);
      border-radius: 12px;
      box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.45);
      position: relative;
      overflow: hidden;
    }
    .laser-line {
      position: absolute;
      width: 100%;
      height: 2px;
      background: #ff3b30;
      box-shadow: 0 0 8px #ff3b30;
      top: 0;
      animation: scanLaser 2s ease-in-out infinite alternate;
    }
    @keyframes scanLaser {
      0% { top: 4px; }
      100% { top: calc(100% - 6px); }
    }
    .barcode-status {
      position: absolute;
      bottom: 12px;
      background: rgba(0, 0, 0, 0.7);
      color: #ffffff;
      font-size: 0.8rem;
      padding: 4px 12px;
      border-radius: 14px;
      pointer-events: none;
      text-align: center;
    }
    .barcode-tools {
      display: flex;
      gap: 10px;
      margin-top: 4px;
    }
    .scanner-tool-btn {
      flex: 1;
      height: 44px;
      background: var(--paper);
      border: 1px solid var(--paper-edge);
      border-radius: var(--radius-sm);
      font-size: 0.92rem;
      font-weight: 600;
      color: var(--ink);
      cursor: pointer;
    }
    .scanner-tool-btn:active {
      background: var(--paper-dark);
    }

    /* ----------------- Header Navigation Icon Buttons ----------------- */
    .header-icon-btn {
      background: var(--paper);
      border: 1px solid var(--paper-edge);
      border-radius: 50%;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1rem;
      cursor: pointer;
      transition: transform 0.12s, background 0.15s, border-color 0.15s;
      color: var(--ink);
      flex-shrink: 0;
    }
    .header-icon-btn:active {
      transform: scale(0.92);
      background: var(--paper-dark);
    }
    .header-icon-btn.active {
      background: #ffffff;
      border-color: var(--bosch-blue);
      box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.25);
    }

