﻿
    :root {
      color-scheme: light;

      /* Page and surfaces (Carbon) */
      --background: #ffffff;
      --surface-container-low: #f4f4f4;
      --surface-container: #f4f4f4;
      --surface-container-high: #e0e0e0;

      /* Ink */
      --on-surface: #161616;
      --on-surface-variant: #525252;

      /* Rules */
      --outline: #8d8d8d;
      --outline-variant: #e0e0e0;

      /* Accents */
      --primary: #0f62fe;
      --primary-hover: #0043ce;
      --on-primary: #ffffff;
      --primary-container: #d0e2ff;
      --on-primary-container: #161616;
      --secondary: #6f6f6f;
      --tertiary: #198038;
      --tertiary-hover: #0e6027;
      --tertiary-container: #defbe6;
      --error: #da1e28;
      --error-hover: #a2191f;
      --error-container: #ffd7d9;
      --on-error: #ffffff;

      /* Data series */
      --data-1: #0f62fe;
      --data-2: #6929c4;
      --data-3: #005d5d;
      --data-4: #9f1853;
      --data-context: #8d8d8d;

      /* Semantic */
      --positive: #198038;
      --warning: #8e6a00;
      --warning-container: #fcf4d6;
      --focus: #0f62fe;
      --scrim: rgb(22 22 22 / 0.45);

      /* Fonts */
      --font-headline: 'IBM Plex Sans', sans-serif;
      --font-body: 'IBM Plex Sans', sans-serif;
      --font-label: 'IBM Plex Mono', monospace;

      /* Shape */
      --rounded: 0.125rem;
      --rounded-lg: 0.25rem;
      --rounded-full: 0.75rem;

      /* Style effects */
      --shadow-1: 0 2px 6px rgb(0 0 0 / 0.1);
      --shadow-2: 0 4px 12px rgb(0 0 0 / 0.12);
      --rule: 1px solid var(--outline-variant);
      --field-rule: 1px solid var(--outline);
      --indicator: 2px solid var(--primary);

      /* Type scale (Focused Tool) */
      --display-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem);
      --headline-size: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
      --subhead-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
      --body-size: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
      --label-size: 0.75rem;

      /* Spacing scale (4pt base) */
      --space-2xs: 0.125rem;
      --space-xs: 0.25rem;
      --space-sm: 0.5rem;
      --space-md: 1rem;
      --space-lg: 1.5rem;
      --space-xl: 2.5rem;
      --space-2xl: 4rem;

      /* Motion */
      --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
      --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
      --dur-micro: 120ms;
      --dur-short: 220ms;
    }

    html[data-theme="apple"] {
      --background: #f5f5f7;
      --surface-container-low: #fbfbfd;
      --surface-container: #ffffff;
      --surface-container-high: #e8e8ed;
      --on-surface: #1d1d1f;
      --on-surface-variant: #6e6e73;
      --outline: #a1a1a6;
      --outline-variant: #d2d2d7;
      --primary: #0066cc;
      --primary-hover: #004fa3;
      --on-primary: #ffffff;
      --primary-container: #e5f1ff;
      --on-primary-container: #1d1d1f;
      --secondary: #86868b;
      --tertiary: #248a3d;
      --tertiary-hover: #1d7132;
      --tertiary-container: #e7f6ec;
      --error: #d70015;
      --error-hover: #b00012;
      --error-container: #ffe5e3;
      --positive: #248a3d;
      --warning: #8a5c00;
      --warning-container: #fff4d6;
      --focus: #0066cc;
      --scrim: rgb(29 29 31 / 0.38);
      --font-headline: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      --font-label: ui-monospace, SFMono-Regular, Menlo, monospace;
      --rounded: 0.625rem;
      --rounded-lg: 0.875rem;
      --rounded-full: 999px;
      --shadow-1: 0 2px 8px rgb(29 29 31 / 0.07);
      --shadow-2: 0 8px 24px rgb(29 29 31 / 0.14);
    }

    html[data-theme="windows"] {
      --background: #f3f3f3;
      --surface-container-low: #fafafa;
      --surface-container: #ffffff;
      --surface-container-high: #e5e5e5;
      --on-surface: #1a1a1a;
      --on-surface-variant: #5d5d5d;
      --outline: #858585;
      --outline-variant: #d6d6d6;
      --primary: #0067c0;
      --primary-hover: #005a9e;
      --on-primary: #ffffff;
      --primary-container: #d9eaf9;
      --on-primary-container: #17324b;
      --secondary: #616161;
      --tertiary: #107c10;
      --tertiary-hover: #0b5f0b;
      --tertiary-container: #dff6dd;
      --error: #c42b1c;
      --error-hover: #a4261a;
      --error-container: #fde7e9;
      --positive: #107c10;
      --warning: #8a5b00;
      --warning-container: #fff4ce;
      --focus: #0067c0;
      --scrim: rgb(0 0 0 / 0.42);
      --font-headline: "Segoe UI", system-ui, sans-serif;
      --font-body: "Segoe UI", system-ui, sans-serif;
      --font-label: "Cascadia Code", Consolas, monospace;
      --rounded: 0.25rem;
      --rounded-lg: 0.375rem;
      --rounded-full: 999px;
      --shadow-1: 0 2px 6px rgb(0 0 0 / 0.08);
      --shadow-2: 0 6px 18px rgb(0 0 0 / 0.16);
    }

    html[data-theme="android"] {
      --background: #f7f2fa;
      --surface-container-low: #fdf7ff;
      --surface-container: #fffbff;
      --surface-container-high: #ece6f0;
      --on-surface: #1d1b20;
      --on-surface-variant: #49454f;
      --outline: #79747e;
      --outline-variant: #cac4d0;
      --primary: #6750a4;
      --primary-hover: #55418e;
      --on-primary: #ffffff;
      --primary-container: #eaddff;
      --on-primary-container: #21005d;
      --secondary: #625b71;
      --tertiary: #7d5260;
      --tertiary-hover: #65404d;
      --tertiary-container: #ffdad6;
      --error: #b3261e;
      --error-hover: #8c1d18;
      --error-container: #f9dedc;
      --positive: #386a20;
      --warning: #775a00;
      --warning-container: #f9edc8;
      --focus: #6750a4;
      --scrim: rgb(29 27 32 / 0.42);
      --font-headline: Roboto, "Noto Sans", system-ui, sans-serif;
      --font-body: Roboto, "Noto Sans", system-ui, sans-serif;
      --font-label: Roboto, "Noto Sans", system-ui, sans-serif;
      --rounded: 1rem;
      --rounded-lg: 1.5rem;
      --rounded-full: 999px;
      --shadow-1: 0 2px 8px rgb(29 27 32 / 0.08);
      --shadow-2: 0 8px 24px rgb(29 27 32 / 0.16);
    }

    html[data-theme="linux"] {
      --background: #f6f5f4;
      --surface-container-low: #fdfcfb;
      --surface-container: #ffffff;
      --surface-container-high: #e8e6e3;
      --on-surface: #241f31;
      --on-surface-variant: #5e5c64;
      --outline: #85838a;
      --outline-variant: #d5d3d0;
      --primary: #1c71d8;
      --primary-hover: #155eb5;
      --on-primary: #ffffff;
      --primary-container: #d3e6fa;
      --on-primary-container: #16395f;
      --secondary: #5e5c64;
      --tertiary: #26a269;
      --tertiary-hover: #1b8052;
      --tertiary-container: #d7f0e2;
      --error: #c01c28;
      --error-hover: #a11621;
      --error-container: #f9dedc;
      --positive: #26a269;
      --warning: #8a5c00;
      --warning-container: #fff4d6;
      --focus: #1c71d8;
      --scrim: rgb(36 31 49 / 0.42);
      --font-headline: Cantarell, Ubuntu, "Noto Sans", sans-serif;
      --font-body: Cantarell, Ubuntu, "Noto Sans", sans-serif;
      --font-label: "Ubuntu Mono", "Noto Sans Mono", monospace;
      --rounded: 0.625rem;
      --rounded-lg: 1rem;
      --rounded-full: 999px;
      --shadow-1: 0 2px 7px rgb(36 31 49 / 0.08);
      --shadow-2: 0 8px 22px rgb(36 31 49 / 0.16);
    }

    /* Base reset */
    *, *::before, *::after { box-sizing: border-box; }
    html, body {
      overflow-x: clip;
      margin: 0;
      padding: 0;
      background: var(--background);
      color: var(--on-surface);
      font-family: var(--font-body);
      font-size: var(--body-size);
      line-height: 1.5;
      -webkit-font-smoothing: antialiased;
    }
    header { position: static !important; }
    button, input, select, textarea { font-family: inherit; }

    .page-grid {
      display: grid;
      gap: var(--space-lg);
      padding: var(--space-lg);
      max-width: 1440px;
      margin: 0 auto;
      overflow: hidden;
    }

    .auth-gate {
      display: grid;
      min-height: 100vh;
      place-items: center;
      padding: var(--space-lg);
    }

    .auth-gate[hidden],
    .page-grid[hidden] { display: none !important; }

    .auth-card {
      display: grid;
      gap: var(--space-md);
      width: min(100%, 520px);
    }

    #shared-password-form {
      display: grid;
      gap: var(--space-sm);
    }

    #shared-password-form .btn {
      justify-self: start;
    }

    .page-grid * { min-width: 0; }

    /* Focus rings */
    :focus-visible {
      outline: 2px solid var(--focus);
      outline-offset: 2px;
    }

    /* Typography helpers */
    .headline-display {
      font-family: var(--font-headline);
      font-weight: 300;
      font-size: var(--display-size);
      line-height: 1.15;
      letter-spacing: 0;
      margin: 0;
    }
    .headline-display strong { font-weight: 600; }

    .section-title {
      font-family: var(--font-headline);
      font-weight: 600;
      font-size: var(--headline-size);
      line-height: 1.25;
      margin: 0;
    }

    .subhead-title {
      font-family: var(--font-headline);
      font-weight: 600;
      font-size: var(--subhead-size);
      line-height: 1.3;
      margin: 0;
    }

    .mono-label {
      font-family: var(--font-label);
      font-size: var(--label-size);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--on-surface-variant);
      font-weight: 500;
    }

    .helper-text {
      font-size: 0.8125rem;
      color: var(--on-surface-variant);
      margin: 0;
    }

    /* Header & KPI strip */
    .app-header {
      display: grid;
      gap: var(--space-md);
      border-bottom: var(--rule);
      padding-bottom: var(--space-md);
    }
    .header-top {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: flex-end;
      gap: var(--space-md);
    }
    .header-subtitle {
      margin: var(--space-xs) 0 0;
      color: var(--on-surface-variant);
      max-width: 70ch;
      font-size: var(--body-size);
    }
    .header-status-strip {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: var(--space-sm);
    }
    .appearance-picker {
      display: inline-flex;
      align-items: center;
      gap: var(--space-sm);
      min-height: 44px;
      padding: 0 var(--space-sm) 0 var(--space-md);
      border: var(--rule);
      border-radius: var(--rounded-lg);
      background: var(--surface-container);
      color: var(--on-surface-variant);
      font-size: 0.875rem;
      white-space: nowrap;
    }
    .appearance-picker svg {
      width: 18px;
      height: 18px;
      color: var(--primary);
      flex: 0 0 auto;
    }
    .appearance-picker select {
      max-width: 126px;
      border: 0;
      background: transparent;
      color: var(--on-surface);
      font: inherit;
      cursor: pointer;
    }

    /* KPI Grid */
    .kpi-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: var(--space-md);
    }
    .kpi-tile {
      background: var(--surface-container);
      padding: var(--space-md);
      border-bottom: var(--rule);
      display: grid;
      gap: var(--space-xs);
    }
    .kpi-tile.key-tile {
      border-bottom: var(--indicator);
    }
    .kpi-value {
      font-family: var(--font-label);
      font-weight: 300;
      font-size: 2rem;
      line-height: 1.1;
      color: var(--on-surface);
    }

    /* Tabs */
    .nav-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-xs);
      border-bottom: var(--rule);
    }
    .tab-btn {
      appearance: none;
      background: transparent;
      border: 0;
      border-bottom: 2px solid transparent;
      padding: var(--space-sm) var(--space-lg);
      min-height: 44px;
      font-size: var(--body-size);
      font-weight: 400;
      color: var(--on-surface-variant);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: var(--space-sm);
      transition: color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
    }
    .tab-btn:hover {
      background: var(--surface-container);
      color: var(--on-surface);
    }
    .tab-btn.is-active {
      color: var(--on-surface);
      font-weight: 600;
      border-bottom: var(--indicator);
    }
    .tab-count {
      font-family: var(--font-label);
      font-size: var(--label-size);
      background: var(--surface-container-high);
      color: var(--on-surface);
      padding: var(--space-2xs) var(--space-sm);
      border-radius: var(--rounded-full);
    }
    .tab-btn.is-active .tab-count {
      background: var(--primary-container);
      color: var(--on-primary-container);
    }

    .tab-panel { display: none; }
    .tab-panel.is-active { display: grid; gap: var(--space-lg); }

    /* Carbon flat gray layers */
    .layer {
      background: var(--surface-container);
      border-radius: var(--rounded-lg);
      padding: var(--space-lg);
      display: grid;
      gap: var(--space-md);
    }
    .layer .layer-nested {
      background: var(--surface-container-high);
      padding: var(--space-md);
      display: grid;
      gap: var(--space-md);
    }
    .section-head {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: flex-end;
      gap: var(--space-md);
      border-bottom: var(--rule);
      padding-bottom: var(--space-sm);
    }

    /* Form Controls */
    .form-grid {
      display: grid;
      grid-template-columns: repeat(12, minmax(0, 1fr));
      gap: var(--space-md);
      align-items: end;
    }
    .col-3 { grid-column: span 3; }
    .col-4 { grid-column: span 4; }
    .col-5 { grid-column: span 5; }
    .col-6 { grid-column: span 6; }
    .col-8 { grid-column: span 8; }
    .col-12 { grid-column: span 12; }

    .field {
      display: grid;
      gap: var(--space-xs);
      position: relative;
    }
    .field-label {
      font-family: var(--font-label);
      font-size: var(--label-size);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--on-surface-variant);
      font-weight: 500;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: var(--space-xs);
    }
    .field-input, .field-select {
      width: 100%;
      height: 44px;
      background: var(--background);
      border: 0;
      border-bottom: var(--field-rule);
      border-radius: var(--rounded);
      padding: 0 var(--space-md);
      font-size: var(--body-size);
      color: var(--on-surface);
      transition: background-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out);
    }
    .layer .layer-nested .field-input,
    .layer .layer-nested .field-select {
      background: var(--background);
    }
    .field-select {
      padding-right: var(--space-xl);
      cursor: pointer;
    }
    .field-input:focus, .field-select:focus {
      outline: 2px solid var(--focus);
      outline-offset: 0;
    }
    .field-input.is-error, .field-select.is-error {
      border-bottom: 2px solid var(--error);
    }
    .field-input.is-valid, .field-select.is-valid {
      border-bottom: 2px solid var(--tertiary);
    }
    .field-input.mono-input {
      font-family: var(--font-label);
    }

    /* Buttons (Carbon square corners, aligned height) */
    .btn {
      appearance: none;
      border: 1px solid transparent;
      border-radius: var(--rounded);
      min-height: 44px;
      padding: var(--space-sm) var(--space-lg);
      font-size: var(--body-size);
      font-weight: 500;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      gap: var(--space-sm);
      text-decoration: none;
      white-space: nowrap;
      transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
    }
    .btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }
    .btn-primary {
      background: var(--primary);
      color: var(--on-primary);
    }
    .btn-primary:hover:not(:disabled) {
      background: var(--primary-hover);
    }
    .btn-secondary {
      background: var(--background);
      color: var(--primary);
      border-color: var(--primary);
    }
    .btn-secondary:hover:not(:disabled) {
      background: var(--primary-container);
      color: var(--on-primary-container);
    }
    .btn-ghost {
      background: transparent;
      color: var(--primary);
    }
    .btn-ghost:hover:not(:disabled) {
      background: var(--surface-container-high);
    }
    .btn-success {
      background: var(--tertiary);
      color: var(--on-primary);
    }
    .btn-success:hover:not(:disabled) {
      background: var(--tertiary-hover);
    }
    .btn-danger-outline {
      background: var(--background);
      color: var(--error);
      border-color: var(--error);
    }
    .btn-danger-outline:hover:not(:disabled) {
      background: var(--error-container);
      color: var(--on-surface);
    }
    .btn-sm {
      min-height: 36px;
      padding: var(--space-xs) var(--space-md);
      font-size: 0.875rem;
    }

    .btn-row {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-sm);
      align-items: center;
    }

    /* Notification strips */
    .notice {
      background: var(--background);
      border-left: 3px solid var(--primary);
      padding: var(--space-sm) var(--space-md);
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: var(--space-sm);
      font-size: 0.875rem;
    }
    .notice.is-success { border-left-color: var(--tertiary); }
    .notice.is-error { border-left-color: var(--error); }
    .notice.is-warning { border-left-color: var(--warning); }

    /* Autocomplete / Search Dropdowns */
    .combo-wrap {
      position: relative;
      width: 100%;
    }
    .combo-dropdown {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      z-index: 40;
      background: var(--background);
      border: var(--rule);
      box-shadow: var(--shadow-2);
      max-height: 320px;
      overflow-y: auto;
      display: none;
    }
    .combo-dropdown.is-open { display: block; }
    .combo-option {
      width: 100%;
      text-align: left;
      background: var(--background);
      border: 0;
      border-bottom: var(--rule);
      padding: var(--space-sm) var(--space-md);
      cursor: pointer;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      gap: var(--space-md);
      align-items: center;
      color: var(--on-surface);
    }
    .combo-option:hover, .combo-option:focus-visible {
      background: var(--primary-container);
      color: var(--on-primary-container);
    }
    .combo-sku {
      font-family: var(--font-label);
      font-size: var(--label-size);
      background: var(--surface-container-high);
      color: var(--on-surface);
      padding: var(--space-2xs) var(--space-sm);
      border-radius: var(--rounded);
      font-weight: 600;
      white-space: nowrap;
    }
    .combo-name {
      font-size: var(--body-size);
      line-height: 1.35;
      white-space: normal;
      word-break: break-word;
    }

    /* Product Staging List (Wide, Clear, Legible) */
    .product-builder-box {
      background: var(--background);
      border: var(--rule);
      padding: var(--space-md);
      display: grid;
      gap: var(--space-md);
    }
    .product-search-bar {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: var(--space-sm);
      align-items: end;
    }
    .staged-list {
      display: grid;
      gap: var(--space-sm);
    }
    .staged-item {
      background: var(--surface-container);
      border-left: 2px solid var(--primary);
      padding: var(--space-md);
      display: grid;
      grid-template-columns: 150px minmax(320px, 1fr) 170px 140px auto;
      gap: var(--space-md);
      align-items: end;
    }
    .qty-stepper {
      display: grid;
      grid-template-columns: 44px minmax(0, 1fr) 44px;
      height: 44px;
      background: var(--background);
      border-bottom: var(--field-rule);
    }
    .qty-btn {
      appearance: none;
      border: 0;
      background: var(--surface-container-high);
      color: var(--on-surface);
      font-family: var(--font-label);
      font-size: 1.125rem;
      font-weight: 600;
      cursor: pointer;
      display: grid;
      place-items: center;
    }
    .qty-btn:hover { background: var(--primary-container); }
    .qty-input {
      border: 0;
      text-align: center;
      font-family: var(--font-label);
      font-size: var(--body-size);
      font-weight: 600;
      color: var(--on-surface);
      background: var(--background);
      width: 100%;
    }

    /* Inline New Client Drawer */
    .inline-client-box {
      background: var(--background);
      border: var(--rule);
      border-left: 3px solid var(--warning);
      padding: var(--space-md);
      display: none;
      gap: var(--space-md);
    }
    .inline-client-box.is-open { display: grid; }

    /* Checkbox row */
    .check-row {
      display: inline-flex;
      align-items: center;
      gap: var(--space-sm);
      cursor: pointer;
      min-height: 44px;
      font-size: 0.875rem;
      color: var(--on-surface);
    }
    .check-row input[type="checkbox"] {
      width: 18px;
      height: 18px;
      accent-color: var(--primary);
      cursor: pointer;
    }

    /* Tables */
    .table-toolbar {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: flex-end;
      gap: var(--space-md);
    }
    .table-filters {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-md);
      align-items: flex-end;
      flex: 1 1 360px;
    }
    .table-scroll {
      width: 100%;
      overflow-x: auto;
      border-top: var(--rule);
      border-bottom: var(--rule);
      background: var(--background);
    }
    .catalog-table-scroll {
      max-height: min(520px, 100vh);
      overflow-y: auto;
      overscroll-behavior: contain;
    }
    .catalog-table-scroll table.data-table {
      min-width: 680px;
    }
    .catalog-table-scroll thead th {
      position: sticky;
      top: 0;
      z-index: 1;
    }
    .catalog-table-scroll table.data-table tbody td {
      padding: 1px var(--space-sm);
      line-height: 1.1;
    }
    .catalog-table-scroll table.data-table tbody td:nth-child(2) {
      white-space: nowrap;
    }
    .catalog-table-scroll .btn-sm {
      min-height: 20px;
      padding: 0 var(--space-xs);
      font-size: 0.6875rem;
    }
    .catalog-table-scroll .combo-sku {
      height: 20px;
      padding: 0 var(--space-xs);
      font-size: 0.6875rem;
    }
    .customer-table-scroll {
      max-height: min(520px, 100vh);
      overflow-y: auto;
      overscroll-behavior: contain;
    }
    .customer-table-scroll table.data-table {
      width: 790px;
      min-width: 790px;
      table-layout: fixed;
    }
    .customer-table-scroll table.data-table th:nth-child(1),
    .customer-table-scroll table.data-table td:nth-child(1) {
      width: 120px;
    }
    .customer-table-scroll table.data-table th:nth-child(2),
    .customer-table-scroll table.data-table td:nth-child(2) {
      width: 110px;
    }
    .customer-table-scroll table.data-table th:nth-child(3),
    .customer-table-scroll table.data-table td:nth-child(3) {
      width: 120px;
    }
    .customer-table-scroll table.data-table th:nth-child(4),
    .customer-table-scroll table.data-table td:nth-child(4) {
      width: 160px;
    }
    .customer-table-scroll table.data-table th:nth-child(5),
    .customer-table-scroll table.data-table td:nth-child(5) {
      width: 110px;
    }
    .customer-table-scroll table.data-table th:nth-child(6),
    .customer-table-scroll table.data-table td:nth-child(6) {
      width: 170px;
    }
    .customer-table-scroll thead th {
      position: sticky;
      top: 0;
      z-index: 1;
    }
    .customer-table-scroll table.data-table tbody td {
      padding: 1px var(--space-xs);
      line-height: 1.1;
      overflow-wrap: anywhere;
    }
    .customer-table-scroll table.data-table tbody td:nth-child(2),
    .customer-table-scroll table.data-table tbody td:nth-child(3),
    .customer-table-scroll table.data-table tbody td:nth-child(5),
    .customer-table-scroll table.data-table tbody td:nth-child(6) {
      white-space: nowrap;
    }
    .customer-table-scroll .btn-sm {
      min-height: 20px;
      padding: 0 var(--space-2xs);
      font-size: 0.65rem;
    }
    .customer-table-scroll .btn-row {
      gap: var(--space-xs);
    }
    .customer-table-scroll .tag {
      height: 20px;
      padding: 0 var(--space-xs);
      font-size: 0.6875rem;
    }
    table.data-table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
      font-size: 0.875rem;
    }
    table.data-table thead th {
      background: var(--surface-container-high);
      font-family: var(--font-label);
      font-size: var(--label-size);
      text-transform: uppercase;
      letter-spacing: 0.07em;
      color: var(--on-surface);
      font-weight: 600;
      padding: var(--space-sm) var(--space-md);
      white-space: nowrap;
      border-bottom: var(--rule);
    }
    table.data-table tbody tr {
      border-bottom: var(--rule);
      background: var(--background);
    }
    table.data-table tbody tr:nth-child(even) {
      background: var(--surface-container-low);
    }
    table.data-table tbody tr:hover {
      background: var(--primary-container);
    }
    table.data-table tbody td {
      padding: var(--space-sm) var(--space-md);
      vertical-align: top;
      color: var(--on-surface);
    }
    .cell-mono {
      font-family: var(--font-label);
      white-space: nowrap;
    }
    .cell-product {
      min-width: 240px;
      max-width: 360px;
      line-height: 1.4;
    }
    .cell-message {
      min-width: 280px;
      max-width: 380px;
      font-size: 0.8125rem;
      color: var(--on-surface-variant);
      line-height: 1.4;
      white-space: pre-line;
    }

    /* Tags */
    .tag {
      display: inline-flex;
      align-items: center;
      height: 24px;
      padding: 0 var(--space-sm);
      border-radius: var(--rounded-full);
      font-size: var(--label-size);
      font-family: var(--font-label);
      white-space: nowrap;
      background: var(--primary-container);
      color: var(--on-primary-container);
    }
    .tag.is-sent {
      background: var(--tertiary-container);
      color: var(--tertiary);
      font-weight: 600;
    }
    .tag.is-pending {
      background: var(--surface-container-high);
      color: var(--on-surface);
    }
    .tag.is-warn {
      background: var(--warning-container);
      color: var(--warning);
      font-weight: 600;
    }

    /* File drop / upload bar */
    .upload-strip {
      background: var(--background);
      border: 1px dashed var(--outline);
      padding: var(--space-md);
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: var(--space-md);
    }
    .hidden-file-input {
      position: absolute;
      width: 1px;
      height: 1px;
      opacity: 0;
      overflow: hidden;
    }

    /* Split grid for DB management */
    .db-split {
      display: grid;
      grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
      gap: var(--space-lg);
      align-items: start;
    }

    /* Comuna chips grid */
    .comuna-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
      gap: var(--space-sm);
    }
    .comuna-item {
      background: var(--background);
      border-left: 2px solid var(--outline-variant);
      padding: var(--space-sm) var(--space-md);
      display: flex;
      align-items: center;
      gap: var(--space-sm);
      font-size: 0.875rem;
    }
    .comuna-num {
      font-family: var(--font-label);
      font-size: var(--label-size);
      color: var(--on-surface-variant);
      min-width: 2ch;
    }

    /* Modal / Edit Overlay */
    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: var(--scrim);
      z-index: 60;
      display: none;
      align-items: center;
      justify-content: center;
      padding: var(--space-md);
    }
    .modal-backdrop.is-open { display: flex; }
    .modal-card {
      background: var(--background);
      width: 100%;
      max-width: 640px;
      box-shadow: var(--shadow-2);
      border-top: 3px solid var(--primary);
      padding: var(--space-lg);
      display: grid;
      gap: var(--space-md);
      max-height: 90vh;
      overflow-y: auto;
    }

    .frequent-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .frequent-rankings {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-md);
      align-items: start;
    }
    .frequent-rank-panel {
      min-width: 0;
      padding: var(--space-md);
      background: var(--surface-container-low);
      border: var(--rule);
      border-radius: var(--rounded-lg);
    }
    .frequent-rank-panel .section-head { align-items: flex-start; }
    .frequent-table { min-width: 900px; }
    .frequent-sku-list {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-xs);
      max-width: 190px;
    }
    .frequent-sku-chip {
      display: inline-flex;
      padding: var(--space-2xs) var(--space-xs);
      border: 1px solid var(--outline-variant);
      border-radius: var(--rounded);
      background: var(--primary-container);
      color: var(--on-primary-container);
      font: 0.75rem var(--font-label);
      cursor: help;
      white-space: nowrap;
    }
    .frequent-table td small {
      display: block;
      margin-top: var(--space-2xs);
      color: var(--on-surface-variant);
      font-size: 0.75rem;
    }
    .frequent-charts {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-md);
    }
    .frequent-charts[hidden] { display: none; }
    .frequent-chart-card {
      min-width: 0;
      padding: var(--space-md);
      background: var(--surface-container-low);
      border: var(--rule);
      border-radius: var(--rounded-lg);
    }
    .frequent-chart-card h3 {
      margin: 0 0 var(--space-md);
      font-size: var(--subhead-size);
    }
    .frequent-bar-row {
      display: grid;
      grid-template-columns: minmax(90px, 1fr) minmax(60px, 2fr) auto;
      align-items: center;
      gap: var(--space-sm);
      margin: var(--space-sm) 0;
      font-size: 0.8125rem;
    }
    .frequent-bar-label {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .frequent-bar-track {
      height: 0.625rem;
      overflow: hidden;
      background: var(--surface-container-high);
      border-radius: var(--rounded-full);
    }
    .frequent-bar-track span {
      display: block;
      height: 100%;
      background: var(--primary);
      border-radius: inherit;
    }

    /* Toast feedback */
    .toast-bar {
      position: fixed;
      bottom: var(--space-lg);
      right: var(--space-lg);
      z-index: 80;
      background: var(--on-surface);
      color: var(--background);
      padding: var(--space-sm) var(--space-lg);
      box-shadow: var(--shadow-2);
      border-left: 4px solid var(--primary);
      display: none;
      align-items: center;
      gap: var(--space-sm);
      font-size: 0.875rem;
      max-width: min(460px, calc(100vw - 2rem));
    }
    .toast-bar.is-visible { display: flex; }

    /* Empty state */
    .empty-state {
      padding: var(--space-xl);
      text-align: left;
      background: var(--background);
      border: var(--rule);
      display: grid;
      gap: var(--space-sm);
    }

    html[data-theme] .layer,
    html[data-theme] .kpi-tile,
    html[data-theme] .empty-state {
      border: var(--rule);
      border-radius: var(--rounded-lg);
      box-shadow: var(--shadow-1);
    }
    html[data-theme] .kpi-tile.key-tile {
      border-left: var(--indicator);
      border-bottom: var(--rule);
    }
    html[data-theme] .layer .layer-nested {
      border-radius: var(--rounded);
    }
    html[data-theme] .field-input,
    html[data-theme] .field-select {
      border: var(--field-rule);
      border-radius: var(--rounded);
    }
    html[data-theme] .nav-tabs {
      border-bottom: 0;
    }
    html[data-theme] .tab-btn {
      border: 1px solid transparent;
      border-radius: var(--rounded-full);
    }
    html[data-theme] .tab-btn.is-active {
      border: 1px solid var(--outline-variant);
      background: var(--primary-container);
      color: var(--primary);
    }
    html[data-theme="apple"] svg.lucide { stroke-width: 1.8; }
    html[data-theme="windows"] svg.lucide { stroke-width: 2; }
    html[data-theme="android"] svg.lucide { stroke-width: 2.2; }
    html[data-theme="linux"] svg.lucide { stroke-width: 1.9; }

    /* Responsive adjustments */
    @media (max-width: 1024px) {
      .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .db-split { grid-template-columns: 1fr; }
      .frequent-rankings, .frequent-charts { grid-template-columns: 1fr; }
      .staged-item {
        grid-template-columns: 1fr 1fr;
      }
      .staged-item .staged-name-field { grid-column: span 2; }
    }

    @media (max-width: 640px) {
      .page-grid { padding: var(--space-sm); gap: var(--space-md); }
      .kpi-grid { grid-template-columns: 1fr; }
      .frequent-kpis { grid-template-columns: 1fr; }
      .col-3, .col-4, .col-5, .col-6, .col-8, .col-12 { grid-column: span 12; }
      .product-search-bar { grid-template-columns: 1fr; }
      .staged-item { grid-template-columns: 1fr; }
      .staged-item .staged-name-field { grid-column: span 1; }
      .tab-btn { width: 100%; justify-content: space-between; }
    }

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }
  
