/*
 * Monitor pobrań — jeden arkusz stylów: wspólny system wizualny wszystkich modułów (Pobrania, Dostawy, SMS, Zyski).
 * Sekcje: tokeny → baza → pasek górny i nawigacja → układ strony i karty → tooltip „i" → komunikaty → formularze →
 * przyciski → etykiety stanów (badge) → tabele → kafelki KPI → paginacja i sortowanie → modale i akcje masowe →
 * ryzyko → SMS → Zyski → logowanie → responsywność. Kolory i rozmiary tylko przez tokeny z :root.
 */

/* ---------- Tokeny ---------- */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --text: #1f2933;
  --muted: #6b7280;
  --ink: #111827;
  --ink-hover: #1f2937;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-bg: #e0e7ff;
  --primary-soft: #eef2ff;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-bg: #fee2e2;
  --danger-border: #fecaca;
  --success: #15803d;
  --success-bg: #dcfce7;
  --success-border: #bbf7d0;
  --warning: #92400e;
  --warning-bg: #fef3c7;
  --warning-border: #fde68a;
  --warning-row: #fffbeb;
  --danger-row: #fff1f2;
  --info: #1e40af;
  --info-bg: #e0e7ff;
  --neutral-bg: #e5e7eb;
  --zebra: #f8fafc;
  --row-hover: #eef2ff;
  --thead: #111827;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-tile: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-pop: 0 8px 24px rgba(15, 23, 42, 0.25);
  --shadow-modal: 0 10px 40px rgba(15, 23, 42, 0.3);
  --focus: rgba(29, 78, 216, 0.35);
  --font-base: 15px;
  --font-small: 13px;
  --font-table: 15px;
  --font-table-head: 14px;
  --container: 1500px;
  --gutter: 32px;
}

/* ---------- Baza ---------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  font-size: var(--font-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-size: 0.92em;
  background: var(--neutral-bg);
  padding: 1px 5px;
  border-radius: 4px;
}

.muted {
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

.text-warn {
  color: var(--warning);
}

/* ---------- Pasek górny i nawigacja modułów ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.brand img {
  display: block;
  height: 30px;
  width: auto;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.85;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right form {
  margin: 0;
}

.topnav {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}

.topnav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
}

.topnav a:hover {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}

.topnav a.active {
  color: var(--primary);
  background: var(--primary-bg);
}

/* ---------- Zakładki (zakładki pobrań i podzakładki Zysków) ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ---------- Układ strony i karty ---------- */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 24px var(--gutter);
}

.container-wide {
  max-width: var(--container);
  margin: 0 auto;
  padding: 24px var(--gutter);
}

.page-title,
.page-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 18px;
}

.page-title h1,
.page-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.page-title h1 .badge,
.page-header h1 .badge {
  font-size: 14px;
  padding: 2px 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.card + .card {
  margin-top: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Tooltip „i" (objaśnienia zamiast zdań w nagłówkach) ---------- */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  cursor: help;
  flex: none;
  vertical-align: middle;
}

.info-tip .tip {
  display: none;
  position: absolute;
  top: 30px;
  left: 0;
  z-index: 20;
  width: 460px;
  max-width: 80vw;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow-pop);
}

.info-tip:hover .tip,
.info-tip:focus .tip,
.info-tip:focus-within .tip {
  display: block;
}

.info-tip.tip-right .tip {
  left: auto;
  right: 0;
}

.card-title .info-tip,
.kpi .info-tip,
.tile .info-tip,
th .info-tip,
label .info-tip {
  width: 18px;
  height: 18px;
  font-size: 11px;
}

/* ---------- Komunikaty (flash po przekierowaniu, alert w formularzu/modalu) ---------- */
.flash,
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 16px;
}

.flash-ok,
.alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.flash-err,
.alert-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.flash-warn,
.alert-info {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}

/* ---------- Formularze ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: var(--font-small);
  font-weight: 600;
  color: var(--muted);
}

input[type='text'],
input[type='password'],
input[type='search'],
input[type='date'],
input[type='number'],
input[type='email'],
input[type='tel'],
select,
textarea {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--primary);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.filters .field-actions,
.field-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .field-wide,
.filters .field-wide {
  grid-column: 1 / -1;
  flex: 1 1 100%;
}

.form-grid textarea,
.filters textarea {
  width: 100%;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  padding-top: 20px;
}

.filters .checkbox-label {
  padding-top: 0;
  padding-bottom: 8px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 6px 16px;
}

.checkbox-grid .checkbox-label {
  padding-top: 0;
}

.inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin: 2px 0;
}

.inline-form select {
  max-width: 200px;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
}

/* ---------- Przyciski: główny niebieski, drugorzędny biały z obramowaniem, niebezpieczny czerwony ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--zebra);
  text-decoration: none;
}

.btn-primary,
.btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover,
.btn.active:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-dark,
.btn-refresh {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-dark:hover,
.btn-refresh:hover {
  background: var(--ink-hover);
  border-color: var(--ink-hover);
}

.btn-link {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  padding-left: 6px;
  padding-right: 6px;
}

.btn-link:hover {
  background: var(--primary-soft);
}

.btn-link.btn-danger-link,
.btn-link.text-danger {
  color: var(--danger);
}

.btn-link.btn-danger-link:hover,
.btn-link.text-danger:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.segmented {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.row-actions-cell {
  white-space: nowrap;
}

.row-actions-cell .btn,
.row-actions-cell .inline-form {
  margin-right: 4px;
}

/* ---------- Etykiety stanów: licznik (.badge) i kolorowe etykiety (.tag / .pill) ---------- */
.badge {
  display: inline-block;
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
}

.tab.active .badge {
  background: var(--primary);
  color: #fff;
}

.badge-warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.tab-warn.active .badge-warn {
  background: var(--warning);
  color: #fff;
}

.tag,
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  vertical-align: middle;
}

/* tony: neutralny (domyślny), ok, uwaga, błąd, informacja */
.tag-ok,
.tag-success,
.tag-prepaid,
.tag-sms-delivered,
.tag-state-delivered {
  background: var(--success-bg);
  color: var(--success);
}

.tag-warn,
.tag-cod,
.tag-manual,
.tag-risk-medium,
.tag-state-label_only,
.tag-state-awaiting {
  background: var(--warning-bg);
  color: var(--warning);
}

.tag-danger,
.tag-err,
.tag-risk-high,
.tag-sms-failed,
.tag-sms-undelivered,
.tag-state-cancelled,
.tag-state-returned,
.tag-state-return_in_progress,
.tag-state-problem,
.pill-lock {
  background: var(--danger-bg);
  color: var(--danger);
}

.tag-info,
.tag-sms,
.tag-sms-pending,
.tag-sms-queued,
.tag-sms-sent,
.tag-state-collected,
.tag-state-in_transit,
.tag-state-out_for_delivery {
  background: var(--info-bg);
  color: var(--info);
}

.tag-neutral,
.tag-sms-skipped,
.tag-state-unshipped,
.tag-state-unknown {
  background: var(--neutral-bg);
  color: var(--muted);
}

.result-ok {
  color: var(--success);
  font-weight: 600;
}

.result-error {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Tabele: ciemny przyklejony nagłówek, zebra, liczby do prawej ---------- */
.table-wrap {
  overflow: visible;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-table);
}

.table th,
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

.table th {
  white-space: normal;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--thead);
  color: #fff;
  font-size: var(--font-table-head);
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  border-bottom: 0;
}

.table thead th:first-child {
  border-top-left-radius: var(--radius);
}

.table thead th:last-child {
  border-top-right-radius: var(--radius);
}

.table thead th a,
th a.sort-link {
  color: inherit;
}

th a.sort-link:hover {
  text-decoration: none;
  color: var(--primary-bg);
}

.table thead th .info-tip {
  border-color: rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #fff;
  margin-left: 4px;
}

.table thead th .info-tip .tip {
  font-weight: 400;
  text-transform: none;
}

.table tbody tr:nth-child(even) td {
  background: var(--zebra);
}

.table tbody tr:hover td {
  background: var(--row-hover);
}

.table td.num,
.table th.num {
  text-align: right;
}

.table td.wrap {
  white-space: normal;
  min-width: 130px;
  max-width: 320px;
  overflow-wrap: anywhere;
}

.table td.nowrap,
.table th.nowrap {
  white-space: nowrap;
}

.table td small {
  font-size: var(--font-small);
  overflow-wrap: anywhere;
}

.table tbody tr.row-note td {
  border-top: none;
  padding-top: 0;
  background: var(--warning-row);
}

.table tbody tr.row-inactive td {
  color: var(--muted);
}

.table tbody tr.row-total td {
  background: var(--neutral-bg);
  font-weight: 700;
  border-bottom: 2px solid var(--border-strong);
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.table-compact th,
.table-compact td {
  padding: 8px 10px;
  font-size: 14px;
}

/* ---------- Kafelki KPI (Panel Zysków, Dostawy, Statystyki, SMS) ---------- */
.kpi-grid,
.kpi-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi,
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-tile);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 118px;
  min-width: 0;
}

.kpi .kpi-label,
.tile small {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi .kpi-value,
.tile strong {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
}

.kpi .kpi-note,
.tile .tile-note {
  font-size: var(--font-small);
  color: var(--muted);
  margin-top: -4px;
}

.kpi .kpi-note form,
.tile form {
  display: inline;
}

.card > .kpi-grid:last-child,
.card > .kpi-tiles:last-child {
  margin-bottom: 0;
}

.kpi-accent {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset, var(--shadow-tile);
}

.kpi.kpi-good .kpi-value,
.tile.kpi-good strong {
  color: var(--success);
}

.kpi.kpi-bad .kpi-value,
.tile.kpi-bad strong {
  color: var(--danger);
}

.info-line {
  margin: 6px 0 0;
  font-size: var(--font-base);
  color: var(--muted);
  line-height: 1.7;
}

/* ---------- Paginacja z wyborem liczby wierszy ---------- */
.pagination-bar {
  flex-wrap: wrap;
  gap: 12px;
}

.page-sizes a,
.page-sizes strong {
  margin-left: 6px;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Modale, akcje masowe, postęp ---------- */
.bulk {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 20px 24px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow: auto;
}

.action-page .modal {
  box-shadow: none;
  max-width: none;
  padding: 0;
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.modal-list {
  max-height: 40vh;
  overflow: auto;
  margin: 12px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.progress {
  width: 100%;
  height: 10px;
  accent-color: var(--primary);
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

/* ---------- Ryzyko (podejrzane zamówienia COD) ---------- */
.table tbody tr.row-risk-high td {
  background: var(--danger-row);
}

.table tbody tr.row-risk-medium td {
  background: var(--warning-row);
}

.table tbody tr.row-note.row-risk-high td,
.table tbody tr.row-note.row-risk-medium td {
  border-top: none;
  padding-top: 0;
}

.risk-details details {
  margin: 4px 0 6px;
}

.risk-details summary {
  cursor: pointer;
  color: var(--text);
}

.risk-matches {
  margin: 8px 0;
  max-width: 900px;
}

.risk-matches tr.risk-match-returned td {
  color: var(--danger);
}

/* ---------- SMS: podgląd treści i przełącznik reguły ---------- */
.sms-preview {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: var(--font-small);
  word-break: break-word;
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--border-strong);
  padding: 0;
  cursor: pointer;
  transition: background 0.15s ease;
  vertical-align: middle;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.3);
  transition: left 0.15s ease;
}

.switch.on {
  background: var(--success);
  border-color: var(--success);
}

.switch.on .switch-knob {
  left: 20px;
}

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

.switch-form.htmx-request .switch {
  opacity: 0.6;
}

.chart-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 12px;
}

/* ---------- Zyski: pasek zakresu, raporty ---------- */
.range-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.range-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0;
}

.range-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.quick-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 8px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}

.refresh-form {
  margin: 0;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.btn-refresh {
  gap: 8px;
  min-width: 140px;
}

.btn-refresh .spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-refresh.is-loading .spinner,
.btn-refresh:disabled .spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.subtabs {
  margin: 0;
}

.toggle-details {
  padding-top: 0;
}

.profit-wrap {
  overflow: visible;
}

.profit-wrap.show-details {
  overflow-x: auto;
}

.profit-wrap .col-detail {
  display: none;
}

.profit-wrap.show-details .col-detail {
  display: table-cell;
}

.profit-wrap tr.row-total {
  display: none;
}

.profit-wrap.show-total tr.row-total {
  display: table-row;
}

.profit-table th,
.profit-table td {
  white-space: nowrap;
  text-align: right;
}

.profit-table th.sticky-col,
.profit-table td.sticky-col {
  text-align: left;
  font-weight: 600;
}

.profit-table tbody tr.row-total td {
  position: sticky;
  top: 44px;
  z-index: 2;
}

.profit-table th.lock-col,
.profit-table td.lock-col {
  text-align: left;
}

.table .neg {
  color: var(--danger);
}

.table .good {
  color: var(--success);
  font-weight: 700;
}

.table .bad {
  color: var(--danger);
  font-weight: 700;
}

/* ten sam kolor co zysk po ryczałcie, zwykłą czcionką (marża) */
.table .tone-good {
  color: var(--success);
  font-weight: 400;
}

.table .tone-bad {
  color: var(--danger);
  font-weight: 400;
}

.table .strong {
  font-weight: 700;
}

.profit-table tr.row-locked td.sticky-col {
  color: var(--muted);
}

.lock-form {
  gap: 8px;
}

.meta-bar {
  margin-top: 18px;
}

.meta-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0;
}

.meta-title {
  font-weight: 600;
  margin-right: 6px;
}

/* ---------- Logowanie i strona błędu ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: block;
  width: 120px;
  height: auto;
  margin: 4px auto 18px;
}

.login-box h1 {
  margin: 0 0 4px;
  font-size: 22px;
  text-align: center;
}

.login-box p.muted {
  text-align: center;
}

.login-box p.muted {
  margin: 0 0 20px;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Responsywność ---------- */
@media (max-width: 1100px) {
  .kpi-grid,
  .kpi-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  :root {
    --gutter: 16px;
  }

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

  .kpi-grid,
  .kpi-tiles {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .table thead th {
    position: static;
  }
}

/* ---------- Aliasy etykiet stanów używane w modułach (stan paczki, status płatności Shopify, etap COD, zakończenie) ---------- */
.tag-ship-awaiting_pickup,
.tag-stage-awaiting,
.tag-fin-pending,
.tag-fin-partially_paid,
.tag-fin-partially_refunded {
  background: var(--warning-bg);
  color: var(--warning);
}

.tag-ship-delivered,
.tag-stage-delivered,
.tag-fin-paid,
.tag-done-paid {
  background: var(--success-bg);
  color: var(--success);
}

.tag-ship-returned,
.tag-ship-return_in_progress,
.tag-ship-problem,
.tag-stage-returned,
.tag-fin-refunded,
.tag-fin-voided,
.tag-done-cancelled {
  background: var(--danger-bg);
  color: var(--danger);
}

.tag-ship-in_transit,
.tag-stage-shipped,
.tag-fin-authorized {
  background: var(--info-bg);
  color: var(--info);
}

.tag-ship-unknown,
.tag-stage-unshipped,
.tag-stage-completed,
.tag-done-ignored,
.tag-fin-unknown {
  background: var(--neutral-bg);
  color: var(--muted);
}
