/*
  Qurioux brand: Dark Blue #003366, Vivid Turquoise #15f5ba, Pastel Azure #87ceeb,
  Light Gray #c0c0c0, body Arial, titles Palanquin Dark
*/
@import url("https://fonts.googleapis.com/css2?family=Palanquin+Dark:wght@400;600;700&display=swap");

:root {
  --qx-dark-blue: #003366;
  --qx-turquoise: #15f5ba;
  --qx-azure: #87ceeb;
  --qx-yellow: #ffd700;
  --qx-gray: #c0c0c0;
  --qx-black: #000000;
  --qx-white: #ffffff;
  --qx-bg: #f5f8fa;
  --qx-panel: #ffffff;
  --qx-border: #c0c0c0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  color: var(--qx-black);
  background: var(--qx-bg);
  line-height: 1.5;
}

h1,
h2,
h3,
.app-title {
  font-family: "Palanquin Dark", Arial, sans-serif;
  font-weight: 700;
  color: var(--qx-dark-blue);
}

header.app-header {
  background: var(--qx-dark-blue);
  color: var(--qx-white);
  padding: 0.75rem 1.25rem;
  border-bottom: 4px solid var(--qx-turquoise);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

header.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--qx-white);
}

header .tagline {
  font-size: 0.8rem;
  color: var(--qx-azure);
  margin: 0.15rem 0 0;
  font-weight: normal;
}

nav.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  background: var(--qx-panel);
  border-bottom: 1px solid var(--qx-border);
}

nav.tabs button.tab {
  font-family: Arial, sans-serif;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--qx-border);
  background: var(--qx-panel);
  color: var(--qx-dark-blue);
  cursor: pointer;
  border-radius: 2px;
  font-size: 0.9rem;
}

nav.tabs button.tab:hover {
  border-color: var(--qx-turquoise);
  color: var(--qx-dark-blue);
}

nav.tabs button.tab.active {
  background: var(--qx-dark-blue);
  color: var(--qx-white);
  border-color: var(--qx-dark-blue);
}

main.main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.section-desc,
.hint {
  color: #555;
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.hint strong {
  color: var(--qx-dark-blue);
}

.upload-zone {
  border: 2px dashed var(--qx-azure);
  padding: 1.25rem;
  background: var(--qx-panel);
  border-radius: 4px;
  margin-bottom: 1rem;
}

.file-label {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--qx-dark-blue);
  color: var(--qx-white);
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.9rem;
}

.file-label input {
  display: none;
}

button.primary {
  background: var(--qx-dark-blue);
  color: var(--qx-white);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.9rem;
}

button.primary:hover {
  background: #004080;
}

button.secondary {
  background: var(--qx-white);
  color: var(--qx-dark-blue);
  border: 1px solid var(--qx-dark-blue);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  border-radius: 2px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.stat-card {
  background: var(--qx-panel);
  border: 1px solid var(--qx-border);
  border-left: 4px solid var(--qx-turquoise);
  padding: 0.75rem;
  border-radius: 2px;
}

.stat-card--clickable {
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-card--clickable:hover {
  border-color: var(--qx-turquoise);
  box-shadow: 0 2px 8px rgba(0, 51, 102, 0.12);
}

.stat-card--clickable:focus {
  outline: 2px solid var(--qx-turquoise);
  outline-offset: 2px;
}

.stat-card--clickable.stat-card--active {
  border-left-color: #e94560;
  box-shadow: 0 2px 10px rgba(233, 69, 96, 0.2);
}

.understand-inventory-wrap {
  margin-top: 1rem;
  max-height: min(62vh, 36rem);
  overflow: auto;
  border: 1px solid var(--qx-border);
  border-radius: 2px;
  padding: 0.75rem 1rem;
  background: var(--qx-white);
}

.understand-inventory-placeholder {
  margin: 0;
}

.understand-inventory-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--qx-dark-blue);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--qx-dark-blue);
  font-family: "Palanquin Dark", Arial, sans-serif;
}

.stat-label {
  font-size: 0.75rem;
  color: #666;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.5rem 0 1rem;
}

table.data thead {
  background: var(--qx-dark-blue);
  color: var(--qx-white);
}

table.data th,
table.data td {
  border: 1px solid var(--qx-border);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

table.data tbody tr:nth-child(even) {
  background: #f0f4f8;
}

.issue {
  padding: 0.75rem;
  margin: 0.5rem 0;
  border-left: 4px solid var(--qx-yellow);
  background: #fffef5;
}

.issue.error {
  border-left-color: #c62828;
  background: #fff5f5;
}

.gaps-list li {
  margin: 0.35rem 0;
}

.route-visual-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.5rem;
  margin-bottom: 0.5rem;
}

.route-visual-toolbar-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--qx-dark-blue);
}

.route-visual-toolbar-row select {
  min-width: 12rem;
  max-width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--qx-border);
  font-family: Arial, sans-serif;
}

.route-viz-mode-hint {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.82rem;
  color: #37474f;
  max-width: 52rem;
}

/* Collections racetrack (synthetic day timeline) */
.racetrack-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.racetrack-wl-input {
  width: 4rem;
  margin-left: 0.35rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--qx-border);
}

.racetrack-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 0.5rem 0 1rem;
  border: 1px solid var(--qx-border);
  background: #fafbfc;
  border-radius: 6px;
  padding: 0.75rem;
}

.racetrack-outer {
  min-width: 720px;
}

.racetrack-top,
.racetrack-row {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.racetrack-corner,
.racetrack-lane-label {
  width: 11rem;
  min-width: 11rem;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--qx-dark-blue);
  padding: 0.35rem 0.5rem 0.35rem 0;
}

.racetrack-day-strip {
  display: flex;
  flex: 1;
  min-width: 0;
  border-bottom: 1px solid var(--qx-border);
  margin-bottom: 0.25rem;
}

.racetrack-day-num {
  flex: 1;
  text-align: center;
  font-size: 0.7rem;
  color: #546e7a;
  border-left: 1px solid #e0e0e0;
  padding: 0.2rem 0;
}

.racetrack-day-num:first-child {
  border-left: none;
}

.racetrack-track {
  position: relative;
  flex: 1;
  min-height: 46px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 0.35rem;
}

.racetrack-bar {
  position: absolute;
  top: 4px;
  height: 36px;
  box-sizing: border-box;
  border-radius: 4px;
  padding: 2px 4px;
  overflow: hidden;
  border-width: 1px;
  border-style: solid;
}

.racetrack-bar-text {
  font-size: 0.68rem;
  line-height: 1.15;
  display: block;
  color: #212121;
  word-break: break-word;
}

.racetrack-tone-delay {
  background: #fff9c4;
  border-color: #fbc02d;
}

.racetrack-tone-comms {
  background: #ffe0b2;
  border-color: #ef6c00;
}

.racetrack-tone-system {
  background: #ffcdd2;
  border-color: #c62828;
}

.racetrack-tone-worklist {
  background: #bbdefb;
  border-color: #1565c0;
}

.racetrack-tone-decision {
  background: #e1bee7;
  border-color: #7b1fa2;
}

.racetrack-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
}

.racetrack-leg {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border-width: 1px;
  border-style: solid;
}

#routeVisualGraph {
  width: 100%;
  height: 580px;
  min-height: 440px;
  border: 1px solid var(--qx-border);
  background: #fafbfc;
}

.route-legend-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--qx-dark-blue);
}

ul.route-graph-legend {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.25rem;
  font-size: 0.82rem;
  color: #37474f;
  max-width: 52rem;
}

ul.route-graph-legend li {
  margin: 0.2rem 0;
}

table.decision-rules-table {
  font-size: 0.8rem;
}

table.decision-rules-table th,
table.decision-rules-table td {
  vertical-align: top;
  word-break: break-word;
  max-width: 12rem;
}

.search-input {
  width: 100%;
  max-width: 28rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--qx-border);
  font-family: Arial, sans-serif;
}

footer.doc-footer {
  margin-top: 2rem;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--qx-gray);
  border-top: 1px solid var(--qx-border);
  text-align: center;
}

.excel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1rem;
}

.excel-card {
  border: 1px solid var(--qx-border);
  padding: 1rem;
  background: var(--qx-panel);
  border-radius: 4px;
}

.banner-error {
  background: #fff3e0;
  border-left: 4px solid #ff9800;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.banner-ok {
  background: #e8f8f4;
  border-left: 4px solid var(--qx-turquoise);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.search-filters label {
  font-size: 0.88rem;
  color: #333;
}

.table-scroll {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--qx-border);
  background: var(--qx-panel);
  margin-top: 0.5rem;
}

.route-positions-section {
  margin-top: 1.25rem;
}

.qx-link {
  color: var(--qx-dark-blue);
  text-decoration: underline;
  text-decoration-color: var(--qx-turquoise);
  cursor: pointer;
  font-weight: 600;
}

.qx-link:hover {
  color: var(--qx-turquoise);
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.detail-modal.hidden {
  display: none;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.detail-modal-card {
  position: relative;
  background: var(--qx-panel);
  border: 1px solid var(--qx-border);
  border-top: 4px solid var(--qx-turquoise);
  max-width: 48rem;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 1rem 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 51, 102, 0.15);
}

.detail-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.detail-modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.detail-modal-body {
  font-size: 0.88rem;
}

.detail-modal-body table.data {
  font-size: 0.8rem;
}

.database-tool-links {
  margin: 0.5rem 0 0.75rem;
}

.database-tool-links a {
  color: var(--qx-dark-blue);
  font-weight: 600;
}

.database-iframe {
  display: block;
  width: 100%;
  min-height: 72vh;
  border: 1px solid var(--qx-border);
  border-radius: 6px;
  background: var(--qx-panel);
}
