/* ===================================================================
   Manager zasobów domowych – wygląd
   Fonty: Inter (tekst), Plus Jakarta Sans (nagłówki, liczby) – lokalnie, OFL.
   =================================================================== */

@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-wght-normal.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: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-ext-wght-normal.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;
}
@font-face {
  font-family: "Jakarta"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("fonts/plus-jakarta-sans-latin-wght-normal.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: "Jakarta"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("fonts/plus-jakarta-sans-latin-ext-wght-normal.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 {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Jakarta", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #f4f4f9;
  --bg-glow-1: rgb(124 108 255 / .10);
  --bg-glow-2: rgb(16 185 129 / .06);
  --surface: #ffffff;
  --surface-2: #f2f2f8;
  --surface-3: #e9e9f2;
  --glass: rgb(250 250 253 / .78);
  --text: #13131c;
  --text-2: #3b3b4d;
  --muted: #6c6c82;
  --border: #e6e6ef;
  --border-strong: #d6d6e2;
  --photo-bg: #ffffff;

  --primary: #6a5cff;
  --primary-2: #a35cff;
  --primary-ink: #5546f0;
  --primary-soft: #eeecff;
  --primary-text: #ffffff;
  --grad: linear-gradient(135deg, #6a5cff 0%, #9b5cff 55%, #d46bff 100%);

  --med: #0d9f7a;
  --med-ink: #08795c;
  --med-soft: #e1f6ef;
  --grad-med: linear-gradient(135deg, #10b981 0%, #0d9f7a 60%, #0a8a8f 100%);

  --ok: #12a26b;
  --ok-soft: #e2f6ec;
  --warn: #b86e00;
  --warn-strong: #f59e0b;
  --warn-soft: #fff3dc;
  --danger: #dc3c46;
  --danger-soft: #fde8e9;
  --sky: #0a84c6;
  --sky-soft: #e0f1fb;
  --rose: #d6336c;
  --rose-soft: #fce4ee;
  --amber-soft: #fff0d6;

  --shadow-sm: 0 1px 2px rgb(19 19 40 / .05);
  --shadow: 0 1px 2px rgb(19 19 40 / .04), 0 6px 20px -6px rgb(19 19 40 / .10);
  --shadow-lg: 0 2px 6px rgb(19 19 40 / .06), 0 24px 60px -12px rgb(19 19 40 / .28);
  --shadow-primary: 0 6px 18px -6px rgb(106 92 255 / .55);
  --shadow-med: 0 6px 18px -6px rgb(13 159 122 / .55);

  --radius: 20px;
  --radius-md: 14px;
  --radius-sm: 11px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b12;
    --bg-glow-1: rgb(124 108 255 / .16);
    --bg-glow-2: rgb(16 185 129 / .07);
    --surface: #14141e;
    --surface-2: #1b1b27;
    --surface-3: #252533;
    --glass: rgb(16 16 24 / .76);
    --text: #ededf5;
    --text-2: #c9c9d8;
    --muted: #9696ad;
    --border: #252534;
    --border-strong: #33334a;
    --photo-bg: #f4f4f7;
    --primary: #8d82ff;
    --primary-ink: #a59cff;
    --primary-soft: #23214a;
    --med: #2fd3a3;
    --med-ink: #52e0b6;
    --med-soft: #10302a;
    --ok: #3ccf8e;
    --ok-soft: #11301f;
    --warn: #f5b041;
    --warn-strong: #f5b041;
    --warn-soft: #33270f;
    --danger: #ff6b72;
    --danger-soft: #3a1619;
    --sky: #4cb8f0;
    --sky-soft: #0e2a3a;
    --rose: #ff6f9f;
    --rose-soft: #3a1626;
    --amber-soft: #33270f;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --shadow: 0 1px 2px rgb(0 0 0 / .35), 0 8px 24px -8px rgb(0 0 0 / .55);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / .4), 0 24px 60px -12px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b12;
  --bg-glow-1: rgb(124 108 255 / .16);
  --bg-glow-2: rgb(16 185 129 / .07);
  --surface: #14141e;
  --surface-2: #1b1b27;
  --surface-3: #252533;
  --glass: rgb(16 16 24 / .76);
  --text: #ededf5;
  --text-2: #c9c9d8;
  --muted: #9696ad;
  --border: #252534;
  --border-strong: #33334a;
  --photo-bg: #f4f4f7;
  --primary: #8d82ff;
  --primary-ink: #a59cff;
  --primary-soft: #23214a;
  --med: #2fd3a3;
  --med-ink: #52e0b6;
  --med-soft: #10302a;
  --ok: #3ccf8e;
  --ok-soft: #11301f;
  --warn: #f5b041;
  --warn-strong: #f5b041;
  --warn-soft: #33270f;
  --danger: #ff6b72;
  --danger-soft: #3a1619;
  --sky: #4cb8f0;
  --sky-soft: #0e2a3a;
  --rose: #ff6f9f;
  --rose-soft: #3a1626;
  --amber-soft: #33270f;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow: 0 1px 2px rgb(0 0 0 / .35), 0 8px 24px -8px rgb(0 0 0 / .55);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / .4), 0 24px 60px -12px rgb(0 0 0 / .7);
  color-scheme: dark;
}

/* ===== Podstawy ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
html, body { max-width: 100%; touch-action: manipulation; }
button, .tab, a { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  font-feature-settings: "cv11", "ss01";
  background:
    radial-gradient(900px 500px at 100% -10%, var(--bg-glow-1), transparent 70%),
    radial-gradient(700px 500px at -10% 110%, var(--bg-glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.015em; text-wrap: balance; }

.ico {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

::selection { background: var(--primary-soft); }

/* ===== Układ: menu boczne + treść ===== */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px;
  padding: max(22px, env(safe-area-inset-top)) 14px 18px max(14px, env(safe-area-inset-left));
  border-right: 1px solid var(--border); background: var(--glass);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-text strong { font-family: var(--font-display); font-size: 1.05rem; letter-spacing: -.01em; }
.brand-text span { color: var(--muted); font-size: .78rem; }
.brand-mark {
  width: 40px; height: 40px; flex: none; border-radius: 13px; display: grid; place-items: center;
  background: var(--grad); color: #fff; box-shadow: var(--shadow-primary);
}
.brand-mark .ico { width: 22px; height: 22px; stroke-width: 2.1; }
.brand-mark.sm { width: 34px; height: 34px; border-radius: 11px; }
.brand-mark.sm .ico { width: 19px; height: 19px; }
.brand-mark.lg { width: 60px; height: 60px; border-radius: 19px; }
.brand-mark.lg .ico { width: 30px; height: 30px; }

.tabs { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  padding: 14px 12px 6px;
}
.nav-label:first-child { padding-top: 4px; }
.tab {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  font: inherit; font-weight: 500; color: var(--text-2); text-align: left;
  background: none; border: 0; border-radius: 12px; padding: 10px 12px; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tab .ico { width: 20px; height: 20px; color: var(--muted); transition: color .15s var(--ease); }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 650; }
.tab.active .ico { color: var(--primary); }
.tab[data-view="pharmacy"].active { background: var(--med-soft); color: var(--med-ink); }
.tab[data-view="pharmacy"].active .ico { color: var(--med); }
.tab-badge {
  margin-left: auto; background: var(--warn-strong); color: #1d1300; border-radius: 999px;
  font-size: .68rem; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
}
.tab-badge.danger { background: var(--danger); color: #fff; }
.lbl-mobile { display: none; }

.user-card {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 10px; box-shadow: var(--shadow-sm);
}
.user-card:hover { border-color: var(--border-strong); }
.user-card .uc-text { display: grid; min-width: 0; line-height: 1.25; }
.user-card .uc-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .uc-text span { color: var(--muted); font-size: .78rem; }
.user-card .ico { margin-left: auto; color: var(--muted); }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: .9rem;
  border: 0; cursor: pointer; box-shadow: var(--shadow-primary);
}

.content { min-width: 0; display: flex; flex-direction: column; }
.page-header {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) 14px 32px;
  background: linear-gradient(to bottom, var(--bg) 55%, transparent);
}
.page-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title h1 { margin: 0; font-size: 1.75rem; font-weight: 750; line-height: 1.15; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: .8rem; font-weight: 500; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.mobile-only { display: none !important; }

main {
  width: 100%; max-width: 1280px;
  padding: 6px max(32px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) 32px;
}
.view { display: none; }
.view.active { display: block; animation: view-in .35s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Karty i siatki ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 1.02rem; font-weight: 700; margin: 0 0 14px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title h2 { margin: 0; flex: 1; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head .card-title { margin-bottom: 0; }
.ct-ico {
  width: 34px; height: 34px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.ct-ico .ico { width: 18px; height: 18px; }
.ct-ico.warn { background: var(--warn-soft); color: var(--warn); }
.ct-ico.danger { background: var(--danger-soft); color: var(--danger); }
.ct-ico.med { background: var(--med-soft); color: var(--med); }
.link-btn {
  display: inline-flex; align-items: center; gap: 2px; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--primary-ink); background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 8px;
}
.link-btn .ico { width: 16px; height: 16px; }
.link-btn:hover { background: var(--primary-soft); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid2 > .card { margin-bottom: 0; }
.grid2:has(> .card:not([hidden])) { margin-bottom: 18px; }
.grid2:not(:has(> :not([hidden]))) { display: none; }

/* ===== Pulpit: powitanie ===== */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 26px 26px 22px; margin-bottom: 18px; border-radius: 26px; color: #fff;
  background: var(--grad); box-shadow: var(--shadow-primary);
}
.hero::before, .hero::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(4px);
}
.hero::before { width: 340px; height: 340px; right: -90px; top: -170px; background: radial-gradient(circle, rgb(255 255 255 / .28), transparent 65%); }
.hero::after { width: 260px; height: 260px; left: 30%; bottom: -170px; background: radial-gradient(circle, rgb(255 190 240 / .35), transparent 65%); }
.hero-text { min-width: 0; flex: 1 1 280px; }
.hero-greet { margin: 0; font-family: var(--font-display); font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; }
.hero-sub { margin: 6px 0 0; opacity: .9; max-width: 56ch; }
.hero-sub strong { font-weight: 650; }
.hero-actions { display: grid; grid-template-columns: repeat(4, minmax(78px, 1fr)); gap: 10px; flex: 0 1 440px; }
.hero-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 10px;
  font: inherit; font-size: .8rem; font-weight: 600; color: #fff; cursor: pointer;
  background: rgb(255 255 255 / .16); border: 1px solid rgb(255 255 255 / .22); border-radius: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .15s var(--ease), transform .15s var(--ease);
}
.hero-btn .ico { width: 22px; height: 22px; }
.hero-btn:hover { background: rgb(255 255 255 / .26); transform: translateY(-1px); }
.hero-btn:active { transform: scale(.97); }

/* ===== Statystyki ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px;
  align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow-sm); min-width: 0;
}
.stat .s-ico {
  grid-row: 1 / 3; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
}
.stat .s-ico .ico { width: 20px; height: 20px; }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 500; line-height: 1.3; min-width: 0; }
.stat .value {
  font-family: var(--font-display); font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat.c-primary .s-ico { background: var(--primary-soft); color: var(--primary); }
.stat.c-ok .s-ico { background: var(--ok-soft); color: var(--ok); }
.stat.c-med .s-ico { background: var(--med-soft); color: var(--med); }
.stat.c-sky .s-ico { background: var(--sky-soft); color: var(--sky); }
.stat.warn .s-ico { background: var(--warn-soft); color: var(--warn); }
.stat.warn .value { color: var(--warn); }
.stat.danger .s-ico { background: var(--danger-soft); color: var(--danger); }
.stat.danger .value { color: var(--danger); }
button.stat { font: inherit; text-align: left; cursor: pointer; color: inherit; transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s; }
button.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }

/* ===== Listy ===== */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }
.list .empty-li { color: var(--muted); justify-content: flex-start; padding: 14px 2px; }
.list.compact li { padding: 7px 2px; font-size: .88rem; }
.list.compact strong { white-space: nowrap; }
.li-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.li-main > span { min-width: 0; overflow-wrap: anywhere; }
.li-sub { display: block; color: var(--muted); font-size: .8rem; }

.bars .bar-row { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; margin: 8px 0; font-size: .9rem; }
.bars .bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar { height: 10px; background: var(--grad); border-radius: 6px; min-width: 3px; }
.bars .bar-track { background: var(--surface-2); border-radius: 6px; }
.bars .count { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.bars .count.money { white-space: nowrap; min-width: 80px; }
.bars .bar-row:has(.money) { grid-template-columns: 130px 1fr auto; }

/* ===== Formularze i przyciski ===== */
input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; min-width: 0;
  min-height: 42px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 0; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  min-height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, filter .15s;
}
.btn .ico { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .tab:focus-visible, .chip-btn:focus-visible, .hero-btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.btn.primary { background: var(--grad); border-color: transparent; color: var(--primary-text); box-shadow: var(--shadow-primary); }
.btn.primary:hover { filter: brightness(1.06) saturate(1.05); }
.btn.primary.med { background: var(--grad-med); box-shadow: var(--shadow-med); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: .84rem; border-radius: 10px; gap: 6px; }
.btn.sm .ico { width: 16px; height: 16px; }
.btn.icon { padding: 0; width: 42px; }
.btn.sm.icon { width: 34px; }
.btn.lg { min-height: 48px; font-size: 1rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.search { position: relative; flex: 1 1 260px; display: flex; min-width: 0; }
.search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search input { width: 100%; padding-left: 40px; }

.seg-ctl { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; }
.seg-ctl button {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .85rem; font-weight: 550;
  color: var(--muted); background: none; border: 0; border-radius: 10px; padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.seg-ctl button .ico { width: 16px; height: 16px; }
.seg-ctl button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 650; }

.seg { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.seg-opt {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 9px 14px; cursor: pointer; font-weight: 550;
}
.seg-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }

/* Chipy (miejsca, filtry) */
.items-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.loc-chips { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding: 2px; scrollbar-width: none; }
.loc-chips::-webkit-scrollbar { display: none; }
.loc-chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .85rem; font-weight: 550; white-space: nowrap; cursor: pointer; border-radius: 999px;
  min-height: 34px; padding: 0 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.chip-btn:hover { border-color: var(--border-strong); }
.chip-btn[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-btn.c-danger[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.chip-btn.c-warn[aria-pressed="true"] { background: var(--warn-strong); border-color: var(--warn-strong); color: #1d1300; }
.chip-count { opacity: .65; font-variant-numeric: tabular-nums; font-weight: 600; }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip-btn.c-danger .chip-dot { color: var(--danger); }
.chip-btn.c-warn .chip-dot { color: var(--warn-strong); }
.chip-btn[aria-pressed="true"] .chip-dot { color: inherit; }

/* Plakietki */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 650; line-height: 1;
  padding: 5px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.med { background: var(--med-soft); color: var(--med-ink); }
.badge.primary { background: var(--primary-soft); color: var(--primary-ink); }

.empty, .muted { color: var(--muted); }
.empty { padding: 24px; text-align: center; margin: 0; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state p { max-width: 46ch; margin: 12px auto 0; }
.es-ico {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.es-ico .ico { width: 30px; height: 30px; }
.es-ico.med { background: var(--med-soft); color: var(--med); }

.inline-form { display: flex; gap: 8px; margin-bottom: 10px; }
.inline-form input { flex: 1; }

/* ===== Kafelki produktów ===== */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tile {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  overflow: hidden; display: flex; flex-direction: column; min-width: 0; box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile.low { border-color: color-mix(in srgb, var(--warn-strong) 55%, var(--border)); }
.tile.expired { border-color: color-mix(in srgb, var(--danger) 60%, var(--border)); }
.tile-photo {
  position: relative; display: block; margin: 8px 8px 0; aspect-ratio: 4 / 3; min-height: 0; overflow: hidden;
  border: 0; padding: 0; background: var(--photo-bg); cursor: pointer; border-radius: 14px;
}
.tile-img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; padding: 12px; transition: transform .3s var(--ease); }
.tile:hover .tile-img { transform: scale(1.04); }
.tile-img.thumb-empty {
  display: grid; place-items: center; font-family: var(--font-display); font-size: 2.4rem; font-weight: 750;
  color: var(--primary); background: linear-gradient(135deg, var(--primary-soft), var(--surface-2)); padding: 0;
}
.tile-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; flex: 1; }
.tile-name {
  margin: 0; font-size: .95rem; font-weight: 650; line-height: 1.3; font-family: var(--font);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; color: var(--muted); font-size: .78rem; }
.tile-qty {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; padding: 4px;
  background: var(--surface-2); border-radius: 12px;
}
.tile-qty .amount { font-family: var(--font-display); font-weight: 750; font-variant-numeric: tabular-nums; text-align: center; font-size: .95rem; }
.qty-btn { min-width: 34px; min-height: 34px; padding: 0; font-size: 1.15rem; border-radius: 10px; box-shadow: none; background: var(--surface); border-color: var(--border); }
.dialog-actions .spacer { margin-right: auto; }

/* ===== Tabela ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow-sm); }
table.items { width: 100%; border-collapse: collapse; }
table.items th, table.items td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.items th { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
table.items tbody tr { transition: background .12s; }
table.items tbody tr:hover { background: var(--surface-2); }
table.items tr:last-child td { border-bottom: 0; }
table.items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.items .actions { text-align: right; white-space: nowrap; }
table.items .actions .btn { margin-left: 4px; }
tr.low td:first-child { box-shadow: inset 3px 0 0 var(--warn-strong); }
tr.expired td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.item-name { font-weight: 650; }
.item-notes { color: var(--muted); font-size: .84rem; }
.item-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thumb {
  width: 44px; height: 44px; flex: none; border-radius: 12px; object-fit: contain;
  background: var(--photo-bg); border: 1px solid var(--border); padding: 3px;
}
.thumb-empty { display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-family: var(--font-display); border: 0; }

/* ===== Okna dialogowe ===== */
dialog {
  border: 1px solid var(--border); border-radius: 26px; padding: 24px;
  background: var(--surface); color: var(--text); width: min(580px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: var(--shadow-lg);
}
dialog[open] { animation: dlg-in .26s var(--ease); }
dialog::backdrop { background: rgb(10 10 20 / .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
dialog h2 { margin: 0 0 14px; font-size: 1.3rem; font-weight: 750; }
dialog.wide-dialog { width: min(780px, calc(100vw - 24px)); }
dialog.confirm { width: min(420px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.dialog-head h2 { margin: 0; }
.dialog-head p { margin: 2px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.form-error { color: var(--danger); margin: 0; font-weight: 550; }
#confirm-input { width: 100%; margin-top: 8px; }

#item-form, #eq-form, #med-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 14px; }
#item-form > *, #eq-form > *, #med-form > *, .med-first > *, .batches, .batches * { min-width: 0; }
#item-form h2, #item-form .full, #item-form .dialog-actions, #item-form .form-error,
#eq-form h2, #eq-form .full, #eq-form .dialog-actions, #eq-form .form-error { grid-column: 1 / -1; }
#med-form .full { grid-column: 1 / -1; }
#item-form label, #eq-form label, #med-form label, .stack-label {
  display: flex; flex-direction: column; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--text-2);
}
#item-form h2, #eq-form h2 { margin-bottom: 2px; }
label.check { flex-direction: row !important; align-items: center; gap: 10px !important; font-size: .92rem !important; cursor: pointer; }
#history-list .delta-pos { color: var(--ok); font-weight: 700; }
#history-list .delta-neg { color: var(--danger); font-weight: 700; }

/* Powiadomienie */
#toast {
  position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 550;
  transition: transform .3s var(--ease), opacity .3s; max-width: calc(100vw - 32px); z-index: 40; box-shadow: var(--shadow-lg);
}
#toast:not(.show) { visibility: hidden; opacity: 0; }
#toast.show { transform: translateX(-50%) translateY(0); }

/* Pływający przycisk skanowania (telefon) */
.fab {
  display: none; position: fixed; z-index: 9;
  right: max(18px, env(safe-area-inset-right)); bottom: calc(100px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 20px; border: 0; cursor: pointer;
  background: var(--grad); color: #fff; box-shadow: var(--shadow-primary), var(--shadow);
  align-items: center; justify-content: center;
}
.fab .ico { width: 26px; height: 26px; }
.fab:active { transform: scale(.95); }

/* Zdjęcie w formularzu */
.item-photo { display: flex; gap: 14px; align-items: center; }
.item-photo img { width: 96px; height: 96px; object-fit: contain; border-radius: 16px; background: var(--photo-bg); border: 1px solid var(--border); flex: none; padding: 6px; }
.item-photo-side { display: grid; gap: 8px; font-size: .85rem; }

/* Skanowanie */
.input-with-btn { display: flex; gap: 6px; }
.input-with-btn input { flex: 1; }
.scan-live { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; margin-bottom: 10px; }
.scan-live video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 30% 12%; border: 3px solid rgb(255 255 255 / .95); border-radius: 16px;
  box-shadow: 0 0 0 999px rgb(0 0 0 / .4);
}
.scan-manual { margin-top: 12px; }
.ocr-preview { display: block; max-width: 100%; max-height: 220px; margin: 12px 0 0; border-radius: 12px; }
.ocr-date-label { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
#ocr-text, #receipt-raw { white-space: pre-wrap; font-size: .78rem; max-height: 180px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 10px; }
#scan-result-list .row { flex-wrap: nowrap; }
details summary { cursor: pointer; color: var(--primary-ink); font-weight: 600; margin-top: 10px; }

/* ===== Logowanie ===== */
body.locked .app, body.locked > .fab { visibility: hidden; }
.auth-screen {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: var(--bg); overflow-y: auto;
}
.auth-glow {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(600px 400px at 20% 10%, rgb(124 108 255 / .28), transparent 70%),
    radial-gradient(500px 400px at 85% 90%, rgb(212 107 255 / .22), transparent 70%),
    radial-gradient(400px 300px at 80% 15%, rgb(16 185 129 / .14), transparent 70%);
}
.auth-card {
  position: relative; width: min(400px, 100%); display: grid; gap: 14px; background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border); border-radius: 28px; padding: 32px 28px; box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin: 6px 0 0; font-size: 1.6rem; font-weight: 750; }
.auth-card p { margin: 0; }
.auth-card label { display: grid; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--text-2); }
.auth-card label[hidden] { display: none; }

.admin-only { display: none !important; }
body.is-admin .admin-only { display: revert !important; }
body.is-admin form.admin-only { display: grid !important; }
body.is-admin label.btn.admin-only { display: inline-flex !important; }

/* ===== Drobne narzędzia ===== */
.small { font-size: .8rem; }
.small-h { font-size: .95rem; margin: 10px 0 0; }
.stack { display: grid; gap: 10px; }
.stack .row > * { flex: 1 1 140px; }
.nowrap { flex-wrap: nowrap; }
.push-right { margin-left: auto; }
.wide { width: 100%; min-height: 50px; font-size: 1.02rem; margin: 12px 0; }
.clickable { cursor: pointer; border-radius: 10px; transition: background .12s; }
.clickable:hover { background: var(--surface-2); }
a.btn { text-decoration: none; }

/* ===== Partie i opakowania ===== */
.batches { border: 1px solid var(--border); background: var(--surface-2); border-radius: 16px; padding: 12px 14px; color: var(--text); }
.batches p { margin: 4px 0 10px; }
.batches-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.batch-list, .pack-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.batch-list li {
  display: grid; grid-template-columns: 84px auto 1fr auto; gap: 8px; align-items: center;
  padding: 6px 8px 6px 10px; background: var(--surface); border-radius: 12px; border-left: 4px solid var(--border-strong);
}
.batch-list li.warn, .pack-list li.warn { border-left-color: var(--warn-strong); }
.batch-list li.danger, .pack-list li.danger { border-left-color: var(--danger); }
.batch-list input, .pack-list input { width: 100%; padding: 6px 9px; min-height: 36px; }
.batch-acts { display: flex; gap: 4px; }
.batch-add { display: grid; grid-template-columns: 84px 1fr 120px auto; gap: 8px; margin-top: 10px; }
.batch-add input { padding: 6px 9px; min-height: 36px; }
.pack-add { grid-template-columns: 100px 1fr auto; }
.pack-list li {
  display: grid; grid-template-columns: 90px 1fr 1fr auto; gap: 8px; align-items: end;
  padding: 8px 8px 8px 10px; background: var(--surface); border-radius: 12px; border-left: 4px solid var(--med);
}
.pack-list label { font-size: .7rem !important; gap: 3px !important; color: var(--muted) !important; }
.pack-list .pack-info { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
[data-single][hidden] { display: none !important; }

/* ===== Szybkie zużycie ===== */
#quick-log li.undone { opacity: .5; }
#quick-log .item-cell { min-width: 0; }

/* ===== Paragony ===== */
.receipt-meta { display: grid; grid-template-columns: 2fr 1.3fr 1fr; gap: 10px; margin-bottom: 12px; }
.receipt-meta label { display: grid; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--text-2); }
.receipt-lines { display: grid; gap: 8px; margin-bottom: 8px; }
.rline {
  display: grid; grid-template-columns: minmax(0, 2fr) 70px 90px minmax(0, 2fr) 140px auto; gap: 6px; align-items: center;
  padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2);
}
.rline input, .rline select { padding: 6px 9px; width: 100%; min-height: 36px; }
.rline .rl-hint { grid-column: 1 / -1; }
.rline.skipped { opacity: .5; }
#receipt-text { width: 100%; margin: 8px 0; }

/* ===== Wydatki: wykres słupkowy ===== */
.colchart { min-height: 170px; }
.col-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.col-now { font-family: var(--font-display); font-size: 1.5rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.cols {
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; height: 130px;
  align-items: end; border-bottom: 1px solid var(--border);
}
.col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; outline: none; }
.col-bar { width: min(30px, 72%); min-height: 3px; background: var(--grad); border-radius: 8px 8px 3px 3px; transition: filter .15s; }
.waste .col-bar { background: linear-gradient(180deg, #ffb547, #f59e0b); }
.col:hover .col-bar, .col:focus .col-bar { filter: brightness(1.12); }
.col:hover::after, .col:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: .75rem; font-weight: 600; padding: 5px 9px; border-radius: 8px; white-space: nowrap; z-index: 2;
}
.cols-axis { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
.cols-axis span { text-align: center; font-size: .72rem; color: var(--muted); overflow: hidden; white-space: nowrap; }
.chart-empty { margin: 40px 0; text-align: center; }
.table-toggle summary { margin-top: 0; }
.table-wrap.plain { border: 0; margin-top: 10px; box-shadow: none; }

/* ===== Sprzęty ===== */
.eq-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.eq-card {
  display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 14px; cursor: pointer; min-width: 0; box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.eq-card:hover, .eq-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); outline: none; }
.eq-photo {
  width: 64px; height: 64px; flex: none; border-radius: 16px; object-fit: cover;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface-2));
  display: grid; place-items: center; font-family: var(--font-display); font-size: 1.5rem; font-weight: 750; color: var(--primary);
}
.eq-body { min-width: 0; display: grid; gap: 4px; }
.eq-body h3 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#eq-form .input-with-btn select { width: auto; }
.docs { border: 1px solid var(--border); background: var(--surface-2); border-radius: 16px; padding: 12px 14px; color: var(--text); }
.doc-list li { gap: 8px; }
.doc-link { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; flex: 1; }
.doc-link span { min-width: 0; overflow-wrap: anywhere; }
.doc-ico { font-size: 1.3rem; }
.doc-upload { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ===== Domowa apteka ===== */
.med-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 16px;
  border-radius: 18px; background: var(--danger-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.mb-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--danger); color: #fff; flex: none; }
.mb-text { display: grid; flex: 1 1 260px; min-width: 0; font-size: .88rem; }
.mb-text strong { font-size: .98rem; color: var(--danger); }

.med-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.med-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 16px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.med-card:hover, .med-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); outline: none; border-color: var(--border-strong); }
.med-card.expired { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.med-card.expiring { border-color: color-mix(in srgb, var(--warn-strong) 55%, var(--border)); }
.med-card.empty { opacity: .72; }
.med-top { display: flex; gap: 12px; align-items: flex-start; }
.med-ico {
  width: 46px; height: 46px; flex: none; border-radius: 15px; display: grid; place-items: center;
  background: var(--med-soft); color: var(--med);
}
.med-ico .ico { width: 23px; height: 23px; }
.med-ico.lg { width: 52px; height: 52px; border-radius: 17px; }
.med-ico.f-bottle { background: var(--amber-soft); color: var(--warn); }
.med-ico.f-drop { background: var(--sky-soft); color: var(--sky); }
.med-ico.f-tube { background: var(--rose-soft); color: var(--rose); }
.med-ico.f-spray { background: var(--primary-soft); color: var(--primary); }
.med-ico.f-bandage { background: var(--surface-2); color: var(--text-2); }
.med-title { min-width: 0; flex: 1; }
.med-title h3 { margin: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.med-title .med-sub { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.rx { font-size: .64rem; font-weight: 800; letter-spacing: .04em; color: var(--rose); border: 1.5px solid currentColor; border-radius: 6px; padding: 1px 4px; margin-left: 6px; vertical-align: 2px; }
.med-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.med-tag { font-size: .75rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.med-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .8rem; }
.med-meta span { display: inline-flex; align-items: center; gap: 5px; }
.med-meta .ico { width: 14px; height: 14px; }
.med-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto;
  padding: 10px 10px 10px 14px; background: var(--surface-2); border-radius: 15px;
}
.med-qty { display: grid; line-height: 1.2; min-width: 0; }
.med-qty strong { font-family: var(--font-display); font-size: 1.15rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.med-qty span { font-size: .76rem; color: var(--muted); }
.med-last { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.med-last .ico { width: 14px; height: 14px; }
.med-note { margin-top: 18px; text-align: center; }
.med-first { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 12px 14px; background: var(--med-soft); border-radius: 16px; }
.take-last {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 12px; border-radius: 14px;
  background: var(--warn-soft); color: var(--text); font-size: .88rem;
}
.take-last .ico { color: var(--warn); width: 20px; height: 20px; margin-top: 1px; }
.take-last.recent { background: var(--danger-soft); }
.take-last.recent .ico { color: var(--danger); }
.take-dosage { margin: 0 0 12px; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); font-size: .88rem; }
#take-form { display: grid; gap: 14px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { width: 96px; text-align: center; font-family: var(--font-display); font-size: 1.3rem; font-weight: 750; }
.stepper-unit { color: var(--muted); font-weight: 600; min-width: 40px; }
.journal li { align-items: flex-start; }
.journal .j-time { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ===== Kalendarz ===== */
.ev-family { --ev: #7c6cff; } .ev-home { --ev: #f59e0b; } .ev-health { --ev: #10b981; } .ev-school { --ev: #0ea5e9; }
.ev-work { --ev: #64748b; } .ev-birthday { --ev: #ec4899; } .ev-trip { --ev: #14b8a6; } .ev-other { --ev: #8b8ba3; }

.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { margin: 0 6px; font-size: 1.3rem; font-weight: 750; min-width: 9.5em; text-align: center; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 550; color: var(--text-2); cursor: pointer; white-space: nowrap; flex: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .2s; flex: none; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked + .switch-ui { background: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--primary); outline-offset: 2px; }

.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.cal-grid-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekdays span { padding: 10px 8px; font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: left; background: var(--surface-2); }
.cal-weekdays span:nth-child(n+6) { color: var(--rose); }
.cal-cell {
  position: relative; display: flex; flex-direction: column; gap: 3px; min-height: 112px; min-width: 0; padding: 6px;
  border: 0; border-top: 1px solid var(--border); border-right: 1px solid var(--border);
  background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.out { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.cal-cell.out .cal-num { color: var(--muted); opacity: .6; }
.cal-cell.weekend .cal-num { color: var(--rose); }
.cal-cell.selected { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.cal-num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  font-family: var(--font-display); font-weight: 700; font-size: .88rem; font-variant-numeric: tabular-nums;
}
.cal-cell.today .cal-num { background: var(--grad); color: #fff !important; box-shadow: var(--shadow-primary); }
.cal-pill {
  display: block; min-width: 0; padding: 2px 7px; border-radius: 7px; font-size: .74rem; font-weight: 600; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--ev) 15%, transparent); color: var(--text); border-left: 3px solid var(--ev);
}
.cal-pill.home { background: none; border-left-style: dotted; color: var(--muted); font-weight: 550; }
.cal-pill .t { color: var(--muted); font-weight: 650; margin-right: 3px; font-variant-numeric: tabular-nums; }
.cal-more { font-size: .72rem; font-weight: 650; color: var(--muted); padding-left: 6px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; justify-content: center; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ev); }

.cal-day { position: sticky; top: 90px; margin: 0; }
.cal-day-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.cal-day-head h2 { margin: 0; font-size: 1.15rem; }

.agenda { display: grid; gap: 8px; }
.agenda-day { display: grid; gap: 8px; }
.agenda-day + .agenda-day { margin-top: 10px; }
.agenda-date { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.agenda-date.today { color: var(--primary-ink); }
.agenda-empty { color: var(--muted); font-size: .9rem; padding: 8px 2px; }
.ev {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%;
  padding: 10px 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
  border-left: 4px solid var(--ev); font: inherit; color: inherit; text-align: left; cursor: pointer;
  transition: background .12s, transform .12s;
}
.ev:hover { background: var(--surface-2); }
.ev.home { border-left-style: dashed; background: var(--surface-2); }
.ev-time { font-family: var(--font-display); font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ev-time small { display: block; color: var(--muted); font-family: var(--font); font-weight: 500; font-size: .72rem; }
.ev-body { min-width: 0; }
.ev-title { font-weight: 650; overflow-wrap: anywhere; line-height: 1.3; }
.ev-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: .76rem; margin-top: 2px; }
.ev-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ev-meta .ico { width: 13px; height: 13px; }
.ev-who { display: flex; }
.ev-who .avatar { width: 26px; height: 26px; font-size: .68rem; border: 2px solid var(--surface); box-shadow: none; margin-left: -6px; }
.ev-who .avatar:first-child { margin-left: 0; }
.agenda.compact .ev { padding: 8px 10px; }

.ev-ico { width: 52px; height: 52px; border-radius: 17px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--ev, var(--primary)) 16%, transparent); color: var(--ev, var(--primary)); }
.ev-ico .ico { width: 24px; height: 24px; }
#event-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 14px; }
#event-form > * { min-width: 0; }
#event-form .full { grid-column: 1 / -1; }
#event-form label { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--text-2); }
.chip-btn.cat { gap: 7px; }
.chip-btn.cat::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ev); }
.chip-btn.cat[aria-pressed="true"] { background: color-mix(in srgb, var(--ev) 18%, var(--surface)); border-color: var(--ev); color: var(--text); }
.chip-btn .avatar { width: 22px; height: 22px; font-size: .62rem; box-shadow: none; margin-left: -8px; }
.chip-btn.person[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-ink); }
.ht-ico.warm { background: var(--warn-soft); color: var(--warn); }
.tab-badge.primary { background: var(--primary); color: #fff; }

@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-day { position: static; }
}
@media (max-width: 640px) {
  .cal-toolbar { display: grid; grid-template-columns: 1fr auto; }
  .cal-nav { grid-column: 1 / -1; justify-content: space-between; }
  .cal-title { font-size: 1.1rem; min-width: 0; flex: 1; }
  .cal-toolbar .seg-ctl span { display: none; }
  .cal-toolbar .push-right { margin-left: 0; }
  .cal-cell { min-height: 54px; padding: 4px 2px; align-items: center; gap: 4px; }
  .cal-num { width: 26px; height: 26px; font-size: .82rem; }
  .cal-pill, .cal-more { display: none; }
  .cal-dots { display: flex; }
  .cal-weekdays span { text-align: center; padding: 8px 2px; font-size: .66rem; }
  .ev { grid-template-columns: 46px minmax(0, 1fr) auto; padding: 9px 10px; }
  #view-calendar .items-head { flex-wrap: wrap; }
  #view-calendar .loc-chips { flex: 1 1 100%; }
}

/* ===== Integracje ===== */
.grid2.inner { margin: 6px 0 0; gap: 22px; }
.grid2.inner > div { min-width: 0; }
.token-new { padding: 12px; border-radius: 14px; background: var(--ok-soft); margin-bottom: 10px; }
.token-new p { margin: 0 0 8px; }
.token-new input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
#embed-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; overflow-wrap: anywhere; }
/* Wewnątrz Home Assistant / Domoticza: bez własnego paska na górze strony (ma go aplikacja-gospodarz). */
body.embedded .page-header { padding-top: 12px; }
@media (min-width: 901px) {
  body.embedded .app { grid-template-columns: 76px minmax(0, 1fr); }
  body.embedded .sidebar { padding-left: 10px; padding-right: 10px; align-items: center; }
  body.embedded .brand { padding: 0; }
  body.embedded .brand-text, body.embedded .nav-label, body.embedded .tab > span:not(.tab-badge),
  body.embedded .user-card .uc-text, body.embedded .user-card > .ico { display: none; }
  body.embedded .tabs { align-items: center; gap: 6px; }
  body.embedded .tab { justify-content: center; width: 48px; height: 48px; padding: 0; }
  body.embedded .tab .tab-badge { position: absolute; top: 2px; right: 0; margin: 0; min-width: 18px; height: 18px; font-size: .64rem; }
  body.embedded .user-card { width: auto; padding: 6px; justify-content: center; }
  body.embedded .page-header { padding-left: 24px; padding-right: 24px; }
  body.embedded main { padding-left: 24px; padding-right: 24px; }
}

/* ===== Więcej: kafle nawigacji (telefon) ===== */
.hub { display: grid; gap: 10px; margin-bottom: 18px; }
.hub-tile {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 14px; box-shadow: var(--shadow-sm);
}
.hub-tile > span:nth-child(2) { display: grid; flex: 1; min-width: 0; }
.ht-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.ht-ico.alt { background: var(--sky-soft); color: var(--sky); }
.hub-tile .chev { color: var(--muted); }
.hub-tile .tab-badge { margin-left: 0; }

/* ===== Telefon / wąski ekran ===== */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: contents; }
  .brand, .user-card, .nav-label, .tab-secondary, .lbl-desktop { display: none !important; }
  .lbl-mobile { display: inline; }
  .mobile-only { display: revert !important; }
  .avatar.mobile-only { display: grid !important; }
  .hub.mobile-only { display: grid !important; }

  .tabs {
    position: fixed; z-index: 10; flex: none; overflow: visible;
    left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 6px;
    background: var(--glass); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg);
    backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
  }
  .tab { flex-direction: column; justify-content: center; gap: 3px; padding: 8px 2px 6px; font-size: .68rem; border-radius: 18px; text-align: center; }
  .tab .ico { width: 22px; height: 22px; }
  .tab:hover { background: none; }
  .tab.active { background: var(--primary-soft); }
  .tab .tab-badge { position: absolute; top: 3px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 18px; font-size: .64rem; }

  .page-header { padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
  .page-title h1 { font-size: 1.4rem; }
  .eyebrow { font-size: .72rem; }
  .icon-btn { width: 36px; height: 36px; border-radius: 11px; }
  main { padding: 2px max(16px, env(safe-area-inset-right)) calc(120px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  body[data-view="items"] .fab { display: flex; }
  #toast { bottom: calc(100px + env(safe-area-inset-bottom)); }

  /* Okna jako arkusze od dołu */
  dialog {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; border-bottom: 0;
    max-height: 94dvh; padding: 22px max(18px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
  dialog.wide-dialog, dialog.confirm { width: 100%; }
  dialog[open] { animation: sheet-in .3s var(--ease); }
  dialog::before {
    content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: -10px auto 14px;
  }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
  .dialog-actions { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); background: var(--surface); padding: 12px 0 0; margin-top: 12px; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  /* iPhone powiększa stronę przy polach z czcionką mniejszą niż 16 px – stąd „uciekanie” na boki. */
  input, select, textarea { font-size: 16px; }
  .stepper input { font-size: 1.3rem; }
  .hero { padding: 20px 18px 16px; border-radius: 24px; }
  .hero-greet { font-size: 1.4rem; }
  .hero-sub { font-size: .9rem; }
  .hero-actions { flex: 1 1 100%; gap: 8px; }
  .hero-btn { font-size: .74rem; padding: 10px 4px 8px; border-radius: 14px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; column-gap: 10px; border-radius: 16px; }
  .stat .s-ico { width: 34px; height: 34px; border-radius: 11px; }
  .stat .s-ico .ico { width: 17px; height: 17px; }
  .stat .label { font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat .value { font-size: 1.12rem; }
  .med-banner { padding: 12px; gap: 10px; }
  .med-banner .btn { width: 100%; }
  .card { padding: 16px; border-radius: 18px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .bars .bar-row { grid-template-columns: 100px 1fr 32px; }
  .bars .bar-row:has(.money) { grid-template-columns: 90px 1fr auto; }

  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar .search, #btn-med-add, #btn-add-eq { grid-column: 1 / -1; }
  #f-location { display: none; }
  .items-head { flex-wrap: nowrap; }
  .toolbar .seg-ctl { grid-column: 1 / -1; justify-self: start; }
  .toolbar .push-right { grid-column: 1 / -1; margin-left: 0; }
  #btn-scan { display: none; }


  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { border-radius: 18px; }
  .layout-toggle span { display: none; }
  .layout-toggle { margin-left: auto; }
  .med-grid, .eq-list { grid-template-columns: minmax(0, 1fr); }

  #item-form, #eq-form, #med-form, .med-first { grid-template-columns: minmax(0, 1fr); }
  .receipt-meta { grid-template-columns: 1fr 1fr; }
  .receipt-meta label:first-child { grid-column: 1 / -1; }
  .rline { grid-template-columns: minmax(0, 1fr) 64px 84px auto; }
  .rline .rl-target { grid-column: 1 / 3; }
  .rline .rl-date { grid-column: 3 / -1; }
  .batch-list li { grid-template-columns: 64px auto 1fr; }
  .batch-acts { grid-column: 1 / -1; justify-content: flex-end; }
  .batch-add { grid-template-columns: 1fr 1fr; }
  .pack-list li { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pack-list li > label:first-child { grid-column: 1; grid-row: 1; }
  .pack-list li > .btn { grid-column: 2; grid-row: 1; justify-self: end; align-self: end; }
  .pack-add { grid-template-columns: 1fr 1fr; }
  .pack-add .btn { grid-column: 1 / -1; }

  /* Tabela zasobów jako karty */
  #items-table table.items thead { display: none; }
  #items-table table.items, #items-table table.items tbody { display: block; }
  #items-table table.items tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  #items-table table.items tr:last-child { border-bottom: 0; }
  #items-table table.items td { display: block; padding: 0; border: 0; }
  #items-table table.items td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #items-table table.items td:nth-child(4) { grid-column: 2; grid-row: 1; }
  #items-table table.items td:nth-child(2), #items-table table.items td:nth-child(3) { display: inline; grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
  #items-table table.items td:nth-child(2) { grid-row: 2; }
  #items-table table.items td:nth-child(3) { grid-row: 3; }
  #items-table table.items td:nth-child(5) { grid-column: 1 / -1; font-size: .9rem; }
  #items-table table.items td.nil { display: none; }
  #items-table table.items td.actions { grid-column: 1 / -1; text-align: left; margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
  #items-table table.items td.actions .btn { margin: 0; }
  #items-table tr.low { box-shadow: inset 3px 0 0 var(--warn-strong); }
  #items-table tr.expired { box-shadow: inset 3px 0 0 var(--danger); }
  #items-table tr.low td:first-child, #items-table tr.expired td:first-child { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
