:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #16202c;
  --muted: #6b7a8d;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --ok: #0f9d58;
  --err: #d93025;
  --warn: #b7791f;
  --shadow: 0 1px 3px rgba(16, 32, 48, .08), 0 8px 24px rgba(16, 32, 48, .06);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1520;
    --panel: #161f2c;
    --ink: #e8eef6;
    --muted: #93a3b8;
    --line: #263243;
    --brand: #4b83f0;
    --ok: #37c26f;
    --err: #ef5350;
    --warn: #e0a33e;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ---------- auth pages ---------- */
body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
}

.auth-logo { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.auth-card h1 { font-size: 21px; margin: 0 0 6px; }
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.auth-card form { text-align: left; }
.auth-foot { margin: 18px 0 0; font-size: 14px; }

/* ---------- forms ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 6px;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}

select[multiple] { padding: 4px; }
select[multiple] option { padding: 6px 8px; border-radius: 4px; }
select[multiple] option:checked { background: var(--brand); color: #fff; }

.picker-filter { margin-bottom: 6px; font-size: 14px; padding: 8px 10px; }

/* comma-delimited selection mirror */
.chosen {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
  letter-spacing: .02em;
  margin-bottom: 6px;
}

/* suggest-nearby */
.sugg-bar { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.radius { width: auto; padding: 5px 8px; font-size: 12.5px; }
.sugg {
  margin-top: 8px; padding: 10px;
  border: 1px dashed var(--line); border-radius: 8px; background: var(--bg);
}
.sugg-chip {
  display: inline-block; margin: 3px 4px 3px 0; padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink);
}
.sugg-chip:hover { border-color: var(--brand); color: var(--brand); }
.sugg-chip strong { margin-right: 4px; }

/* live progress */
.progress-box {
  margin-top: 14px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.progress-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 9px;
}
#progressPct { font-size: 19px; font-weight: 700; color: var(--brand); min-width: 52px; }
.progress-track {
  height: 9px; border-radius: 999px; background: var(--line); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--ok));
  border-radius: 999px; transition: width .5s ease;
}
.progress-fill.indeterminate { animation: slide 1.4s ease-in-out infinite; }
@keyframes slide {
  0%   { margin-left: 0;   width: 18%; }
  50%  { margin-left: 82%; width: 18%; }
  100% { margin-left: 0;   width: 18%; }
}
#progressFound { margin-top: 8px; }

/* run-cost estimate */
.cost {
  margin-top: 18px; padding: 11px 14px; border-radius: 8px;
  background: rgba(37,99,235,.07); border: 1px solid rgba(37,99,235,.2);
  font-size: 13.5px;
}
.warn-time { color: var(--warn); }

/* exact vs flexible date mode */
.flex-only { display: none; }
body.is-flex .flex-only { display: flex; }
.lbl-flex { display: none; }
body.is-flex .lbl-flex { display: inline; }
body.is-flex .lbl-exact { display: none; }

.combo-box {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
}

/* pin button */
.pin {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; cursor: pointer; font-size: 13px; line-height: 1;
  filter: grayscale(1); opacity: .5; margin-right: 4px;
}
.pin:hover { opacity: .9; }
.pin.on { filter: none; opacity: 1; border-color: var(--brand); background: rgba(37,99,235,.12); }

/* comparison table */
.cmp-tbl th.rowlab {
  text-align: right; white-space: nowrap; width: 130px;
  color: var(--muted); font-weight: 600; vertical-align: middle;
}
.cmp-tbl thead th { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.cmp-tbl td { vertical-align: middle; min-width: 170px; }
#compareWrap { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }

/* selection is click-to-toggle, so make the hit area feel like a list */
select[multiple] option { cursor: pointer; }

/* price movement on pinned deals */
.up   { color: var(--err); font-weight: 700; }
.down { color: var(--ok);  font-weight: 700; }
.flat { color: var(--muted); }

/* scope toggle */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn {
  background: transparent; color: var(--muted); border: 0;
  padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--brand); color: #fff; }

.ctx { font-size: 13px; margin-bottom: 12px; line-height: 1.5; }

/* deal type badges */
.kind {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
}
.kind-pkg    { background: rgba(37,99,235,.14);  color: #2563eb; }
.kind-hotel  { background: rgba(139,92,246,.16); color: #7c4dff; }
.kind-flight { background: rgba(230,126,34,.16); color: #d3711a; }
.kind-ai     { background: rgba(15,157,88,.16);  color: var(--ok); }

/* airline chips, tinted with the carrier colour */
.chip {
  display: inline-block; margin: 1px 3px 1px 0; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: var(--chip); background: color-mix(in srgb, var(--chip) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 38%, transparent);
}
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .chip { background: transparent; border-color: var(--chip); }
}

.price { font-size: 15px; }
.best {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--ok); color: #fff; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
tr.row-best td { background: rgba(15,157,88,.07); }
.tiny { font-size: 11px; }

/* hotel cell in the deals table */
.hotel { line-height: 1.35; min-width: 190px; }
.hotel-name { font-weight: 600; }
.hotel-cost { font-size: 13px; }
.hotel-meta { font-size: 12px; color: var(--muted); }

small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 400;
  font-size: 14px;
  margin-top: 16px;
}
.check input { width: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 22px; }

/* ---------- alerts ---------- */
.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}
.alert-error { background: rgba(217, 48, 37, .1); color: var(--err); border: 1px solid rgba(217, 48, 37, .25); }
.alert-ok    { background: rgba(15, 157, 88, .1); color: var(--ok);  border: 1px solid rgba(15, 157, 88, .25); }

/* ---------- app chrome ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }

.wrap { width: 90%; max-width: 2200px; margin: 0 auto; padding: 22px 0 60px; }
@media (max-width: 900px) { .wrap { width: 96%; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.panel h2 { margin: 0 0 16px; font-size: 17px; }

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters input { width: auto; max-width: 150px; padding: 7px 10px; font-size: 14px; }

.grid { display: block; }
.field { margin-bottom: 4px; }
.field-row { display: flex; flex-wrap: wrap; gap: 14px; }
.field-row .field { flex: 1 1 150px; }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }

.run-status { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.run-status.ok  { color: var(--ok); }
.run-status.err { color: var(--err); }

.spin {
  width: 13px; height: 13px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  display: inline-block;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.tbl th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.tbl tbody tr:hover { background: rgba(127, 143, 166, .07); }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pill-ok     { background: rgba(15, 157, 88, .14); color: var(--ok); }
.pill-empty  { background: rgba(183, 121, 31, .16); color: var(--warn); }
.pill-error  { background: rgba(217, 48, 37, .12); color: var(--err); }

@media (max-width: 640px) {
  .wrap { padding: 14px 12px 48px; }
  .panel { padding: 16px; }
  .filters input { max-width: 110px; }
}
