:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232635;
  --accent: #4f8ef7;
  --accent2: #7c5cbf;
  --text: #e8eaf0;
  --text-muted: #8892a4;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --border: #2a2d3a;
  --radius: 10px;
}

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-title { font-size: 1.1rem; font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.top-email { color: var(--text-muted); }
.top-link { color: var(--text-muted); }
.top-link:hover { color: var(--text); }
.back-btn { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.back-btn:hover { color: var(--text); text-decoration: none; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }

/* Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.login-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 32px; }
.login-error {
  background: rgba(231, 76, 60, 0.15);
  color: var(--danger);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: 6px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #333;
  border: none;
  border-radius: 6px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.google-btn:hover { box-shadow: 0 2px 12px rgba(79, 142, 247, 0.3); text-decoration: none; color: #333; }
.google-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.back-link { color: var(--text-muted); font-size: 0.9rem; display: inline-block; margin-top: 20px; }

/* Search */
.search-bar {
  margin-bottom: 20px;
}
.search-input {
  width: 100%;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }
.search-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 40px 20px;
  display: none;
}

/* Trip sections */
.trip-section { margin-bottom: 36px; }
.section-heading { font-size: 1.3rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.section-heading.muted { color: var(--text-muted); }
.count-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}
.empty-text { color: var(--text-muted); font-style: italic; }

/* Trip grid */
.trip-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) { .trip-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .trip-grid { grid-template-columns: repeat(3, 1fr); } }

/* Trip card */
.trip-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
}
.trip-card.status-confirmed-border { border-left-color: var(--success); }
.trip-card.status-planning-border { border-left-color: var(--warning); }
.trip-card.status-completed-border { border-left-color: var(--text-muted); }
.trip-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(79, 142, 247, 0.1);
  text-decoration: none;
}
.trip-card-past { opacity: 0.7; }
.trip-card-past:hover { opacity: 1; }
.trip-card.search-hidden { display: none; }
.card-flag { font-size: 1.5rem; margin-bottom: 6px; }
.card-name { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.card-dates { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.card-destinations { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-bottom { display: flex; justify-content: space-between; align-items: center; }
.card-travelers { font-size: 0.75rem; color: var(--text-muted); }

/* Year separator */
.year-separator {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 20px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.year-separator.search-hidden { display: none; }
.past-section .trip-grid { display: block; }
.past-section .trip-card { margin-bottom: 8px; display: flex; gap: 12px; align-items: center; padding: 12px 16px; }
.past-section .trip-card.search-hidden { display: none; }
.past-section .card-flag { font-size: 1.2rem; margin-bottom: 0; flex-shrink: 0; }
.past-section .card-name { font-size: 0.9rem; }
.past-section .card-dates { margin-bottom: 0; }
.past-section .card-destinations { margin-bottom: 0; }
.past-section .card-bottom { margin-left: auto; flex-shrink: 0; }

/* Status badges */
.status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
}
.status-confirmed { background: rgba(46, 204, 113, 0.15); color: var(--success); }
.status-planning { background: rgba(243, 156, 18, 0.15); color: var(--warning); }
.status-completed { background: rgba(136, 146, 164, 0.15); color: var(--text-muted); }
.scope-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(124, 92, 191, 0.15);
  color: var(--accent2);
  margin-left: 6px;
}

/* Landing subheader */
.landing-subheader {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* Trip Hero */
.trip-hero {
  padding: 32px 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
}
.trip-hero.hero-confirmed { background: linear-gradient(135deg, var(--surface) 0%, rgba(46, 204, 113, 0.08) 100%); }
.trip-hero.hero-planning { background: linear-gradient(135deg, var(--surface) 0%, rgba(243, 156, 18, 0.08) 100%); }
.trip-hero.hero-completed { background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%); }
.hero-name { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.hero-meta { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-flags { font-size: 1.3rem; }
.hero-destinations { color: var(--text); font-weight: 500; }
.hero-duration { color: var(--accent); font-weight: 500; }
.hero-badges { margin-top: 12px; display: flex; gap: 8px; }

/* Detail sections */
.detail-section { margin-bottom: 28px; }
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title.clickable {
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  padding: 4px 8px;
  margin: -4px -8px 12px;
}
.section-title.clickable:hover { background: var(--surface2); color: var(--accent); }
.section-title.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.collapse-icon { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }
.collapsible .section-body {
  overflow: hidden;
  transition: grid-template-rows 0.3s ease;
  display: grid;
  grid-template-rows: 1fr;
}
.collapsible.collapsed .section-body { grid-template-rows: 0fr; }
.collapsible .section-body > * { overflow: hidden; }
.collapsible.collapsed .collapse-icon { transform: rotate(-90deg); }

/* Empty state for detail sections */
.section-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
  padding: 12px 0;
}

/* Entity cards */
.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.entity-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.entity-route { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; }
.entity-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 8px; }
.tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(79, 142, 247, 0.15);
  color: var(--accent);
}
.tag-confirmed { background: rgba(46, 204, 113, 0.15); color: var(--success); }

/* Entity grid */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 16px;
}
.eg-item { display: flex; flex-direction: column; padding: 4px 0; }
.eg-item.eg-full { grid-column: 1 / -1; }
.eg-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.eg-value { font-size: 0.85rem; }

/* Extras */
.extras-table { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.extras-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }
.extras-nested { margin-left: 12px; font-size: 0.83rem; }

/* Timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-date-group { margin-bottom: 20px; }
.timeline-date-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  position: relative;
}
.timeline-entry {
  position: relative;
  margin-bottom: 6px;
}
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.dot-flight { background: var(--accent); }
.dot-train { background: #e67e22; }
.dot-hotel_checkin, .dot-hotel_checkout { background: var(--accent2); }
.dot-transfer { background: #1abc9c; }
.dot-event { background: var(--warning); }
.dot-excursion { background: #2ecc71; }
.dot-restaurant { background: #e74c3c; }
.timeline-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.timeline-content.clickable { cursor: pointer; }
.timeline-content.clickable:hover { background: var(--surface2); }
.timeline-content.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.timeline-time { font-size: 0.75rem; color: var(--text-muted); min-width: 36px; }
.timeline-icon { font-size: 1rem; }
.timeline-label { flex: 1; }
.timeline-detail {
  margin-left: 54px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.timeline-detail.hidden { display: none; }

/* Alert boxes */
.alert-box {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.alert-warning { background: rgba(243, 156, 18, 0.1); border: 1px solid rgba(243, 156, 18, 0.3); color: var(--warning); }
.alert-info { background: rgba(79, 142, 247, 0.1); border: 1px solid rgba(79, 142, 247, 0.3); color: var(--accent); }

/* Note box */
.note-box {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* Timeline toggle all */
.timeline-toggle-all {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--accent);
  margin-left: auto;
  cursor: pointer;
  text-transform: lowercase;
}
.timeline-toggle-all:hover { text-decoration: underline; }

/* Budget */
.budget-totals { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.budget-total { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.budget-breakdown { margin-bottom: 8px; }
.budget-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.budget-category { color: var(--text-muted); text-transform: capitalize; flex: 1; }
.budget-amount { font-weight: 500; text-align: right; min-width: 100px; }
.budget-bar {
  flex: 1;
  max-width: 120px;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  margin: 0 12px;
  overflow: hidden;
}
.budget-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}
.budget-computed { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: var(--accent2); }

/* Responsive */
@media (max-width: 480px) {
  .hero-name { font-size: 1.4rem; }
  .container { padding: 12px 10px; }
  .login-card { padding: 32px 24px; }
  .entity-grid { grid-template-columns: 1fr; }
  .top-email { display: none; }
  .budget-bar { display: none; }
}

/* Print */
@media print {
  body { background: #fff; color: #000; }
  .top-bar, .back-to-top, .collapse-icon, .timeline-toggle-all, .search-bar { display: none; }
  .trip-hero { background: none; border: 1px solid #ccc; }
  .entity-card { border-color: #ccc; break-inside: avoid; }
  .collapsible.collapsed .section-body { grid-template-rows: 1fr !important; }
  .timeline-detail.hidden { display: block; }
  .alert-warning { border-color: #f39c12; }
  .alert-info { border-color: #4f8ef7; }
  a { color: #000; }
  .status-badge, .scope-badge, .tag { border: 1px solid #ccc; }
}
