:root {
  --bg: #0b0e14;
  --surface: #121721;
  --surface-2: #181f2c;
  --border: #232c3d;
  --text: #e6ebf5;
  --muted: #8b97ad;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --gold: #f59e0b;
  --gold-bg: rgba(245, 158, 11, 0.12);
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-code {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.brand-meta h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status-dot.ok {
  background: var(--green);
}

.status-dot.scanning {
  background: var(--gold);
  animation: pulse 1.2s ease-in-out infinite;
}

.status-dot.err {
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons & inputs */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #323e54;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.icon-btn:hover {
  color: var(--text);
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-inline input {
  accent-color: var(--accent);
}

select,
input[type="search"],
input[type="text"],
input[type="number"] {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
}

input[type="search"] {
  min-width: 190px;
}

/* Inline notice */
.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 9px 14px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* Main table */
.table-wrap {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}

.deals-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.deals-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.deals-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.deals-table tbody tr:last-child td {
  border-bottom: none;
}

.deals-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.num {
  text-align: right !important;
}

.action-col {
  text-align: right !important;
  width: 78px;
}

.dest-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.iata {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.city-name {
  font-weight: 500;
  color: var(--text);
}

.country-sub {
  font-size: 12px;
  color: var(--muted);
}

.leg-times {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
}

.leg-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.leg-meta.direct {
  color: var(--green);
}

.price-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.tier-tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: 1px;
}

.tier-tag.gold {
  color: var(--gold);
  background: var(--gold-bg);
}

.tier-tag.affordable {
  color: var(--green);
  background: var(--green-bg);
}

.median-delta {
  display: block;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--green);
  margin-top: 2px;
}

.link-btn {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
}

.link-btn:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.empty-cell {
  text-align: center;
  padding: 36px 16px !important;
  color: var(--muted);
}

/* Drawers */
.hidden {
  display: none !important;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 13, 0.7);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.drawer-wide {
  width: min(620px, 100vw);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
}

.drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > span {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.field input,
.field select {
  width: 100%;
}

.drawer-feedback {
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 6px;
}

.drawer-feedback.ok {
  background: var(--green-bg);
  color: var(--green);
}

.drawer-feedback.err {
  background: var(--red-bg);
  color: var(--red);
}

.drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.section-title {
  margin: 4px 0 0;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.subtable-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
}

.subtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.subtable th,
.subtable td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.subtable th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}

.subtable tbody tr:last-child td {
  border-bottom: none;
}

.pill-status {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
}

.pill-status.sent,
.pill-status.success {
  color: var(--green);
  background: var(--green-bg);
}

.pill-status.failed {
  color: var(--red);
  background: var(--red-bg);
}

.pill-status.running {
  color: var(--gold);
  background: var(--gold-bg);
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px 12px 36px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
