:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #5d6b7c;
  --line: #e2e8f0;
  --navy: #10243e;
  --navy-2: #1a365d;
  --gold: #c4a15a;
  --gold-soft: rgba(196, 161, 90, 0.16);
  --shadow: 0 10px 30px rgba(16, 36, 62, 0.06);
  --radius: 14px;
  --sidebar: 268px;
  --topbar: 64px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.45;
}

a { color: var(--navy-2); }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: linear-gradient(180deg, #0d1c32 0%, #163056 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .2s ease;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  text-decoration: none;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand img {
  height: 36px;
  width: auto;
  background: #fff;
  border-radius: 8px;
  padding: 4px 6px;
}

.brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name strong { font-size: 1.05rem; letter-spacing: .04em; }
.brand-name span { font-size: .75rem; color: rgba(255,255,255,.65); margin-top: 3px; }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  flex: 1;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.side-link i { width: 1.1rem; color: var(--gold); }

.side-link:hover { background: rgba(255,255,255,.08); color: #fff; }

.side-link.is-active {
  background: rgba(255,255,255,.12);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}

.side-user {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.side-user .who { font-size: .92rem; font-weight: 700; }
.side-user .role { color: rgba(255,255,255,.6); font-size: .78rem; margin-bottom: 10px; }

.side-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
}

.side-logout:hover { color: var(--gold); }

.app-main {
  margin-left: var(--sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.sidebar-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 40px;
  height: 40px;
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.topbar-user {
  margin-left: auto;
  color: var(--muted);
  font-size: .92rem;
}

.page {
  padding: 24px 24px 40px;
  flex: 1;
}

.app-footer {
  padding: 14px 24px 18px;
  color: var(--muted);
  font-size: .82rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 32, .45);
  z-index: 1030;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h1 {
  font-size: 1.7rem;
  margin: 0;
  letter-spacing: -0.02em;
}

.page-lead {
  margin: 4px 0 0;
  color: var(--muted);
}

.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-body { padding: 18px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
  min-height: 132px;
}

.stat-card:hover { border-color: #c5d2e2; transform: translateY(-1px); }

.stat-card .label {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 6px 0 10px;
}

.stat-card .go { font-size: .86rem; font-weight: 700; color: var(--navy-2); }

.status-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.status-board .item { text-align: center; padding: 8px 4px; }
.status-board h3 { margin: 8px 0 0; font-size: 1.45rem; }

.split {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 16px;
  margin-bottom: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-size: .92rem;
}

.bar-track {
  height: 8px;
  background: #e8eef5;
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a365d, #3d6ea8);
  border-radius: 99px;
}

.bar-fill.alt { background: linear-gradient(90deg, #8a6a32, #c4a15a); }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.filter-grid .span-3 { grid-column: span 3; }
.filter-grid .span-2 { grid-column: span 2; }
.filter-grid .span-4 { grid-column: span 4; }
.filter-grid .actions {
  grid-column: span 2;
  display: flex;
  gap: 8px;
  align-items: end;
}

.field label,
.form-label {
  display: block;
  font-weight: 600;
  font-size: .86rem;
  margin-bottom: 4px;
  color: #243044;
}

.field-help { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.field-error { color: #b42318; font-size: .82rem; margin-top: 4px; }

.form-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  background: #fbfcfe;
}

.form-section h2 {
  font-size: .95rem;
  margin: 0 0 12px;
  color: var(--navy);
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: hidden;
  max-width: 100%;
}

.data-table {
  width: 100%;
  margin: 0;
  font-size: .94rem;
  table-layout: fixed;
}

.data-table thead th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  white-space: normal;
  line-height: 1.2;
  position: sticky;
  top: 0;
  z-index: 1;
  overflow-wrap: anywhere;
}

.data-table td, .data-table th {
  vertical-align: middle;
  overflow: hidden;
  padding: .48rem .5rem;
}

.data-table th:last-child,
.data-table td.cell-actions,
.data-table td.cell-files {
  width: 10rem;
  white-space: nowrap;
}

.data-table-spedycja {
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
  font-size: .82rem;
}
.data-table-spedycja th,
.data-table-spedycja td {
  padding: .4rem .28rem;
}
.data-table-spedycja thead th {
  font-size: .7rem;
  line-height: 1.15;
  padding: .4rem .16rem;
  overflow-wrap: normal;
  word-break: keep-all;
}
.data-table-spedycja .sp-nr { width: 7.2%; }
.data-table-spedycja .sp-data { width: 7.3%; }
.data-table-spedycja .sp-miejsce { width: 3.8%; }
.data-table-spedycja .sp-nazwa { width: 5.2%; }
.data-table-spedycja .sp-kto { width: 4%; }
.data-table-spedycja .sp-kwota { width: 6.4%; }
.data-table-spedycja .sp-waluta { width: 5%; }
.data-table-spedycja .sp-termin { width: 5.6%; }
.data-table-spedycja .sp-dok { width: 6.2%; }
.data-table-spedycja .sp-faktura { width: 8.4%; }
.data-table-spedycja .sp-pill { width: 6.2%; }
.data-table-spedycja .cell-clip {
  overflow-wrap: normal;
  word-break: normal;
}
.data-table-spedycja .sp-akcje { width: 12%; }
.data-table-spedycja th:last-child,
.data-table-spedycja td.cell-actions {
  width: 12%;
  white-space: normal;
}
.data-table-spedycja td.cell-fit {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table-spedycja td.cell-pill {
  text-align: center;
}
.data-table-spedycja .status-pill {
  display: inline-block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  padding: 3px 4px;
  font-size: .68rem;
  line-height: 1.15;
}
.data-table-spedycja .action-stack {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.data-table-spedycja .action-stack form {
  width: auto;
  margin: 0;
}
.data-table .ikona-akcja {
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #d5deea;
  border-radius: 8px;
  background: #fff;
  color: var(--navy-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.data-table .ikona-akcja .bi { font-size: .95rem; line-height: 1; }
.data-table .ikona-akcja:hover { background: #f4f7fb; border-color: #b7c5d6; color: var(--navy); }
.data-table .ikona-akcja.jest-wyslij { color: #1d4ed8; }
.data-table .ikona-akcja.jest-edytuj { color: #b45309; }
.data-table .ikona-akcja.jest-usun,
.data-table .ikona-akcja.jest-po-terminie { color: #b42318; }
.data-table .ikona-akcja.jest-usun:hover,
.data-table .ikona-akcja.jest-po-terminie:hover { background: #fff5f5; border-color: #f3c0c0; }
.data-table .ikona-akcja:focus-visible {
  outline: 2px solid var(--navy-2);
  outline-offset: 1px;
}

.data-table th.cell-check,
.data-table td.cell-check {
  width: 2.6rem;
  text-align: center;
  overflow: visible;
}

.cell-clip {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.cell-tip {
  position: fixed;
  z-index: 80;
  max-width: min(420px, calc(100vw - 24px));
  padding: 8px 10px;
  background: var(--navy);
  color: #fff;
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1.35;
  white-space: pre-line;
  box-shadow: var(--shadow);
  pointer-events: none;
}

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

.row-alert { background: #fff6f5 !important; }

.route-main { font-weight: 700; }
.kopiuj-miejsce { cursor: pointer; }
.kopiuj-miejsce:hover { text-decoration: underline; }
.data-table th.col-miejsce,
.data-table td.col-miejsce {
  width: 13rem;
}
.miejsce-linia {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: .28rem;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
}
.miejsce-linia .kopiuj-miejsce {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}
.miejsce-linia .cell-clip {
  display: block;
  -webkit-line-clamp: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}
.route-sub { color: var(--muted); font-size: .82rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.data-table td.cell-status,
.data-table th.cell-status {
  width: 10.5rem;
  overflow: visible;
}
.data-table-trasy { table-layout: fixed; width: 100%; }
.data-table-trasy .tr-skad,
.data-table-trasy .tr-dokad,
.data-table-trasy th.col-miejsce,
.data-table-trasy td.col-miejsce { width: 9.5%; }
.data-table-trasy .tr-data,
.data-table-trasy td.tr-data { width: 8.5%; white-space: nowrap; }
.data-table-trasy .tr-rodzaj { width: 5.5%; }
.data-table-trasy .tr-kierowca { width: 13%; }
.data-table-trasy .tr-kwota,
.data-table-trasy td.tr-kwota { width: 7.1%; white-space: nowrap; }
.data-table-trasy .tr-status,
.data-table-trasy th.cell-status,
.data-table-trasy td.cell-status { width: 9.2%; }
.data-table-trasy .tr-uwagi { width: 4.7%; }
.data-table-trasy .tr-kto { width: 6.6%; }
.data-table-trasy thead th {
  overflow-wrap: normal;
  word-break: keep-all;
}
.data-table-trasy .tr-pliki,
.data-table-trasy td.cell-files { width: 11.4%; }
.data-table-trasy .tr-akcje,
.data-table-trasy th:last-child,
.data-table-trasy td.cell-actions { width: 6.5%; }
.data-table-trasy td.cell-status { text-align: center; }
.data-table-trasy .status-form {
  display: flex;
  justify-content: center;
  width: 100%;
}
.data-table-trasy .status-select {
  padding: 3px 14px;
  font-size: .7rem;
  text-align: center;
  text-align-last: center;
  background-position: right 3px center;
}
.status-form { position: relative; margin: 0; }
.status-etykieta {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  pointer-events: none;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  color: #526070;
}
.status-dialog {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 18, 32, .45);
}
.status-dialog[hidden] { display: none !important; }
.status-dialog form {
  width: min(420px, 100%);
  margin: 0;
  background: #fff;
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.status-dialog h2 { margin: 0 0 6px; font-size: 1.15rem; }
.status-dialog p { margin: 0 0 12px; color: var(--muted); }
.status-dialog-blad { color: #b42318; font-weight: 700; }
.status-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.status-select {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 4px 18px;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  text-align: center;
  text-align-last: center;
  color: transparent;
  appearance: none;
  -webkit-appearance: none;
  background-color: #eef2f6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%231e293b' stroke-width='1.6' d='M1 1.2l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 8px 8px;
}
.status-select:disabled { opacity: .65; cursor: wait; }
.status-select.status-przyjete { background-color: #dbeafe; }
.status-select.status-zaladowane { background-color: #cffafe; }
.status-select.status-wtrasie { background-color: #fef3c7; }
.status-select.status-rozladowane { background-color: #dcfce7; }
.status-select.status-faktura { background-color: #e5e7eb; }
.status-select.status-samofakturowanie { background-color: #ede9fe; }
.status-select option { color: #10243e; }
.status-etykieta.status-przyjete { color: #1d4ed8; }
.status-etykieta.status-zaladowane { color: #0e7490; }
.status-etykieta.status-wtrasie { color: #92400e; }
.status-etykieta.status-rozladowane { color: #166534; }
.status-etykieta.status-faktura { color: #374151; }
.status-etykieta.status-samofakturowanie { color: #5b21b6; }

.status-przyjete { background: #dbeafe; color: #1d4ed8; }
.status-zaladowane { background: #cffafe; color: #0e7490; }
.status-wtrasie { background: #fef3c7; color: #92400e; }
.status-rozladowane { background: #dcfce7; color: #166534; }
.status-faktura { background: #e5e7eb; color: #374151; }
.status-samofakturowanie { background: #ede9fe; color: #5b21b6; }
.status-select,
.status-select.status-przyjete,
.status-select.status-zaladowane,
.status-select.status-wtrasie,
.status-select.status-rozladowane,
.status-select.status-faktura,
.status-select.status-samofakturowanie { color: transparent; }
.status-ok { background: #dcfce7; color: #166534; }
.status-danger { background: #fee2e2; color: #b42318; }
.status-warn { background: #fef3c7; color: #92400e; }
.status-muted { background: #eef2f6; color: #526070; }
.status-dark { background: #e2e8f0; color: #1e293b; }

.trasa-sent td { background: #fff1f1 !important; }

.sent-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  background: #b42318;
  color: #fff;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
}

.note-btn {
  border: 0;
  background: #eef3f8;
  color: var(--navy);
  border-radius: 8px;
  width: 32px;
  height: 32px;
}

.attach-list { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 4px; align-items: center; justify-content: center; }
.attach-list a { text-align: center; }

.form-section { margin: 4px 0 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #1a365d; }
.action-stack { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 4px; min-width: 0; justify-content: center; align-items: center; }
.action-stack form { margin: 0; width: auto; }
.action-stack .btn,
.data-table td.cell-actions .btn {
  width: auto;
  padding: .28rem .55rem;
  font-size: .82rem;
  line-height: 1.3;
}
.data-table td.cell-actions .d-flex { flex-wrap: nowrap; }

.pagination-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

.page-jump { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.page-jump select { width: auto; min-width: 96px; }

.tooltip-dynamic {
  position: fixed;
  background: #122033;
  color: #fff;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: .82rem;
  max-width: 320px;
  z-index: 2000;
  pointer-events: none;
  white-space: pre-wrap;
}

.profit-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8f4ea;
  border: 1px solid #eadcbe;
  font-weight: 700;
}

.profit-bar strong { font-size: 1.15rem; color: var(--navy); }
.profit-item { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.profit-item span { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted, #5c6b7a); }

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  background: #fff;
}
.alert-item:hover { border-color: #d7c08a; }

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

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.flash {
  padding: 10px 12px;
  border-radius: 10px;
  background: #e8f1ff;
  border: 1px solid #c9ddfb;
}
.flash-success { background: #eaf8ef; border-color: #b7e4c7; }
.flash-error, .flash-danger { background: #fdecec; border-color: #f3c0c0; }
.flash-warning { background: #fff7e8; border-color: #f3dfb6; }

.tms-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #122033;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  max-width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .18s ease;
  z-index: 3000;
}
.tms-toast.is-on { opacity: 1; transform: none; }
.tms-toast.is-error { background: #8f1d1d; }

.auth-card { width: min(440px, 100%); }
.auth-card .logo-row {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.auth-card img {
  height: 48px;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
}
.auth-card h1 { font-size: 1.45rem; text-align: center; margin: 8px 0 4px; }
.auth-card .page-lead { text-align: center; margin-bottom: 18px; }

.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { background: #1a365d; border-color: #1a365d; }
.btn-primary:hover, .btn-primary:focus { background: #10243e; border-color: #10243e; }
.form-control, .form-select { border-radius: 10px; border-color: #d5deea; }
.form-control:focus, .form-select:focus {
  border-color: #8aa4c8;
  box-shadow: 0 0 0 .2rem rgba(26, 54, 93, .12);
}

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.role-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.role-checks .form-check { margin: 0; }

.combo { position: relative; }
.combo select.combo-native { display: none !important; }
.combo-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 240px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.combo-option { padding: 8px 12px; cursor: pointer; }
.combo-option.is-active,
.combo-option:hover { background: #eef3f9; }
.combo-empty { padding: 8px 12px; color: var(--muted); }

body.is-login .sidebar,
body.is-login .topbar,
body.is-login .app-footer,
body.is-login .sidebar-backdrop { display: none !important; }

body.is-login .app-main { margin-left: 0; }

body.is-login .page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(196,161,90,.25), transparent 50%),
    linear-gradient(160deg, #0d1c32, #1c3f6e 55%, #eef2f6 55%);
}

body.nav-open { overflow: hidden; }

@media (max-width: 1199px) {
  .sidebar { transform: translateX(-105%); }
  .sidebar.is-open { transform: none; }
  .sidebar-backdrop.is-open { display: block; }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar-user { display: none; }
  .split { grid-template-columns: 1fr; }
  .filter-grid .span-3,
  .filter-grid .span-2,
  .filter-grid .span-4 { grid-column: span 6; }
  .filter-grid .actions { grid-column: span 6; }
}

@media (max-width: 860px) {
  .form-control, .form-select, .page-link { font-size: 16px; }
  .table-wrap { overflow: visible; }
  .data-table { table-layout: auto; }
  .data-table-spedycja { width: 100%; font-size: .94rem; }
  .data-table .action-stack,
  .data-table .attach-list { flex-direction: row; justify-content: flex-end; }
  .data-table .ikona-akcja { width: 36px; height: 36px; flex-basis: 36px; }
  .cell-clip {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
  }
  .miejsce-linia { justify-content: flex-end; width: 100%; }
  .miejsce-linia .cell-clip {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .data-table th.col-miejsce,
  .data-table td.col-miejsce { width: auto; }
  .data-table-trasy th,
  .data-table-trasy td,
  .data-table-trasy col { width: auto !important; }
  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
  .data-table,
  .data-table tbody { display: block; }
  .data-table tr {
    display: block;
    margin: 0 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
  }
  .data-table tr.trasa-sent { background: #fff5f5; }
  .data-table tr.row-alert { background: #fff6f5; }
  .data-table td {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    width: auto;
    text-align: right !important;
    white-space: normal !important;
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }
  .data-table td:last-child { border-bottom: 0; }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    text-align: left;
    margin-right: auto;
    max-width: 46%;
  }
  .data-table td.cell-actions,
  .data-table td.cell-files {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
  .data-table td.cell-actions::before,
  .data-table td.cell-files::before {
    margin-right: 0;
    max-width: none;
  }
  .data-table th:last-child,
  .data-table td.cell-actions { width: auto; white-space: normal; }
  .data-table th.cell-status,
  .data-table td.cell-status { width: auto; }
  .status-form { width: 100%; max-width: 16rem; }
  .action-stack,
  .attach-list { flex-direction: row; justify-content: flex-end; }
  .action-stack .btn,
  .data-table td.cell-actions .btn { width: 100%; }
  .data-table td.cell-actions .d-flex { flex-wrap: wrap; }
  .data-table td.cell-actions .d-flex,
  .data-table td.cell-actions .action-stack,
  .data-table td.cell-files .attach-list { width: 100%; }
  .data-table td.cell-actions .btn { flex: 1 1 auto; }
  .data-table td.empty {
    display: block;
    text-align: center !important;
    border-bottom: 0;
  }
  .data-table td.empty::before { content: none; }
  .pagination { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 640px) {
  .page { padding: 16px 12px 28px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 1.35rem; }
  .page-head .btn,
  .page-head-actions .btn,
  .form-actions .btn,
  .quick-actions .btn { width: 100%; }
  .stat-grid, .status-board { grid-template-columns: 1fr 1fr; }
  .status-pill { white-space: normal; text-align: center; }
  .filter-grid .span-3,
  .filter-grid .span-2,
  .filter-grid .span-4,
  .filter-grid .actions { grid-column: span 12; }
  .filter-grid .actions { flex-direction: column; }
  .filter-grid .actions .btn { width: 100%; }
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-track { grid-column: 1 / -1; }
  .alert-item, .profit-bar { flex-direction: column; align-items: flex-start; }
  .panel-body { padding: 14px; }
  .topbar { padding: 0 12px; }
}
