/* biuro.dream.zary.org — styl biurowy */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #cbd5e1;
  --accent: #1e40af;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.1);
  --radius: 10px;
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-width: 0;
  width: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header__inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.site-title a {
  color: var(--text);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--accent);
}

.site-tagline {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.site-header__user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  font-size: 0.875rem;
}

.site-header__user-name {
  font-weight: 600;
  color: var(--text);
}

.site-header__user a {
  font-weight: 600;
  text-decoration: none;
}

.site-header__user a:hover {
  text-decoration: underline;
}

.home-no-apps {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.7rem 0.88rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.admin-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  table-layout: auto;
}

.admin-table th,
.admin-table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  text-align: center;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--text);
  white-space: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.25;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table__col-user {
  width: 14ch;
  min-width: 12ch;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.admin-table th.admin-table__col-role,
.admin-table td.admin-table__col-role {
  width: 12ch;
  min-width: 10ch;
  vertical-align: top;
}

.admin-table td.admin-table__col-role {
  white-space: nowrap;
}

.admin-table__col-accepted {
  width: 13ch;
  min-width: 11ch;
  vertical-align: top;
}

.admin-table td.admin-table__col-accepted {
  white-space: nowrap;
}

.admin-table__th-apps {
  text-align: left;
  vertical-align: bottom;
  font-size: 0.75rem;
  font-weight: 600;
}

.admin-table td.admin-table__col-apps {
  vertical-align: middle;
  padding: 0.4rem 0.75rem;
}

.admin-apps-grid {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 0.25rem 0.55rem;
  align-items: center;
}

.admin-app-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.admin-app-item span {
  line-height: 1.2;
}

.admin-app-checkbox {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  margin: 0;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.admin-table__col-actions {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

.admin-table__actions {
  text-align: right;
  vertical-align: middle;
}

.admin-table__actions-inner {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Stały układ dwulinijkowy jak w szerszym rzędzie akcji (wąski, wysoki przycisk) */
.admin-table__actions-inner .admin-user-apps-save-btn,
.admin-apps-save-wrap .admin-user-apps-save-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: max(4.5rem, calc(5.75rem - 1ch));
  max-width: calc(6.25rem - 1ch);
  min-height: calc(2 * (0.3rem * 2 + 0.8125rem * 1.28));
  padding: 0.35rem 0.45rem;
  box-sizing: border-box;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.admin-inline-form {
  display: inline-flex;
  margin: 0;
  vertical-align: middle;
}

.admin-user-cell__name {
  font-weight: 600;
  color: var(--text);
}

.admin-user-cell__login {
  margin-top: 0.15rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.admin-user-apps-form {
  margin: 0;
  padding: 0;
  border: 0;
}

.admin-user-apps-form--stacked {
  display: block;
}

.admin-apps-save-wrap {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}

.admin-fieldset {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.admin-fieldset legend {
  padding: 0 0.35rem;
}

.admin-field-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.admin-radio {
  display: block;
  margin: 0.35rem 0;
  font-size: 0.9375rem;
  cursor: pointer;
}

.admin-radio input {
  margin-right: 0.5rem;
}

.admin-app-checks {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.admin-check {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  font-size: 0.9375rem;
  cursor: pointer;
}

.admin-check input {
  margin: 0 0.35rem 0 0;
}

.admin-check__soon {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.admin-subheading {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.site-main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

/* Lista protokołów — główna kolumna na całą szerokość okna */
.site-main--full {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 2rem 0 3rem;
}

/* Panel administratora — 80% szerokości widoku */
.site-main--admin {
  max-width: 80%;
  width: 100%;
  box-sizing: border-box;
  padding: 2rem 1.5rem 3rem;
  margin: 0 auto;
}

.site-main--admin .page-tool,
.site-main--admin .page-tool--wide {
  max-width: 100%;
}

.zwrot-protokoly-intro {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem;
}

.zwrot-protokoly-wide {
  width: 85%;
  max-width: 85%;
  padding: 0;
  margin: 0 auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  box-sizing: border-box;
}

.proto-table-scroll {
  width: 100%;
  overflow-x: auto;
  padding: 0;
  margin: 0;
}

.zwrot-protokoly-actions {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
  display: flex;
  justify-content: flex-end;
}

.zwrot-protokoly-actions--rozliczenie {
  padding-top: 0;
  padding-bottom: 2.5rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.zwrot-rozliczenie-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem 1rem;
}

.zwrot-rozliczenie-form__label {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.zwrot-rozliczenie-form__month {
  width: auto;
  min-width: 11rem;
}

.table-wrap--full {
  margin: 0;
  padding: 0.75rem clamp(0.75rem, 2vw, 1.5rem) 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hero {
  margin-bottom: 2.25rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}

.hero-temp-link {
  margin-top: 0.75rem;
}

.hero-temp-link__note {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.hero p {
  margin: 0;
  max-width: 36rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  /* było 1rem — kafle ~30% zwarte: odstępy też proporcjonalnie */
  gap: 0.7rem;
}

@media (min-width: 640px) {
  .app-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .app-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/*
 * Kafle strony głównej — „ramka” ~30% mniejsza niż pierwotnie (wartości jawne,
 * bez calc(var(...)), żeby zawsze się stosowały). Bazowo: padding 1.35/1.25rem,
 * radius 10px, ikona 2.5rem.
 */
.app-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 0.95rem 0.88rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.app-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 17px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.app-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.app-card--soon {
  cursor: not-allowed;
  opacity: 0.9;
}

.app-card--soon:hover {
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transform: none;
}

.app-card--soon .app-card__icon {
  color: var(--text-muted);
}

.app-card__soon {
  display: block;
  margin-top: 0.53rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.app-card__icon {
  width: 1.75rem;
  height: 1.75rem;
  margin-bottom: 0.61rem;
  color: var(--accent);
}

.app-card__title {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.app-card__hint {
  margin: 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--text-muted);
}

/* Podstrona narzędzia */
.page-tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
  max-width: 40rem;
}

.page-tool h1 {
  margin: 0 0 0.75rem;
  font-size: 1.375rem;
  font-weight: 600;
}

.page-tool p {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
}

.page-tool--wide {
  max-width: 52rem;
}

.page-tool__lead {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.flash {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9375rem;
}

.flash--ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.flash--err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.form-zwrot {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-row {
  display: grid;
  gap: 1rem 1.25rem;
}

@media (min-width: 640px) {
  .form-row--2 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row--3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Zwrot towarów: nazwa, ilość, cena brutto, wartość łączna, cena netto, VAT w jednym rzędzie */
@media (min-width: 900px) {
  .form-row.zwrot-form-row--towar {
    align-items: end;
    grid-template-columns:
      minmax(0, 2fr)    /* Nazwa towaru */
      minmax(0, 0.7fr)  /* Ilość */
      minmax(0, 1fr)    /* Cena brutto */
      minmax(0, 1fr)    /* Wartość łączna */
      minmax(0, 1fr)    /* Cena netto */
      minmax(0, 1fr);   /* Podatek VAT */
  }
}

.form-row.zwrot-form-row--towar .form-input {
  width: 100%;
  min-width: 0;
}

.zwrot-form-hint--pod-netto-vat {
  margin: -0.15rem 0 0;
}

/* Edycja użytkownika: login, e-mail, imię, nazwisko, hasło w jednym rzędzie */
@media (min-width: 960px) {
  .form-row--5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.admin-field-hint--after-edit-row {
  margin: -0.35rem 0 0;
  font-size: 0.8125rem;
}

/* Data dd-mm-rrrr: jedno pole (jak natywny type="date") — tekst + kalendarz w obramowaniu */
.form-date-dmy {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-date-dmy:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-date-dmy__text {
  flex: 1;
  min-width: 0;
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0.5rem 0.35rem 0.5rem 0.65rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
  border-radius: 6px 0 0 6px;
}

.form-date-dmy__text:focus {
  outline: none;
}

/* Obszar ikony: natywny type="date" jako niewidoczna nakładka (klik = kalendarz) */
.form-date-dmy__pick {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  min-width: 2.5rem;
  align-self: stretch;
  border-left: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.form-date-dmy__pick:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.form-date-dmy__native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 1rem;
  z-index: 2;
}

.form-date-dmy__native::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.form-date-dmy__icon {
  position: relative;
  z-index: 1;
  display: flex;
  line-height: 0;
  pointer-events: none;
}

.form-date-dmy__icon svg {
  display: block;
}

/* Miesiąc mm-rrrr — jedno pole z ikoną w środku */
.form-month-my {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-month-my:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-month-my__text {
  flex: 1;
  min-width: 0;
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0.5rem 0.35rem 0.5rem 0.65rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
  border-radius: 6px 0 0 6px;
}

.form-month-my__text:focus {
  outline: none;
}

.form-month-my__pick {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  min-width: 2.5rem;
  align-self: stretch;
  border-left: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.form-month-my__pick:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.form-month-my__native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 1rem;
  z-index: 2;
}

.form-month-my__native::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.form-month-my__icon {
  position: relative;
  z-index: 1;
  display: flex;
  line-height: 0;
  pointer-events: none;
}

.form-month-my__icon svg {
  display: block;
}

.zwrot-rozliczenie-form .form-month-my {
  width: auto;
  min-width: 11rem;
  flex: 1 1 auto;
}

.print-toolbar .form-month-my {
  min-width: 11rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.form-label .req {
  color: #b91c1c;
  font-weight: 700;
}

.form-input,
.form-textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.65rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Szerokość jak ~12 znaków (np. kwoty) */
.form-input--w12 {
  width: 12ch;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Szerokość jak 30 znaków (np. krótka nazwa firmy) */
.form-input--w30 {
  width: 30ch;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-textarea {
  min-height: 5rem;
  resize: vertical;
}

.form-hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.form-actions {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.35rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
  box-sizing: border-box;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn--sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.btn--secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn--secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.btn--outline {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Usuwanie — czerwień przy najechaniu (np. edycja protokołu zwrotu) */
.btn--outline.btn--outline-danger:hover {
  border-color: #dc2626;
  color: #b91c1c;
  background: #fef2f2;
}

.btn--outline.btn--outline-danger:focus-visible {
  outline-color: #dc2626;
}

.tool-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.tool-nav__link {
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.tool-nav__link:hover {
  text-decoration: underline;
}

.zwrot-lista__empty {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.table-wrap {
  margin: 0 -0.35rem;
  padding: 0 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 70rem;
  border-collapse: collapse;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

.data-table thead th {
  background: var(--accent-soft);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.data-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.data-table tbody tr:hover {
  background: #f1f5f9;
}

.data-table tfoot td {
  background: #eef2f7;
  font-weight: 600;
  border-top: 2px solid var(--border);
}

.data-table.data-table--single-line tfoot td:not(.data-table__actions) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.data-table th.data-table__col-id,
.data-table td.data-table__col-id,
th.zwrot-col-id,
td.zwrot-col-id {
  width: 4ch;
  max-width: 4ch;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th.data-table__col-protokol,
.data-table td.data-table__col-protokol,
.data-table th.data-table__col-towar-przyjeto,
.data-table td.data-table__col-towar-przyjeto,
th.zwrot-col-protokol,
td.zwrot-col-protokol,
th.zwrot-col-towar-przyjeto,
td.zwrot-col-towar-przyjeto {
  width: 12ch;
  max-width: 12ch;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th.data-table__col-ilosc,
.data-table td.data-table__col-ilosc,
th.zwrot-col-ilosc,
td.zwrot-col-ilosc {
  width: 7ch;
  max-width: 7ch;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th.data-table__col-vat,
.data-table td.data-table__col-vat,
th.zwrot-col-vat,
td.zwrot-col-vat {
  width: 10ch;
  max-width: 10ch;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th.data-table__col-netto,
.data-table td.data-table__col-netto,
.data-table th.data-table__col-brutto,
.data-table td.data-table__col-brutto,
th.zwrot-col-netto,
td.zwrot-col-netto,
th.zwrot-col-brutto,
td.zwrot-col-brutto {
  width: 11ch;
  max-width: 11ch;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table__cell--wide {
  min-width: 9rem;
  max-width: 16rem;
  word-break: break-word;
}

.data-table.data-table--full.data-table--single-line th.data-table__col-uwagi,
.data-table.data-table--full.data-table--single-line td.data-table__col-uwagi {
  min-width: calc(9rem + 3ch);
}

.data-table.data-table--full {
  width: 100%;
  min-width: 100%;
  table-layout: fixed;
}

/* Jedna linia tekstu — kolumny dzielą całą szerokość okna (bez wąskiego „paska” tabeli) */
.data-table.data-table--full.data-table--single-line {
  min-width: 100%;
}

.data-table.data-table--single-line tbody td:not(.data-table__actions) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  min-width: 0;
  line-height: 1.35;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.data-table.data-table--single-line thead th {
  white-space: normal;
  text-align: center;
  vertical-align: middle;
  min-height: calc(2 * 1.35em);
  line-height: 1.35;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  overflow: visible;
  text-overflow: clip;
  min-width: 0;
}

.data-table__th-actions {
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  width: 5.75rem;
  min-width: 5.75rem;
}

.data-table__actions {
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  width: 6.25rem;
  min-width: 6.25rem;
  max-width: none !important;
  overflow: visible !important;
}

.data-table__th-actions--edytuj {
  width: calc(5.75rem + 1ch);
  min-width: calc(5.75rem + 1ch);
}

.data-table__actions--edytuj {
  width: calc(6.25rem + 1ch);
  min-width: calc(6.25rem + 1ch);
}

.data-table__th-actions--drukuj {
  width: calc(5.75rem + 1ch);
  min-width: calc(5.75rem + 1ch);
}

.data-table__actions--drukuj {
  width: calc(6.25rem + 1ch);
  min-width: calc(6.25rem + 1ch);
}

.data-table__actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.75rem;
}

.data-table__actions--edytuj .btn {
  min-width: calc(4.75rem + 1ch);
}

.data-table__actions--drukuj .btn {
  min-width: calc(4.75rem + 1ch);
}

/* Linki-przyciski w tabeli: jawne kolory (nadpisują .btn, żeby „Drukuj” nie znikał) */
.data-table__actions .btn.btn--secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.data-table__actions .btn.btn--secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.data-table__actions .btn.btn--outline {
  background: #fff !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

.data-table__actions .btn.btn--outline:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.print-dl {
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) 1fr;
  gap: 0.5rem 1.25rem;
  margin: 1rem 0 0;
  font-size: 0.9375rem;
}

.print-dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--text-muted);
}

.print-dl dd {
  margin: 0;
}

.page-tool__back {
  margin-top: 1.5rem;
  margin-bottom: 0;
}

.back-link {
  font-size: 0.9375rem;
}

.site-footer {
  margin-top: auto;
  padding: 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer__inner {
  max-width: 56rem;
  margin: 0 auto;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

body.layout-sticky-footer {
  display: flex;
  flex-direction: column;
}

body.layout-sticky-footer .site-main {
  flex: 1;
}

/* ——— Strona logowania (admin/login.php) ——— */
body.auth-page {
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(30, 64, 175, 0.09), transparent 55%),
    var(--bg);
}

.site-header__inner--auth {
  justify-content: center;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
}

.site-header__inner--auth .site-tagline {
  width: 100%;
}

body.auth-page .auth-page__main.site-main {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  box-sizing: border-box;
}

.auth-card {
  width: 100%;
  max-width: 22.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
}

.auth-card__accent {
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, #3b82f6 50%, var(--accent-soft) 100%);
}

.auth-card__body {
  padding: 1.65rem 1.5rem 1.5rem;
}

.auth-card__title {
  margin: 0 0 0.4rem;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.2;
}

.auth-card__lead {
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.auth-card__flash {
  margin: 0 0 1rem;
}

.auth-card__form {
  gap: 1rem;
}

.auth-card__form .form-group {
  gap: 0.4rem;
}

.auth-card__submit {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.65rem 1.25rem;
  justify-content: center;
  font-size: 0.9375rem;
}

.auth-card__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.auth-card__links-sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.auth-card__link {
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
}

.auth-card__link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.auth-card__hint {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
}

/* ======================================================================
   Pola daty na urządzeniach mobilnych (< 640 px)
   Na wąskich ekranach zamiast kombinacji tekst + niewidoczna nakładka
   wyświetlamy natywny input[type="date"] na pełnej szerokości pola.
   Niestandardowa ikona SVG jest ukryta – przeglądarka renderuje własną.
   Wersja desktopowa (≥ 640 px) pozostaje bez zmian.
   ====================================================================== */
@media (max-width: 639px) {
  /* Pole tekstowe dd-mm-rrrr jest ukryte (nadal w DOM i wysyłane przez
     formularz; wartość jest synchronizowana przez JS z natywnego pola). */
  .form-date-dmy__text {
    display: none;
  }

  /* Obszar ikony rozszerza się na całą szerokość wrappera */
  .form-date-dmy__pick {
    flex: 1 1 auto;
    width: 100%;
    border-left: none;
    border-radius: 6px;
  }

  /* Natywny input[type="date"] staje się widoczny i zajmuje całe pole */
  .form-date-dmy__native {
    position: static;
    opacity: 1;
    width: 100%;
    height: auto;
    min-height: 2.75rem;
    padding: 0.5rem 0.65rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.45;
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 6px;
    box-sizing: border-box;
    cursor: pointer;
    z-index: auto;
  }

  /* Przywróć widoczność natywnego wskaźnika kalendarza */
  .form-date-dmy__native::-webkit-calendar-picker-indicator {
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    opacity: 1;
    cursor: pointer;
  }

  /* Ukryj niestandardową ikonę SVG – przeglądarka ma własną */
  .form-date-dmy__icon {
    display: none;
  }
}

/* ======================================================================
   Panel administratora — widok kart na telefonach (max-width: 639px)
   Tabela użytkowników zamienia się w stos kart: jeden użytkownik = karta.
   ====================================================================== */
@media (max-width: 639px) {

  /* Kontener: bez własnego obramowania — karty zastępują */
  .admin-table-wrap {
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    border-radius: 0;
    margin-top: 0.5rem;
  }

  /* Tabela i tbody jako bloki */
  .admin-table,
  .admin-table tbody {
    display: block;
    width: 100%;
  }

  /* Nagłówki kolumn ukryte — etykiety biorą z data-label */
  .admin-table thead { display: none; }

  /* Każdy wiersz = karta */
  .admin-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 0.875rem;
  }

  /* Domyślna komórka: pełna szerokość */
  .admin-table td {
    display: block;
    background: var(--surface);
    padding: 0.55rem 0.9rem;
    box-sizing: border-box;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    border: none !important;
    flex: 0 0 100%;
    vertical-align: top;
  }

  /* Etykieta nad wartością (z atrybutu data-label) */
  .admin-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
  }

  /* Użytkownik: nagłówek karty — pełna szerokość, niebieskie tło */
  .admin-table td.admin-table__col-user {
    flex: 0 0 100%;
    background: var(--accent-soft);
    padding: 0.8rem 0.9rem;
  }

  /* Rola i data: obok siebie (50% / 50%) */
  .admin-table td.admin-table__col-role {
    flex: 1 1 50%;
  }

  .admin-table td.admin-table__col-accepted {
    flex: 1 1 50%;
  }

  /* Aplikacje: siatka 2-rzędowa w jednej komórce */
  .admin-table td.admin-table__col-apps {
    flex: 0 0 100%;
    padding: 0.6rem 0.9rem;
  }

  .admin-apps-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem 1rem;
  }

  .admin-app-item {
    font-size: 0.8125rem;
  }

  .admin-app-item .admin-app-checkbox {
    width: 1.2rem;
    height: 1.2rem;
    flex-shrink: 0;
  }

  /* Akcje: pełna szerokość, przyciski od lewej */
  .admin-table td.admin-table__actions {
    flex: 0 0 100%;
    text-align: left;
    background: #f8fafc;
    padding: 0.65rem 0.9rem;
  }

  .admin-table__col-actions {
    width: auto !important;
    white-space: normal !important;
  }

  .admin-table__actions-inner {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.45rem;
  }

  .admin-table__actions-inner .btn {
    min-height: 2.5rem;
    padding: 0.45rem 1rem;
    font-size: 0.9375rem;
  }

  /* Przycisk „Zapisz aplikacje" — w jednej linii bez łamania */
  .admin-table__actions-inner .admin-user-apps-save-btn,
  .admin-apps-save-wrap .admin-user-apps-save-btn {
    flex-direction: row;
    gap: 0.2rem;
    min-height: 2.5rem;
    min-width: auto;
    max-width: none;
    padding: 0.45rem 1rem;
    white-space: nowrap;
  }

  .admin-table__actions-inner .admin-user-apps-save-btn br,
  .admin-apps-save-wrap .admin-user-apps-save-btn br {
    display: none;
  }
}

/* ─── Mobile: aplikacja Zwrot Towarów (max 639px) ───────────────────────── */
@media (max-width: 639px) {

  /* Sekcja z tabelą — pełna szerokość, bez bocznych marginesów */
  .zwrot-protokoly-wide {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0;
  }

  /* Pasek akcji nad/pod tabelą — wyrównaj do lewej, zawijaj */
  .zwrot-protokoly-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    padding: 0.75rem 1rem 1.25rem;
    gap: 0.5rem;
  }

  .zwrot-protokoly-actions--nad-tabela {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }

  /* Kursor grab na tabeli przewijanej */
  .proto-table-scroll {
    cursor: grab;
  }
  .proto-table-scroll:active {
    cursor: grabbing;
  }

  /* Pasek filtra miesiąca — każdy element na własnej linii gdy brak miejsca */
  .zwrot-filtr-miesiac {
    width: 100%;
  }
  .zwrot-filtr-miesiac .form-month-my {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Przyciski akcji formularza (edytuj) — pełna szerokość na telefonie */
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Narzędzia drukowania — przyciski pełnej szerokości */
  .print-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .print-toolbar .btn {
    width: 100%;
    justify-content: center;
  }

  /* Tool-nav (górne łącza nawigacyjne) — zawijaj */
  .tool-nav {
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
  }

  /* Formularz nowego/edycji protokołu — zmniejsz padding strony */
  .page-tool,
  .page-tool--wide {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}
