/* Monitor Dostaw: beton, grafit i jeden pomarańcz ostrzegawczy. Najpierw telefon (na budowie,
   w słońcu, w rękawicach: duży kontrast i duże pola), od 900 px menu z boku i tabele. */

:root {
  --bg: #eeece8;
  --bg-2: #e5e2dc;
  --tile: #ffffff;
  --line: #dcd8d0;
  --text: #17191c;
  --muted: #5b5f66;
  --faint: #8a8e94;
  --dark: #1d2126;
  --dark-2: #2a2f36;
  --dark-text: #b9bec5;
  --signal: #ff6b1a;
  --signal-ink: #b8460a;
  --signal-soft: #fff0e6;
  --ok: #2f7d4f;
  --ok-soft: #e7f2ea;
  --bad: #c8381f;
  --bad-soft: #fbe9e5;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 0 rgba(23, 25, 28, .04), 0 6px 18px -8px rgba(23, 25, 28, .18);
  --tabbar-h: 68px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --bg-2: #1c2025;
    --tile: #1f2328;
    --line: #2f343b;
    --text: #eef0f2;
    --muted: #a3a9b1;
    --faint: #7b8189;
    --dark: #0d0f12;
    --dark-2: #24292f;
    --signal-ink: #ff8a4a;
    --signal-soft: #3a2416;
    --ok: #6fcf97;
    --ok-soft: #1b3326;
    --bad: #ff7a64;
    --bad-soft: #3d201b;
    --warn: #ffc26b;
    --warn-soft: #3a2d16;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); }
a { color: var(--signal-ink); }
h1, h2, h3 { letter-spacing: -.015em; }
h1 { font-size: 1.75rem; line-height: 1.08; margin: 0 0 .25rem; font-weight: 800; font-stretch: 85%; }
h2 { font-size: 1.15rem; margin: .25rem 0 .5rem; font-weight: 750; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; font-weight: 700; }
p { margin: .25rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.strong { font-weight: 650; }
.boot, .loading { padding: 2rem 1rem; color: var(--muted); text-align: center; }
[hidden] { display: none !important; }

/* --- Ikony ---------------------------------------------------------------------------- */

.ic { flex: none; display: block; color: inherit; }
.ic .ic-line { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ic .ic-thin { stroke-width: 1.4; opacity: .6; }
.ic .ic-bold { stroke-width: 2.8; }
.ic .ic-accent { fill: none; stroke: var(--signal); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ic .ic-fill { fill: var(--signal); }
.ic .ic-solid { fill: var(--tile); }
.btn-in { display: inline-flex; align-items: center; gap: .5rem; }

/* --- Szkielet ------------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-weight: 750; font-size: 1.05rem; letter-spacing: -.01em; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; position: relative; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--tile);
  color: var(--text); cursor: pointer; text-decoration: none; padding: 0;
}
.icon-btn:hover { border-color: var(--faint); }
.modal-head .icon-btn, .item-row .icon-btn { border-color: transparent; background: transparent; }
.user-btn { background: var(--dark); border-color: var(--dark); color: #fff; font: 700 1rem var(--font); }
.user-menu {
  position: absolute; right: 0; top: 52px; min-width: 250px; padding: 1rem; z-index: 30;
  background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .35);
}
.user-menu-name { font-weight: 700; }
.user-menu .btn { margin-top: .6rem; width: 100%; }

.nav-badge {
  position: absolute; top: 4px; right: 2px; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--signal); color: #fff; font-size: .72rem; font-weight: 750; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--tile);
}
.bell .nav-badge { top: -6px; right: -6px; box-shadow: 0 0 0 2px var(--bg); }

main { padding: .5rem 1rem calc(var(--tabbar-h) + 1.75rem + env(safe-area-inset-bottom)); max-width: 1120px; margin: 0 auto; outline: none; }

.sidenav { display: none; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom);
  background: var(--tile); border-top: 1px solid var(--line);
}
.tabbar .nav-link {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); text-decoration: none; font-size: .72rem; font-weight: 600; min-width: 0; border-radius: 14px;
}
.tabbar .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }
.tabbar .nav-link.active { color: var(--text); background: var(--bg); }
.tabbar .nav-badge { right: calc(50% - 26px); }

@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
  .topbar { grid-column: 2; padding: 1rem 2rem .25rem; background: transparent; backdrop-filter: none; position: static; }
  .topbar .brand { visibility: hidden; }
  .tabbar { display: none; }
  .sidenav {
    grid-column: 1; grid-row: 1 / span 2;
    display: flex; flex-direction: column; gap: 4px; padding: 1.1rem .75rem;
    background: var(--bg-2); border-right: 1px solid var(--line);
    position: sticky; top: 0; height: 100vh;
  }
  .sidenav::before {
    content: "Monitor Dostaw"; display: flex; align-items: center; height: 44px; padding: 0 .75rem 0 3.1rem; margin-bottom: .75rem;
    font-weight: 750; font-size: 1.05rem; letter-spacing: -.01em;
    background: url("/icons/icon.svg") .6rem center / 30px no-repeat;
  }
  .sidenav .nav-link {
    position: relative; display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem;
    border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 600;
  }
  .sidenav .nav-link:hover { color: var(--text); background: color-mix(in srgb, var(--tile) 55%, transparent); }
  .sidenav .nav-link.active { background: var(--tile); color: var(--text); box-shadow: var(--shadow); }
  .sidenav .nav-badge { position: static; margin-left: auto; box-shadow: none; }
  main { grid-column: 2; padding: 1rem 2rem 3rem; width: 100%; }
}

/* --- Strony --------------------------------------------------------------------------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin: .5rem 0 1.1rem; }
.page-head h1 { margin: 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.narrow { max-width: 660px; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }
.card {
  background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow);
}
.card + .card, .card + h2, .card + table, table + .card { margin-top: 1rem; }
.task-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.grow-right { margin-left: auto; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .9rem; margin: .6rem 0; }
.facts dt { color: var(--muted); font-size: .875rem; padding-top: .1rem; }
.facts dd { margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.note { background: var(--warn-soft); color: var(--text); border-radius: 10px; padding: .5rem .7rem; }
.pre { white-space: pre-wrap; word-break: break-word; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); background: var(--tile); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-title { font-size: 1.1rem; color: var(--text); font-weight: 700; }
.steps { margin: 0; padding-left: 1.25rem; }
.steps li { padding: .3rem 0; }
.steps li.done { color: var(--muted); text-decoration: line-through; }

.badge {
  display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .6rem; border-radius: 999px;
  font-size: .76rem; font-weight: 650; white-space: nowrap; background: var(--bg); color: var(--muted);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--signal-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-done { background: var(--bg); color: var(--faint); }

.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

/* --- Pulpit (kafle) ------------------------------------------------------------------- */

.hello { margin: .25rem .1rem 1.1rem; }
.hello p { margin: 0; color: var(--muted); font-size: .9rem; }
.hello p::first-letter { text-transform: uppercase; }
.hello h1 { font-size: 2rem; margin-top: .15rem; }

.bento { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: .6rem; padding: 1rem;
  min-height: 138px; border-radius: var(--radius); background: var(--tile); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .12s ease, border-color .12s;
}
a.tile:hover { border-color: var(--faint); }
a.tile:active, .hero-item:active { transform: scale(.98); }
.tile h3 { margin: auto 0 0; font-size: 1.2rem; line-height: 1.1; font-weight: 750; }
.tile small { color: var(--muted); font-size: .86rem; line-height: 1.3; }
.tile-badge { position: absolute; top: .9rem; right: .9rem; padding: .3rem .6rem; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: .82rem; font-weight: 700; }
.tile-badge.hot { background: var(--signal); color: #fff; }
.tile-wide { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 0; gap: 1rem; }
.tile-wide h3 { margin: 0; }
.tile-chev { margin-left: auto; color: var(--faint); }

.tile-hero { grid-column: 1 / -1; background: var(--dark); border-color: var(--dark); color: #fff; min-height: 0; padding: 1.1rem; gap: .8rem; }
.tile-hero a { color: inherit; text-decoration: none; }
.hero-head { display: flex; align-items: center; justify-content: space-between; }
.hero-head span { font-size: .8rem; letter-spacing: .09em; text-transform: uppercase; color: var(--dark-text); font-weight: 650; }
.hero-count { display: flex; align-items: center; gap: .8rem; }
.hero-count b { font-size: 3.6rem; line-height: .85; font-weight: 800; font-stretch: 78%; color: var(--signal); font-variant-numeric: tabular-nums; }
.hero-count em { font-style: normal; font-size: 1.05rem; font-weight: 600; line-height: 1.25; }
.tile-hero.quiet .hero-count b { color: #fff; opacity: .9; }
.hero-item { display: flex; gap: .8rem; align-items: center; padding: .75rem; border-radius: 14px; background: var(--dark-2); transition: transform .12s ease; }
.hero-item strong { display: block; font-size: .98rem; font-weight: 650; }
.hero-item strong::first-letter { text-transform: uppercase; }
.hero-item span { color: var(--dark-text); font-size: .86rem; }
.hero-bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--signal); flex: none; }
.hero-bar.calm { background: var(--faint); }
.hero-go { margin-left: auto; flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--signal); display: grid; place-items: center; color: #fff; }
.hero-more { font-size: .9rem; color: var(--dark-text) !important; padding-left: .2rem; }

.start-card { margin: 12px 0; padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--signal-soft); border: 1px solid color-mix(in srgb, var(--signal) 30%, transparent); }
.start-card h2 { margin: 0 0 .4rem; }
.start-card ol { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: .35rem; }
.start-card li { counter-increment: s; display: flex; align-items: center; gap: .6rem; }
.start-card li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--tile); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.start-card li a { display: inline-flex; align-items: center; gap: .3rem; font-weight: 650; color: var(--text); }
.start-card li.done { color: var(--muted); }
.start-card li.done span { display: inline-flex; align-items: center; gap: .3rem; }

@media (min-width: 900px) {
  .bento { grid-template-columns: 1.35fr 1fr 1fr; grid-template-rows: minmax(160px, auto) minmax(160px, auto); grid-auto-rows: auto; gap: 14px; }
  .tile-hero { grid-column: 1; grid-row: span 2; }
  .tile-wide { grid-column: 1 / -1; }
  .hello h1 { font-size: 2.2rem; }
}

/* --- Przyciski i formularze ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 48px; padding: .55rem 1.1rem; border-radius: 14px;
  border: 1px solid var(--line); background: var(--tile); color: var(--text);
  font: 650 1rem var(--font); text-decoration: none; cursor: pointer; transition: transform .1s, border-color .1s;
}
.btn:hover { border-color: var(--faint); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-primary:hover { border-color: var(--dark); filter: brightness(1.15); }
@media (prefers-color-scheme: dark) { .btn-primary { background: var(--signal); border-color: var(--signal); color: #1a0d05; } }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 38px; padding: .3rem .8rem; font-size: .9rem; border-radius: 11px; }
.btn-big { min-height: 56px; font-size: 1.05rem; flex: 1; }
.btn-call { background: var(--signal); border-color: var(--signal); color: #fff; min-height: 56px; font-size: 1.05rem; }
.btn-call:hover { border-color: var(--signal); filter: brightness(1.06); }
.btn-call .phone { font-weight: 450; opacity: .92; font-variant-numeric: tabular-nums; }
.btn-call-ghost { background: transparent; color: var(--signal-ink); border-color: color-mix(in srgb, var(--signal) 60%, transparent); }
.btn-call-ghost:hover { background: var(--signal-soft); filter: none; }
.danger { color: var(--bad); }

.form { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field-label { font-weight: 650; font-size: .9rem; }
.field-hint { color: var(--muted); font-size: .8rem; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: .6rem .8rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--tile); color: var(--text); font: 1rem var(--font);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--signal); outline-offset: 0; border-color: transparent; }
input[readonly] { background: var(--bg); }
select.needs-fix, input.needs-fix { border-color: var(--signal); background: var(--signal-soft); }
.check { display: flex; align-items: flex-start; gap: .65rem; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; flex: none; accent-color: var(--signal); }
.form-error { color: var(--bad); font-weight: 650; }
.form-error:empty { display: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.form-actions .btn-primary { flex: 1 1 auto; }
.grid-2, .grid-3 { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 560px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .form-actions .btn-primary { flex: 0 0 auto; }
}

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.filters select { width: auto; flex: 1 1 180px; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; align-items: center; }
.chip {
  border: 1px solid var(--line); background: var(--tile); color: var(--text); border-radius: 999px;
  padding: .4rem .95rem; font: 600 .9rem var(--font); cursor: pointer; text-decoration: none; min-height: 40px;
  display: inline-flex; align-items: center;
}
.chip.active { background: var(--dark); border-color: var(--dark); color: #fff; }
.chip-bad:not(.active) { border-color: var(--signal); color: var(--signal-ink); }

/* --- Zadania: zastępcy ------------------------------------------------------------------ */

.task { position: relative; overflow: hidden; }
.task h2::first-letter, .card h1::first-letter, .page-head h1::first-letter { text-transform: uppercase; }
.task::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--signal); }
.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.option { border: 1px solid var(--line); border-radius: 14px; padding: .85rem; background: var(--tile); }
.option.first { border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.option.closed { opacity: .7; }
.option-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .2rem; }
.option-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .7rem; }
.option-actions > :first-child { grid-column: 1 / -1; }
@media (min-width: 700px) {
  .option-actions { display: flex; flex-wrap: wrap; }
  .option-actions > :first-child { flex: 1 1 280px; }
}
.closed-options { margin-top: .75rem; }
.closed-options summary { cursor: pointer; color: var(--muted); padding: .3rem 0; }

/* --- Dostawy kierownika ----------------------------------------------------------------- */

.delivery { background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.delivery-top { display: flex; gap: .9rem; padding: 1rem 1rem .75rem; }
.date-block { flex: none; width: 76px; padding: .55rem 0; border-radius: 14px; background: var(--bg); text-align: center; align-self: flex-start; }
.date-block b { display: block; font-size: 1.85rem; line-height: 1; font-weight: 800; font-stretch: 78%; font-variant-numeric: tabular-nums; }
.date-block span { font-size: .72rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.delivery.at-risk .date-block { background: var(--signal-soft); color: var(--bad); }
.delivery-main { min-width: 0; }
.delivery-main h2 { margin: .1rem 0 .15rem; font-size: 1.15rem; line-height: 1.15; }
.delivery-main h2::first-letter { text-transform: uppercase; }
.delivery-main p { margin: 0; }
.delivery-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 .35rem; }
.delivery-info { margin: 0 1rem; padding: .7rem 0; border-top: 1px solid var(--line); font-size: .92rem; color: var(--muted); }
.delivery-info strong { color: var(--ok); }
.btn-receive { display: flex; width: calc(100% - 1.5rem); margin: .35rem .75rem .75rem; min-height: 60px; border-radius: 14px; background: var(--dark); border-color: var(--dark); color: #fff; font-size: 1.12rem; font-weight: 700; }
.btn-receive:hover { border-color: var(--dark); filter: brightness(1.15); }
.delivery.delivered { opacity: .85; }

/* --- Powiadomienia ---------------------------------------------------------------------- */

.notifications { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.notification {
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .85rem 1rem;
}
.notification.unread { border-left: 5px solid var(--signal); font-weight: 600; }
.notification-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .2rem; }

/* --- Historia --------------------------------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem .8rem; }
.timeline li::before {
  content: ""; position: absolute; left: -1.43rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%;
  background: var(--tile); border: 2px solid var(--signal);
}
.timeline-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.log-more summary { cursor: pointer; color: var(--muted); }
.log-more[open] summary { margin-bottom: .25rem; }
.followups { border-top: 1px solid var(--line); margin-top: .75rem; padding-top: .5rem; }
.plain { list-style: none; margin: .25rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }

/* --- Tabele: na telefonie karty, od 700 px tabela --------------------------------------- */

.table { width: 100%; border-collapse: collapse; }
.table thead { display: none; }
.table tr {
  display: block; background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: .6rem; box-shadow: var(--shadow);
}
.table td { display: flex; gap: .75rem; padding: .18rem 0; }
.table td[data-label]::before { content: attr(data-label); flex: 0 0 6.5rem; color: var(--muted); font-size: .85rem; font-weight: 450; padding-top: .1rem; }
.table td > select, .table td > .picker { flex: 1; min-width: 0; }
.table td.cell-actions { justify-content: flex-end; flex-wrap: wrap; gap: .4rem; padding-top: .45rem; }
.table td.cell-actions:empty { display: none; }
.rows-link tr { cursor: pointer; }
.table tr.inactive { opacity: .6; }
.table tr.state-error { border-left: 5px solid var(--signal); }
.table tr.state-skipped { opacity: .65; }
.issues { margin: .25rem 0 0; padding-left: 1rem; color: var(--bad); font-size: .85rem; }
.issues.muted { color: var(--muted); }
.import-table td[data-label="Stan"] { flex-wrap: wrap; }

@media (min-width: 700px) {
  .table { background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
  .table thead { display: table-header-group; }
  .table tr { display: table-row; border: 0; border-radius: 0; padding: 0; margin: 0; box-shadow: none; }
  .table th { text-align: left; font-size: .76rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 650; padding: .7rem .8rem; border-bottom: 1px solid var(--line); background: var(--bg-2); }
  .table td { display: table-cell; padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
  .table td[data-label]::before { display: none; }
  .table td.cell-actions { text-align: right; white-space: nowrap; }
  .table td.cell-actions:empty { display: table-cell; }
  .table tbody tr:last-child td { border-bottom: 0; }
  .rows-link tbody tr:hover { background: var(--bg); }
  .table tr.state-error td:first-child { box-shadow: inset 5px 0 var(--signal); }
  .import-table select { min-width: 160px; }
  .rows-link td:first-child, .table td[data-label="Ilość"] { white-space: nowrap; }
  .rows-link td.strong::first-letter { text-transform: uppercase; }
}

/* --- Import i zamówienia z maili ------------------------------------------------------- */

.mapping-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.mapping .form { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.commit { margin-top: 1rem; }
.unit-fix { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; flex: 1; min-width: 0; }
.unit-fix-row { display: grid; grid-template-columns: 5rem minmax(0, 1fr) auto; gap: .4rem; }

.email-order-grid { display: grid; gap: 1rem; }
.mail-preview { background: var(--bg); border-radius: 14px; padding: .85rem; min-width: 0; }
.mail-body { max-height: 320px; overflow: auto; margin-top: .5rem; }
.item-row { display: grid; grid-template-columns: 1fr 5rem 6.5rem 40px; gap: .4rem; align-items: center; }
.item-hint { grid-column: 1 / -1; margin: 0; }
.missing { color: var(--bad); }
@media (min-width: 900px) {
  .email-order-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
  .mail-body { max-height: 520px; }
}

/* --- Zaproszenia, skrzynka -------------------------------------------------------------- */

.invite-box { background: var(--ok-soft); border-radius: var(--radius); padding: 1rem; }
.copy-row { display: flex; gap: .5rem; margin-top: .5rem; }
.copy-row input { flex: 1; font-size: .85rem; }
.advanced { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; }
.advanced summary { cursor: pointer; font-weight: 650; font-size: .92rem; }
.advanced[open] summary { margin-bottom: .75rem; }

/* --- Okna i komunikaty ------------------------------------------------------------------ */

.modal {
  width: min(580px, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); padding: 1.1rem;
  border: 0; border-radius: var(--radius); background: var(--tile); color: var(--text);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45);
}
.modal::backdrop { background: rgba(13, 15, 18, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.modal-head h2 { margin: 0; }
.modal .btn-call { width: 100%; }
@media (max-width: 559px) {
  .modal { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; padding-bottom: calc(1.1rem + env(safe-area-inset-bottom)); }
}

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom));
  z-index: 1000; display: flex; flex-direction: column; gap: .5rem; width: min(480px, calc(100vw - 2rem)); pointer-events: none;
}
@media (min-width: 900px) { #toasts { bottom: 1.5rem; } }
.toast {
  padding: .8rem 1rem; border-radius: 14px; background: var(--dark); color: #fff;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .45); transition: opacity .3s, transform .3s; pointer-events: auto;
  border-left: 5px solid var(--ok);
}
.toast-error { border-left-color: var(--bad); }
.toast-warn { border-left-color: var(--signal); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* --- Logowanie -------------------------------------------------------------------------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.auth-card {
  width: min(430px, 100%); background: var(--tile); border: 1px solid var(--line);
  border-radius: 24px; padding: 1.6rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .8rem;
}
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 750; }
.auth-brand img { width: 36px; height: 36px; }
.auth .form-actions .btn-primary { flex: 1 1 100%; }
.auth-switch { text-align: center; padding: .6rem 0 .1rem; border-top: 1px solid var(--line); margin-top: .25rem; }
.auth-switch a { font-weight: 700; }
#app:has(.auth) { display: block; }
.auth { grid-template-rows: 1fr auto; }
.auth-credit { text-align: center; margin: 1rem 0 0; }
.auth-credit a, .user-menu-credit a { color: inherit; text-decoration: underline; }
.user-menu-credit { margin: .5rem 0 0; padding-top: .5rem; border-top: 1px solid var(--line); }

/* --- Suwaki uprawnień i osoby przy budowie --------------------------------------------- */

.switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch:last-child { border-bottom: 0; }
.switch-text { display: flex; flex-direction: column; font-weight: 600; }
.switch-text small { color: var(--muted); font-weight: 450; font-size: .8rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { flex: none; position: relative; width: 52px; height: 32px; border-radius: 16px; background: var(--line); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--signal); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--text); outline-offset: 2px; }
.switches { border: 1px solid var(--line); border-radius: 14px; padding: 0 .9rem; background: var(--tile); }

.people { display: flex; flex-direction: column; gap: .6rem; }
.person { display: flex; gap: .9rem; align-items: flex-start; padding: .9rem 1rem; background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.person-ic { flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--bg); display: grid; place-items: center; }
.person-main { flex: 1; min-width: 0; }
.person-main h3 { margin: 0; font-size: 1.05rem; }
.perm-list { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.perm-list span { font-size: .74rem; font-weight: 600; padding: .18rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); }
.person-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.site-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.billing-total { font-size: 2.6rem; font-weight: 800; font-stretch: 80%; font-variant-numeric: tabular-nums; line-height: 1; }
.search-results { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; }
.search-hit { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; width: 100%; text-align: left; padding: .65rem .8rem; border-radius: 12px; border: 1px solid var(--line); background: var(--tile); color: var(--text); font: inherit; cursor: pointer; }
.search-hit:hover { border-color: var(--signal); }
.search-hit span, .search-hit small { color: var(--muted); font-size: .85rem; }
.chosen { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 12px; background: var(--ok-soft); }
.chosen div { flex: 1; display: flex; flex-direction: column; }
.chosen small { color: var(--muted); }
.check-pill { align-items: center; padding: .5rem .9rem; min-height: 46px; border: 1px solid var(--line); border-radius: 999px; background: var(--tile); font-weight: 600; }
.check-pill:has(input:checked) { border-color: var(--signal); background: var(--signal-soft); }
.check-pill input { margin: 0; }

/* --- Komputer: fokus klawiatury, szersze listy, sortowanie, instalacja --------------------- */

:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.btn:focus-visible, .tile:focus-visible, .chip:focus-visible, .nav-link:focus-visible, .hero-item:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
.table tr[tabindex]:focus-visible { outline: 3px solid var(--signal); outline-offset: -3px; }
.list-count { margin: 0 0 .5rem; }
.filters input[type="search"] { flex: 2 1 240px; width: auto; }
@media (min-width: 700px) {
  .table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
  .table th.sortable::after { content: ""; display: inline-block; width: 0; height: 0; margin-left: .4rem; vertical-align: middle; border: 4px solid transparent; border-top-color: var(--faint); opacity: .6; transform: translateY(2px); }
  .table th.sorted { color: var(--text); }
  .table th.sorted[data-dir="asc"]::after { border-top-color: transparent; border-bottom-color: var(--signal); opacity: 1; transform: translateY(-2px); }
  .table th.sorted[data-dir="desc"]::after { border-top-color: var(--signal); opacity: 1; }
  .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
}
@media (min-width: 700px) and (max-width: 1099px) { .table .hide-narrow { display: none; } }
@media (min-width: 1280px) {
  main { max-width: 1440px; }
  .table td, .table th { padding: .6rem .9rem; }
}
.nav-install { margin-top: auto; display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border: 1px dashed var(--faint); border-radius: 12px; background: transparent; color: var(--text); font: 600 .95rem var(--font); cursor: pointer; }
.nav-install:hover { border-color: var(--signal); background: var(--signal-soft); }

.ios-hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); z-index: 900;
  display: flex; gap: .8rem; align-items: flex-start; padding: .9rem; border-radius: 18px;
  background: var(--dark); color: #fff; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .5);
}
.ios-hint img { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.ios-hint p { margin: 0; font-size: .9rem; color: var(--dark-text); }
.ios-hint strong { display: block; color: #fff; font-size: 1rem; margin-bottom: .15rem; }
.ios-hint .icon-btn { background: transparent; border-color: transparent; color: #fff; flex: none; }
#app:has(.auth) ~ .ios-hint, body:not(:has(.tabbar)) .ios-hint { bottom: calc(12px + env(safe-area-inset-bottom)); }
