:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f1ede4;
  --ink: #1d232b;
  --muted: #6b7380;
  --line: #e3ddd1;
  --accent: #e8590c;
  --accent-2: #0f766e;
  --od: #1971c2;
  --ekipa: #e8590c;
  --good: #2f9e44;
  --bad: #e03131;
  --warn: #f08c00;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 6px 24px rgb(0 0 0 / .06);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161b; --surface: #1a2027; --surface-2: #222a33; --ink: #e9edf1; --muted: #98a2ae;
    --line: #2d3640; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 24px rgb(0 0 0 / .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161b; --surface: #1a2027; --surface-2: #222a33; --ink: #e9edf1; --muted: #98a2ae;
  --line: #2d3640; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.1rem; margin-bottom: .5rem; }
a { color: var(--accent-2); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.mt { margin-top: 2rem; }

/* ── top bar ── */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: .6rem; min-width: max-content; }
.brand h1 { font-size: 1.25rem; }
.brand .sub { margin: 0; font-size: .78rem; color: var(--muted); }
.logo { font-size: 1.8rem; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .me {
  border: 0; background: transparent; color: var(--ink); font: 500 .9rem var(--font);
  padding: .5rem .75rem; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); }
.tabs button.active { background: var(--ink); color: var(--bg); }
.me { background: var(--surface-2); }
.banner { padding: .5rem 1rem; background: #fff3bf; color: #5c3c00; font-size: .85rem; text-align: center; }

main { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; overflow: auto; }
.view.active { display: block; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.section-head { margin-bottom: 1.25rem; }
.section-head p { margin: .25rem 0 0; }

/* ── buttons & forms ── */
button { font-family: var(--font); }
.primary, .ghost {
  border-radius: 10px; padding: .55rem 1rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-size: .9rem;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { filter: brightness(1.08); }
.primary.big { padding: .9rem 1.4rem; font-size: 1.05rem; }
.primary:disabled { opacity: .5; cursor: wait; }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.ghost:hover { background: var(--surface-2); }
.tiny { padding: .2rem .55rem; font-size: .78rem; border-radius: 8px; }
.form { display: flex; flex-direction: column; gap: .6rem; }
.form.inline { flex-direction: row; flex-wrap: wrap; margin-bottom: 1rem; }
.form.inline input { flex: 1 1 160px; }
.form .row { display: flex; gap: .5rem; }
.form .row > * { flex: 1; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: .55rem .7rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form.inline input, .form.inline select { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.checks label, .chips label { display: inline-flex; align-items: center; gap: .3rem; font-size: .88rem; cursor: pointer; }
.checks input, .chips input { width: auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin: 1rem 0; }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }

/* ── map view ── */
#view-map.active { display: grid; grid-template-columns: 360px 1fr; height: 100%; overflow: hidden; }
#map { height: 100%; width: 100%; background: var(--surface-2); position: relative; isolation: isolate; }
.panel { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; z-index: 500; }
.panel-head { display: flex; gap: .4rem; padding: .75rem .75rem .25rem; }
#panelToggle { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; padding: .35rem .75rem; }
.chips.small { gap: .75rem; align-items: center; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: .2rem .6rem; font-size: .78rem; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.place-list { list-style: none; margin: 0; padding: .25rem .5rem 1rem; overflow-y: auto; flex: 1; }
.place-list li {
  display: grid; grid-template-columns: 30px 1fr auto; gap: .5rem; align-items: center;
  padding: .5rem; border-radius: 10px; cursor: pointer;
}
.place-list li:hover, .place-list li.sel { background: var(--surface-2); }
.place-list .ico { font-size: 1.2rem; text-align: center; }
.place-list .nm { font-weight: 500; font-size: .9rem; line-height: 1.25; }
.place-list .meta { font-size: .75rem; color: var(--muted); }
.place-list .score { font-size: .75rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; background: var(--surface-2); }
.place-list .score.pos { background: #d3f9d8; color: #1b5e20; }
.place-list .score.neg { background: #ffe3e3; color: #a61e1e; }
.legend {
  position: absolute; right: 12px; bottom: 22px; z-index: 600; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: .35rem .7rem; font-size: .75rem; display: flex; gap: .8rem; box-shadow: var(--shadow);
}
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .3);
}
.pin span { transform: rotate(45deg); font-size: 16px; line-height: 1; }
.pin.hot { outline: 3px solid #fab005; }
.pin .badge {
  position: absolute; top: -8px; right: -10px; transform: rotate(45deg); background: #2f9e44; color: #fff;
  font: 700 10px var(--font); border-radius: 999px; padding: 1px 5px; border: 1.5px solid #fff;
}
.leaflet-popup-content-wrapper { border-radius: 14px; background: var(--surface); color: var(--ink); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 14px 16px; width: 300px !important; font: 14px/1.45 var(--font); }
.pop h4 { margin: 0 0 .2rem; font: 600 1.05rem var(--display); }
.pop .tags { display: flex; gap: .35rem; flex-wrap: wrap; margin: .35rem 0; }
.pop .tag { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); }
.pop p { margin: .35rem 0; }
.votes { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; margin: .5rem 0 .3rem; }
.votes button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px;
  padding: .35rem .2rem; font-size: .75rem; cursor: pointer; line-height: 1.2;
}
.votes button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.voters { font-size: .78rem; color: var(--muted); }
.voters b { color: var(--ink); font-weight: 600; }

/* ── tables ── */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td[contenteditable] { cursor: text; }
td[contenteditable]:hover { background: var(--surface-2); }
td[contenteditable]:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
.itin td:first-child { white-space: nowrap; font-weight: 600; }
.itin .dow { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }
.itin .col-ekipa { border-left: 3px solid var(--ekipa); }
.itin .col-od { border-left: 3px solid var(--od); }
tr.total td { font-weight: 700; background: var(--surface-2); }

/* ── ideas ── */
.filters { display: flex; gap: .3rem; flex-wrap: wrap; margin: 1rem 0 .6rem; }
.wish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.wish { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem .9rem; display: flex; flex-direction: column; gap: .4rem; }
.wish .top { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--muted); }
.wish .txt { white-space: pre-wrap; }
.wish .foot { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.wish.must { border-left: 4px solid #fab005; }
.wish.nogo { border-left: 4px solid var(--bad); }
.wish.need { border-left: 4px solid var(--accent-2); }
.wish.question { border-left: 4px solid var(--od); }
.wish.idea { border-left: 4px solid var(--accent); }
.plus { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: .1rem .55rem; font-size: .78rem; cursor: pointer; }
.plus.on { background: #d3f9d8; border-color: #8ce99a; color: #1b5e20; }
.who-pill { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; color: #fff; }
.pref-grid { display: grid; grid-template-columns: auto 1fr; gap: .5rem .8rem; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); color: var(--ink); padding: .35rem .6rem; font-size: .82rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }

/* ── stays ── */
.scenarios { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin-top: 1rem; }
.scen { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .5rem; cursor: pointer; }
.scen.best { border-color: var(--good); }
.scen.picked { box-shadow: 0 0 0 4px rgb(232 89 12 / .25); border-color: var(--accent); }
.scen .price { font: 700 1.6rem var(--display); }
.scen .bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.scen .bar i { display: block; height: 100%; background: var(--good); }
.scen ul { margin: 0; padding-left: 1.1rem; font-size: .85rem; }
.ribbon { align-self: flex-start; font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: #d3f9d8; color: #1b5e20; }
.params { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem 1rem; }
.params label { font-size: .8rem; color: var(--muted); display: flex; flex-direction: column; gap: .2rem; }
.offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem; }
.offer { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 .9rem .9rem; display: flex; flex-direction: column; gap: .35rem; overflow: hidden; }
.offer-img { display: block; width: calc(100% + 1.8rem); margin: 0 -.9rem .3rem; aspect-ratio: 3 / 2; object-fit: cover; background: var(--surface-2); }
.offer-img.ph { display: grid; place-items: center; font-size: 3rem; }
.offer .t { font-weight: 600; }
.offer .p { font: 700 1.2rem var(--display); }
.offer .src { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* ── flights ── */
.flight { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin-bottom: .6rem; }
.flight.ekipa { border-left-color: var(--ekipa); }
.flight.od { border-left-color: var(--od); }
.flight .route { font-weight: 600; }
.flight .src { font-size: .78rem; color: var(--muted); }
.flight .pp { font: 700 1.3rem var(--display); text-align: right; cursor: pointer; }
.flight .st { font-size: .7rem; padding: .05rem .45rem; border-radius: 99px; background: #fff3bf; color: #5c3c00; }
.flight .st.live { background: #d3f9d8; color: #1b5e20; }
.flight .opts { grid-column: 1 / -1; font-size: .85rem; }
.flight .opts table { margin-top: .4rem; }

/* ── costs ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .v { font: 700 1.6rem var(--display); }
.kpi .l { font-size: .78rem; color: var(--muted); }
.stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); min-width: 120px; }
.stack i { display: block; height: 100%; }
.vacc { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.vacc:last-child { border-bottom: 0; }
.vacc .note { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); }
.vacc .who { grid-column: 1 / -1; display: flex; gap: .25rem; flex-wrap: wrap; }

/* ── AI ── */
.ai-actions { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; flex-wrap: wrap; }
.md { line-height: 1.6; overflow-x: auto; }
.md h2 { font-size: 1.3rem; margin: 1.4rem 0 .5rem; }
.md h2:first-child { margin-top: 0; }
.md table { margin: .5rem 0; border: 1px solid var(--line); }
.md td, .md th { position: static; }
.meter { display: grid; grid-template-columns: 90px 1fr 42px; align-items: center; gap: .6rem; margin: .35rem 0; font-size: .88rem; }
.meter .bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 99px; }

/* ── dialog ── */
dialog { border: 0; border-radius: 18px; padding: 1.4rem; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog::backdrop { background: rgb(15 20 25 / .55); backdrop-filter: blur(3px); }
.who-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.who-list button { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: .45rem .9rem; cursor: pointer; font-weight: 600; }
.who-list button:hover { border-color: var(--accent); }

/* ── mobile ── */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding: .5rem 16px; gap: .4rem; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; }
  .tabs button span { display: none; }
  .tabs button { font-size: 1.15rem; padding: .35rem .6rem; }
  .wrap { padding: 1rem 16px 4rem; }
  #view-map.active { display: block; position: relative; }
  #map { position: absolute; inset: 0; }
  .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 60%; border-radius: 18px 18px 0 0; border: 1px solid var(--line); box-shadow: 0 -6px 24px rgb(0 0 0 / .15); }
  .panel.collapsed { max-height: 64px; overflow: hidden; }
  #panelToggle { display: block; }
  .legend { top: 10px; bottom: auto; left: 56px; right: auto; }
  .leaflet-popup-content { width: 250px !important; }
  .grid2 { grid-template-columns: 1fr; }
  h2 { font-size: 1.4rem; }
}

.offer-group { font: 600 1rem var(--display); margin: 1.4rem 0 .6rem; }
.scen table { font-size: .82rem; }
.scen table td { padding: .3rem .2rem; }

/* ── zdjęcia ── */
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; }
.thumb.ph { display: grid; place-items: center; font-size: 1.3rem; }
.place-list li { grid-template-columns: 44px 1fr auto; }
.pop-img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-bottom: .5rem; background: var(--surface-2); }
.pop-img.ph { display: grid; place-items: center; font-size: 2.4rem; }
.credit { font-size: .72rem; color: var(--muted); }
.scen { overflow: hidden; }
.scen-img { display: block; width: calc(100% + 2.2rem); margin: -1rem -1.1rem .4rem; aspect-ratio: 16 / 7; object-fit: cover; background: var(--surface-2); }
.scen-img.ph { display: grid; place-items: center; font-size: 2.4rem; }
.rank-place { display: flex; gap: .6rem; align-items: center; }

/* ── porównanie lotów ── */
.cmp-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; margin-bottom: .6rem; }
.cmp-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cmp-chart-group { margin: .8rem 0; }
.cmp-chart-date { font-weight: 700; font-size: .85rem; margin-bottom: .3rem; }
.cmp-bar-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 2fr) auto; gap: .6rem; align-items: center; padding: .3rem .4rem; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .85rem; }
.cmp-bar-row:hover { background: var(--surface-2); }
.cmp-bar { height: 14px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cmp-bar i { display: block; height: 100%; border-radius: 99px; }
.cmp-bar-val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmp-dates { margin: 1rem 0 .5rem; }
.cmp-dates button { padding: .55rem .9rem; font-size: .9rem; }
.cmp-group { margin: .5rem 0 1rem; font-size: .9rem; }
.cmp-card { margin: .8rem 0; scroll-margin-top: 90px; }
.cmp-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.cmp-head h3 { margin-bottom: .3rem; }
.cmp-total { font: 700 1.7rem var(--display); text-align: right; }
.cmp-total .muted { font: 400 .78rem var(--font); }
.cmp-costs { list-style: none; padding: 0; margin: .6rem 0; display: grid; gap: .3rem; font-size: .88rem; }
.cmp-costs li { display: grid; grid-template-columns: 1fr auto auto; gap: .8rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.cmp-leg { margin-top: .9rem; }
.cmp-leg-head { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; font-size: .92rem; }
.cmp-time { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin: .4rem 0; font-size: .72rem; }
.cmp-time i { display: flex; align-items: center; padding: 0 .4rem; white-space: nowrap; overflow: hidden; font-style: normal; color: #fff; }
.cmp-time i.fly { background: #4c6ef5; }
.cmp-time i.wait { background: repeating-linear-gradient(45deg, #f08c00, #f08c00 6px, #f59f00 6px, #f59f00 12px); }
.cmp-steps { margin: .2rem 0 0; padding-left: 1.2rem; font-size: .86rem; display: grid; gap: .2rem; }
.cmp-steps li.wait { color: #c76d00; }
.cmp-note { font-size: .82rem; margin: .3rem 0 0; }
@media (max-width: 820px) {
  .cmp-bar-row { grid-template-columns: 1fr auto; }
  .cmp-bar-row .cmp-bar { grid-column: 1 / -1; grid-row: 2; }
  .cmp-costs li { grid-template-columns: 1fr auto; }
  .cmp-costs li a, .cmp-costs li > .muted { grid-column: 1 / -1; }
}
