/* Kryształowa Spiżarnia — styl: ciepłe jasne tło, białe powierzchnie, jeden zielony akcent. */

:root {
  --bg: #faf7f2;
  --bg-soft: #f3efe7;
  --surface: #ffffff;
  --line: #e7e0d4;
  --line-strong: #d8cfbe;
  --ink: #241f1a;
  --ink-soft: #5d554a;
  --ink-mute: #8a8073;

  --accent: #1f7a4d;
  --accent-ink: #ffffff;
  --accent-soft: #e7f2ec;
  --accent-line: #b9dcc9;

  --warn: #9a5b06;
  --warn-soft: #fcf1df;
  --warn-line: #f0d9ae;

  --danger: #a3301f;
  --danger-soft: #fceceb;
  --danger-line: #f0c3bd;

  --info: #2a5b8c;
  --info-soft: #e9f1f9;
  --info-line: #c2d8ec;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(36, 31, 26, .06), 0 8px 24px rgba(36, 31, 26, .06);
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.is-locked { overflow: hidden; }

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ───────────────────────────── szkielet ───────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(250, 247, 242, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 680; }
.brand__mark { color: var(--accent); font-size: 20px; }
.brand__name { font-size: 17px; letter-spacing: -.02em; }
.brand--big { flex-direction: column; gap: 4px; }
.brand--big .brand__mark { font-size: 32px; }
.brand--big .brand__name { font-size: 22px; }

.topbar__actions { display: flex; align-items: center; gap: 4px; }

.offline-pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line);
}

.layout { display: flex; align-items: flex-start; }

.sidenav { display: none; }

.main {
  flex: 1;
  min-width: 0;
  padding: 16px;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: 980px;
  margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar__link {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 58px;
  text-decoration: none;
  color: var(--ink-mute);
  font-size: 12px; font-weight: 600;
}

.tabbar__link.is-active { color: var(--accent); }
.tabbar__link.is-active svg { stroke-width: 2.1; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .layout { gap: 24px; padding: 16px; max-width: 1200px; margin: 0 auto; }
  .sidenav {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 76px;
    width: 220px; flex: none;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .sidenav__link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--ink-soft); text-decoration: none; font-weight: 600;
  }
  .sidenav__link:hover { background: var(--bg-soft); }
  .sidenav__link.is-active { background: var(--accent-soft); color: var(--accent); }
  .main { padding: 0; padding-bottom: 40px; }
}

/* ───────────────────────────── elementy ───────────────────────────── */

.view { display: flex; flex-direction: column; gap: 14px; }
.view__title { font-size: 22px; }
.view__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 620; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: #196340; }
.btn--danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--wide { width: 100%; }
.btn--small { min-height: 36px; padding: 6px 12px; font-size: 14px; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap);
  border: 0; border-radius: 12px; background: transparent; color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.icon-btn--accent { background: var(--accent-soft); color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.dot {
  position: absolute; top: 6px; right: 6px;
  min-width: 18px; height: 18px; padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
}

.linkish {
  background: none; border: 0; padding: 6px 0;
  color: var(--accent); font: inherit; font-weight: 620; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.linkish:hover { text-decoration: underline; }

/* wyszukiwarka */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  color: var(--ink-mute);
  box-shadow: var(--shadow);
}
.search__input {
  flex: 1; border: 0; background: transparent; min-height: 40px; padding: 0;
  font-size: 16px; color: var(--ink);
}
.search__input:focus { outline: none; }
.search:focus-within { border-color: var(--accent-line); }

.chips {
  display: flex; gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: none;
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* starszy Edge */
}
.chips::-webkit-scrollbar { display: none; width: 0; height: 0; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink-soft);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip--static { cursor: default; }
.chip__x { border: 0; background: none; color: var(--ink-mute); cursor: pointer; font-size: 16px; padding: 0 2px; }

/* lista i wiersze */
.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.row--low { border-left: 4px solid var(--warn); }
.row--archived { opacity: .72; }
.row__head { display: flex; align-items: stretch; }
.row__main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px;
  background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.row--link { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; text-align: left; font: inherit; cursor: pointer; }
.row--notif .row__main { cursor: default; }
.row--notif.is-unread { border-left: 4px solid var(--accent); }
.row--compact { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; }
.row__title { font-weight: 640; }
.row__brand { font-weight: 500; color: var(--ink-mute); }
.row__meta { color: var(--ink-soft); font-size: 14px; }
.row__badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.row__quick { display: flex; align-items: center; gap: 0; padding: 4px; border-left: 1px solid var(--line); }
.row__details { border-top: 1px solid var(--line); padding: 10px 14px; background: var(--bg-soft); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 620;
  border: 1px solid var(--line-strong); background: var(--bg-soft); color: var(--ink-soft);
}
.badge--ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.badge--info { background: var(--info-soft); border-color: var(--info-line); color: var(--info); }
.badge--warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.badge--danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }

.batch {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-strong);
}
.batch:last-child { border-bottom: 0; }
.batch--card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.batch__info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14.5px; color: var(--ink-soft); }
.batch__info strong { color: var(--ink); }
.batch__note { font-style: italic; }
.batch__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.batch__actions--end { justify-content: flex-end; padding-top: 10px; }

/* karty */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.card__title { font-size: 16px; }
.card__row { display: flex; flex-direction: column; gap: 8px; }

.product__head { display: flex; flex-direction: column; gap: 6px; }
.product__sub { margin: 0; color: var(--ink-soft); font-size: 14.5px; }
.product__total { margin: 0; font-weight: 650; }

.history { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-soft); }
.history__when { color: var(--ink-mute); }

/* formularze */
.form { display: flex; flex-direction: column; gap: 12px; }
.form__section { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; border-top: 1px solid var(--line); }
.form__legend { font-size: 14px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .04em; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: 14px; font-weight: 620; color: var(--ink-soft); }
.field__hint, .hint { font-size: 13px; color: var(--ink-mute); margin: 0; }

.input {
  width: 100%; min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-mute) 50%), linear-gradient(135deg, var(--ink-mute) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

.grid { display: grid; gap: 12px; }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
@media (min-width: 560px) {
  .grid--2 { grid-template-columns: 1fr 1fr; }
  .grid--3 { grid-template-columns: 1fr 1fr 1fr; }
}

.row-inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row-inline .field { flex: 1; min-width: 180px; }

.switch-row { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 560; cursor: pointer; }
.switch-row--inline { min-height: 36px; font-size: 14px; }
.switch { width: 20px; height: 20px; accent-color: var(--accent); }

.prose { margin: 0; color: var(--ink-soft); }

.notice {
  margin: 0; padding: 12px 14px;
  background: var(--info-soft); border: 1px solid var(--info-line); color: var(--info);
  border-radius: var(--radius-sm); font-size: 14.5px;
}
.notice--danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 36px 20px; text-align: center;
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.empty__title { margin: 0; font-weight: 650; }
.empty__text { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

.loading { display: flex; align-items: center; gap: 10px; padding: 18px; color: var(--ink-mute); }
.loading__dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading__dot { animation: none; } }

.suggestion { padding: 10px 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius-sm); }

/* skaner */
.scanner {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #14110e;
  border-radius: var(--radius);
  overflow: hidden;
}
.scanner__video { width: 100%; height: 100%; object-fit: cover; }
.scanner__frame {
  position: absolute; inset: 18% 12%;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 10px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28);
}
.scanner__status { margin: 0; color: var(--ink-soft); font-size: 14.5px; min-height: 22px; }

/* picker */
.picker { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; }
.picker__item {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font: inherit; cursor: pointer;
}
.picker__item:hover { background: var(--bg-soft); }
.picker__item--create { flex-direction: row; align-items: center; gap: 8px; color: var(--accent); border-style: dashed; font-weight: 620; }
.picker__name { font-weight: 620; }
.picker__meta { font-size: 13.5px; color: var(--ink-soft); }

/* arkusze */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(36, 31, 26, .4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .2);
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(16px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet__title { font-size: 17px; }
.sheet__body { padding: 16px 18px; overflow-y: auto; }
.sheet__foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 18px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { max-width: 620px; border-radius: 18px; animation: none; }
  .sheet--small { max-width: 440px; }
}

/* toasty */
.toast-host {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
  width: min(560px, calc(100vw - 24px));
}
@media (min-width: 900px) { .toast-host { bottom: 24px; } }

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px;
  background: #241f1a; color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
  font-size: 14.5px;
}
.toast--success { background: #14563a; }
.toast--danger { background: #7e2718; }
.toast--warn { background: #7a4805; }
.toast__text { flex: 1; }
.toast__action { background: rgba(255, 255, 255, .16); border: 0; color: #fff; font: inherit; font-weight: 650; padding: 8px 12px; border-radius: 999px; cursor: pointer; }
.toast__action:hover { background: rgba(255, 255, 255, .26); }
.toast__close { background: none; border: 0; color: rgba(255, 255, 255, .8); cursor: pointer; display: inline-flex; padding: 6px; }

/* logowanie */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth__card {
  width: min(420px, 100%);
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 24px; box-shadow: var(--shadow);
  text-align: center;
}
.auth__lead { margin: 0; color: var(--ink-soft); font-size: 14.5px; }
.auth__form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth__msg { margin: 0; min-height: 20px; font-size: 14px; color: var(--danger); }
.auth__links { display: flex; flex-direction: column; align-items: center; gap: 2px; }

/* link pomijający nawigację */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 10px 0;
  font-weight: 650; text-decoration: none;
}
.skip-link:focus { left: 0; }

/* atrybut hidden musi wygrywać z display ustawionym w komponentach */
[hidden] { display: none !important; }

/* znaczniki stanu w wierszu: jedna linia, żeby lista była zwarta na telefonie */
.row__badges .badge { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.row__badges .badge > span { overflow: hidden; text-overflow: ellipsis; }
.row__quick .icon-btn { min-width: 40px; }
@media (max-width: 420px) {
  .badge { font-size: 12px; padding: 3px 8px; }
  .row__quick { padding: 4px 2px; }
  .row__quick .icon-btn { min-width: 38px; }
}
