/* ==========================================================================
   Component Library — AlleProfit
   Buttons, Cards, Badges, Forms, Tables, Modals, Toasts, Skeletons, KPIs
   ========================================================================== */

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.25rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

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

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-color: var(--color-primary);
  box-shadow: 0 1px 2px rgba(255, 90, 0, 0.2);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 4px 12px rgba(255, 90, 0, 0.3);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(255, 90, 0, 0.2);
}

/* Secondary */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
  box-shadow: var(--shadow);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  transform: translateY(-1px);
}

/* Success */
.btn-success {
  background: var(--color-success);
  color: #ffffff;
  border-color: var(--color-success);
}

.btn-success:hover {
  background: var(--color-success-hover);
  border-color: var(--color-success-hover);
  transform: translateY(-1px);
}

/* Sizes */
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: var(--text-base);
  border-radius: var(--radius-md);
}

.btn-lg svg {
  width: 20px;
  height: 20px;
}

/* Icon-only button */
.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius);
}

/* Full width */
.btn-block {
  width: 100%;
}

/* Button group */
.btn-group {
  display: flex;
  gap: var(--space-sm);
}

@media (max-width: 480px) {
  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
    justify-content: center;
  }

  .btn {
    font-size: var(--text-xs);
    padding: 0.5rem 0.875rem;
  }

  .btn-lg {
    font-size: var(--text-sm);
    padding: 0.75rem 1.25rem;
  }
}

/* ==========================================================================
   CARDS
   ========================================================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow var(--transition),
    transform var(--transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-interactive:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.card-body {
  padding: var(--space-xl);
}

.card-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-hover);
}

.card-body + .card-body {
  border-top: 1px solid var(--color-border);
}

/* Compact card variant */
.card-compact .card-header,
.card-compact .card-body,
.card-compact .card-footer {
  padding: var(--space-md) var(--space-lg);
}

/* Card responsive */
@media (max-width: 768px) {
  .card-header {
    padding: var(--space-md);
    flex-wrap: wrap;
  }

  .card-body {
    padding: var(--space-md);
  }

  .card-footer {
    padding: var(--space-md);
  }

  .card-header h3 {
    font-size: var(--text-sm);
  }
}

@media (max-width: 480px) {
  .card {
    border-radius: var(--radius);
  }

  .card-header {
    padding: var(--space-sm) var(--space-md);
  }

  .card-body {
    padding: var(--space-sm) var(--space-md);
  }

  .card-footer {
    padding: var(--space-sm) var(--space-md);
  }
}

/* ==========================================================================
   BADGES
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}

.badge-neutral {
  background: var(--color-surface-hover);
  color: var(--color-text-secondary);
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success-text);
}

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

.badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning-text);
}

.badge-primary {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

/* Dot indicator in badge */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 6px;
}

/* ==========================================================================
   FORMS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-group + .form-group {
  margin-top: var(--space-lg);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.form-label-required::after {
  content: ' *';
  color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--color-text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, 0.15);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--color-danger);
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-check input[type='checkbox'],
.form-check input[type='radio'] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}

/* Input group with icon */
.input-group {
  position: relative;
}

.input-group .form-input {
  padding-left: 2.5rem;
}

.input-group-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.input-group-icon svg {
  width: 16px;
  height: 16px;
}

/* Clearable inputs — injected wrapper + "X" button (see js/clearable-inputs.js).
   The wrapper preserves the full-width block flow of .form-input fields and is
   the positioning context for the absolutely-placed clear button. */
.clearable-input {
  position: relative;
  display: block;
  width: 100%;
}

.clearable-input > input {
  /* room so the value doesn't slide under the X */
  padding-right: 2.25rem;
}

/* In a left-icon group the icon is hidden (occluded by the wrapper), so undo the
   2.5rem icon padding and sit at the normal input inset. */
.clearable-input.in-input-group > input {
  padding-left: 0.875rem;
}

.clearable-input-clear {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition:
    color var(--transition),
    background var(--transition);
}

.clearable-input.has-value > .clearable-input-clear {
  display: inline-flex;
}

.clearable-input-clear:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.clearable-input-clear:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

/* ==========================================================================
   TABLES
   ========================================================================== */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.table {
  width: 100%;
  font-size: var(--text-sm);
  text-align: left;
}

.table th {
  padding: 0.75rem 1rem;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-surface-hover);
  /* Border drawn inside the cell (inset shadow) instead of as `border-bottom`
     — eliminates the sub-pixel gap that otherwise pokazuje się podczas scrolla
     między sticky nagłówkiem a pierwszym wierszem (tło nagłówka wypełnia
     komórkę do samej krawędzi). */
  box-shadow: inset 0 -1px 0 var(--color-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

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

.table tr:hover td {
  background: var(--color-surface-hover);
}

.table-striped tr:nth-child(even) td {
  background: var(--color-surface-hover);
}

.table-striped tr:nth-child(even):hover td {
  background: var(--color-border);
}

/* Numeric columns right-aligned */
.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  /* Kwoty w jednej linii — „117,69 zł" łamane na dwie nie zwężało realnie
     tabeli, a czytało się fatalnie. */
  white-space: nowrap;
}

/* Gęste tabele (Zamówienia: 11 kolumn przy aktywnym filtrze zwrotów)
   przestają mieścić kolumnę „Szczegóły" już ~1500px. Zanim wrapper zacznie
   scrollować, zwężamy poziomy padding komórek. */
@media (max-width: 1700px) {
  .table th,
  .table td {
    padding: 0.75rem 0.6rem;
  }
}

@media (max-width: 1500px) {
  .table th,
  .table td {
    padding: 0.65rem 0.4rem;
  }
}

/* Table responsive — ensure horizontal scroll on mobile */
@media (max-width: 768px) {
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
    margin-left: calc(-1 * var(--space-sm));
    margin-right: calc(-1 * var(--space-sm));
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .card .table-wrapper {
    margin-left: 0;
    margin-right: 0;
  }

  /* When the table itself is in card-mode (stacked rows), drop the wrapper's
     bleed margins and border — each card row already has its own border,
     so the wrapper's margins would make cards extend outside the parent
     padding, visually pulling them toward one edge of the viewport. */
  .table-wrapper--cards {
    margin-left: 0;
    margin-right: 0;
    border: none;
    border-radius: 0;
    width: 100%;
    overflow: visible;
  }

  .table th {
    padding: 0.5rem 0.75rem;
    font-size: 0.65rem;
  }

  .table td {
    padding: 0.5rem 0.75rem;
    font-size: var(--text-xs);
  }
}

@media (max-width: 480px) {
  .table th {
    padding: 0.375rem 0.5rem;
  }

  .table td {
    padding: 0.375rem 0.5rem;
  }
}

/* ==========================================================================
   MODAL
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--transition-slow),
    visibility var(--transition-slow);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-slow);
}

.modal-backdrop.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: var(--text-lg);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-xl);
}

.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* Modal sizes */
.modal-sm {
  max-width: 380px;
}
.modal-lg {
  max-width: 700px;
}
.modal-xl {
  max-width: 900px;
}

/* Subscription-gate modal: the pricing grid sits inside a <=960px modal
   with its own scrollbar, so landing.css's viewport-based rules misjudge
   it - a classic (non-overlay) scrollbar alone pushed the 3rd card to a
   second row, and the <1024px branch forced a single 440px column. Size
   by what actually fits: three ~190px cards from ~600px of modal width. */
#sub-gate-pricing-slot .pricing-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  max-width: none;
  margin: 0;
}

/* Modal responsive — nearly full width on mobile */
@media (max-width: 768px) {
  .modal-backdrop {
    padding: var(--space-md);
    align-items: center;
  }

  .modal {
    max-width: calc(100vw - var(--space-md) * 2);
    max-height: calc(100vh - var(--space-md) * 2);
    border-radius: var(--radius-lg);
  }

  .modal-sm,
  .modal-lg,
  .modal-xl {
    max-width: calc(100vw - var(--space-md) * 2);
  }

  .modal-header {
    padding: var(--space-md);
  }

  .modal-body {
    padding: var(--space-md);
  }

  .modal-footer {
    padding: var(--space-md);
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .modal-header h3 {
    font-size: var(--text-base);
  }
}

@media (max-width: 480px) {
  .modal-backdrop {
    padding: var(--space-sm);
  }

  .modal,
  .modal-sm,
  .modal-lg,
  .modal-xl {
    max-width: calc(100vw - var(--space-sm) * 2);
    max-height: calc(100vh - var(--space-sm) * 2);
    border-radius: var(--radius-lg);
  }
}

/* Add-cost modal calc row: responsive wrap */
.acm-calc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.acm-calc-row > input,
.acm-calc-row > select {
  flex: 0 0 auto;
}

@media (max-width: 500px) {
  .acm-calc-row:not(.acm-calc-row--compact) {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
  }
  /* Child order: qty × price = total currency */
  .acm-calc-row:not(.acm-calc-row--compact) > *:nth-child(1) {
    width: 100% !important;
    grid-column: 1;
    min-width: 56px;
  }
  .acm-calc-row:not(.acm-calc-row--compact) > *:nth-child(2) {
    grid-column: 2;
    text-align: center;
  }
  .acm-calc-row:not(.acm-calc-row--compact) > *:nth-child(3) {
    width: 100% !important;
    grid-column: 3;
  }
  .acm-calc-row:not(.acm-calc-row--compact) > *:nth-child(4) {
    grid-column: 1 / -1;
    text-align: center;
    margin: 2px 0;
  }
  .acm-calc-row:not(.acm-calc-row--compact) > *:nth-child(5) {
    width: 100% !important;
    grid-column: 1 / 3;
  }
  .acm-calc-row:not(.acm-calc-row--compact) > *:nth-child(6) {
    width: 100% !important;
    grid-column: 3;
  }

  .acm-calc-row--compact {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .acm-calc-row--compact > input {
    flex: 1;
    min-width: 100px;
  }
}

/* Fill-gaps modal: cost rows table becomes cards on mobile/tablet.
   600px → 860px: the fixed-width table (~712px) inside the 780px modal
   forced a sideways scroll through a FORM in the 601-860 band — cards are
   the same pattern the rest of the app switches to at 860. */
@media (max-width: 860px) {
  #fg-costs-table {
    border: none;
  }
  #fg-costs-table thead {
    display: none;
  }
  #fg-costs-table,
  #fg-costs-table tbody {
    display: block;
  }
  #fg-costs-table tbody tr.fg-cost-row {
    display: grid;
    /* minmax(0,1fr), not bare 1fr: grid items' auto-minimum is their
       content width, so the datepicker inside a cell blew the column past
       50% and pushed the right half of the card off-screen on phones. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm);
    /* No card fill/outline — the tinted surface box read as out of place on
       mobile; a plain bottom separator keeps rows distinct without the box. */
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-sm);
  }
  #fg-costs-table tbody tr.fg-cost-row td {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: none;
    width: 100%;
    text-align: left;
  }
  #fg-costs-table tbody tr.fg-cost-row td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.03em;
  }
  /* Center the "bezterminowo" label + checkbox in its cell (flex-column cell
     would otherwise left-align them). */
  #fg-costs-table tbody tr.fg-cost-row td.fg-indefinite-cell {
    align-items: center;
  }
  #fg-costs-table tbody tr.fg-cost-row td.fg-remove-cell {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
  }
  #fg-costs-table tbody tr.fg-cost-row td.fg-remove-cell::before {
    display: none;
  }
  /* Row 0 has no delete button — an empty grid stripe reads as a bug. */
  #fg-costs-table tbody tr.fg-cost-row td.fg-remove-cell.fg-remove-empty {
    display: none;
  }
  /* Inputs/selects fill their grid cell — inline min-widths on the
     currency select otherwise poke past the card edge on 320-375px. */
  #fg-costs-table .fg-price,
  #fg-costs-table .fg-cur {
    width: 100%;
    min-width: 0 !important;
    box-sizing: border-box;
  }
  #fg-costs-table .fg-from-wrap,
  #fg-costs-table .fg-to-wrap {
    width: 100% !important;
  }
  #fg-costs-table .fg-from-wrap .datepicker-input,
  #fg-costs-table .fg-to-wrap .datepicker-input {
    width: 100%;
    min-width: 0;
    display: flex;
    justify-content: space-between;
  }
}

/* Fill-gaps desktop table uses table-layout:fixed, so every control must
   shrink to its (now percentage-based) column. Without this the datepicker
   inputs and the currency select keep their intrinsic width and overflow the
   cell, which is what reintroduced the sideways scroll on desktop. */
#fg-costs-table .fg-price,
#fg-costs-table .fg-cur,
#fg-costs-table .fg-from-wrap,
#fg-costs-table .fg-to-wrap,
#fg-costs-table .fg-from-wrap .datepicker-input,
#fg-costs-table .fg-to-wrap .datepicker-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* "≈ zł" NBP conversion badge: a small inline chip next to a foreign-currency
   amount; click reveals the PLN value (currency.js). Sized to sit on the same
   baseline as the amount without disrupting line height. */
.pln-badge,
.pln-badge-static {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0 7px;
  margin-left: 6px;
  line-height: 1.55;
  cursor: pointer;
  white-space: nowrap;
  vertical-align: middle;
}
.pln-badge:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
/* Static look-alike chip (dashboard unprofitable rows): same pill, but inert so
   a row click bubbles through to navigate instead of converting. cursor:inherit
   picks up the row's pointer. */
.pln-badge-static {
  cursor: inherit;
}

/* Orders list in table mode (>1490px): drop the "≈ zł" chip onto its own line
   under the amount so the right-aligned numbers line up across PLN and
   foreign-currency rows, and the chip never widens the money columns (the
   reason columns "rozjeżdżały się" once "Wszystkie waluty" mixed PLN + EUR
   rows). At <=1490px the table is in card mode (one cell per line), where the
   chip stays inline next to its value. */
@media (min-width: 1491px) {
  .orders-table td.num .pln-badge {
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-top: 3px;
  }
}

/* Orders page filter-preset tabs: a row of pills above the filter bar; clicking
   one applies a saved filter combination and re-queries (orders.js). Scrolls
   horizontally on narrow screens so every tab stays reachable. */
.orders-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}
.orders-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition);
}
.orders-tab:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}
.orders-tab.is-active {
  color: var(--color-primary-text);
  background: var(--color-primary);
  border-color: var(--color-primary);
}
/* Saved-filter builder (SF-style pass 2026-07-04): numbered condition
   cards, segmented AND/OR toggle, chip multi-selects with a checkbox
   popover - the raw selects-in-a-row layout read as clutter. */
/* Slide-in drawer from the right (SF 'Edit List Filters'): sticky header
   and footer, scrollable body. */
.sfb-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(460px, 100vw);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.sfb-drawer.is-open {
  transform: translateX(0);
}

.sfb-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
}

/* One header row: view picker left, slim controls (search/sort/new filter)
   right - the old full dropdown bar is gone, its selects live on hidden. */
.orders-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

.filter-bar-slim {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-left: auto;
  padding: 0;
  background: none;
  border: none;
}

.filter-bar-slim .fb-search {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.filter-bar-slim .fb-search svg {
  position: absolute;
  left: 10px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.filter-bar-slim .fb-search .form-input {
  padding-left: 30px;
  width: 210px;
}

.filter-bar-slim .form-select {
  width: auto;
}

@media (max-width: 767px) {
  .filter-bar-slim {
    margin-left: 0;
    width: 100%;
  }

  /* One control per line: squeezed next to the sort select the search
     input shrank to an unlabeled stub (user screenshot 18.07). */
  .filter-bar-slim .fb-search,
  .filter-bar-slim .form-select {
    flex: 1 1 100%;
  }

  .filter-bar-slim .form-select {
    width: 100%;
  }

  .filter-bar-slim .fb-search .form-input {
    width: 100%;
  }
}

/* Commission-recovery card (orders tab): headline amount, NBP conversion
   table, and the what-to-do hint. Emerald accent = money coming back. */
.crn-card {
  /* Lives inside .orders-list-header (flex, wrap) - force a full-width
     row of its own or it renders BESIDE the view picker instead of below
     it (user report 21.07). */
  flex-basis: 100%;
  width: 100%;
  margin: var(--space-sm) 0;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-left: 3px solid rgba(16, 185, 129, 0.75);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.09), rgba(16, 185, 129, 0.03));
}

.crn-head {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.crn-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.14);
  color: var(--color-success);
}

.crn-eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.crn-total {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.crn-desc {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.crn-table {
  margin-top: var(--space-sm);
  border-collapse: collapse;
  font-size: var(--text-sm);
  min-width: 300px;
}

.crn-table th {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  text-align: left;
  padding: 4px 18px 4px 0;
}

.crn-table td {
  padding: 5px 18px 5px 0;
  border-top: 1px solid rgba(16, 185, 129, 0.16);
  color: var(--color-text);
}

.crn-table th.num,
.crn-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.crn-table th:last-child,
.crn-table td:last-child {
  padding-right: 0;
}

.crn-total-row td {
  border-top: 1px solid rgba(16, 185, 129, 0.45);
  font-weight: 700;
}

.crn-hint {
  display: flex;
  gap: var(--space-xs);
  align-items: flex-start;
  margin-top: var(--space-md);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.crn-hint svg {
  flex: 0 0 auto;
  margin-top: 2px;
}

@media (max-width: 480px) {
  .crn-card {
    padding: var(--space-md);
  }

  .crn-table {
    width: 100%;
    min-width: 0;
  }
}

/* SF-style view picker: one big selector replacing the tab strip. */
.orders-view-picker {
  position: relative;
  display: inline-block;
  margin-bottom: var(--space-sm);
}

.ovp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: 4px 6px 4px 0;
}

.ovp-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ovp-name {
  font-size: var(--text-lg);
  font-weight: 700;
}

.ovp-caret {
  color: var(--color-text-muted);
  font-size: 12px;
}

.ovp-btn:hover .ovp-name {
  color: var(--color-primary);
}

.ovp-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 300px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
}

.ovp-sec {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 8px 10px 4px;
}

.ovp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
}

.ovp-item:hover {
  background: var(--color-surface-hover, rgba(255, 255, 255, 0.05));
}

.ovp-item.is-active .ovp-item-name {
  color: var(--color-primary);
  font-weight: 600;
}

.ovp-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ovp-item-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Saved-views dropdown on the tab strip (SF list-view picker). */
.orders-tab-dd {
  position: relative;
  display: inline-block;
}

.orders-tab-dd-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
}

.orders-tab-dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
}

.orders-tab-dd-item:hover {
  background: var(--color-surface-hover, rgba(255, 255, 255, 0.05));
}

.orders-tab-dd-item.is-active .orders-tab-dd-name {
  color: var(--color-primary);
  font-weight: 600;
}

.orders-tab-dd-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orders-tab-dd-sep {
  height: 1px;
  background: var(--color-border);
  margin: 6px 4px;
}

.orders-tab-dd-new {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.orders-tab-dd-new:hover {
  background: var(--color-surface-hover, rgba(255, 255, 255, 0.05));
}

.sfb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.sfb-head h3 {
  margin: 0;
  font-size: var(--text-md);
}

.sfb-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-md);
  padding: 4px 8px;
}

.sfb-name-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.sfb-name-label .form-input {
  margin-top: 4px;
}

.sfb-cond-header {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.sfb-seg {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.sfb-seg-btn {
  background: none;
  border: none;
  padding: 5px 12px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.sfb-seg-btn.is-on {
  background: var(--color-primary);
  color: var(--color-primary-text);
  font-weight: 600;
}

.sfb-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr) 28px;
  grid-template-areas: 'num field op del' 'num value value del';
  gap: 8px;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  margin-bottom: 6px;
}

.sfb-row .sf-field {
  grid-area: field;
}

.sfb-row .sf-op {
  grid-area: op;
}

.sfb-row .sfb-val-cell {
  grid-area: value;
}

.sfb-row .sf-del-row {
  grid-area: del;
}

.sfb-num {
  grid-area: num;

  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sfb-val-cell {
  min-width: 0;
}

.sfb-val-cell .form-input,
.sfb-val-cell .form-select {
  width: 100%;
}

.sfb-icon-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.sfb-icon-btn:hover {
  color: #ef4444;
  background: var(--color-surface-hover, rgba(255, 255, 255, 0.05));
}

.sfb-group {
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-md);
  background: rgba(255, 90, 0, 0.03);
  padding: 10px 10px 4px;
  margin-bottom: 6px;
}

.sfb-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sfb-adders {
  display: flex;
  gap: var(--space-md);
  margin: 2px 0 var(--space-sm);
}

.sfb-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
}

.sfb-link:hover {
  text-decoration: underline;
}

.sfb-multi {
  position: relative;
}

.sfb-multi-btn {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--color-text);
  font-size: var(--text-xs);
  text-align: left;
}

.sfb-multi-ph {
  color: var(--color-text-muted);
}

.sfb-caret {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 10px;
}

.sfb-chip {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sfb-chip-more {
  background: var(--color-border);
  color: var(--color-text-muted);
}

.sfb-multi-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  max-height: 210px;
  overflow-y: auto;
}

.sfb-multi-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  cursor: pointer;
}

.sfb-multi-opt:hover {
  background: var(--color-surface-hover, rgba(255, 255, 255, 0.05));
}

.sfb-multi-opt input {
  accent-color: var(--color-primary);
}

.sfb-cols-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-sm);
}

.sfb-col-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
}

.sfb-col-row:hover {
  background: var(--color-surface-hover, rgba(255, 255, 255, 0.04));
}

.sfb-col-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  cursor: pointer;
}

.sfb-col-check input {
  accent-color: var(--color-primary);
}

.sfb-col-arrows {
  display: inline-flex;
  gap: 2px;
}

.sfb-col-arrows .sfb-icon-btn[disabled] {
  opacity: 0.3;
  cursor: default;
}

.sfb-foot {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.sfb-delete {
  background: #ef4444;
  color: #fff;
  margin-right: auto;
}

/* Custom saved-filter tabs: the add button reads as an action, not a view;
   the inline pencil edits the ACTIVE custom view only. */
.orders-tab-add {
  border-style: dashed;
  color: var(--color-text-muted);
}

.sf-tab-edit {
  margin-left: 4px;
  opacity: 0.7;
}

.sf-tab-edit:hover {
  opacity: 1;
  color: var(--color-primary);
}

.orders-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 0 6px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  background: var(--color-surface-hover);
  border-radius: 999px;
}
.orders-tab.is-active .orders-tab-count {
  color: var(--color-primary-text);
  background: rgba(255, 255, 255, 0.25);
}
@media (max-width: 768px) {
  .orders-tabs {
    flex-wrap: nowrap;
    /* Leftover from the old horizontally-scrolled tab strip: the bar now
       holds only the view-picker, and overflow-x:auto turned it into a
       clip container that cut the picker's dropdown to a grey sliver
       (user report 17.07). */
    overflow: visible;
    padding-bottom: 2px;
  }
}

/* Dashboard "unprofitable orders" Zysk column: two aligned sub-columns — the
   ≈zł chip in one vertical line, the prices in another. The price slot is a
   fixed (data-driven, inline min-width) width so the chips share a right edge
   across rows; prices are right-aligned within it so their right edges line up
   too. PLN rows have no chip and still align via the fixed price slot. */
.zysk-cell-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}
.zysk-cell-row .pln-badge-static {
  margin-left: 0;
  flex: 0 0 auto;
}
.zysk-num {
  display: inline-block;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Fill-gaps modal: dim the "Do" datepicker when the "Bezterminowo" checkbox
   (separate column) is ticked. */
#fg-costs-table .fg-to-wrap {
  transition: opacity 0.15s ease;
}
#fg-costs-table .fg-to-wrap.is-indefinite {
  opacity: 0.35;
  pointer-events: none;
}

/* ==========================================================================
   TOAST / NOTIFICATIONS
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition:
    transform var(--transition-slow),
    opacity var(--transition-slow);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.toast-close {
  flex-shrink: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px;
}

.toast-close:hover {
  color: var(--color-text);
}

/* Toast variants */
.toast-success {
  border-left: 3px solid var(--color-success);
}
.toast-success .toast-icon {
  color: var(--color-success);
}

.toast-error {
  border-left: 3px solid var(--color-danger);
}
.toast-error .toast-icon {
  color: var(--color-danger);
}

.toast-info {
  border-left: 3px solid var(--color-info);
}
.toast-info .toast-icon {
  color: var(--color-info);
}

.toast-warning {
  border-left: 3px solid var(--color-warning);
}
.toast-warning .toast-icon {
  color: var(--color-warning);
}

@media (max-width: 640px) {
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    /* Sit above the bug-report FAB (44px + its bottom inset) so a full-width
       toast doesn't cover it or the bottom-edge actions while it's shown
       (audit ALPR-75). The container itself is pointer-events:none, so only
       the toast body intercepts taps — and now it clears the corner button. */
    bottom: calc(var(--space-xl) + 52px);
  }

  .toast {
    min-width: auto;
    max-width: none;
  }
}

/* ==========================================================================
   SKELETON LOADING
   ========================================================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-hover) 25%,
    var(--color-border) 50%,
    var(--color-surface-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  border-radius: var(--radius-sm);
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-heading {
  height: 1.5em;
  width: 60%;
  margin-bottom: 1em;
  border-radius: var(--radius-sm);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-lg);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-button {
  height: 38px;
  width: 120px;
  border-radius: var(--radius);
}

/* ==========================================================================
   PRICING CARDS
   ========================================================================== */

.pricing-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  text-align: center;
  position: relative;
  transition: all var(--transition-slow);
  display: flex;
  flex-direction: column;
}

.pricing-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.pricing-card--featured {
  border: 2px solid var(--color-primary);
  box-shadow:
    0 0 0 1px var(--color-primary),
    var(--shadow-lg);
  transform: scale(1.02);
  background: linear-gradient(180deg, var(--color-primary-light) 0%, var(--color-surface) 120px);
}

.pricing-card--featured:hover {
  transform: scale(1.02) translateY(-4px);
  box-shadow:
    0 0 30px rgba(255, 90, 0, 0.15),
    var(--shadow-xl);
}

.pricing-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: var(--color-primary-text);
  padding: 0.25rem 1rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pricing-card-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-lg);
}

.pricing-card-price {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: var(--space-xs);
  line-height: 1;
}

.pricing-card-price .price-amount {
  font-size: var(--text-4xl);
  font-weight: var(--weight-extrabold);
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.pricing-card-price .price-currency {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.pricing-card-price .price-period {
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  color: var(--color-text-muted);
}

/* Fallback for old span-only markup (landing page) */
.pricing-card-price > span:first-child {
  font-size: var(--text-4xl);
  font-weight: var(--weight-extrabold);
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.pricing-card-price > span:last-child {
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  color: var(--color-text-muted);
}

.pricing-card-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

.pricing-features {
  list-style: none;
  text-align: left;
  margin-bottom: var(--space-xl);
  flex: 1;
}

.pricing-features li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.pricing-features li svg {
  width: 18px;
  height: 18px;
  color: var(--color-success);
  flex-shrink: 0;
  margin-top: 1px;
}

.pricing-features li.disabled {
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.pricing-features li.disabled svg {
  color: var(--color-text-muted);
}

.pricing-card .btn {
  margin-top: auto;
}

/* ==========================================================================
   PASSWORD STRENGTH INDICATOR
   ========================================================================== */

.password-strength {
  display: flex;
  gap: 4px;
  margin-top: var(--space-sm);
}

.password-strength-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  transition: background var(--transition);
}

.password-strength[data-strength='1'] .password-strength-bar:nth-child(1) {
  background: var(--color-danger);
}

.password-strength[data-strength='2'] .password-strength-bar:nth-child(-n + 2) {
  background: var(--color-warning);
}

.password-strength[data-strength='3'] .password-strength-bar:nth-child(-n + 3) {
  background: var(--color-warning);
}

.password-strength[data-strength='4'] .password-strength-bar {
  background: var(--color-success);
}

.password-strength-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* ==========================================================================
   DROPDOWN
   ========================================================================== */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
}

.dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--color-surface-hover);
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xs) 0;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-state > svg {
  width: 64px;
  height: 64px;
  color: var(--color-text-muted);
  margin: 0 auto var(--space-lg);
  opacity: 0.5;
  display: block;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 360px;
  margin: 0 auto var(--space-lg);
}

/* ==========================================================================
   AVATAR
   ========================================================================== */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: var(--text-xs);
}
.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: var(--text-lg);
}

/* ==========================================================================
   DIVIDER WITH TEXT
   ========================================================================== */

.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin: var(--space-xl) 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ---- Custom number input spinners (orange arrows) ---- */
input[type='number'].form-input,
input[type='number'].form-input-sm {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type='number'].form-input::-webkit-inner-spin-button,
input[type='number'].form-input-sm::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 100%;
  cursor: pointer;
  opacity: 1;
  background: transparent;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5' viewBox='0 0 10 5'%3E%3Cpath d='M5 0l5 5H0z' fill='%23ea580c'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5' viewBox='0 0 10 5'%3E%3Cpath d='M5 5L0 0h10z' fill='%23ea580c'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position:
    center 2px,
    center calc(100% - 2px);
  background-size:
    8px 4px,
    8px 4px;
}

/* Hover-driven opacity on the dashboard KPI info icon. Replaces inline
 * onmouseover/onmouseout handlers in dashboard.js (CSP `script-src 'self'`
 * doesn't allow inline event handlers). */
.info-popover-trigger:hover {
  opacity: 1 !important;
}

/* Replaces inline onmouseover/onmouseout in orders-export.js
 * (CSP `script-src 'self'` blocks inline handlers). */
.export-dropdown-item:hover {
  background: var(--color-surface-hover);
}

/* ==========================================================================
   iOS INPUT ZOOM GUARD
   Safari on iOS auto-zooms the page whenever a focused control has
   font-size < 16px. Keep the desktop look, bump controls to 16px only on
   touch-size screens so the viewport stays put (RWD audit 2026-07-02).
   ========================================================================== */
@media (max-width: 768px) {
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
  }
}

/* Touch target: modal close is the primary dismiss affordance - 32px is
   below the 44px guideline; enlarge on touch-size screens. */
@media (max-width: 768px) {
  .modal-close {
    width: 40px;
    height: 40px;
  }
}

/* Tap-to-show bubble for title="" hints on touch devices (touch-tooltips.js). */
.touch-tooltip {
  position: fixed;
  z-index: 12000;
  max-width: min(300px, calc(100vw - 16px));
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: #0b1220;
  border: 1px solid var(--color-border);
  color: #e2e8f0;
  font-size: var(--text-xs);
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* "Starter after expiry" tail row in the plan-management queue: let it wrap
   instead of overlapping - on narrow modals the italic hint takes its own
   full-width line under the plan name (user report 17.07). */
.queue-tail-row {
  flex-wrap: wrap;
}
.queue-tail-hint {
  white-space: normal;
  text-align: right;
  margin-left: auto;
}
@media (max-width: 520px) {
  .queue-tail-hint {
    flex: 1 1 100%;
    margin-left: 26px; /* icon 16px + gap */
    text-align: left;
  }
}

/* Manual price-list entry (import wizard step 2, "Dodaj ręcznie"): the
   5-column fixed table can't fit under ~640px - each row becomes a small
   card: EAN and name full-width, then price | VAT | delete on one line.
   Works down to 320px. */
@media (max-width: 640px) {
  #manual-table,
  #manual-table tbody {
    display: block;
    width: 100%;
    /* dashboard.css forces .table-wrapper .table to min-width:600px for
       scrollable tables - this one is card-stacked and must shrink. */
    min-width: 0;
  }
  #manual-table thead {
    display: none;
  }
  #manual-table tbody tr {
    display: grid;
    width: 100%;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr) 108px 36px;
    gap: var(--space-xs) var(--space-sm);
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    margin-bottom: var(--space-sm);
  }
  #manual-table tbody td {
    display: block;
    padding: 0;
    border: none;
  }
  /* EAN and name span the full card width. */
  #manual-table tbody td:nth-child(1),
  #manual-table tbody td:nth-child(2) {
    grid-column: 1 / -1;
  }
}

/* Manual-entry name cell: the clearable-input wrapper must flex-shrink
   next to the product thumbnail instead of forcing its own line. */
#manual-rows td .clearable-input {
  flex: 1 1 auto;
  min-width: 0;
}
