: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-left: 20px;
  padding-right: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  /* 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;
  width: 140px;
  min-height: 160px;
}

.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;
  bottom: 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;
}

/* Premium Cloud Modal Styling */
.cloud-modal {
  max-width: 600px !important;
  background: #ffffff !important; /* Force pure white */
  padding: 0 !important;
  border-radius: 20px !important;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.cloud-header {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  padding: 30px;
  color: white;
  display: flex;
  align-items: center;
  gap: 20px;
}

.cloud-icon-bg {
  width: 50px;
  height: 50px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(5px);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.cloud-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.cloud-header p {
  margin: 4px 0 0 0;
  opacity: 0.9;
  font-size: 13px;
}

.cloud-card-section {
  padding: 30px;
  background: #ffffff; /* White background */
  border-bottom: 1px solid #f1f5f9;
}

.section-tag {
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.save-input-group {
  display: flex;
  gap: 12px;
}

.cloud-input {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
  color: #1e293b;
  font-size: 14px;
  transition: all 0.3s ease;
}

.cloud-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.cloud-save-btn {
  background: linear-gradient(to right, var(--accent), #4f46e5) !important;
  color: white !important;
  border: none !important;
  padding: 12px 24px !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease !important;
}

.cloud-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.cloud-list-header {
  padding: 24px 30px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff; /* White background */
}

.cloud-list-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.saves-count {
  font-size: 11px;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 20px;
  color: #64748b;
  font-weight: 600;
}

.cloud-sessions-container {
  max-height: 350px;
  overflow-y: auto;
  padding: 0 30px 20px;
  background: #ffffff; /* White background */
}

.cloud-session-item {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.cloud-session-item:hover {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateX(4px);
}

.session-info-main {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 4px;
}

.session-info-meta {
  font-size: 11px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cloud-empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--text3);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.cloud-footer {
  padding: 20px 30px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  background: var(--surface);
}

/* Custom scrollbar for cloud list */
.cloud-sessions-container::-webkit-scrollbar {
  width: 6px;
}
.cloud-sessions-container::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 10px;
}

.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: 13px;
  font-weight: 600;
  color: var(--text2);
}

.sim-channel-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 8px;
  transition: all 0.2s;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text);
}

.sim-channel-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

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: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* RESPONSIVENESS */
@media (max-width: 1200px) {

  .topbar,
  .stats-bar,
  .controls,
  .table-wrap,
  .heatmap-section,
  .chart-section {
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 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 */
}

/* MODERN TOOLBAR & MENUS */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 20px;
  position: sticky;
  top: 104px;
  /* below topbar + tabs */
  z-index: 90;
}

.toolbar-left {
  flex: 1;
  max-width: 400px;
}

.toolbar-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dropdown-group {
  position: relative;
}

/* FILTER PANEL (FLYOUT) */
.filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  width: 580px;
  max-width: 90vw;
  padding: 24px;
  display: none;
  flex-direction: column;
  gap: 20px;
  z-index: 200;
  animation: menuFadeIn 0.2s ease-out;
  max-height: 80vh;
  overflow-y: auto;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.filter-full-width {
  grid-column: 1 / -1;
}

.filter-panel.open {
  display: flex;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ACTION DROPDOWN */
.action-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  width: 220px;
  padding: 8px;
  display: none;
  flex-direction: column;
  z-index: 200;
  animation: menuFadeIn 0.2s ease-out;
}

.action-dropdown.open {
  display: flex;
}

.action-item {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
}

.action-item:hover {
  background: var(--surface2);
}

.action-item.danger {
  color: var(--red);
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

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

/* PREMIUM TABS */
.tabs {
  background: var(--surface);
  padding: 0 32px;
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 64px;
  /* below topbar */
  z-index: 95;
}

.tab {
  padding: 14px 4px;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--accent);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}

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

/* CLEANER SCROLLBAR FOR MENUS */
.filter-panel::-webkit-scrollbar {
  width: 6px;
}

.filter-panel::-webkit-scrollbar-track {
  background: transparent;
}

.filter-panel::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 10px;
}

/* COMPACT STOCK PILL */
.stock-pills-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.stock-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
}
/* ── FLOATING SCROLLBARS ── */
.floating-scroll-h {
  position: fixed;
  bottom: 20px;
  left: 15%;
  width: 70%;
  height: 20px;
  background: transparent;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 1000;
  display: none;
  border: none;
}

.floating-scroll-h-content {
  height: 1px;
}

/* Custom scrollbar style - transparent track, visible thumb */
.floating-scroll-h::-webkit-scrollbar {
  height: 14px;
}
.floating-scroll-h::-webkit-scrollbar-track {
  background: transparent;
}
.floating-scroll-h::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 4px solid transparent;
  background-clip: padding-box;
}
.floating-scroll-h::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .floating-scroll-h::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .floating-scroll-h::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Vertical Floating Scrollbar - Minimalist/Transparent */
.floating-scroll-v {
  position: fixed;
  right: 6px;
  top: 100px;
  bottom: 40px;
  width: 10px;
  z-index: 1001;
  pointer-events: none;
}

.floating-scroll-v-thumb {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
  opacity: 0.3; /* visible by default but subtle */
  transition: opacity 0.3s;
  pointer-events: auto;
  cursor: pointer;
}

.floating-scroll-v:hover .floating-scroll-v-thumb,
.floating-scroll-v-thumb.active {
  opacity: 1;
  background: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .floating-scroll-v-thumb {
  background: rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .floating-scroll-v:hover .floating-scroll-v-thumb {
  background: rgba(255, 255, 255, 0.4);
}

/* SIMPLE INTEGRATED ACTIONS */
.session-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.primary-action-btn {
  background: var(--green) !important;
  color: white !important;
  padding: 6px 14px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none !important;
  transition: opacity 0.2s;
}

.primary-action-btn:hover {
  opacity: 0.9;
}

.secondary-actions {
  display: flex;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.icon-action-btn {
  background: none !important;
  border: none !important;
  color: var(--text3) !important;
  padding: 4px !important;
  font-size: 14px !important;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-action-btn:hover {
  color: var(--accent) !important;
  transform: scale(1.1);
}

.icon-action-btn.delete:hover {
  color: var(--red) !important;
}

.cloud-session-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column; /* Vertical layout */
  gap: 16px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.cloud-session-item:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
