:root {
      --bg: #f4f6fb;
      --surface: #ffffff;
      --surface2: #f0f2f8;
      --border: #e2e6f0;
      --border2: #d0d6e8;
      --text: #0f1623;
      --text2: #5a6480;
      --text3: #9ba3b8;
      --accent: #2563eb;
      --accent2: #6c5ce7;
      --green: #059669;
      --red: #dc2626;
      --yellow: #b45309;
      --orange: #c2410c;
      --card-r: 12px;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      overflow-x: hidden;
    }

    /* TOPBAR */
    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 32px;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      position: sticky;
      top: 0;
      z-index: 100;
    }

    .logo {
      font-size: 19px;
      font-weight: 700;
      letter-spacing: -0.022em;
    }

    .logo span {
      color: var(--accent);
    }

    .topbar-actions {
      display: flex;
      gap: 10px;
      align-items: center;
    }

    /* UPLOAD ZONE */
    .upload-section {
      padding: 48px 32px;
      display: flex;
      gap: 20px;
      justify-content: center;
      flex-wrap: wrap;
    }

    .upload-card {
      background: var(--surface);
      border: 2px dashed var(--border2);
      border-radius: var(--card-r);
      padding: 32px 40px;
      text-align: center;
      cursor: pointer;
      transition: all .2s;
      min-width: 300px;
      position: relative;
    }

    .upload-card:hover {
      border-color: var(--accent);
      background: rgba(37, 99, 235, .04);
    }

    .upload-card.loaded {
      border-style: solid;
      border-color: var(--green);
    }

    .upload-card input[type=file] {
      display: none;
    }

    .upload-icon {
      font-size: 36px;
      margin-bottom: 12px;
    }

    .upload-card h3 {
      font-family: 'Syne', sans-serif;
      font-size: 15px;
      font-weight: 700;
      margin-bottom: 6px;
    }

    .upload-card p {
      font-size: 12px;
      color: var(--text2);
    }

    .upload-status {
      font-size: 11px;
      color: var(--green);
      margin-top: 8px;
      font-family: 'DM Mono', monospace;
    }

    /* STATS BAR */
    .stats-bar {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 12px;
      padding: 0 32px 28px;
    }

    .stat-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--card-r);
      padding: 20px;
      position: relative;
      overflow: hidden;
    }

    .stat-card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 3px;
    }

    .stat-card.total::before {
      background: var(--accent);
    }

    .stat-card.expensive::before {
      background: var(--red);
    }

    .stat-card.cheap::before {
      background: var(--green);
    }

    .stat-card.competitive::before {
      background: var(--yellow);
    }

    .stat-card.unmatched::before {
      background: var(--text3);
    }

    .stat-label {
      font-size: 11px;
      color: var(--text2);
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-bottom: 8px;
    }

    .stat-value {
      font-family: 'Syne', sans-serif;
      font-size: 32px;
      font-weight: 800;
    }

    .stat-card.expensive .stat-value {
      color: var(--red);
    }

    .stat-card.cheap .stat-value {
      color: var(--green);
    }

    .stat-card.competitive .stat-value {
      color: var(--yellow);
    }

    .stat-card.unmatched .stat-value {
      color: var(--text2);
    }

    .stat-sub {
      font-size: 11px;
      color: var(--text3);
      margin-top: 4px;
    }

    /* CONTROLS */
    .controls {
      padding: 0 32px 20px;
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      align-items: center;
    }
    
    .controls .search-box {
      width: 280px;
    }

    .search-box {
      background: var(--surface);
      border: 1px solid var(--border2);
      border-radius: 8px;
      padding: 10px 16px;
      color: var(--text);
      font-size: 13px;
      font-family: 'Inter', sans-serif;
      width: 100%;
      outline: none;
      transition: border .2s;
    }

    .search-box:focus {
      border-color: var(--accent);
    }

    .search-box::placeholder {
      color: var(--text3);
    }

    select.filter-select {
      background: var(--surface);
      border: 1px solid var(--border2);
      border-radius: 8px;
      padding: 10px 14px;
      color: var(--text);
      font-size: 13px;
      cursor: pointer;
      outline: none;
    }

    .btn {
      padding: 10px 18px;
      border-radius: 8px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      border: none;
      font-family: 'Inter', sans-serif;
      transition: all .2s;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .btn-primary {
      background: var(--accent);
      color: #fff;
    }

    .btn-primary:hover {
      background: #3a7de8;
    }

    .btn-danger {
      background: rgba(220, 38, 38, .08);
      color: var(--red);
      border: 1px solid rgba(220, 38, 38, .25);
    }

    .btn-danger:hover {
      background: rgba(220, 38, 38, .15);
    }

    .btn-success {
      background: rgba(5, 150, 105, .08);
      color: var(--green);
      border: 1px solid rgba(5, 150, 105, .25);
    }

    .btn-success:hover {
      background: rgba(5, 150, 105, .15);
    }

    .btn-outline {
      background: transparent;
      color: var(--text2);
      border: 1px solid var(--border2);
    }

    .btn-outline:hover {
      border-color: var(--text2);
      color: var(--text);
    }

    .spacer {
      flex: 1;
    }

    /* TABS */
    .tabs {
      display: flex;
      gap: 4px;
      padding: 0 32px 20px;
    }

    .tab {
      padding: 8px 18px;
      border-radius: 8px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      color: var(--text2);
      transition: all .2s;
      border: 1px solid transparent;
    }

    .tab.active {
      background: var(--surface);
      color: var(--text);
      border-color: var(--border2);
    }

    .tab:hover:not(.active) {
      color: var(--text);
    }

    /* TABLE */
    .table-wrap {
      padding: 0 32px 32px;
      overflow-x: auto;
    }

    table {
      width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      font-size: 13px;
      background: var(--surface);
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid var(--border);
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    }

    thead {
      position: sticky;
      top: 0;
      z-index: 20;
    }

    thead tr {
      background: #f8fafc;
    }

    th {
      padding: 14px 12px;
      text-align: left;
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text2);
      cursor: pointer;
      user-select: none;
      border-bottom: 2px solid var(--border);
      white-space: nowrap;
      transition: background 0.2s;
    }

    th:hover {
      background: var(--surface2);
      color: var(--text);
    }

    th .sort-arrow {
      opacity: .3;
      margin-left: 4px;
      font-size: 10px;
    }

    th.sorted .sort-arrow {
      opacity: 1;
      color: var(--accent);
    }

    tbody tr {
      transition: all .2s;
    }

    tbody tr:nth-child(even) {
      background: #fafbfc;
    }

    tbody tr:hover {
      background: #f1f5f9 !important;
      transform: scale(1.001);
      z-index: 1;
    }

    tbody tr.deleted-row {
      opacity: .4;
      background: #fef2f2 !important;
    }

    td {
      padding: 12px;
      vertical-align: middle;
      border-bottom: 1px solid var(--border);
      color: var(--text);
    }

    .prod-name {
      font-weight: 600;
      max-width: 320px;
      color: var(--text);
    }

    .prod-name small {
      display: block;
      color: var(--text3);
      font-size: 11px;
      font-family: 'DM Mono', monospace;
      margin-top: 3px;
      font-weight: 400;
    }

    .brand-badge {
      display: inline-block;
      padding: 4px 10px;
      border-radius: 6px;
      font-size: 10.5px;
      font-weight: 700;
      background: rgba(37, 99, 235, 0.06);
      color: var(--accent);
      border: 1px solid rgba(37, 99, 235, 0.15);
      white-space: nowrap;
    }

    .price-cell {
      font-weight: 600;
      letter-spacing: -0.02em;
    }

    .my-price {
      font-size: 15px;
    }

    /* FLAGS */
    .flag {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 5px 12px;
      border-radius: 100px;
      font-size: 11.5px;
      font-weight: 700;
      white-space: nowrap;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    .flag-expensive {
      background: #fef2f2;
      color: #991b1b;
      border: 1px solid #fee2e2;
    }

    .flag-cheaper {
      background: #f0fdf4;
      color: #166534;
      border: 1px solid #dcfce7;
    }

    .flag-competitive {
      background: #fffbeb;
      color: #92400e;
      border: 1px solid #fef3c7;
    }

    .flag-no_data {
      background: #f8fafc;
      color: #64748b;
      border: 1px solid #e2e8f0;
    }

    .diff-pct {
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      font-weight: 600;
    }

    .diff-pos {
      color: #b91c1c;
    }

    .diff-neg {
      color: #15803d;
    }

    /* COMPETITOR MINI */
    .comp-list {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .comp-chip {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 10px;
      background: white;
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 11px;
      font-family: 'DM Mono', monospace;
      font-weight: 500;
      cursor: pointer;
      transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
      text-decoration: none;
      color: var(--text2);
      box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    }

    .comp-chip:hover {
      border-color: var(--accent);
      color: var(--accent);
      transform: translateY(-1px);
      box-shadow: 0 4px 6px rgba(37, 99, 235, 0.1);
    }

    .comp-cheap {
      border-color: #bbf7d0;
      color: #166534;
      background: #f0fdf4;
    }

    .comp-expensive {
      border-color: #fecaca;
      color: #991b1b;
      background: #fef2f2;
    }

    /* Global Checkbox Polish */
    input[type="checkbox"] {
      accent-color: var(--accent);
      width: 15px;
      height: 15px;
      cursor: pointer;
    }

    /* DECISION SELECT */
    .decision-select {
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      padding: 6px 10px;
      color: var(--text);
      font-size: 11.5px;
      cursor: pointer;
      outline: none;
      transition: all 0.2s;
      width: 100%;
    }

    .decision-select:hover {
      border-color: #cbd5e1;
      background: white;
    }

    .decision-select:focus {
      border-color: var(--accent);
      background: white;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

    .notes-input {
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      padding: 6px 10px;
      color: var(--text);
      font-size: 11.5px;
      outline: none;
      transition: all 0.2s;
      width: 160px;
      font-family: 'Inter', sans-serif;
    }

    .notes-input:hover {
      border-color: #cbd5e1;
      background: white;
    }

    .notes-input:focus {
      border-color: var(--accent);
      background: white;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

    /* PRICE STRATEGY */
    .strategy-cell {
      min-width: 180px;
    }

    .strategy-row {
      display: flex;
      gap: 4px;
      margin-bottom: 6px;
      align-items: center;
    }

    .strategy-input {
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      padding: 5px 8px;
      color: var(--text);
      font-size: 11.5px;
      outline: none;
      transition: all 0.2s;
      width: 75px;
      font-family: 'DM Mono', monospace;
    }

    .strategy-input:hover {
      border-color: #cbd5e1;
      background: white;
    }

    .strategy-input:focus {
      border-color: var(--accent);
      background: white;
    }

    .strategy-inputs {
      margin-top: 8px;
      border-top: 1px solid var(--border);
      padding-top: 8px;
      animation: slideDown 0.2s ease-out;
    }

    @keyframes slideDown {
      from {
        opacity: 0;
        transform: translateY(-5px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .table-img {
      width: 50px;
      height: 50px;
      object-fit: contain;
      border-radius: 6px;
      background: var(--surface2);
      border: 1px solid var(--border);
    }

    .pharmacy-label {
      font-size: 10px;
      color: var(--text2);
      text-align: center;
      margin-top: 4px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 120px;
    }

    .modal-img-container {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      position: relative;
    }

    .modal-img-container .remove-comp-btn,
    .modal-price-card .remove-comp-btn {
      opacity: 0;
      transform: translate(5px, -5px) scale(0.8);
      pointer-events: none;
    }

    .modal-img-container:hover .remove-comp-btn,
    .modal-price-card:hover .remove-comp-btn {
      opacity: 1;
      transform: translate(0, 0) scale(1);
      pointer-events: all;
    }

    .remove-comp-btn {
      position: absolute;
      top: 8px;
      right: 8px;
      background: rgba(220, 38, 38, 0.9);
      backdrop-filter: blur(8px);
      color: white;
      border: 1px solid rgba(255, 255, 255, 0.2);
      width: 28px;
      height: 28px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 10;
      box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
      transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .remove-comp-btn:hover {
      background: #dc2626;
      transform: scale(1.1) !important;
      box-shadow: 0 6px 16px rgba(220, 38, 38, 0.3);
    }

    .remove-comp-btn svg {
      width: 14px;
      height: 14px;
      stroke: currentColor;
      stroke-width: 2.5;
      fill: none;
    }

    /* Toast Notification */
    .toast {
      position: fixed;
      bottom: 32px;
      left: 50%;
      transform: translateX(-50%) translateY(100px);
      background: var(--text);
      color: white;
      padding: 12px 24px;
      border-radius: 12px;
      font-size: 13px;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 10px;
      box-shadow: 0 10px 25px rgba(0,0,0,0.15);
      z-index: 3000;
      transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .toast.show {
      transform: translateX(-50%) translateY(0);
    }

    .toast .icon {
      font-size: 16px;
    }

    /* MODAL */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, .45);
      z-index: 1000;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
      backdrop-filter: blur(4px);
    }

    .modal-overlay.open {
      display: flex;
    }

    .modal {
      background: var(--surface);
      border: 1px solid var(--border2);
      border-radius: 16px;
      padding: 32px;
      max-width: 700px;
      width: 100%;
      max-height: 85vh;
      overflow-y: auto;
      position: relative;
    }

    .modal .search-box {
      width: 100%;
      max-width: none;
    }

    .modal-close {
      position: absolute;
      top: 16px;
      right: 16px;
      background: var(--surface2);
      border: none;
      color: var(--text2);
      width: 32px;
      height: 32px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .modal-close:hover {
      color: var(--text);
      background: var(--border);
    }

    .modal h2 {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 4px;
    }

    .modal .barcode {
      font-size: 11px;
      color: var(--text3);
      margin-bottom: 20px;
    }

    .modal-prices {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
      margin-bottom: 20px;
    }

    .modal-price-card {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 16px;
      position: relative;
    }

    .modal-price-card.mine {
      border-color: rgba(79, 142, 247, .3);
    }

    .modal-price-card .label {
      font-size: 10px;
      color: var(--text2);
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-bottom: 8px;
    }

    .modal-price-card .price-big {
      font-family: 'DM Mono', monospace;
      font-size: 26px;
      font-weight: 500;
    }

    .modal-price-card .source-name {
      font-size: 12px;
      color: var(--text2);
      margin-top: 4px;
    }

    .modal-price-card .badge {
      position: absolute;
      top: 12px;
      right: 12px;
    }

    .modal-img-row {
      display: flex;
      gap: 10px;
      margin-bottom: 20px;
      flex-wrap: wrap;
    }

    .modal-img {
      width: 140px;
      height: 140px;
      object-fit: contain;
      border-radius: 8px;
      background: var(--surface);
      border: 1px solid var(--border);
      cursor: pointer;
      transition: transform 0.2s;
    }

    .modal-img:hover {
      transform: scale(1.05);
      border-color: var(--accent);
    }

    /* HEATMAP */
    .heatmap-section {
      padding: 0 32px 32px;
    }

    .heatmap-title {
      font-family: 'Syne', sans-serif;
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 16px;
    }

    .heatmap-table {
      overflow-x: auto;
    }

    .heatmap-table table {
      border-collapse: separate;
      border-spacing: 3px;
    }

    .heatmap-table th {
      font-size: 11px;
      padding: 8px 12px;
    }

    .heatmap-table td {
      width: 60px;
      height: 40px;
      text-align: center;
      border-radius: 6px;
      font-size: 11px;
      font-family: 'DM Mono', monospace;
      font-weight: 500;
      cursor: default;
    }

    /* CHART BARS */
    .chart-section {
      padding: 0 32px 32px;
    }

    .chart-title {
      font-family: 'Syne', sans-serif;
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 16px;
    }

    .bar-chart {
      display: flex;
      align-items: flex-end;
      gap: 8px;
      height: 160px;
    }

    .bar-group {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
    }

    .bar {
      width: 52px;
      border-radius: 6px 6px 0 0;
      transition: opacity .2s;
      cursor: default;
      min-height: 4px;
    }

    .bar:hover {
      opacity: .8;
    }

    .bar-label {
      font-size: 10px;
      color: var(--text2);
      text-align: center;
      white-space: nowrap;
    }

    .bar-val {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--text2);
    }

    /* QUICK WIN */
    .qw-section {
      padding: 0 32px 32px;
    }

    .qw-title {
      font-family: 'Syne', sans-serif;
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 16px;
    }

    .qw-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--card-r);
      padding: 14px 18px;
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      gap: 16px;
    }

    .qw-card:hover {
      border-color: var(--green);
    }

    .qw-gap {
      font-family: 'DM Mono', monospace;
      font-size: 20px;
      font-weight: 500;
      color: var(--green);
      min-width: 60px;
      text-align: right;
    }

    .qw-info {
      flex: 1;
    }

    .qw-name {
      font-size: 13px;
      font-weight: 500;
    }

    .qw-detail {
      font-size: 11px;
      color: var(--text2);
      margin-top: 3px;
      font-family: 'DM Mono', monospace;
    }

    /* UNMATCHED */
    .unmatched-section {
      padding: 0 32px 32px;
    }

    /* SIMULATOR */
    .sim-section {
      padding: 0 32px 32px;
    }

    .sim-controls {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--card-r);
      padding: 20px;
      margin-bottom: 20px;
      display: flex;
      gap: 16px;
      align-items: center;
      flex-wrap: wrap;
    }

    .sim-label {
      font-size: 12px;
      color: var(--text2);
    }

    input[type=range] {
      width: 200px;
      accent-color: var(--accent);
      -webkit-appearance: none;
      height: 6px;
      border-radius: 3px;
      background: var(--border);
      outline: none;
      cursor: pointer;
    }

    input[type=range]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: var(--accent);
      cursor: pointer;
    }

    .sim-val {
      font-family: 'DM Mono', monospace;
      font-size: 22px;
      font-weight: 500;
      color: var(--accent);
      min-width: 50px;
    }

    .empty-state {
      text-align: center;
      padding: 80px 20px;
      color: var(--text3);
      font-size: 14px;
    }

    .empty-state .icon {
      font-size: 48px;
      margin-bottom: 16px;
    }

    /* COMP SCORE */
    .comp-score-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 12px;
      padding: 0 32px 32px;
    }

    .comp-score-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--card-r);
      padding: 20px;
    }

    .comp-score-name {
      font-family: 'Syne', sans-serif;
      font-size: 14px;
      font-weight: 700;
      margin-bottom: 12px;
    }

    .comp-score-row {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      margin-bottom: 8px;
    }

    .comp-score-row .label {
      color: var(--text2);
    }

    .comp-score-row .val {
      font-family: 'DM Mono', monospace;
      font-weight: 500;
    }

    .comp-score-bar {
      height: 6px;
      border-radius: 3px;
      background: var(--border);
      margin-top: 8px;
      overflow: hidden;
    }

    .comp-score-fill {
      height: 100%;
      border-radius: 3px;
      background: linear-gradient(90deg, var(--accent), var(--accent2));
    }

    .hidden {
      display: none !important;
    }

    /* SECTION WRAPPER */
    .section {
      display: none;
    }

    .section.active {
      display: block;
    }

    /* OUTLIER badge */
    .outlier-badge {
      display: inline-block;
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 9px;
      font-weight: 700;
      background: rgba(194, 65, 12, .1);
      color: var(--orange);
      border: 1px solid rgba(194, 65, 12, .25);
      margin-left: 6px;
      vertical-align: middle;
    }

    .match-badge {
      display: inline-block;
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 9px;
      font-weight: 700;
      margin-left: 6px;
      vertical-align: middle;
    }

    .match-yes {
      background: rgba(5, 150, 105, .08);
      color: var(--green);
      border: 1px solid rgba(5, 150, 105, .25);
    }

    .match-no {
      background: rgba(220, 38, 38, .08);
      color: var(--red);
      border: 1px solid rgba(220, 38, 38, .25);
    }

    ::-webkit-scrollbar {
      width: 12px;
      height: 12px;
    }

    ::-webkit-scrollbar-track {
      background: var(--bg);
    }

    ::-webkit-scrollbar-thumb {
      background: var(--text3);
      border-radius: 6px;
      border: 3px solid var(--bg);
    }
    
    ::-webkit-scrollbar-thumb:hover {
      background: var(--text2);
    }

    /* RESPONSIVENESS */
    @media (max-width: 1200px) {
      .topbar, .stats-bar, .controls, .table-wrap, .heatmap-section, .chart-section {
        padding-left: 20px;
        padding-right: 20px;
      }
      .stats-bar { grid-template-columns: repeat(3, 1fr); }
    }

    @media (max-width: 992px) {
      .stats-bar { grid-template-columns: repeat(2, 1fr); }
      .controls .search-box { width: 100% !important; max-width: none; }
      .topbar { padding: 12px 20px; }
      .topbar-actions { gap: 8px; }
    }

    @media (max-width: 768px) {
      .stats-bar { grid-template-columns: 1fr; }
      .tabs { overflow-x: auto; white-space: nowrap; padding-bottom: 5px; }
      
      /* Transform table into professional cards */
      table, thead, tbody, th, td, tr { display: block; }
      thead tr { position: absolute; top: -9999px; left: -9999px; }
      
      table { border: none; box-shadow: none; background: transparent; }
      
      tbody tr {
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 8px 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
        transform: none !important;
      }
      
      td {
        border: none !important;
        position: relative;
        padding: 8px 0 8px 40% !important;
        text-align: right !important;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        border-bottom: 1px solid #f1f5f9 !important;
        font-size: 12px;
      }
      
      td:last-child { border-bottom: none !important; }
      
      td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 35%;
        text-align: left;
        font-weight: 700;
        font-size: 9px;
        text-transform: uppercase;
        color: var(--text3);
        letter-spacing: 0.5px;
      }

      .prod-name { max-width: none !important; text-align: right; font-size: 13px; }
      .strategy-cell { min-width: 0; padding-top: 12px !important; }
      .comp-list { justify-content: flex-end; }
      .strategy-input { width: 100% !important; font-size: 11px; }
      .notes-input { width: 100% !important; font-size: 11px; }

      .controls { flex-direction: column; align-items: stretch; gap: 8px; }
      .spacer { display: none; }
      
      #bulkActionsContainer {
        border-left: none !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border2);
      }
    }

    #bulkActionsContainer {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-left: 8px;
      padding-left: 8px;
      border-left: 1px solid var(--border2);
    }
    
    #bulkActionsContainer.hidden {
      display: none !important;
    }

    @media (max-width: 480px) {
      .topbar-actions { flex-direction: column; width: 100%; align-items: stretch; }
      .btn { justify-content: center; }
      .stat-value { font-size: 28px; }
    }

    /* ── MULTI-SELECT FILTER DROPDOWNS ── */
    .ms-wrap { position: relative; }

    .ms-btn {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 10px 14px;
      background: var(--surface); border: 1px solid var(--border2);
      border-radius: 8px; color: var(--text);
      font-size: 13px; font-family: 'Inter', sans-serif;
      cursor: pointer; white-space: nowrap; transition: border-color .2s;
    }
    .ms-btn:hover { border-color: var(--accent); }
    .ms-btn.ms-active {
      border-color: var(--accent); color: var(--accent);
      background: rgba(37,99,235,.06);
    }
    .ms-arrow { font-size: 10px; opacity: .5; }

    .ms-dropdown {
      display: none; position: absolute;
      top: calc(100% + 6px); left: 0; z-index: 500;
      background: var(--surface); border: 1px solid var(--border2);
      border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
      min-width: 200px; max-height: 280px; overflow-y: auto; padding: 6px 0;
    }
    .ms-dropdown.open { display: block; }

    .ms-item {
      display: flex; align-items: center; gap: 9px;
      padding: 8px 14px; font-size: 13px; color: var(--text);
      cursor: pointer; transition: background .12s; user-select: none;
    }
    .ms-item:hover { background: var(--surface2); }
    .ms-item input[type=checkbox] {
      accent-color: var(--accent); width: 14px; height: 14px;
      cursor: pointer; flex-shrink: 0;
    }
    .ms-all {
      border-bottom: 1px solid var(--border);
      margin-bottom: 4px; font-weight: 600; color: var(--text2);
    }
    .ms-count {
      background: var(--accent); color: #fff;
      border-radius: 10px; padding: 0 6px;
      font-size: 10px; font-weight: 700;
    }

    /* AUTH SCREEN */
    .auth-screen {
      position: fixed;
      inset: 0;
      background: var(--bg);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 9999;
    }

    .auth-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 20px;
      padding: 48px;
      width: 100%;
      max-width: 440px;
      box-shadow: 0 20px 40px rgba(0,0,0,0.08);
      animation: authIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes authIn {
      from { opacity: 0; transform: translateY(20px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* CRITICAL SECURITY GUARD: Entire body is hidden while Firebase resolves auth state */
    body.auth-loading * {
      visibility: hidden !important;
    }

    body.auth-loading::before {
      content: '';
      visibility: visible !important;
      position: fixed;
      inset: 0;
      background: var(--bg);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 99999;
    }

    body.auth-loading::after {
      content: '';
      visibility: visible !important;
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 36px;
      height: 36px;
      border: 3px solid var(--border2);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
      z-index: 100000;
    }

    @keyframes spin {
      to { transform: translate(-50%, -50%) rotate(360deg); }
    }

    .fab-container {
      position: fixed;
      bottom: 24px;
      right: 24px;
      display: none;
      z-index: 1000;
      animation: fabIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes fabIn {
      from { opacity: 0; transform: translateY(20px) scale(0.8); }
      to { opacity: 1; transform: translateY(0) scale(1); }
    }

    .fab {
      width: 48px;
      height: 48px;
      border-radius: 12px;
      background: var(--accent);
      color: white;
      border: 1px solid rgba(255,255,255,0.2);
      cursor: pointer;
      font-size: 20px;
      box-shadow: 0 8px 16px rgba(37, 99, 235, 0.25);
      transition: all 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .fab:hover {
      transform: scale(1.1);
    }

    /* BULK MODAL CUSTOM */
    #bulkStrategyOverlay .modal {
      max-width: 800px !important;
      width: 90%;
    }

    .preview-remove-btn {
      background: none;
      border: none;
      color: #ef4444;
      cursor: pointer;
      padding: 4px;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s;
      opacity: 0.6;
    }

    .preview-remove-btn:hover {
      opacity: 1;
      background: #fef2f2;
    }

    .preview-remove-btn svg {
      width: 14px;
      height: 14px;
      stroke: currentColor;
      fill: none;
      stroke-width: 2.5;
    }

    /* STICKY FOOTER LAYOUT
       JS sets display:flex on #appContent — these CSS rules complete the flex column layout
       so footer always sits at the bottom of the viewport on short pages. */
    #appContent {
      display: none; /* JS changes to flex on login */
      flex-direction: column;
      min-height: 100vh;
      flex: 1;
    }

    footer {
      text-align: center;
      padding: 40px 32px;
      color: var(--text3);
      font-size: 13px;
      border-top: 1px solid var(--border);
      background: var(--surface);
      margin-top: auto; /* pushes footer to bottom */
    }
