/* === BPE Travel Cost Estimator === */

:root {
  --primary: #091d83;
  --primary-light: #1a3399;
  --primary-hover: #061560;
  --primary-bg: #e8ecf5;
  --accent: #c8df40;
  --accent-hover: #b5cc2e;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --bg: #f6f5e2;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --input-border: #cbd5e1;
  --input-focus: rgba(9, 29, 131, 0.15);
  --sw-orange: #e97c00;
  --sw-orange-hover: #c56800;
  --google-blue: #4285f4;
  --google-blue-hover: #3367d6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
header {
  background: linear-gradient(135deg, #091d83 0%, #1a3399 100%);
  padding: 28px 40px;
  color: white;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  position: relative;
}

.subtitle {
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  margin-top: 4px;
  font-weight: 400;
  position: relative;
}

/* --- Feedback Dropdown --- */
.feedback-dropdown {
  position: relative;
  z-index: 200;
  max-height: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #091d83 0%, #0e2499 100%);
  border-bottom: 3px solid var(--accent);
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 0;
}

.feedback-dropdown.open {
  max-height: 900px;
  opacity: 1;
  overflow-y: auto;
}

.feedback-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 40px 28px;
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.feedback-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
}

.feedback-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}

.feedback-close:hover {
  color: white;
  background: rgba(255,255,255,0.12);
}

.feedback-desc {
  color: rgba(255,255,255,0.65);
  font-size: 0.82rem;
  margin-bottom: 18px;
  line-height: 1.5;
}

.feedback-row {
  margin-bottom: 14px;
}

.feedback-row label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.6);
  margin-bottom: 6px;
}

.feedback-row label .optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.feedback-type-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.feedback-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.8);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.feedback-chip:hover {
  border-color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.12);
  color: white;
}

.feedback-chip.active {
  border-color: var(--accent);
  background: rgba(200, 223, 64, 0.15);
  color: var(--accent);
}

.feedback-row textarea,
.feedback-row input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: white;
  font-size: 0.88rem;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
  resize: vertical;
}

.feedback-row textarea::placeholder,
.feedback-row input[type="text"]::placeholder {
  color: rgba(255,255,255,0.35);
}

.feedback-row textarea:focus,
.feedback-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 223, 64, 0.15);
}

.feedback-submit {
  width: 100%;
  margin-top: 4px;
  padding: 12px 20px;
  font-size: 0.92rem;
}

.feedback-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.feedback-success {
  text-align: center;
  padding: 20px 0 8px;
}

.feedback-success-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.feedback-success p {
  color: white;
  margin: 4px 0;
}

.feedback-success .text-muted {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
}

.feedback-success .text-muted a {
  color: rgba(255,255,255,0.9);
}

.feedback-bug-fields {
  animation: feedbackSlideIn 0.2s ease;
}

@keyframes feedbackSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.feedback-env-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  padding: 6px 0;
  margin-top: 2px;
}

/* --- Main Layout --- */
main {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 28px;
  padding: 28px 40px;
  max-width: 1320px;
  margin: 0 auto;
}

/* --- Input Panel --- */
.input-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  align-self: start;
  position: sticky;
  top: 28px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="month"],
.form-group input[type="number"] {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--input-focus);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-group.half {
  flex: 1;
}

.radio-group {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.radio-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
  color: var(--text-secondary);
}

.radio-label:has(input:checked) {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.radio-label input[type="radio"] {
  display: none;
}

/* --- Buttons --- */
.btn-primary {
  width: 100%;
  height: 48px;
  background: var(--accent);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(9, 29, 131, 0.25);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--input-border);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-secondary {
  width: 100%;
  height: 42px;
  background: var(--card-bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--input-border);
}

/* --- Top Navigation --- */
.top-nav {
  display: flex;
  gap: 4px;
  margin-top: 14px;
}

.nav-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all var(--transition);
}

.nav-link:hover {
  color: white;
  background: rgba(255,255,255,0.12);
}

.nav-link.active {
  color: white;
  background: rgba(255,255,255,0.18);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(255,255,255,0.25);
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}

/* --- Save Button --- */
.btn-save {
  flex: 1;
  padding: 10px;
  background: var(--success-bg);
  border: 1.5px solid var(--success);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--success);
}

.btn-save:hover {
  background: var(--success);
  color: white;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}

/* --- Saved Estimates Page --- */
.saved-page {
  grid-column: 1 / -1;
}

.saved-header {
  margin-bottom: 20px;
}

.saved-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

.saved-card:hover {
  box-shadow: var(--shadow-md);
}

.saved-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.saved-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.saved-card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.saved-card-total {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}

.saved-card-details {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.saved-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn-delete-saved {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.btn-delete-saved:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: #fef2f2;
}

/* --- Travel Time Card --- */
.travel-time-total {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

/* --- Select Input --- */
.form-group select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--input-focus);
}

/* --- Results Panel --- */
.results-panel {
  min-height: 200px;
}

/* Enforce card display order: Flights → Search Analysis → Cost Summary → Trip Map */
#results-content {
  display: flex;
  flex-direction: column;
}
#error-card      { order: 0; }
.flight-card     { order: 1; }
.analysis-card   { order: 2; }
.summary-card    { order: 3; }
.map-card        { order: 4; }

.result-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  transition: box-shadow var(--transition);
}

.result-card:hover {
  box-shadow: var(--shadow-md);
}

.result-card h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 700;
}

.result-card p {
  font-size: 1rem;
  line-height: 1.5;
}

.result-card strong {
  color: var(--text);
}

.resolved-address {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: color var(--transition);
}

.action-link:hover {
  color: var(--primary-hover);
}

.action-link::after {
  content: '\2192';
  font-size: 1rem;
  transition: transform var(--transition);
}

.action-link:hover::after {
  transform: translateX(3px);
}

/* --- Flight Links --- */
.flight-links {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-flight {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}

.btn-southwest {
  background: var(--sw-orange);
  color: white;
}

.btn-southwest:hover {
  background: var(--sw-orange-hover);
  box-shadow: 0 4px 12px rgba(233, 124, 0, 0.3);
  transform: translateY(-1px);
}

.btn-google {
  background: var(--google-blue);
  color: white;
}

.btn-google:hover {
  background: var(--google-blue-hover);
  box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
  transform: translateY(-1px);
}

/* --- Per Diem Breakdown --- */
.breakdown {
  margin: 12px 0;
  font-size: 0.88rem;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.breakdown-row:last-child {
  border-bottom: none;
}

/* Per diem editable percentage select */
.perdiem-pct-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--primary-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 2px 20px 2px 6px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23091d83'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  background-size: 8px;
}

.perdiem-pct-select:hover {
  border-color: var(--primary);
}

.perdiem-pct-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--input-focus);
}

.perdiem-day-row {
  align-items: center;
}

.perdiem-day-amount {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.total {
  font-size: 1.05rem;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1.5px solid var(--border);
}

/* --- Summary Table --- */
.summary-card {
  background: var(--card-bg);
}

#summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

#summary-table th {
  text-align: left;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}

#summary-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

#summary-table td:first-child {
  font-weight: 600;
  color: var(--text);
}

#summary-table .amount-col {
  text-align: right;
  width: 120px;
}

#summary-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

#summary-table tfoot td {
  font-weight: 800;
  font-size: 1.05rem;
  border-top: 2px solid var(--text);
  border-bottom: none;
  color: var(--text);
  padding-top: 14px;
}

.export-buttons {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn-export {
  flex: 1;
  padding: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.btn-export:hover {
  background: var(--card-bg);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: 80px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --- Chat Panel --- */
.chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #1a3399 100%);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(9, 29, 131, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 100;
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-lg), 0 0 0 6px rgba(9, 29, 131, 0.2);
}

.chat-panel {
  position: fixed;
  top: 0;
  right: -440px;
  width: 420px;
  height: 100vh;
  background: var(--card-bg);
  box-shadow: -8px 0 30px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.open {
  right: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #091d83 0%, #1a3399 100%);
  color: white;
}

.chat-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.chat-close {
  background: rgba(255,255,255,0.2);
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.chat-close:hover {
  background: rgba(255,255,255,0.3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg);
}

.chat-message {
  margin-bottom: 16px;
  line-height: 1.5;
}

.chat-message.user {
  text-align: right;
}

.chat-message.user p {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 10px 16px;
  border-radius: 18px 18px 4px 18px;
  max-width: 85%;
  text-align: left;
  font-size: 0.88rem;
}

.chat-message.assistant p {
  display: inline-block;
  background: var(--card-bg);
  padding: 10px 16px;
  border-radius: 18px 18px 18px 4px;
  max-width: 85%;
  font-size: 0.88rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

.chat-input-area input {
  flex: 1;
  height: 42px;
  padding: 0 16px;
  border: 1.5px solid var(--input-border);
  border-radius: 21px;
  font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input-area input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--input-focus);
}

.btn-send {
  padding: 0 22px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  border-radius: 21px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-send:hover {
  box-shadow: 0 3px 10px rgba(9, 29, 131, 0.3);
}

/* --- Help / Learn More Modal --- */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.help-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.help-modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: 92%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 36px 32px 32px;
  position: relative;
  transform: scale(0.95) translateY(12px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.help-overlay.open .help-modal {
  transform: scale(1) translateY(0);
}

.help-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.help-close:hover {
  color: var(--text);
  background: var(--bg);
}

.help-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.help-content .help-intro {
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.6;
}

.help-content h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin: 24px 0 12px;
}

.help-content ol,
.help-content ul {
  margin: 0;
  padding-left: 20px;
}

.help-content li {
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.help-content li strong {
  color: var(--text);
}

/* Algorithm deep-dive section */
.algo-details {
  margin-top: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.algo-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  cursor: pointer;
  background: var(--primary-bg);
  list-style: none;
  user-select: none;
  transition: background 0.2s;
}

.algo-summary::-webkit-details-marker { display: none; }
.algo-summary::before {
  content: "▸";
  font-size: 0.75rem;
  transition: transform 0.2s;
}
.algo-details[open] .algo-summary::before {
  transform: rotate(90deg);
}

.algo-summary:hover {
  background: #d5dced;
}

.algo-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--primary);
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
}

.algo-body {
  padding: 20px 16px 16px;
}

.algo-body p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.65;
  margin: 0 0 12px;
}

.algo-body h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 8px;
}

.algo-body h4:first-child {
  margin-top: 0;
}

.algo-list {
  padding-left: 20px;
  margin: 0 0 12px;
}

.algo-list li {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.65;
  margin-bottom: 6px;
}

.algo-list li strong {
  color: var(--text);
}

.algo-formula {
  background: var(--bg);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 0.84rem;
  color: var(--text);
  margin: 12px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.algo-warning-example {
  background: #fef9e7;
  border: 1px solid #f5d76e;
  border-left: 3px solid #d4ac0d;
  padding: 10px 14px;
  font-size: 0.84rem;
  color: #7d6608;
  margin: 12px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

@media (max-width: 600px) {
  .help-modal {
    padding: 28px 20px 24px;
    max-height: 90vh;
  }
  .algo-body {
    padding: 16px 12px 12px;
  }
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: white;
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
  z-index: 300;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- Nearby Stores --- */
.stores-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.store-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.store-row .store-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.store-row .store-detail {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.store-row .store-time {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.9rem;
  white-space: nowrap;
}

.store-row.not-found {
  opacity: 0.5;
}

/* Store name links in summary */
.store-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition);
}
.store-link:hover {
  color: var(--primary-light);
  text-decoration: underline;
}
.breakdown-row .store-link {
  font-weight: 500;
}

/* --- Usage Bar --- */
.usage-bar {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 10px 40px;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.usage-bar .usage-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.usage-bar .usage-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.usage-bar .usage-cost {
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.usage-bar .usage-reset {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.usage-bar .usage-reset:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* --- Flight Cards --- */
.flight-card {
  border-left: 3px solid var(--primary);
  border-top: none;
}
.flight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.flight-card-header h3 {
  margin-bottom: 0;
}
.flight-route {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.flight-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
/* --- Flight Tabs --- */
.flight-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--border);
}
.flight-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.flight-tab:hover {
  color: var(--text-secondary);
  background: var(--bg);
}
.flight-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-bg);
}
.flight-tab-label {
  font-size: 0.88rem;
}
.flight-tab-route {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.flight-tab.active .flight-tab-route {
  color: var(--primary-light);
}

/* --- Flight Tab Panels --- */
.flight-tab-panel {
  display: none;
}
.flight-tab-panel.active {
  display: block;
}

/* --- Combined cheapest (shared across tabs) --- */
.flight-combined-cheapest {
  margin-top: 12px;
  background: linear-gradient(135deg, var(--success-bg) 0%, #ecfdf5 100%);
  font-weight: 500;
}
.combined-breakdown {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.flight-section {
  margin-bottom: 16px;
}
.flight-section h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 8px 0;
}
.flight-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Direction sections within each tab (Outbound / Return) */
.flight-direction-section {
  margin-bottom: 12px;
}
.flight-direction-section:last-child {
  margin-bottom: 0;
}
.flight-direction-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 6px 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Airport badge for non-nearest airport flights */
.flight-airport-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  color: #4338ca;
  background: #e0e7ff;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.03em;
}

.flight-date {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  margin-right: 2px;
}

.flight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.88rem;
}
.flight-row:first-child {
  background: var(--primary-bg);
}
.flight-row-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.flight-row-link:hover {
  background: var(--primary-bg);
  box-shadow: var(--shadow-sm);
}
.flight-row-link:first-child:hover {
  box-shadow: 0 1px 4px rgba(9, 29, 131, 0.15);
}
.flight-book-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.8rem;
  opacity: 0.4;
  transition: opacity var(--transition), transform var(--transition);
}
.flight-row-link:hover .flight-book-icon {
  opacity: 1;
  transform: translate(1px, -1px);
}
.flight-book-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--primary);
  opacity: 0;
  margin-top: 2px;
  transition: opacity var(--transition);
}
.flight-row-link:hover .flight-book-label {
  opacity: 1;
}

/* Best-pick flight highlight */
.flight-row-best {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1.5px solid #86efac;
  box-shadow: 0 1px 4px rgba(16, 185, 129, 0.12);
}
.flight-row-best:hover {
  background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.18);
}

/* User-selected flight highlight */
.flight-row-selected {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1.5px solid #93c5fd;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.12);
}
.flight-row-selected:hover {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.18);
}

/* Select button on flight rows */
.flight-select-btn {
  display: inline-block;
  padding: 2px 8px;
  margin-top: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1.5px solid var(--primary);
  border-radius: 4px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.flight-select-btn:hover {
  background: var(--primary);
  color: #fff;
}
.flight-select-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.flight-select-btn.selected:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.best-pick-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #047857;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  padding: 1px 7px;
  border-radius: 10px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.flight-times {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.flight-time {
  font-weight: 600;
  white-space: nowrap;
}
.flight-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.flight-stops {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
}
.flight-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.flight-nums {
  font-family: monospace;
}
.flight-fare-type {
  text-transform: capitalize;
}
.flight-airline {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.flight-duration {
  white-space: nowrap;
}
.flight-price {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--success);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}
.flight-ground-cost {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 400;
  color: #92400e;
  margin-left: 6px;
}
@media (max-width: 600px) {
  .flight-ground-cost {
    display: block;
    margin-left: 0;
    margin-top: 2px;
  }
}
.cross-airport-warning {
  background: #fef9c3;
  border-left: 4px solid #eab308;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.88rem;
  color: #713f12;
  margin: 4px 0;
}
.perdiem-locality {
  font-weight: 600;
  color: var(--primary);
}
.flight-error {
  padding: 12px;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 6px;
  font-size: 0.88rem;
}
.flight-cheapest {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 6px;
  font-size: 0.9rem;
  text-align: center;
}
.flight-cheapest:empty {
  display: none;
}
.flight-insights {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.85rem;
}
.insight-badge {
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}
.insight-text {
  color: var(--text-secondary);
}

/* --- Price History Chart --- */
.price-chart-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.price-chart-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin: 0 0 6px 0;
}
.price-chart-subtitle {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: #6b7280;
  font-size: 0.68rem;
}
.price-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 80px;
  overflow-x: auto;
  padding-bottom: 3px;
}
.price-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
  min-width: 28px;
  max-width: 48px;
  height: 100%;
  justify-content: flex-end;
  cursor: default;
  position: relative;
}
.price-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  opacity: 0.35;
  transition: opacity 0.2s;
  min-height: 4px;
}
.price-bar-col:hover .price-bar {
  opacity: 0.65;
}
.price-bar-col.cheapest .price-bar {
  background: #10b981;
  opacity: 0.85;
}
.price-bar-col.cheapest:hover .price-bar {
  opacity: 1;
}
.price-bar-col.midweek .price-bar {
  opacity: 0.55;
}
.price-bar-price {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
  display: none;
}
.price-bar-col:hover .price-bar-price,
.price-bar-col.cheapest .price-bar-price {
  display: block;
}
.price-bar-day {
  font-size: 0.6rem;
  color: var(--text-secondary);
  margin-top: 1px;
  line-height: 1;
}
.price-bar-date {
  font-size: 0.58rem;
  color: var(--text-secondary);
  opacity: 0.6;
  line-height: 1;
}
.price-chart-hint {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin: 4px 0 0;
  opacity: 0.7;
}
@media (max-width: 600px) {
  .price-chart {
    height: 64px;
  }
  .price-bar-col {
    min-width: 22px;
  }
}

/* --- Collapsible Summary Rows --- */
.collapsible-row {
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.collapsible-row:hover {
  background: var(--bg);
}
.row-toggle {
  display: inline-block;
  width: 1em;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform var(--transition);
  vertical-align: middle;
  margin-right: 4px;
}
.detail-row {
  display: none;
}
.detail-row.open {
  display: table-row;
}
.detail-row td {
  padding: 0 14px 12px 14px !important;
  border-bottom: 1px solid var(--border);
}
.detail-row td[colspan] {
  font-weight: 400 !important;
  color: var(--text-secondary) !important;
}
.summary-detail {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.84rem;
}
.summary-detail .breakdown {
  margin: 0;
}
.summary-detail .breakdown-row {
  padding: 4px 0;
}
.summary-detail p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}
.summary-detail .store-row {
  margin-top: 6px;
}

/* --- Toggle Button --- */
.toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 12px;
  cursor: pointer;
  margin-left: 8px;
  transition: all var(--transition);
}
.toggle-btn:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
}

/* --- Collapsible Cards --- */
.collapsible h3 {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.collapsible h3::after {
  content: '\25B2';
  font-size: 0.55rem;
  color: var(--text-muted);
  margin-left: auto;
  transition: transform var(--transition);
  flex-shrink: 0;
}
.collapsible.collapsed h3::after {
  transform: rotate(180deg);
}
.collapsible.collapsed .card-body {
  display: none;
}
.card-peek {
  display: none;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.collapsible.collapsed .card-peek {
  display: inline;
}
/* Flight cards: header also needs flex for peek */
.flight-card.collapsible .flight-card-header h3 {
  flex: 1;
  min-width: 0;
}
.flight-card.collapsible.collapsed .flight-route {
  display: none;
}

/* --- Nonstop Badge --- */
.nonstop-badge {
  background: var(--success-bg) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
  font-weight: 700;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 20px;
  }

  .input-panel {
    position: static;
  }

  .chat-panel {
    width: 100%;
    right: -100%;
  }

  header {
    padding: 20px;
  }

  header h1 {
    font-size: 1.35rem;
  }

  .usage-bar {
    padding: 10px 20px;
    gap: 12px;
    flex-wrap: wrap;
  }
}

/* === Search Analysis Card === */
.analysis-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 16px;
}

.analysis-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 0 20px;
}

.analysis-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.analysis-body {
  padding: 12px 20px 20px 20px;
}

.analysis-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
}

.analysis-text:last-child {
  margin-bottom: 0;
}

.analysis-text strong {
  color: var(--text);
  font-weight: 600;
}

.analysis-verdict {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.7;
}

.analysis-verdict.verdict-sw {
  background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 100%);
  border-left: 4px solid var(--sw-orange);
}

.analysis-verdict.verdict-other {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border-left: 4px solid var(--success);
}

@media (max-width: 640px) {
  .analysis-body {
    padding: 10px 16px 16px 16px;
  }
  .analysis-text {
    font-size: 13px;
  }
}

/* ── Team Size ── */
.hint-inline {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.team-multiplier {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.rental-car-row td {
  font-style: italic;
  color: var(--text-secondary);
}

/* ── Trip Map ── */
.trip-map {
  width: 100%;
  height: 400px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .trip-map {
    height: 300px;
  }
}

/* === Changelog === */
.changelog-page {
  grid-column: 1 / -1;
}

.changelog-header {
  margin-bottom: 20px;
}

.changelog-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.changelog-header .text-muted {
  font-size: 0.88rem;
  margin-top: 4px;
}

.changelog-entry {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 14px;
}

.changelog-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.changelog-version {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary);
}

.changelog-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.changelog-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.changelog-item {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.changelog-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.changelog-feature .changelog-badge {
  background: var(--primary-bg);
  color: var(--primary);
}

.changelog-improvement .changelog-badge {
  background: #fef3c7;
  color: #92400e;
}

.changelog-fix .changelog-badge {
  background: var(--success-bg);
  color: var(--success);
}

/* Add bottom padding to body for fixed usage bar */
body {
  padding-bottom: 44px;
}

/* === Mobile Responsive === */
@media (max-width: 600px) {
  /* --- Header --- */
  header {
    padding: 16px 16px 12px;
  }
  header h1 {
    font-size: 1.2rem;
  }
  .subtitle {
    font-size: 0.8rem;
  }

  /* --- Navigation --- */
  .top-nav {
    margin-top: 10px;
    gap: 2px;
    flex-wrap: wrap;
  }
  .nav-link {
    font-size: 0.78rem;
    padding: 8px 10px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* --- Main layout --- */
  main {
    padding: 12px;
    gap: 14px;
  }

  /* --- Input panel --- */
  .input-panel {
    padding: 16px;
  }

  /* --- Form fields: stack on mobile --- */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  /* --- Inputs: touch-friendly size --- */
  input[type="text"],
  input[type="date"],
  input[type="number"],
  input[type="month"],
  select {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom */
  }

  /* --- Buttons --- */
  .btn-primary {
    min-height: 48px;
    font-size: 1rem;
  }

  /* --- Export buttons: stack vertically --- */
  .export-buttons {
    flex-direction: column;
    gap: 8px;
  }
  .btn-export {
    min-height: 44px;
  }

  /* --- Summary table --- */
  #summary-table {
    font-size: 0.82rem;
  }
  #summary-table th,
  #summary-table td {
    padding: 10px 8px;
  }
  #summary-table .amount-col {
    width: 80px;
  }
  /* Hide details column on very narrow screens */
  #summary-table td:nth-child(2) {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #summary-table tfoot td {
    font-size: 0.95rem;
  }

  /* --- Results cards --- */
  .result-card,
  .summary-card,
  .analysis-card {
    border-radius: var(--radius-sm);
  }
  .card-header {
    padding: 14px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .card-body {
    padding: 12px;
  }

  /* --- Flight tabs --- */
  .flight-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .flight-tab {
    padding: 8px 10px;
    font-size: 0.8rem;
    min-width: 0;
    white-space: nowrap;
  }
  .flight-tab-label {
    font-size: 0.8rem;
  }
  .flight-tab-route {
    font-size: 0.65rem;
  }

  /* --- Flight links --- */
  .flight-links {
    flex-wrap: wrap;
    gap: 8px;
  }
  .flight-links a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* --- Chat toggle --- */
  .chat-toggle {
    bottom: 54px;
    right: 12px;
    width: 50px;
    height: 50px;
  }

  /* --- Chat panel: full-screen on mobile --- */
  .chat-panel {
    width: 100%;
    max-width: 100%;
  }

  /* --- Usage bar --- */
  .usage-bar {
    padding: 6px 12px;
    gap: 8px;
    font-size: 0.7rem;
  }
  .usage-bar .usage-label {
    font-size: 0.65rem;
  }
  .usage-bar .usage-reset {
    padding: 4px 10px;
    font-size: 0.7rem;
  }

  /* --- Map --- */
  .trip-map {
    height: 250px;
  }
  .map-legend {
    font-size: 0.75rem;
    flex-wrap: wrap;
  }

  /* --- Feedback dropdown --- */
  .feedback-form {
    padding: 16px;
  }

  /* --- Radio group (Specific/Month) --- */
  .radio-label {
    font-size: 0.8rem;
    padding: 8px 8px;
    min-height: 44px;
  }

  /* --- Loading spinner --- */
  .loading {
    padding: 40px 16px;
  }

  /* --- Help modal --- */
  .help-modal {
    width: 95vw;
    max-width: 95vw;
  }
}
