/* Light by default; dark follows the system unless the user picked a theme (data-theme on <html>,
   set by theme.js before first paint). The dark tokens are repeated for the manual choice. */
:root {
  color-scheme: light;
  --bg: #f5f6f8; --panel: #ffffff; --text: #1c2430; --muted: #6b7684; --line: #e3e7ec;
  --accent: #1f6feb; --accent-text: #ffffff; --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  --chip: #eef1f5; --row-hover: #f3f7ff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1419; --panel: #171d24; --text: #e6edf3; --muted: #8b96a3; --line: #2a333d;
    --accent: #4c8dff; --accent-text: #0b1220; --ok: #3fb950; --warn: #d29922; --bad: #f85149;
    --chip: #212932; --row-hover: #1c2633;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419; --panel: #171d24; --text: #e6edf3; --muted: #8b96a3; --line: #2a333d;
  --accent: #4c8dff; --accent-text: #0b1220; --ok: #3fb950; --warn: #d29922; --bad: #f85149;
  --chip: #212932; --row-hover: #1c2633;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
header h1 { margin: 0; font-size: 18px; }
header p { margin: 2px 0 0; color: var(--muted); }
/* minmax(0, 1fr) + min-width: 0: a grid track otherwise grows to its widest unbreakable content
   (a nowrap table) and the panels spill past a phone screen */
main { max-width: 1400px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
main > * { min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.ai { display: flex; gap: 8px; }
.ai textarea { flex: 1; min-height: 44px; resize: vertical; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; margin-top: 14px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { font: inherit; border: 0; border-radius: 6px; padding: 8px 16px; cursor: pointer; background: var(--accent); color: var(--accent-text); font-weight: 600; white-space: nowrap; }
button.secondary { background: var(--chip); color: var(--text); font-weight: 500; }
button:disabled { opacity: .55; cursor: default; }
.ages { display: flex; gap: 6px; }
.ages input { width: 56px; }
.ops { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.op { display: inline-flex; align-items: center; gap: 6px; background: var(--chip); border-radius: 999px; padding: 4px 10px; font-size: 13px; color: var(--text); }
.op input { width: auto; margin: 0; }
.op small { color: var(--muted); }
.actions { display: flex; gap: 10px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.status { display: flex; flex-wrap: wrap; gap: 8px; }
.st { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; min-width: 150px; }
.st b { display: block; }
.st span { color: var(--muted); font-size: 12px; }
.st.ok b::before { content: "● "; color: var(--ok); }
.st.skip b::before, .st.empty b::before { content: "● "; color: var(--warn); }
.st.error b::before { content: "● "; color: var(--bad); }
.st.wait b::before { content: "◌ "; color: var(--muted); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input { max-width: 280px; }
.toolbar select { width: auto; }
.count { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 980px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort=""] { cursor: default; }
tbody tr:hover { background: var(--row-hover); }
td.price { white-space: nowrap; font-weight: 600; }
td.price small { display: block; font-weight: 400; color: var(--muted); }
td.nowrap { white-space: nowrap; }
.stars { color: var(--warn); white-space: nowrap; }
.av { font-size: 12px; white-space: nowrap; }
.av .yes { color: var(--ok); } .av .few, .av .request { color: var(--warn); } .av .no { color: var(--bad); }
a { color: var(--accent); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--chip); color: var(--warn); margin-top: 2px; }
.error-box { color: var(--bad); margin-top: 8px; }
@media (max-width: 640px) {
  main { padding: 10px 16px; }
  .ai { flex-direction: column; }
}

/* header with account menu */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.account { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.account a { text-decoration: none; }

/* login page */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; font-size: 20px; }

/* admin page */
.users td, .users th { white-space: nowrap; }
.users { min-width: 760px; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 4px 10px; font-size: 12px; }
button.danger { background: var(--bad); color: #fff; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--chip); }
.badge.off { color: var(--bad); }
.notice { color: var(--ok); margin-top: 8px; }

/* offer detail page */
.offer-page { max-width: 1000px; }
.offer-page h2 { margin: 0 0 12px; font-size: 16px; }
.offer-page h3 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv .yes { color: var(--ok); } .kv .request { color: var(--warn); } .kv .no { color: var(--bad); }
.ourprice { border-color: var(--accent); }
.ourprice .big { font-size: 20px; color: var(--accent); }
.note { margin: 10px 0 0; color: var(--muted); }
.note.bad { color: var(--bad); }
table.plain { min-width: 0; }
table.plain td { border-bottom: 1px solid var(--line); }
.kind { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--chip); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.bar { flex: 1 1 0; min-width: 3px; background: var(--line); border-radius: 2px 2px 0 0; }
.bar.instant { background: var(--ok); }
.bar.stop { background: var(--bad); opacity: .55; }
.bar.no_flight { background: var(--warn); opacity: .55; }
.bar.current { background: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.bars-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.cheapest { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.cheapest .current { color: var(--accent); }
a.button { display: inline-block; text-decoration: none; border-radius: 6px; padding: 8px 16px; font-weight: 600; background: var(--accent); color: var(--accent-text); }
a.button.secondary { background: var(--chip); color: var(--text); font-weight: 500; }
td a.hotel-link { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
td a.hotel-link:hover { color: var(--accent); text-decoration-color: currentColor; }
@media (max-width: 640px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i.bar { display: inline-block; width: 10px; height: 10px; min-width: 0; flex: none; border-radius: 2px; outline-width: 1px; }
/* package and extras tables: on a phone each row becomes a small card, so the description
   (the column that matters) is not pushed into a horizontal scroll */
@media (max-width: 640px) {
  table.plain, table.plain tbody, table.plain tr, table.plain td { display: block; }
  table.plain tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.plain td { border: 0; padding: 2px 0; white-space: normal; }
  table.plain thead { display: none; }
}
.panel > h2 { margin: 0 0 8px; font-size: 16px; }

/* flight choice on the offer page */
.seg { display: inline-flex; gap: 4px; margin: 4px 0 10px; flex-wrap: wrap; }
.seg button { padding: 5px 12px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
table.flights td.pick { width: 28px; }
table.flights td.pick input { width: auto; margin: 2px 0 0; accent-color: var(--accent); }
table.flights tbody tr[data-flight] { cursor: pointer; }
table.flights tr.chosen { background: var(--row-hover); box-shadow: inset 3px 0 0 var(--accent); }
.m-only { display: none; }
#moreFlights { margin-top: 10px; }
details.fare { margin-top: 10px; }
details.fare summary { cursor: pointer; color: var(--accent); }
details.fare ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 2px; }
/* the previous price stays readable while the next flight is being priced */
.ourprice[aria-busy="true"] #ourPrice { opacity: .6; transition: opacity .2s; }
#recalcStatus:empty { display: none; }
@media (max-width: 640px) {
  .m-only { display: inline; }
  table.flights tr[data-flight] { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 6px; }
  table.flights tr[data-flight] td.pick { grid-row: span 4; }
}

/* price block: the operator's prices on top, the scheme (gross − commission = net, + markup = ours)
   under them, one column per currency */
.op-price { display: grid; gap: 2px; margin: 4px 0 12px; }
.op-amounts { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 20px; }
table.scheme { min-width: 0; width: auto; border-collapse: collapse; }
table.scheme th, table.scheme td { padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.scheme th { position: static; cursor: default; background: none; }
table.scheme th[scope="row"] { color: var(--muted); font-weight: 400; font-size: 14px; white-space: normal; padding-left: 0; }
table.scheme th[scope="col"] { text-align: right; }
table.scheme td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.scheme tbody tr:hover { background: none; }
table.scheme tr.sum td { font-weight: 600; }
table.scheme tr.ours th, table.scheme tr.ours td { border-bottom: 0; }
table.scheme tr.ours th { color: var(--text); font-weight: 600; }
table.scheme tr.ours td { font-size: 20px; font-weight: 700; color: var(--accent); }
.kv.facts { margin-top: 12px; }
/* the receipt: a plain-language note under every line */
.receipt { margin-top: 4px; }
table.scheme th[scope="row"] small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
table.scheme th[scope="row"] { color: var(--text); font-weight: 500; }
table.scheme td { vertical-align: top; }
table.scheme td .cur { color: var(--muted); font-size: 13px; font-weight: 400; }
table.scheme tr.ours td .cur { font-size: 14px; color: var(--accent); }
table.scheme tr.ours { background: color-mix(in srgb, var(--accent) 8%, transparent); }
table.scheme tr.ours th, table.scheme tr.ours td { padding-top: 10px; padding-bottom: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.panel-head h2 { margin: 0; }
.panel-head button { padding: 5px 12px; }
