/* PLIK: app.css   KATALOG: /home/srv117603/domains/codogrosza.com.pl/public_html/ */

@font-face {
  font-family: "Plex";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url(fonts/plex-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plex";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url(fonts/plex-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --paper: #F3F6FC;      /* kartka */
  --sheet: #FFFFFF;      /* arkusz z treścią */
  --grid: #DCE5F4;       /* kratka */
  --line: #C5D1E6;       /* obramowania */
  --ink: #16233F;        /* atrament */
  --ink2: #566380;       /* atrament jaśniejszy */
  --blue: #2447C6;       /* długopis */
  --on-blue: #FFFFFF;
  --red: #C2362E;
  --green: #1B7F52;
  --amber: #A66A12;
  --margin: #E06A63;     /* czerwona linia marginesu */
  --tint: #EEF2FB;
  --font: "Plex", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0E1524;
    --sheet: #151F33;
    --grid: #1A2540;
    --line: #2B3A58;
    --ink: #E6ECF8;
    --ink2: #9AA7C2;
    --blue: #8AA4FF;
    --on-blue: #0E1524;
    --red: #FF8A82;
    --green: #62D39C;
    --amber: #E3B257;
    --margin: #8C3F3B;
    --tint: #1B2740;
  }
}

* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font: 400 16px/1.45 var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: clip;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, dl, dd, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.boot { padding: 32px; color: var(--ink2); }

/* ---------------------------------------------------------------- układ */
.shell { min-height: 100vh; min-height: 100dvh; }
.main { padding: calc(var(--safe-t) + 0px) 0 calc(var(--nav-h) + var(--safe-b) + 84px); max-width: 1040px; margin: 0 auto; }
.view { padding: 4px 12px 0; display: grid; gap: 14px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--sheet); border-top: 1px solid var(--line);
}
.nav .brand, .nav .add, .nav .navfoot { display: none; }
.tab {
  flex: 1; min-width: 0; border: 0; background: none; padding: 6px 2px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; font-weight: 500; color: var(--ink2);
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--blue); font-weight: 600; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 21;
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--blue); color: var(--on-blue);
  font-size: 34px; font-weight: 300; line-height: 1; padding-bottom: 4px;
  box-shadow: 0 6px 16px rgba(22, 35, 63, .28);
}
.fab:active { transform: scale(.96); }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-t) + 8px) 12px 8px;
  background: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.top h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; padding: 6px 4px; }
.month { display: flex; align-items: center; gap: 0; min-width: 0; }
.month button { border: 0; background: none; height: 44px; border-radius: 4px; }
.month .arr { width: 36px; flex: none; font-size: 26px; line-height: 1; color: var(--ink2); padding-bottom: 4px; }
.month .mlabel { font-size: 19px; font-weight: 600; letter-spacing: -.01em; padding: 0 2px; min-width: 8.2em; text-align: center; white-space: nowrap; }
.month .mlabel::first-letter { text-transform: uppercase; }
.syncbtn {
  display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--sheet);
  border-radius: 999px; padding: 0 12px 0 10px; height: 34px; font-size: 13px; color: var(--ink2); white-space: nowrap;
  min-width: 0; flex: 0 1 auto;
}
.syncbtn span:last-child { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink2); flex: none; }
.dot.ok { background: var(--green); }
.dot.wait { background: var(--amber); }
.dot.err { background: var(--red); }
.dot.busy { background: var(--blue); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* -------------------------------------------------------------- arkusze */
.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: 4px; padding: 16px; }
.sheet > h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sheet > h2 small { font-weight: 400; color: var(--ink2); font-size: 13px; }
.hint { color: var(--ink2); font-size: 14px; }
.empty { text-align: center; padding: 28px 16px; }
.empty p { color: var(--ink2); margin-bottom: 14px; }

.btn {
  border: 1px solid var(--line); background: var(--sheet); border-radius: 4px;
  padding: 0 16px; min-height: 44px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); font-weight: 600; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------- słupek: działanie pisemne */
.slupek { max-width: 460px; }
.slupek .sl { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; font-size: 17px; }
.slupek .sl span { color: var(--ink2); }
.slupek .sl b { font-weight: 500; white-space: nowrap; }
.slupek .res { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; }
.slupek .res span { color: var(--ink); font-weight: 600; }
.slupek .res b { font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.delta { margin-top: 10px; font-size: 14px; color: var(--ink2); }

/* --------------------------------------------------------------- wykresy */
.cats { display: grid; gap: 16px; align-items: center; }
.donut { width: 100%; max-width: 190px; margin: 0 auto; display: block; }
.donut text { fill: var(--ink); font-family: var(--font); }
.legend { display: grid; gap: 2px; }
.lrow {
  display: grid; grid-template-columns: 12px 1fr auto 3.2em; align-items: center; gap: 10px;
  border: 0; background: none; text-align: left; padding: 8px 4px; border-radius: 4px; width: 100%;
  border-bottom: 1px solid var(--grid);
}
.lrow:last-child { border-bottom: 0; }
.lrow i, .chip i, .row .mk, .crow i { width: 12px; height: 12px; border-radius: 50%; display: block; flex: none; }
.lrow .nm { overflow-wrap: anywhere; line-height: 1.25; }
.lrow .am { font-weight: 500; white-space: nowrap; }
.lrow .pc { color: var(--ink2); font-size: 13px; text-align: right; }

.who { display: grid; gap: 10px; }
.wrow { display: grid; grid-template-columns: 5.5em 1fr auto; gap: 10px; align-items: center; }
.bar { height: 10px; background: var(--tint); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); border-radius: 2px; }
.bar.over > span { background: var(--red); }
.bar.warn > span { background: var(--amber); }

.year { width: 100%; height: auto; display: block; }
.year text { fill: var(--ink2); font-family: var(--font); font-size: 10px; text-anchor: middle; }
.year .mcol { cursor: pointer; }
.year .mcol .hit { fill: transparent; }
.year .mcol.cur .hit { fill: var(--tint); }
.year .mcol.cur text { fill: var(--ink); font-weight: 600; }
.year .binc { fill: var(--green); }
.year .bexp { fill: var(--blue); }
.year .base { stroke: var(--line); stroke-width: 1; }
.ykey { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink2); margin-top: 10px; }
.ykey i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.ykey b { color: var(--ink); font-weight: 500; }

/* ----------------------------------------------- strona zeszytu z wpisami */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters .q { flex: 1 1 100%; }
.filters select { flex: 1 1 0; min-width: 0; font-size: 14px; padding: 0 4px 0 8px; }
.filters select, .filters input, .fld input, .fld select {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 4px; background: var(--sheet); padding: 0 10px;
}
.page {
  background: var(--sheet); border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
  background-image: linear-gradient(90deg, transparent 47px, var(--margin) 47px, var(--margin) 48px, transparent 48px);
}
.dhead { display: flex; align-items: baseline; gap: 0; padding: 14px 14px 6px 0; border-bottom: 1px solid var(--line); }
.dhead .dnum { width: 48px; text-align: center; font-size: 22px; font-weight: 600; line-height: 1; flex: none; }
.dhead .dname { flex: 1; padding-left: 12px; color: var(--ink2); font-size: 14px; }
.dhead .dsum { font-size: 14px; font-weight: 500; white-space: nowrap; display: flex; gap: 10px; }
.row {
  display: flex; align-items: center; width: 100%; min-height: 52px; padding: 6px 14px 6px 0;
  border: 0; border-bottom: 1px solid var(--grid); background: none; text-align: left;
}
.row:hover { background: var(--tint); }
.row .mkw { width: 48px; display: flex; justify-content: center; flex: none; }
.row .rmain { flex: 1; min-width: 0; padding-left: 12px; display: grid; }
.row .rcat { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .rnote { font-size: 13px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .ramt { font-weight: 500; white-space: nowrap; padding-left: 10px; text-align: right; }
.row .ramt small { display: block; font-weight: 400; font-size: 12px; color: var(--ink2); }
.pagefoot { display: flex; justify-content: space-between; padding: 12px 14px 12px 60px; font-weight: 600; }

/* --------------------------------------------------------------- budżety */
.brow { padding: 12px 0; border-bottom: 1px solid var(--grid); display: grid; grid-template-columns: 1fr 112px; gap: 6px 12px; align-items: center; }
.brow:last-child { border-bottom: 0; }
.brow .bn { display: flex; align-items: center; gap: 8px; font-weight: 500; min-width: 0; }
.brow .bn i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.brow .bn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .bi { position: relative; }
.brow .bi input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 4px; background: var(--sheet); padding: 0 28px 0 8px; text-align: right; }
.brow .bi::after { content: "zł"; position: absolute; right: 9px; top: 9px; color: var(--ink2); font-size: 14px; pointer-events: none; }
.brow .bs { grid-column: 1 / -1; display: grid; gap: 5px; }
.brow .bt { font-size: 13px; color: var(--ink2); display: flex; justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------ listy ustawień */
.crow {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 4px;
  border: 0; border-bottom: 1px solid var(--grid); background: none; text-align: left; border-radius: 0;
}
.crow:last-of-type { border-bottom: 0; }
.crow .cn { flex: 1; min-width: 0; }
.crow .cn b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .cn small { color: var(--ink2); font-size: 13px; }
.crow .ca { font-weight: 500; white-space: nowrap; }
.crow.off { opacity: .55; }
.sub { font-size: 13px; font-weight: 600; color: var(--ink2); margin: 14px 0 2px; }
.rowbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.kv { display: grid; gap: 4px; font-size: 14px; color: var(--ink2); }
.kv b { color: var(--ink); font-weight: 500; }

/* ------------------------------------------------------------ formularze */
dialog {
  border: 0; padding: 0; background: var(--sheet); color: var(--ink);
  width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 10px 10px 0 0;
  max-height: 94dvh; overflow: auto; border-top: 1px solid var(--line);
}
dialog::backdrop { background: rgba(10, 16, 30, .5); }
.form { padding: 18px 16px calc(18px + var(--safe-b)); display: grid; gap: 14px; }
.form h2 { font-size: 18px; font-weight: 600; }
.fld { display: grid; gap: 5px; }
.fld > span, .form legend { font-size: 13px; font-weight: 500; color: var(--ink2); padding: 0; margin-bottom: 5px; }
.fld > span { margin-bottom: 0; }
.fld.amt { position: relative; }
.fld.amt input { height: 58px; font-size: 28px; font-weight: 600; padding-right: 44px; text-align: right; }
.fld.amt em { position: absolute; right: 14px; bottom: 15px; font-style: normal; font-size: 18px; color: var(--ink2); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; text-align: center; padding: 11px 8px; font-weight: 500; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:checked + span { background: var(--blue); color: var(--on-blue); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: -4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px 7px 9px; font-size: 15px; }
.chip input:checked + span { border-color: var(--blue); background: var(--tint); box-shadow: inset 0 0 0 1px var(--blue); font-weight: 500; }
.chip input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { position: relative; }
.sw input { position: absolute; opacity: 0; inset: 0; }
.sw span { display: block; width: 34px; height: 34px; border-radius: 50%; }
.sw input:checked + span { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 5px var(--ink); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 20px; height: 20px; }
.ferr { color: var(--red); font-size: 14px; font-weight: 500; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.actions .grow { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 20px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--sheet); padding: 10px 16px; border-radius: 4px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%); }

/* -------------------------------------------------------------- logowanie */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .sheet { width: 100%; max-width: 380px; padding: 28px 22px; display: grid; gap: 16px; border-left: 0; position: relative; }
.login .sheet::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--margin); border-radius: 4px 0 0 4px; }
.login h1 { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.login p { color: var(--ink2); font-size: 14px; }

/* ----------------------------------------------------------------- desktop */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh; flex-direction: column; align-items: stretch; gap: 2px;
    border-top: 0; border-right: 1px solid var(--line); padding: 20px 12px;
  }
  .nav .brand { display: block; font-size: 19px; font-weight: 600; letter-spacing: -.01em; padding: 0 10px 16px; }
  .nav .add { display: inline-flex; margin: 0 0 14px; }
  .nav .navfoot { display: block; margin-top: auto; padding: 10px; font-size: 12.5px; color: var(--ink2); }
  .tab { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px; font-size: 15px; border-radius: 4px; }
  .tab[aria-current="page"] { background: var(--tint); }
  .fab { display: none; }
  .main { padding: 0 20px 48px; width: 100%; }
  .view { padding: 4px 0 0; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; }
  .view > .wide { grid-column: 1 / -1; }
  .top { padding: 16px 0 12px; }
  .cats { grid-template-columns: 170px 1fr; }
  .slupek .res b { font-size: 40px; }
  .filters { flex-wrap: nowrap; }
  .filters .q { flex: 1.5 1 0; }
  .filters select { font-size: 15px; padding: 0 10px; }
  dialog { margin: auto; width: 480px; border-radius: 6px; border: 1px solid var(--line); }
  #toast { bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
