/* Dom.app – styl wg makiet (lawendowe tło, fioletowy akcent, białe karty) */
:root {
  --bg: #F5F4FE;
  --card: #FFFFFF;
  --ink: #1E1B3A;
  --muted: #625F7A;
  --line: #ECEAF6;
  --accent: #5B47E0;
  --accent-soft: #ECE9FF;
  --ok: #0E8A7B;
  --ok-soft: #E3F5F2;
  --warn: #B23C0B;
  --warn-soft: #FFEDE3;
  --err: #C42B2B;
  --err-soft: #FDECEC;
  --r: 16px;
  --shadow: 0 6px 18px rgba(80, 64, 200, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; }
.screen { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-top: env(safe-area-inset-top, 0px); }
body.has-nav .screen { padding-bottom: calc(100px + var(--safe-b)); }
.page { padding: 18px 18px 24px; display: flex; flex-direction: column; gap: 12px; }
.page-flush { padding: 0 0 24px; }
.page-flush > :not(.calendar) { margin-left: 18px; margin-right: 18px; }
.muted { color: var(--muted); }
.small, small { font-size: 12px; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- elementy wspólne ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo .ic { width: 17px; height: 17px; stroke-width: 2.4; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar-title { font-weight: 700; font-size: 16px; text-align: center; }
.iconbtn { width: 44px; height: 44px; border-radius: 14px; background: var(--card); border: 0; display: grid; place-items: center; color: var(--ink); cursor: pointer; flex: none; }
.iconbtn.round { border-radius: 50%; border: 1px solid #E7E4F7; }
.iconbtn.soft { background: var(--bg); color: var(--accent); width: 44px; height: 40px; border-radius: 12px; }
.iconbtn.ghost, .textbtn.ghost { visibility: hidden; }
.textbtn { min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--muted); min-width: 60px; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; min-height: 40px; padding: 0 4px; }
.page-title { font-size: 24px; font-weight: 800; }
.section { font-size: 17px; font-weight: 700; margin-top: 8px; }
.card { background: var(--card); border-radius: 18px; padding: 12px 14px; }
.card-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .4px; padding: 4px 0; }
.card-label.spaced { margin-top: 10px; }
.empty { background: var(--card); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.empty a { color: var(--accent); font-weight: 700; }
.flash { margin: 12px 18px 0; padding: 12px 14px; border-radius: 14px; background: var(--ok-soft); color: #0B6E62; font-weight: 600; font-size: 14px; }
.flash-err { background: var(--err-soft); color: var(--err); }
.alert { padding: 11px 14px; border-radius: 14px; background: var(--err-soft); color: var(--err); font-size: 14px; font-weight: 600; }
.alert-link { display: block; }

/* ---------- przyciski ---------- */
.btn { min-height: 50px; border-radius: 16px; border: 0; font: inherit; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; cursor: pointer; padding: 0 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 10px 22px rgba(91, 71, 224, .3); }
.btn-primary:active { transform: translateY(1px); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-white { background: var(--card); color: var(--ink); font-size: 14px; min-height: 46px; }
.btn-white.danger { color: var(--err); }
.btn .ic { width: 18px; height: 18px; stroke-width: 2.4; }

/* ---------- formularze ---------- */
.form { display: flex; flex-direction: column; gap: 6px; }
.form label, .form .lbl { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 8px; }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1.5px solid transparent; background: var(--card);
  padding: 0 14px; font: inherit; font-size: 16px; color: var(--ink); outline: none; appearance: none;
}
.card.form input:not([type=checkbox]):not([type=radio]), .sheet input:not([type=radio]) { background: var(--bg); }
.form textarea { padding: 12px 14px; resize: vertical; }
.form select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--accent); }
.form .btn { margin-top: 14px; }
.check { display: flex !important; align-items: center; gap: 10px; min-height: 44px; color: var(--ink) !important; font-weight: 500 !important; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.field-err { color: var(--err); font-size: 12px; font-weight: 600; }
.hint { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

.segmented { background: #E9E6FB; border-radius: 14px; padding: 4px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: 4px; }
.segmented label { margin: 0 !important; }
.segmented input, .segopt input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 11px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; text-align: center; }
.segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(80, 64, 200, .15); }
.segmented input:focus-visible + span, .segopt input:focus-visible + span { outline: 2px solid var(--accent); }
.small-seg { margin-top: 12px; }
.seg3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 8px; }
.segopt { margin: 0 !important; position: relative; }
.segopt span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 4px; border-radius: 12px; border: 1px solid #E7E4F7; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; }
.segopt input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.money-input { display: flex; align-items: center; background: var(--bg); border-radius: 14px; padding-right: 14px; }
.money-input input { background: transparent !important; font-size: 18px !important; font-weight: 700; }
.money-input span { font-weight: 600; color: var(--muted); }
.sheet { background: var(--card); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); }
.sheet h2 { font-size: 20px; font-weight: 800; }

/* ---------- logowanie ---------- */
.auth { padding: 48px 22px 32px; display: flex; flex-direction: column; gap: 8px; }
.auth h1 { font-size: 28px; font-weight: 800; margin-top: 28px; }
.auth .alert { margin-top: 8px; }

/* ---------- start ---------- */
.home-head { display: flex; justify-content: space-between; align-items: center; }
.greet h1 { font-size: 26px; font-weight: 800; line-height: 1.2; margin-top: 2px; }
.hero { display: block; background: var(--accent); color: #fff; border-radius: 22px; padding: 18px; box-shadow: 0 14px 30px rgba(91, 71, 224, .28); }
.hero-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; }
.pill-light { background: rgba(255, 255, 255, .18); padding: 4px 10px; border-radius: 20px; font-size: 12px; }
.hero-amount { font-size: 32px; font-weight: 800; letter-spacing: -.5px; margin-top: 6px; }
.progress { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .25); margin-top: 14px; overflow: hidden; }
.progress span { display: block; height: 100%; background: #fff; border-radius: 6px; }
.hero-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-top: 8px; opacity: .95; }
.hero-note { font-size: 12px; margin-top: 6px; opacity: .9; }
.modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.module { background: var(--card); border-radius: 18px; padding: 12px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); min-height: 62px; }
.module b { display: block; font-size: 15px; }
.module small { color: var(--muted); }
.module.is-soon { box-shadow: none; opacity: .75; }
.module-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.module-ic.violet { background: var(--accent-soft); color: var(--accent); }
.module-ic.teal { background: #E6F6F3; color: #0E8A7B; }
.module-ic.orange { background: #FFF1E3; color: #B85A00; }

/* ---------- lista rachunków ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.bill { display: block; background: var(--card); border-radius: var(--r); padding: 12px 14px; }
a.bill:active { transform: scale(.99); }
.bill-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.bill-tag { margin-left: auto; color: var(--accent); font-weight: 700; }
.bill-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.bill-name { font-weight: 700; font-size: 15px; }
.bill-amount { font-weight: 700; font-size: 14px; white-space: nowrap; }
.bill.is-paid { opacity: .65; }
.bill.is-paid .bill-name { text-decoration: line-through; }
.bill.is-overdue { box-shadow: inset 0 0 0 1.5px #F3B7B7; }
.bill.is-projected { background: transparent; border: 1.5px dashed #D3CEF3; }
.tpl-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }

/* ---------- kalendarz ---------- */
.calendar { background: var(--card); border-radius: 0 0 28px 28px; padding: 18px 16px 12px; box-shadow: 0 8px 24px rgba(80, 64, 200, .06); }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-title { text-align: center; }
.cal-title b { display: block; font-size: 17px; }
.cal-title small { color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 2px; }
.cal-dow { margin: 10px 0 4px; font-size: 11px; font-weight: 500; color: var(--muted); text-align: center; }
.cal-day { height: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.cal-day .num { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.cal-day.today .num { box-shadow: inset 0 0 0 1.5px #D9D4F7; }
.cal-day.sel .num { background: var(--accent); color: #fff; box-shadow: 0 6px 14px rgba(91, 71, 224, .35); }
.dots { display: flex; gap: 2px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; }
.chips { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; background: var(--card); font-size: 13px; font-weight: 600; display: flex; align-items: center; }
.chip.on { background: var(--ink); color: #fff; }
.month-sum { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 12px 0 10px; }
.month-sum b { color: var(--ink); }
.clear-day { display: block; padding: 2px 2px 4px; }

/* ---------- szczegóły ---------- */
.bill-hero { text-align: center; padding: 6px 0 2px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 20px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-due { background: var(--warn-soft); color: var(--warn); }
.st-over { background: var(--err-soft); color: var(--err); }
.st-paid { background: var(--ok-soft); color: #0B6E62; }
.bill-hero-name { font-size: 15px; font-weight: 600; margin-top: 12px; }
.bill-hero-amount { font-size: 38px; font-weight: 800; letter-spacing: -1px; }
.source-note { background: var(--accent-soft); border-radius: 14px; padding: 10px 12px; font-size: 12px; font-weight: 600; color: #3B2CA8; }
.copy-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.copy-row:last-child { border-bottom: 0; }
.copy-text { flex: 1; min-width: 0; }
.copy-text small { display: block; color: var(--muted); font-size: 11px; }
.copy-text span { display: block; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.copy-row.copied .iconbtn { background: var(--ok-soft); color: var(--ok); }
.pay-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

/* ---------- dolna nawigacja ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(76px + var(--safe-b)); padding: 0 10px var(--safe-b);
  background: #fff; border-radius: 24px 24px 0 0; box-shadow: 0 -6px 20px rgba(80, 64, 200, .08);
  display: flex; align-items: center; justify-content: space-around; max-width: 520px; margin: 0 auto;
}
.tabbar a { width: 56px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #8E8AA6; font-size: 10px; font-weight: 600; }
.tabbar a.on { color: var(--accent); }
.tabbar .fab { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; margin-top: -30px; box-shadow: 0 8px 18px rgba(91, 71, 224, .4); }
.tabbar .fab .ic { width: 24px; height: 24px; stroke-width: 2.6; }

@media (min-width: 560px) {
  .screen { padding-top: 16px; }
  .calendar { border-radius: 28px; }
}

/* ---------- źródła danych ---------- */
.hero-compact { padding: 14px 16px; }
.small-amount { font-size: 20px; }
.pill { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 10px; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: #0B6E62; }
.pill-warn { background: #FFEBD2; color: #8A4300; }
.pill-err { background: var(--err-soft); color: var(--err); }
.pill-off { background: #EFEEF5; color: #4A4763; }
.source { display: flex; flex-direction: column; gap: 6px; }
.source-head { display: flex; align-items: center; gap: 12px; }
.source-ic { font-weight: 800; font-size: 15px; }
.source-main { flex: 1; min-width: 0; }
.source-main b { display: block; font-size: 14px; }
.source-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-msg { font-size: 12px; color: #0B6E62; }
.source-msg.is-bad { color: #8A4300; background: #FFF4E5; border-radius: 10px; padding: 8px 10px; }
.source-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn-sm { min-height: 40px; width: auto; font-size: 13px; border-radius: 12px; padding: 0 12px; }
.btn-dashed { background: transparent; border: 1.5px dashed #C9C3F5; color: var(--accent); font-size: 14px; min-height: 48px; }
.linkbtn.danger { color: var(--err); }
a.source-note { display: block; }
.source-actions form { display: flex; }
.source-actions .linkbtn { display: flex; align-items: center; }

/* ---------- import faktur ---------- */
.import-card { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.import-card > span:nth-child(2) { flex: 1; }
.import-card b { display: block; font-size: 15px; }
.import-card small { color: var(--muted); }
.import-card > .ic { color: var(--muted); width: 16px; height: 16px; }
.dropzone { display: flex !important; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 26px 16px; margin-top: 12px !important;
  border: 1.5px dashed #C9C3F5; border-radius: 18px; background: var(--bg); color: var(--ink) !important; cursor: pointer; }
.dropzone .ic { width: 30px; height: 30px; color: var(--accent); }
.dropzone b { font-size: 15px; }
.dropzone input[type=file] { font-size: 13px; margin-top: 6px; max-width: 100%; }
.badge-ok, .badge-warn { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 1px; }
.badge-ok { background: var(--ok-soft); color: #0B6E62; }
.badge-warn { background: #FFEBD2; color: #8A4300; }
.chip-import { margin-top: 10px; gap: 6px; color: var(--accent); width: max-content; }
.chip-import .ic { width: 16px; height: 16px; }

/* ---------- serwisy ---------- */
.portal { display: flex; flex-direction: column; gap: 4px; }
.portal-head { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
.portal-main { flex: 1; min-width: 0; }
.portal-main b { display: block; font-size: 14px; }
.portal-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-head .btn-sm .ic { width: 16px; height: 16px; }
.portal-actions { display: flex; align-items: center; gap: 12px; justify-content: flex-end; padding: 4px 4px 0; }
.portal-actions form { display: flex; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin-top: 0; }
.add-portal { align-self: flex-start; }
[data-pw-text] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5px; }

/* edycja / usuwanie rachunków stałych */
a.bill-name { color: inherit; text-decoration: none; }
a.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }
.tpl-actions .linkbtn + .linkbtn { margin-left: 8px; }
.danger-zone { margin-top: 8px; }
.btn-danger { background: transparent; color: var(--err); border: 1.5px solid var(--err); }
.tpl-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tpl-actions > a.linkbtn:first-of-type { margin-left: auto; }
