/* Medibot Mini App — wyglad wg makiety (miniapp_plan/makieta).
   Paleta makiety = motyw ciemny i domyslny; jasny wyprowadzony z niej.
   Motyw wybiera app.js (Telegram.WebApp.colorScheme, poza Telegramem ?motyw=). */

:root, :root[data-theme="dark"] {
  --bg: #0F1720;
  --card: #1A2430;
  --line: #263342;
  --divider: #1E2A37;
  --text: #E8EEF4;
  --text2: #8FA0B2;
  --text3: #C9D5E1;
  --accent: #5CB0F0;
  --accent-text: #7CC0F5;
  --on-accent: #08131D;
  --green: #3DBE7A;
  --on-green: #06180E;
  --green-soft: #1F3A2C;
  --green-text: #8BE0B0;
  --green-strong: #6FD69C;
  --green-line: #2F5A43;
  --amber: #E3A13B;
  --red: #E5534B;
  --chip: #22303F;
  --input-line: #2F3D4E;
  --btn-2: #2A3646;
  --danger-text: #F2B8B5;
  --track-off: #3A4757;
  --icon-found: #1C3247;
  --scrim: rgba(5, 10, 15, .62);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

:root[data-theme="light"] {
  --bg: #F2F5F8;
  --card: #FFFFFF;
  --line: #DCE3EA;
  --divider: #E2E8EE;
  --text: #0F1720;
  --text2: #5B6B7C;
  --text3: #33475B;
  --accent: #2B8AD4;
  --accent-text: #1C76BE;
  --on-accent: #FFFFFF;
  --green: #2EA567;
  --on-green: #FFFFFF;
  --green-soft: #DDF2E6;
  --green-text: #1C7447;
  --green-strong: #1F8A52;
  --green-line: #9FD8B8;
  --amber: #C98418;
  --red: #C93A33;
  --chip: #E8EEF3;
  --input-line: #C9D3DD;
  --btn-2: #E6ECF1;
  --danger-text: #B3261E;
  --track-off: #C2CCD6;
  --icon-found: #DCEAF7;
  --scrim: rgba(15, 23, 32, .45);
  --shadow: 0 10px 30px rgba(15, 23, 32, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent-text); }

/* ---------- uklad ekranu: gora / przewijana tresc / dolny pasek ---------- */
/* Wysokosc = widoczny obszar Telegrama (zmienna ustawia telegram-web-app.js),
   poza nim 100dvh. BEZ min-height: przy nizszym oknie Telegrama dolny pasek i
   koniec listy wychodzily poza ekran. */
.screen {
  height: var(--tg-viewport-stable-height, 100dvh);
  display: flex; flex-direction: column; overflow: hidden;
  max-width: 560px; margin: 0 auto;
}
.top { padding: 20px 16px 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top.sub { padding: 14px 8px 6px; justify-content: flex-start; gap: 4px; }
.top-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--text2); letter-spacing: .02em; }
.h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.h2 { font-size: 22px; font-weight: 800; }
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.back-btn { width: 44px; height: 44px; border: 0; background: none; color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.content { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 28px; display: flex; flex-direction: column; gap: 16px; }
/* bez tego karty z overflow:hidden (listy) kurczyly sie zamiast przewijac tresc */
.content > * { flex-shrink: 0; }
.bottom { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--divider);
  background: var(--bg); display: flex; flex-direction: column; gap: 10px; }

/* ---------- karty i elementy ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px;
  display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.state { display: flex; align-items: center; gap: 10px; min-width: 0; }
.state-label { font-size: 17px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--amber); }
.dot.green { background: var(--green); animation: pulse 1.8s infinite; }
.dot.red { background: var(--red); }
.dot.blue { background: var(--accent); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 55%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .dot.green { animation: none; } }
.muted { font-size: 13px; font-weight: 600; color: var(--text2); }
.small { font-size: 13px; color: var(--text2); }
.progress { display: flex; flex-direction: column; gap: 6px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); width: 0; transition: width .9s linear; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: var(--chip); color: var(--text3); }
.pill.on { background: var(--green-soft); color: var(--green-text); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile b { font-size: 26px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile b small { font-size: 15px; font-weight: 700; color: var(--text2); }
.tile b.blue { color: var(--accent-text); }
.tile b.green { color: var(--green-strong); }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-title { font-size: 17px; font-weight: 700; }
.link { border: 0; background: none; padding: 4px 0; color: var(--accent-text); font-size: 14px; font-weight: 600; }
.notice { font-size: 13px; color: var(--text3); background: var(--card); border: 1px dashed var(--line);
  border-radius: 16px; padding: 12px 14px; }
.notice.warn { border-style: solid; border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }

/* ---------- lista terminow ---------- */
.slot { width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; display: flex; align-items: center; gap: 14px; color: var(--text); }
.slot.booked { border-color: var(--green-line); }
.datebox { width: 48px; height: 52px; border-radius: 12px; background: var(--chip); display: flex;
  flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.datebox small { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; }
.datebox b { font-size: 18px; font-weight: 800; }
.slot.booked .datebox { background: var(--green-soft); }
.slot.booked .datebox small { color: var(--green-text); }
.slot-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.slot-main > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-main b { font-size: 15px; font-weight: 700; }
.slot-main .clinic { font-size: 14px; font-weight: 600; color: var(--text); }
.slot-main span { font-size: 13px; color: var(--text2); }
.badge { font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 999px; background: var(--chip);
  color: var(--text3); flex-shrink: 0; }
.badge.green { background: var(--green-soft); color: var(--green-text); }

/* ---------- przyciski ---------- */
.btn { width: 100%; min-height: 54px; border-radius: 16px; border: 0; font-size: 16px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; padding: 0 16px; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-green { background: var(--green); color: var(--on-green); }
.btn-stop { background: var(--btn-2); color: var(--danger-text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: none; border: 1px solid var(--input-line); color: var(--text3); min-height: 50px;
  font-size: 15px; font-weight: 700; }

/* ---------- ustawienia ---------- */
.group { display: flex; flex-direction: column; gap: 8px; }
.group-title { font-size: 13px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.nav-row { width: 100%; min-height: 56px; padding: 0 16px; background: none; border: 0; display: flex;
  align-items: center; justify-content: space-between; gap: 12px; text-align: left; }
.nav-row > span:first-child { font-size: 15px; font-weight: 600; flex-shrink: 0; }
.nav-row .val { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--text3);
  min-width: 0; text-align: right; }
.nav-row .val em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-row .val svg { flex-shrink: 0; }
.fields { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text2); min-width: 0; }
.field select { height: 44px; width: 100%; min-width: 0; padding: 0 10px; border-radius: 12px;
  border: 1px solid var(--input-line); background: var(--chip); color: var(--text); font-size: 15px; }
.field input { height: 44px; width: 100%; min-width: 0; padding: 0 10px; border-radius: 12px; border: 1px solid var(--input-line);
  background: var(--chip); color: var(--text); font-size: 15px; }
:root[data-theme="dark"] .field input { color-scheme: dark; }
:root[data-theme="light"] .field input { color-scheme: light; }
.seg { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 4px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.seg.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg button { min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--text3);
  font-size: 13px; font-weight: 700; line-height: 1.15; padding: 4px 2px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.switch-row { width: 100%; min-height: 64px; padding: 10px 16px; background: none; border: 0; display: flex;
  align-items: center; justify-content: space-between; gap: 12px; text-align: left; }
.switch-row .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-row .txt b { font-size: 15px; font-weight: 600; }
.switch-row .txt span { font-size: 13px; color: var(--text2); }
.track { width: 50px; height: 30px; border-radius: 15px; background: var(--track-off); padding: 3px; flex-shrink: 0;
  display: flex; justify-content: flex-start; transition: background .15s; }
.track i { width: 24px; height: 24px; border-radius: 50%; background: #fff; display: block; }
.switch-row[aria-checked="true"] .track { background: var(--green); justify-content: flex-end; }
.account { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--chip); color: var(--text3);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ok-text { color: var(--green-strong); }
.warn-text { color: var(--amber); }

/* ---------- listy wyboru ---------- */
.search { height: 46px; width: 100%; padding: 0 14px; border-radius: 14px; border: 1px solid var(--input-line);
  background: var(--card); color: var(--text); font-size: 15px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--input-line); background: none; color: var(--text3); border-radius: 999px;
  padding: 8px 12px; font-size: 13px; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.check-row { width: 100%; min-height: 52px; padding: 8px 16px; background: none; border: 0; display: flex;
  align-items: center; gap: 12px; text-align: left; font-size: 15px; }
.check-row > span:not(.box) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--input-line); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--on-accent); }
.check-row[aria-checked="true"] .box { background: var(--accent); border-color: var(--accent); }
.radio { border-radius: 50%; }
.check-row.all { font-weight: 700; }
.empty { padding: 16px; font-size: 14px; color: var(--text2); text-align: center; }

/* ---------- termin ---------- */
.hero { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0 4px; text-align: center; }
.hero-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--icon-found); display: flex;
  align-items: center; justify-content: center; color: var(--accent-text); }
.hero-icon.done { background: var(--green-soft); color: var(--green-strong); }
.hero b { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.hero span { font-size: 15px; color: var(--text2); max-width: 320px; }
.details { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 4px 18px; }
.detail { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 52px; padding: 8px 0; }
.detail + .detail { border-top: 1px solid var(--line); }
.detail span { font-size: 14px; color: var(--text2); font-weight: 600; flex-shrink: 0; }
.detail b { font-size: 15px; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
/* dlugie wartosci (adres placowki): pod etykieta, na cala szerokosc */
.detail.stack { flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 0; }
.detail.stack b { text-align: left; line-height: 1.35; }
.info { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
  display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--text3); }
.info svg { flex-shrink: 0; color: var(--text2); }

/* ---------- komunikaty ---------- */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 528px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 14px;
  padding: 12px 14px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
.toast.error { background: var(--red); color: #fff; }
.modal { position: fixed; inset: 0; z-index: 30; background: var(--scrim); display: flex;
  align-items: flex-end; justify-content: center; padding: 16px; }
.modal[hidden], .toast[hidden] { display: none; }
.modal-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 20px; box-shadow: var(--shadow);
  margin-bottom: env(safe-area-inset-bottom); }
.modal-card h2 { margin: 0 0 8px; font-size: 19px; font-weight: 800; }
.modal-card p { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: var(--text3); white-space: pre-line; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions .btn { min-height: 48px; font-size: 15px; }
.banner { margin: 0 16px; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--amber) 18%, var(--card)); color: var(--text); }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center; color: var(--text2); }
.center b { color: var(--text); font-size: 18px; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Moje wizyty, przejscie z pulpitu ---------- */
.nav-card { width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; color: var(--text); }
.nav-card > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-card b { font-size: 16px; font-weight: 700; }
.nav-card svg { color: var(--text2); flex-shrink: 0; }
.mini-danger { flex-shrink: 0; border: 1px solid color-mix(in srgb, var(--red) 45%, var(--line)); background: none;
  color: var(--danger-text); border-radius: 12px; padding: 8px 10px; font-size: 13px; font-weight: 700; }
.chip[data-act="refresh-lists"] { align-self: flex-start; }
