*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background: #0f0d1a;
  color: #e8e4ff;
  font-family: "DM Sans", sans-serif;
  min-height: 100vh;
}

header {
  background: #1a1730;
  border-bottom: 1px solid #2a2445;
  padding: 24px 32px 20px;
}
header .eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #7b6faa;
  text-transform: uppercase;
  margin-bottom: 6px;
}
header h1 {
  font-family: "Playfair Display", serif;
  font-size: 28px;
  color: #f0eeff;
  margin-bottom: 18px;
}

.date-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.date-pill {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid #2a2445;
  background: transparent;
  color: #9b8fc5;
  font-size: 13px;
  font-family: "DM Sans", sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.date-pill:hover {
  border-color: #7c6fdd;
  color: #c4b8ff;
}
.date-pill.active {
  background: #7c6fdd;
  border-color: #7c6fdd;
  color: #fff;
  font-weight: 500;
}

#sortOrderBtn {
  background: #1a1730;
  border-color: #2a2445;
  color: #7b6faa;
  min-width: 100px;
}

#sortOrderBtn:hover {
  border-color: #7c6fdd;
  color: #fff;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  display: flex;
  flex-direction: column;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 20px;
  width: 100%; 
}

.controls h2 {
  font-family: "Playfair Display", serif;
  font-size: 18px;
  color: #c4b8ff;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #9b8fc5;
  user-select: none;
}
.toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #2a2445;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-track.on {
  background: #7c6fdd;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}
.toggle-track.on .toggle-thumb {
  left: 19px;
}

.legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9b8fc5;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid;
  flex-shrink: 0;
}

.grid-wrap {
  background: #160f2e;
  border: 1px solid #2a2445;
  border-radius: 16px;
  /* CRITICAL: Change overflow: hidden to visible (or keep hidden only on X) */
  /* This allows the tooltip to 'pop out' of the container at the top */
  overflow: visible; 
  margin: 0 auto;
  width: 100%;
}

.grid-header-cell:first-child {
  border-left: none;
}

.grid-row:nth-child(odd) {
  background: #160f2e;
}
.grid-row:nth-child(even) {
  background: #130c28;
}
.grid-row:not(:last-child) {
  border-bottom: 1px solid #1e1838;
}

.grid-header,
.grid-row {
  display: grid;
  grid-template-columns: 96px repeat(3, 1fr);
  width: 100%;
}

.time-cell {
  padding: 8px 10px 8px 4px;
  font-size: 11px;
  font-family: "DM Mono", monospace;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
  border-left: none;
  min-height: 40px;
}

.grid-header {
  display: grid;
  grid-template-columns: 90px repeat(3, 1fr);
  background: #1a1730;
  position: sticky;
  top: 0;
  /* Use a lower z-index than the tooltip */
  z-index: 10; 
  border-bottom: 1px solid #2a2445;
}

.grid-header-cell {
  padding: 12px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: #c4b8ff;
  border-left: 1px solid #2a2445;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.slot-cell {
  padding: 5px 5px;
  border-left: 1px solid #2a2445;
  display: flex;
  align-items: center;
}

.chip {
  display: block;
  width: 100%;
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid;
  font-size: 12px;
  font-weight: 500;
  font-family: "DM Mono", monospace;
  text-align: center;
  cursor: default;
  transition: transform 0.1s;
  position: relative;
}
.chip.has-slot {
  cursor: pointer;
}
.chip.has-slot:hover {
  transform: scale(1.05);
}

.chip-good {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}
.chip-low {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}
.chip-full {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.chip-none {
  background: #1e1838;
  color: #4a4270;
  border-color: #2a2445;
}

.tooltip {
  display: none;
  position: absolute;
  /* Increase z-index to a high number to beat the headers */
  z-index: 9999; 
  bottom: calc(100% + 10px); /* Lift it a bit higher so it doesn't touch the cell */
  left: 50%;
  transform: translateX(-50%);
  background: #1e1b2e;
  color: #f0eeff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5); /* Stronger shadow so it pops against the header */
  line-height: 1.7;
  pointer-events: none;
  font-family: "DM Sans", sans-serif;
  font-weight: 400;
  border: 1px solid #3d346d; /* Added border to make it distinct */
}
.chip.has-slot:hover .tooltip {
  display: block;
}
.tooltip-price {
  color: #a89ddd;
}

.empty-state {
  padding: 48px;
  text-align: center;
  color: #4a4270;
  font-size: 14px;
}
.hint {
  margin-top: 14px;
  font-size: 12px;
  color: #4a4270;
  text-align: center;
}
.nav-arrow {
  background: #1a1730;
  border: 1px solid #2a2445;
  color: #7c6fdd;
  width: 32px; /* Smaller, cleaner size */
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.nav-arrow:hover {
  background: #7c6fdd;
  color: #fff;
  border-color: #7c6fdd;
}

.nav-arrow:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  border-color: #2a2445;
}

/* On small phones, reduce side margins to keep the grid wide */
@media (max-width: 480px) {
  .nav-arrow { width: 32px; height: 32px; font-size: 16px; }
}