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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1117;
  color: #e0e0e0;
  line-height: 1.5;
}

header {
  background: #1a1d27;
  border-bottom: 1px solid #2a2d3a;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #fff;
}

.controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #b0b0b0;
}

.checkbox-label input { cursor: pointer; }

.attendance-input-label {
  gap: 8px;
  cursor: default;
}

.attendance-input-label input[type="number"] {
  width: 52px;
  background: #12141c;
  border: 1px solid #2a2d3a;
  color: #e0e0e0;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  text-align: center;
}

#refreshBtn {
  background: #3b82f6;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

#refreshBtn:hover { background: #2563eb; }

#saveBtn {
  background: #059669;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
#saveBtn:hover { background: #047857; }

.save-feedback {
  font-size: 0.8rem;
  color: #34d399;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.save-feedback.visible { opacity: 1; }

main { padding: 0 24px 20px; }

/* --- Unified row grid --- */

.column-headers,
.constraint-row,
.unified-row {
  display: grid;
  grid-template-columns: 210px 36px 100px 1fr 36px 1fr;
  align-items: center;
  gap: 0;
}

.column-headers {
  padding: 14px 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #94a3b8;
  border-bottom: 1px solid #2a2d3a;
  position: sticky;
  top: 0;
  background: #0f1117;
  z-index: 10;
}

.column-headers .subtitle {
  font-weight: 400;
  font-size: 0.78rem;
  color: #555;
  margin-left: 6px;
}

.col-ob-check, .col-ib-check { text-align: center; }
.col-ob { padding-left: 8px; }
.col-ib { padding-left: 8px; }
.col-date { text-align: center; }
.col-attendance { text-align: center; }

.constraint-row {
  padding: 6px 0;
  border-bottom: 1px solid #1e2130;
}

.constraint {
  font-size: 0.72rem;
  color: #555;
}

/* --- Weekend rows --- */

.unified-row {
  padding: 8px 0;
  border-bottom: 1px solid #1e2130;
  transition: background 0.1s;
}

.pre-week-row { opacity: 0.55; }
.pre-week-row:hover { opacity: 0.85; }
.pre-week-label { color: #555; font-size: 0.78rem; }

.unified-row:hover {
  background: #13151d;
}

.unified-row.recovery-easy { background: rgba(45, 212, 191, 0.05); }
.unified-row.recovery-moderate { background: rgba(74, 222, 128, 0.08); }
.unified-row.recovery-normal { background: rgba(250, 204, 21, 0.08); }
.unified-row.recovery-hard { background: rgba(251, 146, 60, 0.11); }
.unified-row.recovery-extreme { background: rgba(239, 68, 68, 0.11); }

.cell {
  padding: 0 4px;
  min-width: 0;
}

.cell-check {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-check input[type="checkbox"] {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: #3b82f6;
}

.cell-ob, .cell-ib {
  padding: 0 8px;
  overflow: hidden;
}

.cell-date {
  text-align: center;
  font-weight: 600;
  font-size: 0.88rem;
  color: #e0e0e0;
  white-space: nowrap;
}

.cell-attendance {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 4px;
}

/* --- Attendance radio buttons --- */

.att-radios {
  display: inline-flex;
  gap: 2px;
}

.att-btn {
  width: 22px;
  height: 22px;
  border: 1px solid #2a2d3a;
  background: #12141c;
  color: #888;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  line-height: 22px;
  text-align: center;
  transition: background 0.1s, color 0.1s;
}

.att-btn:hover {
  background: #1e2130;
  color: #ccc;
}

.att-btn.att-active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.att-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4ade80;
  min-width: 28px;
  text-align: center;
}

.att-count.att-red {
  color: #ef4444;
}

/* --- Flight summary & details --- */

.flight-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 0;
  min-height: 28px;
  border-radius: 4px;
  transition: background 0.1s;
}

.flight-summary:hover {
  background: #1a1d27;
}

.flight-summary .best-price {
  color: #4ade80;
  font-weight: 600;
  font-size: 0.92rem;
}

.flight-summary .best-duration {
  color: #94a3b8;
  font-size: 0.82rem;
}

.flight-summary .backup-info {
  color: #ef4444;
  font-size: 0.78rem;
  font-weight: 500;
}

.flight-summary .best-arrival {
  color: #888;
  font-size: 0.8rem;
}

.flight-summary .count {
  margin-left: auto;
  font-size: 0.72rem;
  color: #555;
}

.flight-details {
  display: none;
  padding: 8px 0 4px;
}

.flight-details.open {
  display: block;
}

.loading-indicator {
  color: #64748b;
  font-size: 0.82rem;
  font-style: italic;
}

/* --- Itineraries (inside expanded details) --- */

.itinerary {
  background: #12141c;
  border: 1px solid #2a2d3a;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}

.itinerary.best {
  border-color: #3b82f6;
}

.itin-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 12px;
  cursor: pointer;
  flex-wrap: wrap;
}

.itin-header:hover { background: #1a1d27; }

.itin-rank {
  font-size: 0.75rem;
  color: #555;
  min-width: 20px;
}

.itin-price {
  font-weight: 600;
  color: #4ade80;
  min-width: 70px;
}

.itin-duration {
  color: #94a3b8;
  font-size: 0.85rem;
  min-width: 80px;
}

.itin-arrival {
  color: #888;
  font-size: 0.8rem;
  min-width: 90px;
}

.backup-saves {
  color: #4ade80;
  font-weight: 600;
}

.itin-summary {
  font-size: 0.82rem;
  color: #888;
  flex: 1;
  min-width: 100px;
}

.itin-flags {
  display: flex;
  gap: 6px;
}

.flag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
}

.flag.non-eu {
  background: #7c2d12;
  color: #fb923c;
}

.flag.tight {
  background: #713f12;
  color: #fbbf24;
}

.backup-inline {
  color: #ef4444;
  font-size: 0.82rem;
  font-weight: 600;
}

.itin-legs {
  display: none;
  padding: 0 14px 12px;
  border-top: 1px solid #1e2130;
}

.itinerary.expanded .itin-legs {
  display: block;
}

.leg {
  display: grid;
  grid-template-columns: 70px 1fr auto 60px;
  padding: 6px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid #1a1d27;
  align-items: start;
}

.leg:last-child { border-bottom: none; }

.leg-type {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  padding-top: 2px;
}

.leg-type.flight { color: #60a5fa; }
.leg-type.taxi { color: #fbbf24; }
.leg-type.bus { color: #34d399; }
.leg-type.hotel { color: #c084fc; }
.leg-type.wait { color: #64748b; }

.leg.wait-leg {
  border-bottom: none;
  opacity: 0.6;
}

.leg-detail { color: #ccc; }
.leg-detail .route { font-weight: 500; }
.leg-detail .carrier { color: #888; font-size: 0.78rem; }
.leg-detail .layover-info { color: #888; font-size: 0.76rem; font-style: italic; }

.buy-ticket {
  display: inline-block;
  background: #22c55e;
  color: #fff;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 1px 8px;
  border-radius: 10px;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.buy-ticket:hover {
  background: #16a34a;
}

.leg-time {
  text-align: right;
  color: #94a3b8;
  font-size: 0.78rem;
}

.leg-price {
  text-align: right;
  color: #4ade80;
  font-size: 0.82rem;
}

.backup-section {
  margin-top: 8px;
  padding: 10px 12px;
  background: #1c1012;
  border: 1px solid #3b1515;
  border-radius: 4px;
}

.backup-section h4 {
  font-size: 0.78rem;
  color: #ef4444;
  margin-bottom: 6px;
  font-weight: 600;
}

.backup-section .backup-desc {
  font-size: 0.8rem;
  color: #f87171;
}

.no-data {
  padding: 20px;
  text-align: center;
  color: #555;
  font-size: 0.85rem;
}

/* --- Footer / reference --- */

footer {
  padding: 20px 24px;
}

footer details {
  background: #1a1d27;
  border: 1px solid #2a2d3a;
  border-radius: 8px;
  overflow: hidden;
}

footer summary {
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: #94a3b8;
}

footer summary:hover { color: #e0e0e0; }

#reference-data {
  padding: 12px 18px;
  font-size: 0.82rem;
}

.ref-section {
  margin-bottom: 16px;
}

.ref-section h3 {
  font-size: 0.88rem;
  margin-bottom: 8px;
  color: #94a3b8;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.ref-table th {
  text-align: left;
  padding: 6px 10px;
  background: #12141c;
  color: #888;
  font-weight: 500;
  border-bottom: 1px solid #2a2d3a;
}

.ref-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #1e2130;
}

.cache-status {
  width: 100%;
  font-size: 0.75rem;
  color: #64748b;
  padding-top: 6px;
}

@media (max-width: 900px) {
  .column-headers,
  .constraint-row,
  .unified-row {
    grid-template-columns: 160px 28px 80px 1fr 28px 1fr;
  }
  .att-btn { width: 18px; height: 18px; font-size: 0.65rem; line-height: 18px; }
}
