.fv-page {
  background: #f6f8fb;
  color: #101827;
}

.fv-shell {
  width: min(1560px, calc(100vw - 18px));
  margin: 22px auto 48px;
}

.fv-alarm {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  border-radius: var(--radius-md, 12px);
  padding: var(--space-sm, 12px) var(--space-md, 16px);
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .07);
}

.fv-alarm.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.fv-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-sm, 12px);
  margin: 14px 0;
}

.fv-tile {
  background: var(--surface-1, #fff);
  border: 1px solid var(--border-color, #dde4ee);
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-md, 16px);
  min-height: 92px;
  text-align: left;
  cursor: default;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15,23,42,.08));
  transition: border-color var(--transition-normal, .19s ease), box-shadow var(--transition-normal, .19s ease), transform var(--transition-fast, .15s ease);
}

.fv-tile.is-clickable {
  cursor: pointer;
}

.fv-tile.is-clickable:hover {
  border-color: var(--color-info, #2563eb);
  box-shadow: var(--shadow-md, 0 8px 20px rgba(16,24,40,.06));
  transform: translateY(-1px);
}

.fv-tile span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.fv-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

.fv-tile small {
  display: block;
  margin-top: 8px;
  color: #475569;
  font-weight: 700;
}

.fv-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 12px;
}

.fv-tabs button,
.fv-btn {
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--color-secondary, #fff);
  color: var(--text-primary, #0f172a);
  border-radius: var(--radius-md, 12px);
  min-height: 40px;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color var(--transition-normal, .19s ease), border-color var(--transition-normal, .19s ease), box-shadow var(--transition-normal, .19s ease), transform var(--transition-fast, .15s ease);
}

.fv-tabs button.is-active,
.fv-primary {
  background: var(--color-primary, #0f172a);
  border-color: var(--color-primary, #0f172a);
  color: #fff;
}
@media (hover:hover) {
  .fv-tabs button:hover,
  .fv-btn:hover {
    background: var(--color-secondary-hover, #f8fafc);
    transform: translateY(-1px);
  }
  .fv-tabs button.is-active:hover,
  .fv-primary:hover {
    background: var(--color-primary-hover, #1e293b);
  }
}

.fv-panel {
  display: none;
  background: var(--surface-1, #fff);
  border: 1px solid var(--border-color, #dde4ee);
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-md, 16px);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15,23,42,.08));
}

.fv-panel.is-active {
  display: block;
}

.fv-toolbar,
.fv-filters,
.fv-filter-row,
.fv-filter-checks,
.fv-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.fv-filter-top {
  justify-content: space-between;
  margin-bottom: 8px;
}

.fv-filter-actions {
  margin-bottom: 0;
}

.fv-filters {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.fv-filter-row,
.fv-filter-checks {
  margin-bottom: 0;
}

.fv-search {
  flex: 1 1 320px;
}

.fv-toolbar input,
.fv-filters input,
.fv-filters select,
.fv-form-grid input,
.fv-form-grid select,
.fv-form-grid textarea,
.fv-settings input,
.fv-import input,
.fv-small textarea,
.fv-files-body input,
.fv-files-body select,
#vendorSort {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
}

.fv-filters select,
.fv-filters input[type="date"] {
  width: auto;
  min-width: 148px;
}

.fv-filters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.fv-filters input[type="checkbox"] {
  width: auto;
}

.fv-reset-filters {
  padding: 8px 10px;
  font-size: 13px;
}

.fv-cashflow,
.fv-stalker {
  background: #fff;
  border: 1px solid #dde4ee;
  border-radius: 8px;
  margin: 12px 0;
  padding: 12px;
}

.fv-cashflow-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.fv-cashflow-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.fv-cashflow-grid > div {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px;
  background: #f8fafc;
}

.fv-cashflow-grid span,
.fv-cashflow-grid small {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.fv-cashflow-grid strong {
  display: block;
  margin: 4px 0;
  font-size: 16px;
}

.fv-tension {
  border-radius: 999px;
  padding: 5px 9px;
  font-weight: 900;
  background: #dcfce7;
  color: #166534;
}

.fv-tension.uwaga { background: #fef9c3; color: #854d0e; }
.fv-tension.duże,
.fv-tension.duże.zobowiązania { background: #ffedd5; color: #9a3412; }
.fv-tension.krytyczne { background: #fee2e2; color: #991b1b; }

.fv-stalker {
  display: grid;
  gap: 4px;
  border-color: #fbbf24;
  background: #fffbeb;
  color: #713f12;
}

.fv-table-wrap {
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.fv-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 5px;
  table-layout: fixed;
  min-width: 920px;
  font-size: 12.5px;
}

.fv-table th,
.fv-table td {
  padding: 6px 7px;
  text-align: left;
  vertical-align: middle;
  line-height: 1.18;
}

.fv-table td {
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  background: inherit;
}

.fv-table td:first-child {
  border-left: 1px solid #e2e8f0;
  border-radius: 8px 0 0 8px;
}

.fv-table td:last-child {
  border-right: 1px solid #e2e8f0;
  border-radius: 0 8px 8px 0;
}

.fv-table th:nth-child(1),
.fv-table td:nth-child(1) { width: 100px; }
.fv-table th:nth-child(2),
.fv-table td:nth-child(2) { width: 42px; text-align: center; }
.fv-table th:nth-child(3),
.fv-table td:nth-child(3) { width: 270px; }
.fv-table th:nth-child(4),
.fv-table td:nth-child(4) { width: 112px; }
.fv-table th:nth-child(5),
.fv-table td:nth-child(5) { width: 106px; }
.fv-table th:nth-child(6),
.fv-table td:nth-child(6) { width: 96px; }
.fv-table th:nth-child(7),
.fv-table td:nth-child(7) { width: 118px; }
.fv-table th:nth-child(8),
.fv-table td:nth-child(8) { width: 88px; }
.fv-table th:nth-child(9),
.fv-table td:nth-child(9) { width: 74px; }
.fv-table th:nth-child(10),
.fv-table td:nth-child(10) {
  width: 52px;
  position: sticky;
  right: 0;
  z-index: 3;
  box-shadow: -10px 0 16px rgba(15, 23, 42, .08);
}

.fv-table th:nth-child(10) {
  width: 52px;
  position: sticky;
  right: 0;
  z-index: 4;
  background: #fff;
  box-shadow: -10px 0 16px rgba(15, 23, 42, .08);
}

.fv-table th {
  color: var(--text-secondary, #475569);
  font-size: 10px;
  text-transform: uppercase;
  background: var(--surface-2, #f8fafc);
}

.fv-table th button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  font: inherit;
  font-weight: 900;
  text-align: left;
  text-transform: inherit;
  max-width: 100%;
  white-space: nowrap;
}

.fv-table th button.is-active {
  color: #0f766e;
}

.fv-sort-arrow {
  display: inline-flex;
  width: 12px;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1;
}

.fv-table th button.is-active .fv-sort-arrow {
  color: #0f766e;
}

.fv-table tr.overdue {
  background: #fff1f2;
}

.fv-table tr.today,
.fv-table tr.tomorrow {
  background: #fff7ed;
}

.fv-table tr.soon {
  background: #fefce8;
}

.fv-table tr.paid {
  color: #64748b;
  background: #f0fdf4;
}

.fv-table tr.fv-empty-row {
  background: #fff;
}

.fv-table tr[data-invoice-row] {
  cursor: context-menu;
}

.fv-table tr[data-invoice-row]:hover,
.fv-table tr.is-menu-open {
  filter: saturate(1.05);
  outline: 1px solid rgba(37, 99, 235, .22);
}

.fv-priority,
.fv-company {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
  background: #eef2ff;
  color: #3730a3;
}

.fv-company {
  white-space: nowrap;
}

.fv-deadline-badge {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  border-radius: 999px;
  padding: 3px 6px;
  background: #f1f5f9;
  color: #334155;
  font-size: 10.5px;
  font-weight: 900;
  white-space: nowrap;
}

.fv-deadline-badge strong {
  overflow: visible;
  text-overflow: clip;
}

.fv-deadline-badge em {
  min-width: 28px;
  border-radius: 999px;
  padding: 1px 4px;
  background: rgba(255, 255, 255, .75);
  font-style: normal;
  text-align: center;
}

.fv-deadline-badge.overdue { background: #fee2e2; color: #991b1b; }
.fv-deadline-badge.today,
.fv-deadline-badge.tomorrow { background: #ffedd5; color: #9a3412; }
.fv-deadline-badge.soon { background: #fef9c3; color: #854d0e; }
.fv-deadline-badge.future { background: #e0f2fe; color: #075985; }
.fv-deadline-badge.paid { background: #dcfce7; color: #166534; }
.fv-deadline-badge.on_hold { background: #e5e7eb; color: #374151; }
.fv-deadline-badge.dispute { background: #f3e8ff; color: #6b21a8; }

.fv-table td:nth-child(3),
.fv-table td:nth-child(4),
.fv-table td:nth-child(6),
.fv-table td:nth-child(7),
.fv-table td:nth-child(9) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fv-table td:nth-child(5) strong {
  white-space: nowrap;
}

.fv-company.art { background: #ecfeff; color: #155e75; }
.fv-company.segurro { background: #f0fdf4; color: #166534; }
.fv-priority.urgent,
.fv-priority.high { background: #ffe4e6; color: #9f1239; }
.fv-priority.queue { background: #fef3c7; color: #92400e; }

.fv-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  align-items: center;
  white-space: nowrap;
}

.fv-row-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.fv-row-menu-btn:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.fv-context-menu {
  position: fixed;
  z-index: 3000;
  width: 230px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md, 12px);
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .22);
  padding: 6px;
  overflow: auto;
}

.fv-context-menu-head {
  display: grid;
  grid-template-columns: 1fr 24px;
  align-items: center;
  gap: 8px;
  padding: 5px 4px 7px 8px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 4px;
  color: #475569;
  font-size: 11px;
  text-transform: uppercase;
}

.fv-context-menu-head strong {
  min-width: 0;
  white-space: nowrap;
  line-height: 1;
}

.fv-context-menu-head button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-height: 24px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  justify-self: end;
}

.fv-context-menu-head button:hover {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

.fv-context-menu button,
.fv-context-menu a {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: var(--radius-sm, 8px);
  background: transparent;
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
  text-decoration: none;
  padding: 6px 8px;
}

.fv-context-menu button:hover,
.fv-context-menu a:hover {
  background: #f1f5f9;
}

.fv-context-menu .danger {
  color: #b91c1c;
}

.fv-card .fv-actions,
.fv-vendor-row .fv-actions {
  flex-wrap: wrap;
  white-space: normal;
}

.fv-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
}

.fv-tile .ui-icon,
.fv-context-menu .ui-icon,
.fv-icon .ui-icon,
.fv-table .ui-icon,
.fv-card .ui-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
}

.fv-icon.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.fv-mobile-list {
  display: none;
}

.fv-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  background: #fff;
}

.fv-card.overdue { border-color: #fecaca; background: #fff1f2; }
.fv-card.today,
.fv-card.tomorrow { border-color: #fed7aa; background: #fff7ed; }
.fv-card.soon { border-color: #fde68a; background: #fefce8; }

.fv-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
}

.fv-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
  color: #334155;
  font-size: 14px;
}

.fv-dialog {
  width: min(860px, calc(100vw - 24px));
  border: 0;
  border-radius: var(--radius-lg, 12px);
  padding: 0;
  box-shadow: var(--shadow-lg, 0 18px 45px rgba(15,23,42,.16));
}

.fv-dialog::backdrop {
  background: rgba(15, 23, 42, .42);
}

.fv-dialog header,
.fv-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.fv-dialog footer {
  border-top: 1px solid var(--border-color, #e2e8f0);
  border-bottom: 0;
  justify-content: flex-end;
}

.fv-dialog h2 {
  margin: 0;
  font-size: 18px;
}

.fv-dialog header button {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.fv-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.fv-form-grid label,
.fv-settings label,
.fv-small label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.fv-wide {
  grid-column: 1 / -1;
}

.fv-small {
  width: min(520px, calc(100vw - 24px));
}

.fv-vendor-row,
.fv-report-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
}

.fv-vendor-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.fv-vendor-metrics span {
  border-radius: 999px;
  background: #f1f5f9;
  padding: 4px 7px;
  font-size: 11px;
  color: #334155;
}

.fv-calendar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.fv-calendar-head h2 {
  margin: 0;
}

.fv-calendar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fv-calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.fv-calendar-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.fv-cal-week {
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  padding: 4px;
}

.fv-cal-day {
  min-height: 86px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 7px;
  text-align: left;
  cursor: pointer;
}

.fv-cal-day span,
.fv-cal-day small,
.fv-day-block span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.fv-cal-day strong {
  display: block;
  margin-top: 8px;
  font-size: 13px;
}

.fv-cal-day.muted {
  opacity: .48;
}

.fv-cal-day.overdue { background: #fff1f2; border-color: #fecaca; }
.fv-cal-day.today { background: #fff7ed; border-color: #fed7aa; }
.fv-cal-day.soon { background: #fefce8; border-color: #fde68a; }
.fv-cal-day.paid { background: #f0fdf4; border-color: #bbf7d0; }
.fv-cal-day.held { background: #f1f5f9; border-color: #cbd5e1; }

.fv-calendar-agenda {
  border-left: 1px solid #e2e8f0;
  padding-left: 14px;
}

.fv-calendar-agenda h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.fv-day-block {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 0;
}

.fv-day-block button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.fv-day-invoice,
.fv-file-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
}

.fv-files-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.fv-files-body label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.fv-file-row {
  border-bottom: 1px solid #e2e8f0;
}

.fv-file-row span {
  display: block;
  color: #64748b;
  margin-top: 3px;
}

.fv-muted {
  color: #64748b;
  font-size: 13px;
}

.fv-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  background: #0f172a;
  color: #fff;
  border-radius: var(--radius-md, 12px);
  padding: 10px 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal, 190ms cubic-bezier(.22,.61,.36,1)), transform var(--transition-normal, 190ms cubic-bezier(.22,.61,.36,1));
  z-index: 2000;
}

.fv-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .fv-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fv-cashflow-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .fv-calendar-layout {
    grid-template-columns: 1fr;
  }
  .fv-calendar-agenda {
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 860px) {
  .fv-shell {
    width: min(100% - 16px, 760px);
    margin-top: 12px;
  }
  .fv-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fv-cashflow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fv-cashflow-head,
  .fv-calendar-head {
    align-items: stretch;
    flex-direction: column;
  }
  .fv-panel {
    padding: 10px;
  }
  .fv-table-wrap {
    display: none;
  }
  .fv-mobile-list {
    display: block;
  }
  .fv-form-grid,
  .fv-card-grid {
    grid-template-columns: 1fr;
  }
  .fv-toolbar > *,
  .fv-filters select,
  .fv-filters input[type="date"],
  .fv-filter-row > *,
  .fv-filter-actions,
  .fv-filter-actions > * {
    width: 100%;
  }
  .fv-calendar-month {
    grid-template-columns: 1fr;
  }
  .fv-cal-week {
    display: none;
  }
}

@media (max-width: 640px) {
  .fv-dashboard,
  .fv-cashflow-grid {
    grid-template-columns: 1fr;
  }
}
