:root {
  --ink: #0B2545;
  --ink-2: #13315C;
  --ink-soft: #4A5D7E;
  --muted: #8895AE;
  --line: #E6E9F0;
  --line-strong: #D4DAE6;
  --bg: #F6F7FA;
  --card: #FFFFFF;
  --accent: #0B2545;
  --chip: #EEF1F7;
  --good: #1F7A4D;
  --warn: #B8621B;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #EDEFF4;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

.app {
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ───────── Top bar ───────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 13px;
}
.avatar-me {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #E6E9F0;
  color: var(--ink);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.back-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}
.back-btn:hover { background: var(--chip); }
.back-btn svg { width: 16px; height: 16px; stroke: var(--ink); }

/* ───────── Screens ───────── */
#screen-search, #screen-results {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.screen {
  flex: 1;
  padding: 0 20px 40px;
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ───────── Search screen ───────── */
.greeting {
  margin: 8px 0 4px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.headline {
  margin: 0 0 28px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
  text-wrap: pretty;
}
.headline em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}

.search-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 6px;
  box-shadow: 0 1px 2px rgba(11, 37, 69, 0.04);
}

.field {
  padding: 14px 16px 12px;
  border-radius: 14px;
  position: relative;
  cursor: text;
  transition: background 0.15s;
}
.field + .field { border-top: 1px solid var(--line); border-radius: 0; }
.field:last-of-type { border-radius: 0 0 14px 14px; }
.field:first-of-type { border-radius: 14px 14px 0 0; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.field input {
  border: none;
  outline: none;
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
  width: 100%;
  padding: 0;
  letter-spacing: 0.02em;
}
.field input::placeholder {
  color: #C3CAD8;
  font-weight: 400;
}
.field input[type="date"] {
  font-family: 'JetBrains Mono', monospace;
}
.field:focus-within { background: #FAFBFD; }

.search-btn {
  width: 100%;
  padding: 16px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  margin-top: 14px;
  transition: transform 0.1s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}
.search-btn:hover { background: var(--ink-2); }
.search-btn:active { transform: scale(0.98); }
.search-btn:disabled {
  background: var(--ink-soft);
  cursor: wait;
  opacity: 0.85;
}
.search-btn svg { width: 16px; height: 16px; }

.recent {
  margin-top: 32px;
}
.recent-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  padding-left: 4px;
}
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  font-family: inherit;
  text-align: left;
  width: 100%;
}
.recent-item:hover { border-color: var(--line-strong); }
.recent-item:active { transform: scale(0.99); }
.recent-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.recent-flight {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.recent-route {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.recent-date {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ───────── Results screen ───────── */
.flight-header {
  background: var(--ink);
  color: #fff;
  border-radius: 20px;
  padding: 20px 22px 22px;
  margin-top: 4px;
  position: relative;
  overflow: hidden;
}
.flight-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(255,255,255,0.06) 0%, transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(255,255,255,0.04) 0%, transparent 40%);
  pointer-events: none;
}
.fh-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.fh-flight {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  opacity: 0.85;
}
.fh-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.route {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  position: relative;
}
.route-end {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.route-end.right { align-items: flex-end; }
.route-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
}
.route-city {
  font-size: 12px;
  opacity: 0.65;
  margin-top: 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.route-end.right .route-city { text-align: right; }
.route-line {
  position: relative;
  height: 1px;
  background: rgba(255,255,255,0.25);
  min-width: 40px;
}
.route-line::after {
  content: "";
  position: absolute;
  right: -4px;
  top: -3px;
  width: 0;
  height: 0;
  border-left: 7px solid rgba(255,255,255,0.7);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
.route-line::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
}

.fh-meta {
  display: flex;
  gap: 22px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed rgba(255,255,255,0.14);
}
.fh-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.fh-meta-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.55;
  font-weight: 500;
}
.fh-meta-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Crew sections */
.section {
  margin-top: 28px;
}
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.section-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.crew-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.crew-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  transition: border-color 0.15s, transform 0.1s;
}
.crew-card:hover { border-color: var(--line-strong); }

.crew-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: #fff;
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
}

.crew-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.crew-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crew-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.crew-meta .dot {
  width: 2px; height: 2px;
  background: var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
}
.crew-base {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.crew-seniority {
  color: var(--muted);
}

.crew-side {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.role-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.06em;
  background: var(--chip);
  color: var(--ink);
}
.role-badge.cp { background: var(--ink); color: #fff; }
.role-badge.fo { background: #E7ECF5; color: var(--ink); }
.role-badge.cc { background: #F2E8DE; color: #6B4A2B; }
.role-badge.fa { background: #EEF1F7; color: var(--ink-soft); }

/* S1 = senior crew. Warm sand chip sits to the left of the role badge. */
.s1-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 6px;
  background: #F2E8DE;
  color: #6B4A2B;
}

/* Card-level accent so the row stands out at a glance even when scanning. */
.crew-card.is-s1 {
  background: linear-gradient(180deg, #FBF6F0 0%, #FFFFFF 100%);
  border-color: #E6D6C2;
}
.crew-card.is-s1:hover { border-color: #D8C2A6; }

/* Empty / loading / error state */
.state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}
.state strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.state .mono {
  font-family: 'JetBrains Mono', monospace;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden { display: none !important; }

.app::-webkit-scrollbar { display: none; }
