/* ============================================================
   NajemPanel — arkusz stylów
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #14231e;
  --paper: #f2f4ef;
  --card: #ffffff;
  --line: #dde3da;
  --green: #1e6b4f;
  --green-soft: #e2f0e8;
  --amber: #9a6a12;
  --amber-soft: #f7ecd6;
  --red: #a03427;
  --red-soft: #fbe9e6;
  --mute: #6c7a72;
}

body {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- logowanie ---------- */
.login-wrap { display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 40px; }
.login-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 30px 26px; width: 100%; max-width: 380px;
}
.login-brand { font-size: 22px; font-weight: 700; letter-spacing: .02em; }
.login-sub { font-size: 13.5px; color: var(--mute); margin: 6px 0 20px; }
.login-error { background: var(--red-soft); color: var(--red); font-size: 13.5px; padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; }

/* ---------- pasek górny ---------- */
.topbar {
  background: var(--ink); color: #f4f6f2; padding: 13px 16px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { color: #7fc8a4; font-size: 18px; }
.brand-name { font-weight: 700; letter-spacing: .02em; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .65; }
.top-right { display: flex; align-items: center; gap: 8px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-label { font-variant-numeric: tabular-nums; font-size: 14px; min-width: 126px; text-align: center; text-transform: capitalize; }
.mbtn {
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 30px; height: 30px; border-radius: 8px; font-size: 16px; cursor: pointer;
}
.mbtn:hover { background: rgba(255,255,255,.22); }
.logout { font-size: 14px; }

/* ---------- zakładki ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; background: var(--ink); padding: 0 10px 10px; }
.tab {
  background: transparent; color: rgba(244,246,242,.7);
  border: 1px solid rgba(255,255,255,.18);
  padding: 7px 13px; border-radius: 999px;
  font-size: 13px; white-space: nowrap; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.tab-on { background: var(--paper); color: var(--ink); border-color: var(--paper); font-weight: 600; }
.badge {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 11px; min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- treść ---------- */
.content { padding: 14px; max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 60px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; }
.stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--mute); margin-top: 3px; }
.stat-warn .stat-value { color: var(--red); }
.stat-ok .stat-value { color: var(--green); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; flex-wrap: wrap; gap: 6px; }
.card h3 { font-size: 14px; font-weight: 700; }
.muted { color: var(--mute); font-size: 12px; }
.overdue-txt { color: var(--red); }

.bar { height: 10px; background: #e6eae3; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #2b8763, var(--green)); border-radius: 999px; transition: width .4s; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: none; }
.row-title { font-size: 14px; font-weight: 600; }
.row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.amount { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }
.amount.due { color: var(--red); }
.amount.pos { color: var(--green); }

.chip { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.chip-ok { background: var(--green-soft); color: var(--green); }
.chip-warn { background: var(--amber-soft); color: var(--amber); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-mute { background: #eceee9; color: var(--mute); }
.chip-click { cursor: pointer; }

.btn {
  background: var(--green); color: #fff; border: none;
  padding: 9px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #17523d; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-ghost { background: #eef1ec; color: var(--ink); }
.btn-ghost:hover { background: #e2e6e0; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-wide { width: 100%; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 15px; color: var(--mute); padding: 4px; }
.icon-btn:hover { color: var(--red); }

.pay-block { border-top: 1px solid var(--line); padding: 10px 0; }
.pay-block:first-of-type { border-top: none; }
.pay-lines { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.pay-line { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; gap: 8px; }
.hint { font-size: 12px; color: var(--mute); padding-top: 10px; }

.form { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; }
.form input, .form select,
.fld input, .fld select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; background: #fbfcfa; color: var(--ink);
}
.form input:focus, .form select:focus, .fld input:focus { outline: 2px solid #2b8763; border-color: transparent; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 10px; }
.fld { font-size: 12.5px; color: var(--mute); display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-weight: 600; }

table.rpt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rpt th { text-align: left; color: var(--mute); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.rpt td { padding: 9px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.rpt tr:last-child td { border-bottom: none; }
.rpt-wrap { overflow-x: auto; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 50;
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

@media (max-width: 430px) {
  .month-label { min-width: 108px; font-size: 13px; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- import wyciągu (v2) ---------- */
.imp-table select, .imp-table input[type="month"] {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 12.5px; background: #fbfcfa; max-width: 190px;
}
.imp-table td { vertical-align: middle; }
.imp-title { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-nomatch { background: #fdf6f0; }
input[type="file"] { font-size: 13px; }

/* ---------- poprawka: atrybut hidden musi mieć pierwszeństwo ----------
   (bez tego .login-wrap { display:flex } nadpisywał ukrycie formularza
   logowania i pozostawał on widoczny po zalogowaniu) */
[hidden] { display: none !important; }

/* ============================================================
   PWA + czytelność na telefonie (v4.2)
   ============================================================ */
body { -webkit-text-size-adjust: 100%; }

/* obszar bezpieczny na telefonach z wcięciem (iPhone) */
.topbar { padding-top: calc(13px + env(safe-area-inset-top)); }
.content { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

.install-tip {
  font-size: 12.5px; color: var(--mute); line-height: 1.5;
  background: #f4f6f2; border-radius: 9px; padding: 10px 12px; margin-top: 14px;
}

/* --- telefon: większa czytelność, mniej ścisku --- */
@media (max-width: 560px) {
  .content { padding: 12px 12px 70px; gap: 12px; }
  .card { padding: 6px 12px 12px; border-radius: 14px; }

  /* wiersze łamane w pion: tytuł u góry, kwota i akcje poniżej */
  .row { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 0; }
  .row-right { justify-content: flex-start; gap: 8px; }
  .row-title { font-size: 15px; line-height: 1.3; }
  .muted { font-size: 12.5px; line-height: 1.45; }
  .amount { font-size: 15px; }

  /* wygodne cele dotyku (min. 40px) */
  .btn { padding: 11px 16px; font-size: 14px; }
  .btn-sm { padding: 9px 14px; font-size: 13px; }
  .icon-btn { font-size: 19px; padding: 8px 10px; }
  .mbtn { width: 36px; height: 36px; font-size: 18px; }
  .tab { padding: 9px 15px; font-size: 13.5px; }

  .pay-line { flex-direction: column; align-items: flex-start; gap: 6px; font-size: 14px; }
  .pay-line > span:last-child { display: flex; gap: 8px; flex-wrap: wrap; }

  .stats { grid-template-columns: 1fr; gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 19px; }

  /* pola formularzy: 16px zapobiega automatycznemu zoomowi w iOS */
  .form input, .form select, .fld input, .fld select { font-size: 16px; padding: 12px; }

  /* tabele (raport, import) przewijane w poziomie ze wskazówką */
  .rpt-wrap { -webkit-overflow-scrolling: touch; }
  table.rpt { font-size: 12.5px; min-width: 520px; }
  .imp-table { min-width: 700px; }

  .toast { bottom: calc(14px + env(safe-area-inset-bottom)); font-size: 13.5px; }
}

/* tryb zainstalowanej aplikacji: ukryj podpowiedź o instalacji */
@media (display-mode: standalone) {
  .install-tip { display: none !important; }
}
