:root {
  --yellow: #f8c312;
  --yellow-soft: #fff6d6;
  --yellow-dark: #d9a800;
  --ink: #222222;
  --ink-2: #555555;
  --ink-3: #8a8a8a;
  --bg: #fafaf7;
  --card: #ffffff;
  --line: #ecebe4;
  --green: #1f9d55;
  --green-soft: #e6f6ec;
  --red: #d64545;
  --red-soft: #fdecec;
  --blue-soft: #eef2ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Nagłówek ---------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 40px; width: auto; display: block; }
.brand .app-name { font-weight: 700; font-size: 15px; border-left: 2px solid var(--yellow); padding-left: 12px; line-height: 1.15; }
.brand .app-name small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
nav.tabs { display: flex; gap: 4px; margin-left: auto; }
nav.tabs a {
  text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: 14px;
  color: var(--ink-2); display: flex; align-items: center; gap: 6px; position: relative;
}
nav.tabs a:hover { background: var(--yellow-soft); color: var(--ink); }
nav.tabs a.active { background: var(--yellow); color: var(--ink); font-weight: 600; }
nav.tabs svg { width: 18px; height: 18px; }
.badge-count {
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
nav.tabs a.active .badge-count { background: var(--ink); }
.demo-flag { background: var(--ink); color: var(--yellow); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: .05em; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; min-height: calc(100vh - 220px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }

/* ---------- Karty ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.kpi { padding: 16px 18px; cursor: pointer; transition: transform .12s; }
.kpi:hover { transform: translateY(-1px); }
.kpi .label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.kpi .value { font-size: 30px; font-weight: 700; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--ink-3); }
.kpi.alert { background: var(--yellow); border-color: var(--yellow); }
.kpi.alert .label, .kpi.alert .sub { color: var(--ink); }
.two { grid-template-columns: 1.3fr 1fr; }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; padding: 9px 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  min-height: 40px; transition: background .12s, border-color .12s;
}
.btn:hover { border-color: #d6d4ca; background: #fcfcfa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--yellow); border-color: var(--yellow); }
.btn.primary:hover { background: var(--yellow-dark); border-color: var(--yellow-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--yellow-soft); }
.btn.sm { padding: 5px 11px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Statusy ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #f1f0eb; color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--yellow-soft); color: #8a6a00; }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.bot { background: var(--ink); color: var(--yellow); }
.pill.info { background: var(--blue-soft); color: #3b4cc0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- Formularze ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
label.field > small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=email], select, textarea {
  width: 100%; border: 1px solid #dddbd2; border-radius: 10px; padding: 9px 12px; background: #fff; min-height: 42px;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--yellow-dark); box-shadow: 0 0 0 3px rgba(248, 195, 18, .25); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 500; }
.switch input { display: none; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: #dcdad2; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .15s; }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { left: 21px; background: var(--yellow); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { cursor: pointer; }
.days input { display: none; }
.days span { display: inline-flex; width: 42px; height: 38px; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid #dddbd2; font-weight: 600; font-size: 13px; }
.days input:checked + span { background: var(--yellow); border-color: var(--yellow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.active .badge-count { background: var(--yellow); color: var(--ink); }

/* ---------- Oferty ---------- */
.offer { display: grid; grid-template-columns: 1fr auto; gap: 12px 20px; align-items: center; }
.offer + .offer { margin-top: 10px; }
.offer.decide { border: 2px solid var(--yellow); }
.offer .name { font-weight: 600; }
.offer .meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.prices { display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap; }
.price-block .lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.price-block .val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-block .val.cheaper { color: var(--red); }
.proposal { grid-column: 1 / -1; background: var(--yellow-soft); border-radius: 10px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.proposal .new-price { display: flex; align-items: center; gap: 8px; }
.proposal input { width: 110px; min-height: 38px; font-weight: 700; text-align: right; }
details.offer-settings { grid-column: 1 / -1; }
details.offer-settings summary { cursor: pointer; font-size: 13px; color: var(--ink-2); font-weight: 500; }
details.offer-settings .row3 { margin-top: 10px; align-items: end; }
.competitors { font-size: 13px; margin: 8px 0 12px; padding: 0; list-style: none; }
.competitors li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* ---------- Wiadomości ---------- */
.inbox { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
.inbox > *, .grid > *, .offer > * { min-width: 0; }
.thread-list { padding: 6px; max-height: calc(100vh - 230px); overflow: auto; }
.thread-item { padding: 12px; border-radius: 10px; cursor: pointer; display: block; }
.thread-item:hover { background: #f7f6f1; }
.thread-item.active { background: var(--yellow-soft); }
.thread-item.waits { border-left: 4px solid var(--yellow); }
.thread-item .t-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.thread-item .login { font-weight: 600; }
.thread-item .preview { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.thread-item .when { font-size: 12px; color: var(--ink-3); }
.conv { display: flex; flex-direction: column; min-height: 420px; }
.conv-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bubbles { flex: 1; padding: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; background: #f3f2ed; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--yellow-soft); }
.bubble.bot { align-self: flex-end; background: #2a2a2a; color: #fff; }
.bubble .b-meta { font-size: 11px; opacity: .7; margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.bubble.bot .pill.bot { background: var(--yellow); color: var(--ink); padding: 1px 7px; font-size: 10px; }
.reply-box { border-top: 1px solid var(--line); padding-top: 12px; }
.reply-box textarea { min-height: 80px; }
.waiting-banner { background: var(--yellow); border-radius: 10px; padding: 10px 14px; font-weight: 600; margin-top: 12px; display: flex; gap: 8px; align-items: center; }

/* ---------- Inne ---------- */
.notice { background: var(--yellow-soft); border: 1px solid #f3dc8a; border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.notice.dark { background: var(--ink); color: #fff; border: none; }
.notice.dark a { color: var(--yellow); }
.device-code { font-size: 34px; font-weight: 700; letter-spacing: .12em; background: var(--yellow); border-radius: 12px; padding: 10px 16px; display: inline-block; margin: 8px 0; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; white-space: pre-line; }
.list-plain li:last-child { border-bottom: none; }
.list-plain .when { font-size: 12px; color: var(--ink-3); }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty .big { font-size: 34px; }
.settings-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
code { background: #f1f0eb; padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.lan { font-family: ui-monospace, Consolas, monospace; font-weight: 600; font-size: 15px; }
.log-line { font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.log-line.error { color: var(--red); }
.log-line.warn { color: #8a6a00; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 500; font-size: 14px;
  transition: all .2s; z-index: 100; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

/* ---------- Logowanie ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card img { width: 220px; max-width: 80%; margin: 0 auto 18px; display: block; }
.login-card form { text-align: left; margin-top: 18px; }

/* ---------- Stopka (wykonawca) ---------- */
footer.foot { border-top: 4px solid var(--yellow); background: #fff; }
.foot-inner { max-width: 1180px; margin: 0 auto; padding: 22px 20px; display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.foot-inner img { height: 46px; }
.foot-inner strong { color: var(--ink); }
.foot-inner a { font-weight: 600; }

.about { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: center; }
.about img { width: 100%; }
.about dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.about dt { color: var(--ink-3); font-size: 13px; }
.about dd { margin: 0; font-weight: 500; }

/* ---------- Telefon ---------- */
nav.bottom { display: none; }
@media (max-width: 860px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .two, .inbox, .about { grid-template-columns: 1fr; }
  nav.tabs { display: none; }
  .top-inner { padding: 8px 16px; }
  .brand img { height: 32px; }
  .brand .app-name { font-size: 13px; }
  main { padding: 16px 16px 100px; }
  h2 { font-size: 20px; }
  .row, .row3 { grid-template-columns: 1fr; }
  .offer { grid-template-columns: 1fr; }
  .proposal { flex-direction: column; align-items: stretch; }
  .proposal .actions .btn { flex: 1; }
  .thread-list { max-height: none; }
  .inbox.has-open .thread-col { display: none; }
  .inbox:not(.has-open) .conv-col { display: none; }
  .bubble { max-width: 90%; }
  .kpi .value { font-size: 26px; }
  .about img { max-width: 240px; }
  footer.foot { padding-bottom: 76px; }
  nav.bottom {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  nav.bottom a { text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 4px 0; position: relative; }
  nav.bottom a svg { width: 24px; height: 24px; }
  nav.bottom a.active { color: var(--ink); }
  nav.bottom a.active svg { background: var(--yellow); border-radius: 10px; padding: 2px 10px; width: 44px; box-sizing: content-box; height: 22px; }
  nav.bottom .badge-count { position: absolute; top: 0; left: calc(50% + 8px); }
}

/* ---------- Licencja ---------- */
.lic-banner { background: var(--yellow); color: var(--ink); text-align: center; font-weight: 600; font-size: 14px; padding: 8px 16px; }
.lic-banner a { margin-left: 6px; }

/* ---------- Weryfikacja dwuetapowa ---------- */
.login-card.tfa-setup { max-width: 440px; text-align: left; }
.login-card.tfa-setup img, .login-card.tfa-setup h2 { text-align: center; }
.login-card.tfa-setup h2, .login-card.tfa-setup > p { text-align: center; }
.tfa-steps { padding-left: 20px; margin: 16px 0 8px; font-size: 14px; }
.tfa-steps li { margin-bottom: 12px; }
.qr-box { display: flex; justify-content: center; margin: 12px 0 8px; }
.qr-box .qr { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 12px; padding: 4px; background: #fff; }
.secret { font-family: Consolas, monospace; font-size: 15px; font-weight: 700; letter-spacing: .08em; background: var(--yellow-soft); border-radius: 8px; padding: 8px 10px; margin: 6px 0; word-break: break-all; }
input.otp { text-align: center; font-size: 26px; font-weight: 700; letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.recovery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.recovery code { font-family: Consolas, monospace; font-size: 15px; text-align: center; padding: 8px; background: var(--yellow-soft); border-radius: 8px; }
.mobile-only { display: none; }
@media (max-width: 860px) { .mobile-only { display: block; } }
