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

:root {
  --app-zoom: 100%;
}

/* Fixed full-height viewport flex layout to guarantee vertical scrolling */
html, body {
  height: 100%;
  height: 100vh;
  width: 100%;
  max-width: 100vw;
  margin: 0;
  padding: 0;
  background-color: #F8FAFC;
  color: #000000;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-transform: uppercase !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  -webkit-font-smoothing: antialiased;
}

/* All text and numbers MUST be in UPPERCASE */
* {
  text-transform: uppercase;
}

/* Single, uniform, enlarged dark black font across all cells without emphasizing specific rows */
.cell-text,
.cell-input,
.col-header-text,
.lowest-price-btn {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: #000000 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.02em;
}

.cell-input {
  width: 100%;
  height: 100%;
  background: transparent;
  outline: none;
  border: none;
  padding: 6px 8px;
  text-align: center;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.cell-input.text-left {
  text-align: left;
}

.cell-input:focus {
  background-color: #FFFFFF !important;
  box-shadow: inset 0 0 0 2px #0F172A;
  border-radius: 2px;
}

/* Top Action Bar & Navigation */
.top-action-bar {
  background: #FFFFFF;
  border-bottom: 1px solid #CBD5E1;
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 50;
  flex-shrink: 0;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-suite-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  padding: 6px 12px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #0F172A;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  cursor: pointer;
}

.back-suite-btn:hover {
  background: #E2E8F0;
  border-color: #94A3B8;
  color: #000000;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #000000;
  margin: 0;
}

.live-indicator-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  display: inline-block;
}

.live-text {
  color: #047857;
}

.search-wrapper {
  flex: 1;
  max-width: 340px;
  min-width: 160px;
  position: relative;
}

.search-wrapper input {
  width: 100%;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  background: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  outline: none;
  color: #000000;
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.zoom-controls {
  display: flex;
  align-items: center;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  padding: 2px;
  font-size: 12px;
}

.zoom-btn {
  padding: 4px 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: #334155;
  border-radius: 2px;
}

.zoom-display-btn {
  padding: 4px 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: monospace;
  font-size: 12px;
  font-weight: 600;
  color: #000000;
}

.btn {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

.btn-outline {
  background: #FFFFFF;
  border-color: #CBD5E1;
  color: #000000;
}

.btn-outline:hover {
  background: #F8FAFC;
  border-color: #94A3B8;
}

.btn-primary {
  background: #059669;
  color: #FFFFFF;
  font-weight: 600;
}

.btn-primary:hover {
  background: #047857;
}

.btn-danger {
  background: #DC2626;
  color: #FFFFFF;
  font-weight: 600;
}

.btn-danger:hover {
  background: #B91C1C;
}

/* Bounded main grid area that flexes to remaining viewport height */
#mainGridArea {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  position: relative !important;
}

/* Scroll container: provides both horizontal and vertical scrolling */
#scrollContainer {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  height: 100% !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  width: 100% !important;
  position: relative !important;
  background-color: #F8FAFC;
}

#gridWrapper {
  min-width: 100%;
  width: -moz-max-content;
  width: max-content;
  display: inline-flex;
  flex-direction: column;
  vertical-align: top;
  zoom: var(--app-zoom);
}

#headerBar {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: #0F172A !important;
  color: #FFFFFF !important;
  display: flex;
  min-width: 100%;
  width: 100%;
  border-bottom: 2px solid #334155;
}

.header-col {
  background-color: #0F172A !important;
  color: #FFFFFF !important;
}

#rowsContainer {
  display: flex;
  flex-direction: column;
  min-width: 100%;
  width: 100%;
}

.row-block {
  display: flex;
  min-width: 100%;
  width: 100%;
}

/* Alternating row blocks of four rows (Dual-tone row banding across ALL detail columns) */
/* Block 1 (Even Item): Soft Light Background */
.block-even,
.block-even .col-item,
.block-even .col-detail,
.block-even .detail-cols-wrapper,
.block-even .row-cell {
  background-color: #FFFFFF !important;
}
.block-even {
  border-bottom: 2px solid #CBD5E1;
}
.block-even .sub-row {
  border-bottom: 1px solid #E2E8F0;
}
.block-even .col-border {
  border-right: 1px solid #CBD5E1;
}
.block-even .col-detail:hover {
  background-color: #F1F5F9 !important;
}

/* Block 2 (Odd Item): Light Blue Accented Background */
.block-odd,
.block-odd .col-item,
.block-odd .col-detail,
.block-odd .detail-cols-wrapper,
.block-odd .row-cell {
  background-color: #E0F2FE !important;
}
.block-odd {
  border-bottom: 2px solid #7DD3FC;
}
.block-odd .sub-row {
  border-bottom: 1px solid #BAE6FD;
}
.block-odd .col-border {
  border-right: 1px solid #7DD3FC;
}
.block-odd .col-detail:hover {
  background-color: #BAE6FD !important;
}

/* Column 1 Item Column styling (Column 1 is NOT sticky/fixed, scrolls with the grid) */
.col-item {
  min-width: 200px;
  max-width: 280px;
  flex: 0 0 220px;
  border-right: 2px solid #94A3B8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Detail column container and cells */
.detail-cols-wrapper {
  display: flex;
  flex: 1 0 auto;
  min-width: -moz-max-content;
  min-width: max-content;
}

.col-detail {
  min-width: 130px;
  flex: 1 0 130px;
  display: flex;
  flex-direction: column;
}

/* Uniform 4-row height */
.row-cell {
  height: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  position: relative;
}

.row-cell.justify-between {
  justify-content: space-between;
  padding: 0 10px;
}

.row-cell.justify-start {
  justify-content: flex-start;
  padding: 0 8px;
}

/* Dedicated LOWEST PRICE indicator button */
.lowest-price-btn {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #94A3B8;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

.lowest-price-btn:hover {
  background: #FFFFFF;
  border-color: #0F172A;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.lowest-price-btn:active {
  transform: scale(0.99);
  background: #F1F5F9;
}

/* Lowest Price cell blinking animation */
@keyframes blinkLowest4 {
  0%, 100% {
    background-color: transparent;
    box-shadow: none;
    transform: scale(1);
  }
  12.5%, 37.5%, 62.5%, 87.5% {
    background-color: #FEF08A;
    box-shadow: inset 0 0 0 2px #EAB308, 0 0 14px rgba(234, 179, 8, 0.8);
    transform: scale(1.03);
  }
}

.blink-4-times {
  animation: blinkLowest4 2s ease-in-out forwards !important;
  z-index: 30;
  position: relative;
}

/* Lowest Price 3-second highlight for each individual subclass */
@keyframes highlightLowest3Sec {
  0% {
    background-color: #FEF08A;
    box-shadow: inset 0 0 0 2px #EAB308, 0 0 18px rgba(234, 179, 8, 0.95);
    transform: scale(1.04);
  }
  15%, 45%, 75% {
    background-color: #FDE047;
    box-shadow: inset 0 0 0 2px #CA8A04, 0 0 20px rgba(202, 138, 4, 0.95);
    transform: scale(1.05);
  }
  30%, 60% {
    background-color: #FEF08A;
    box-shadow: inset 0 0 0 2px #EAB308, 0 0 14px rgba(234, 179, 8, 0.85);
    transform: scale(1.02);
  }
  90% {
    background-color: #FEF9C3;
    box-shadow: inset 0 0 0 2px #EAB308, 0 0 8px rgba(234, 179, 8, 0.5);
    transform: scale(1.01);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
    transform: scale(1);
  }
}

.highlight-lowest-3s {
  animation: highlightLowest3Sec 3s ease-in-out forwards !important;
  z-index: 35 !important;
  position: relative !important;
}

/* Mobile Pull-to-Refresh Container */
.pull-to-refresh-container {
  width: 100%;
  height: 0px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0F172A;
  color: #38BDF8;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: height 0.15s ease, opacity 0.15s ease;
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  border-bottom: 1px solid #1E293B;
  flex-shrink: 0;
  z-index: 25;
}
.ptr-content {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ptr-icon {
  display: inline-block;
  font-size: 16px;
  transition: transform 0.2s ease;
  color: #38BDF8;
  font-weight: 800;
}
.ptr-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-top-color: #38BDF8;
  border-radius: 50%;
  animation: ptrSpin 0.7s linear infinite;
}
@keyframes ptrSpin {
  to { transform: rotate(360deg); }
}

/* Delete column header button */
.delete-col-header-btn {
  background: transparent;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 2px;
  transition: color 0.15s ease, background 0.15s ease;
}
.delete-col-header-btn:hover {
  color: #EF4444;
  background: rgba(255, 255, 255, 0.1);
}

/* Subclass buttons */
.add-subclass-btn {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px dashed #0284C7;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #0284C7;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}
.add-subclass-btn:hover {
  background: #0284C7;
  color: #FFFFFF;
  border-style: solid;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.25);
}
.delete-sub-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94A3B8;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 2px;
  transition: color 0.15s ease;
}
.delete-sub-btn:hover {
  color: #EF4444;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #E2E8F0;
}
::-webkit-scrollbar-thumb {
  background: #94A3B8;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #64748B;
}

/* Toast Notification */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-msg {
  pointer-events: auto;
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-left: 4px solid #10B981;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease-out forwards;
}

.toast-msg.toast-alert {
  border-left-color: #EAB308;
}

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

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

@keyframes shakeModal {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.shake {
  animation: shakeModal 0.35s ease-in-out !important;
}
