.finance-operation-categories-catalog,
.finance-category-issues,
.finance-operation-category-block {
  display: grid;
  gap: 16px;
  min-width: 0;
  color: #1e293b;
}

.finance-category-page-header,
.finance-category-block-header,
.finance-category-bucket > header,
.finance-category-issue-cards article > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.finance-category-page-header h2,
.finance-category-block-header h3,
.finance-category-bucket h4 {
  margin: 0;
  color: #0f172a;
}

.finance-category-page-header h2 {
  font-size: 22px;
}

.finance-operation-category-block > .finance-category-block-header h3 {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.finance-category-page-header p,
.finance-category-bucket header p {
  margin: 5px 0 0;
  color: #64748b;
  font-size: 13px;
}

.finance-category-start-action-footer-only {
  display: none;
}

.finance-category-count {
  min-width: 34px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e0edff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.finance-category-catalog-controls,
.finance-category-issue-filters {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.finance-category-search,
.finance-category-correction-reason,
.finance-category-filter {
  display: grid;
  gap: 6px;
}

.finance-category-search {
  flex: 1 1 320px;
  max-width: 560px;
}

.finance-category-search > span,
.finance-category-correction-reason > span,
.finance-category-filter > span,
.finance-category-field-label,
.finance-category-line-amount > span,
.finance-category-line-comment > span {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.finance-category-search input,
.finance-category-correction-reason textarea,
.finance-category-line-amount input,
.finance-category-line-comment textarea,
.finance-category-picker-menu input {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  outline: none;
}

.finance-category-search input,
.finance-category-line-amount input,
.finance-category-picker-menu input {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
}

.finance-category-line-comment textarea {
  min-height: 64px;
  padding: 8px 10px;
  resize: vertical;
}

.finance-category-correction-reason textarea {
  min-height: 80px;
  padding: 10px;
  resize: vertical;
}

.finance-category-search input:focus,
.finance-category-correction-reason textarea:focus,
.finance-category-line-amount input:focus,
.finance-category-line-comment textarea:focus,
.finance-category-picker-menu input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgb(37 99 235 / 10%);
}

.finance-category-section-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.finance-category-section-button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.finance-category-section-button:hover,
.finance-category-section-button:focus-visible {
  border-color: #93c5fd;
  background: #f8fbff;
  outline: none;
}

.finance-category-section-button.is-active {
  border-color: #93c5fd;
  background: #eaf3ff;
  color: #1d4ed8;
}

.finance-category-section-button.is-incoming {
  border-color: #a7f3d0;
  color: #047857;
}

.finance-category-section-button.is-incoming:hover,
.finance-category-section-button.is-incoming:focus-visible,
.finance-category-section-button.is-incoming.is-active {
  border-color: #6ee7b7;
  background: #ecfdf5;
  color: #047857;
}

.finance-category-section-button.is-outgoing {
  border-color: #fed7aa;
  color: #b45309;
}

.finance-category-section-button.is-outgoing:hover,
.finance-category-section-button.is-outgoing:focus-visible,
.finance-category-section-button.is-outgoing.is-active {
  border-color: #fdba74;
  background: #fff7ed;
  color: #9a3412;
}

.finance-category-section-button.is-returns {
  border-color: #ddd6fe;
  color: #6d28d9;
}

.finance-category-section-button.is-returns:hover,
.finance-category-section-button.is-returns:focus-visible,
.finance-category-section-button.is-returns.is-active {
  border-color: #c4b5fd;
  background: #f5f3ff;
  color: #6d28d9;
}

.finance-category-section-button.is-transit {
  border-color: #93c5fd;
  color: #1d4ed8;
}

.finance-category-section-button.is-transit:hover,
.finance-category-section-button.is-transit:focus-visible,
.finance-category-section-button.is-transit.is-active {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.finance-category-section-button.is-technical {
  border-color: #cbd5e1;
  color: #475569;
}

.finance-category-section-button.is-technical:hover,
.finance-category-section-button.is-technical:focus-visible,
.finance-category-section-button.is-technical.is-active {
  border-color: #94a3b8;
  background: #f1f5f9;
  color: #334155;
}

.finance-category-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #dbe5f0;
  border-radius: 12px;
  background: #fff;
}

.finance-category-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
}

.finance-category-table th,
.finance-category-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #e8eef5;
  text-align: left;
  vertical-align: top;
}

.finance-category-table th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.finance-category-table td {
  overflow-wrap: anywhere;
  color: #334155;
  font-size: 13px;
  line-height: 1.45;
}

.finance-category-table th:first-child,
.finance-category-table td:first-child {
  width: 190px;
}

.finance-category-table th:nth-child(2),
.finance-category-table td:nth-child(2) {
  width: 25%;
}

.finance-category-table tbody tr:last-child td {
  border-bottom: 0;
}

.finance-category-table tbody tr.is-incoming td:first-child,
.finance-category-catalog-card.is-incoming {
  border-left: 4px solid #10b981;
}

.finance-category-table tbody tr.is-outgoing td:first-child,
.finance-category-catalog-card.is-outgoing {
  border-left: 4px solid #f59e0b;
}

.finance-category-table tbody tr.is-returns td:first-child,
.finance-category-catalog-card.is-returns {
  border-left: 4px solid #8b5cf6;
}

.finance-category-table tbody tr.is-transit td:first-child,
.finance-category-catalog-card.is-transit {
  border-left: 4px solid #3b82f6;
}

.finance-category-table tbody tr.is-technical td:first-child,
.finance-category-catalog-card.is-technical {
  border-left: 4px solid #64748b;
}

.finance-category-catalog-cards,
.finance-category-issue-cards {
  display: none;
}

.finance-category-empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: #64748b;
  text-align: center;
}

.finance-category-issue-target {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 5px;
  margin: 7px 0 0;
  color: #334155;
  font-size: 12px;
}

.finance-category-issue-target small {
  color: #64748b;
}

.finance-category-instruction {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.finance-category-instruction-toggle {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
}

.finance-category-instruction-panel {
  width: 100%;
  box-sizing: border-box;
}

.finance-category-catalog-link {
  width: fit-content;
  color: #1d4ed8;
  text-decoration: none;
}

.finance-category-buckets {
  display: grid;
  gap: 12px;
}

.finance-category-bucket {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dbe5f0;
  border-radius: 12px;
  background: #fff;
}

.finance-category-bucket.is-embedded {
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.finance-category-bucket.is-embedded.is-no-deal {
  border: 0;
  background: transparent;
}

.finance-operation-category-block[data-embedded="false"] .finance-category-bucket.is-deal,
.finance-operation-category-block[data-embedded="false"] .finance-category-bucket.is-no-deal {
  border-color: #93c5fd;
  background: #fff;
}

.finance-category-bucket.has-overflow {
  border-color: #fca5a5;
  background: #fffafa;
}

.finance-category-bucket > header {
  padding-bottom: 10px;
  border-bottom: 1px solid #e8eef5;
}

.finance-category-bucket h4 {
  font-size: 14px;
}

.finance-category-deal-link {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 3px 6px;
  border-radius: 7px;
  color: #1d4ed8;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.finance-category-deal-link:hover {
  background: #eff6ff;
  box-shadow: 0 4px 10px rgb(37 99 235 / 10%);
  text-decoration: none;
  transform: translateY(-1px);
}

.finance-category-deal-link:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.finance-category-bucket > header > strong {
  white-space: nowrap;
  color: #0f172a;
  font-size: 14px;
}

.finance-category-lines {
  display: grid;
  gap: 8px;
}

.finance-category-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 160px);
  align-items: end;
  gap: 10px;
  max-width: 100%;
  padding: 12px;
  border: 1px solid #dbe5f0;
  border-radius: 11px;
  background: #f8fafc;
}

.finance-category-line.is-readonly {
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  padding: 9px 10px;
}

.finance-category-line-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.finance-category-line.is-readonly .finance-category-line-header {
  padding-bottom: 6px;
}

.finance-category-line-header > strong {
  color: #334155;
  font-size: 13px;
}

.finance-category-line-picker,
.finance-category-line-amount,
.finance-category-line-comment {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.finance-category-line-comment {
  grid-column: 1 / -1;
}

.finance-category-picker {
  position: relative;
  min-width: 0;
}

.finance-category-picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-align: left;
}

.finance-category-picker-button > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-category-picker-button:hover,
.finance-category-picker-button:focus-visible {
  border-color: #60a5fa;
  outline: none;
}

.cash-ledger-entry-panel .finance-category-picker-button,
.cash-ledger-entry-panel .finance-category-line-amount input {
  font-size: 12px;
}

.finance-category-picker-menu,
.finance-category-filter-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 5px);
  left: 0;
  display: grid;
  box-sizing: border-box;
  width: 100%;
  max-width: min(420px, calc(100vw - 32px));
  max-height: 320px;
  gap: 6px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 14px 34px rgb(15 23 42 / 16%);
}

.finance-category-picker-menu {
  grid-template-rows: auto minmax(0, 1fr);
}

.finance-operation-category-block {
  box-sizing: border-box;
  max-width: 100%;
  container-type: inline-size;
  overflow-anchor: none;
}

.finance-operation-category-block[data-embedded="true"] {
  gap: 10px;
}

.finance-category-picker-menu[hidden],
.finance-category-filter-menu[hidden],
.finance-category-instruction-panel[hidden],
.finance-category-line-comment[hidden],
.finance-category-editor-error[hidden] {
  display: none;
}

.finance-category-picker-options {
  display: grid;
  min-height: 0;
  gap: 3px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.finance-category-picker-option,
.finance-category-filter-menu button {
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #1e293b;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-align: left;
  overflow-wrap: anywhere;
}

.finance-category-picker-option:hover,
.finance-category-picker-option:focus-visible,
.finance-category-filter-menu button:hover,
.finance-category-filter-menu button:focus-visible {
  background: #eff6ff;
  color: #1d4ed8;
  outline: none;
}

.finance-category-delete {
  display: grid;
  flex: 0 0 36px;
  place-items: center;
  width: 36px;
  height: 40px;
  border: 1px solid #fecaca;
  border-radius: 9px;
  background: #fff;
  color: #b91c1c;
  cursor: pointer;
  font-size: 20px;
}

.finance-category-delete:hover,
.finance-category-delete:focus-visible {
  background: #fef2f2;
  outline: none;
}

.finance-category-add {
  justify-self: start;
}

.finance-transfer-category-embedded {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid #dbe5f0;
}

.finance-transfer-category-embedded-title {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.finance-transfer-category-pair {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(110px, 145px);
  align-items: end;
}

.finance-transfer-category-pair.is-readonly {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.finance-transfer-category-side {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.finance-transfer-category-arrow {
  align-self: center;
  color: #64748b;
  font-weight: 800;
}

.finance-transfer-category-pair-amount,
.finance-transfer-category-pair-amount-input {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.finance-transfer-category-pair-amount {
  grid-column: 1 / -1;
  grid-template-columns: auto auto auto;
  justify-content: start;
  color: #334155;
  font-size: 12px;
}

.finance-transfer-category-pair-amount-input small {
  color: #64748b;
  font-size: 11px;
}

.finance-transfer-allocation-line .finance-transfer-category-embedded {
  grid-column: 1 / -1;
  width: 100%;
}

.finance-transfer-allocation-no-deal {
  border-color: #93c5fd;
}

@container (max-width: 620px) {
  .finance-transfer-category-pair,
  .finance-transfer-category-pair.is-readonly {
    grid-template-columns: minmax(0, 1fr);
  }

  .finance-transfer-category-arrow {
    justify-self: center;
    transform: rotate(90deg);
  }

  .finance-transfer-category-pair-amount,
  .finance-transfer-category-pair-amount-input {
    grid-column: 1;
  }
}

@media (max-width: 760px) {
  .finance-transfer-category-pair,
  .finance-transfer-category-pair.is-readonly {
    grid-template-columns: minmax(0, 1fr);
  }

  .finance-transfer-category-arrow {
    justify-self: center;
    transform: rotate(90deg);
  }

  .finance-transfer-category-pair-amount,
  .finance-transfer-category-pair-amount-input {
    grid-column: 1;
  }
}

.finance-category-readonly-value {
  display: flex;
  align-items: center;
  min-width: 0;
  color: #1e293b;
  font-size: 12px;
  line-height: 1.35;
}

.finance-category-readonly-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.finance-category-readonly-row > strong:last-child {
  color: #0f172a;
  font-size: 12px;
  white-space: nowrap;
}

.finance-category-bucket-error {
  margin: 0;
}

.finance-category-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.finance-category-deal-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.finance-category-deal-summary > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: #f1f5f9;
}

.finance-category-deal-summary dt {
  color: #64748b;
  font-size: 11px;
}

.finance-category-deal-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #1e293b;
  font-size: 13px;
  font-weight: 800;
}

.finance-category-deal-summary .is-missing {
  background: #fef2f2;
}

.finance-category-deal-summary .is-missing dd {
  color: #b91c1c;
}

.finance-category-summary > div {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #f8fafc;
}

.finance-category-summary dt {
  color: #64748b;
  font-size: 11px;
}

.finance-category-summary dd {
  margin: 0;
  color: #1e293b;
  font-size: 13px;
  font-weight: 800;
}

.finance-category-summary .is-missing {
  background: #fff7ed;
}

.finance-category-summary .is-missing dd {
  color: #9a3412;
}

.finance-category-summary .is-overflow {
  background: #fef2f2;
}

.finance-category-summary .is-overflow dd {
  color: #b91c1c;
}

.finance-category-editor-error {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 9px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 700;
}

.finance-category-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.finance-category-filter {
  position: relative;
  min-width: 240px;
}

.finance-category-issues-table th:first-child,
.finance-category-issues-table td:first-child {
  width: 90px;
}

.finance-category-issues-table th:last-child,
.finance-category-issues-table td:last-child {
  width: 90px;
}

.finance-category-issues-table small {
  color: #64748b;
}

.finance-category-load-more {
  width: 100%;
}

@media (max-width: 760px) {
  .finance-category-page-header h2 {
    font-size: 19px;
  }

  .finance-category-catalog-controls,
  .finance-category-issue-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .finance-category-search,
  .finance-category-filter {
    width: 100%;
    max-width: none;
    flex-basis: auto;
  }

  .finance-category-section-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-category-table-wrap {
    display: none;
  }

  .finance-category-catalog-cards,
  .finance-category-issue-cards {
    display: grid;
    gap: 10px;
  }

  .finance-category-catalog-card,
  .finance-category-issue-cards article {
    display: grid;
    gap: 10px;
    padding: 13px;
    border: 1px solid #dbe5f0;
    border-radius: 12px;
    background: #fff;
  }

  .finance-category-catalog-card h3 {
    margin: 0;
    color: #0f172a;
    font-size: 14px;
  }

  .finance-category-catalog-card dl {
    display: grid;
    gap: 9px;
    margin: 0;
  }

  .finance-category-catalog-card dl > div {
    display: grid;
    gap: 3px;
  }

  .finance-category-catalog-card dt,
  .finance-category-issue-cards span,
  .finance-category-issue-cards time {
    color: #64748b;
    font-size: 11px;
  }

  .finance-category-catalog-card dd {
    margin: 0;
    overflow-wrap: anywhere;
    color: #334155;
    font-size: 13px;
    line-height: 1.4;
  }

  .finance-category-issue-cards article > p {
    margin: 0;
    overflow-wrap: anywhere;
    color: #475569;
    font-size: 13px;
  }

  .finance-category-issue-cards article > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .finance-category-line {
    grid-template-columns: minmax(0, 1fr);
  }

  .finance-category-line-picker {
    grid-column: 1;
  }

  .finance-category-line-amount {
    grid-column: 1;
  }

  .finance-category-line-comment {
    grid-column: 1 / -1;
  }

  .finance-category-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-category-editor-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .finance-category-editor-actions > * {
    width: 100%;
  }
}

@container (max-width: 520px) {
  .finance-category-block-header {
    align-items: stretch;
    flex-direction: column;
  }

  .finance-category-block-header > button {
    width: 100%;
  }

  .finance-category-line {
    grid-template-columns: minmax(0, 1fr);
  }

  .finance-category-line-picker {
    grid-column: 1;
  }

  .finance-category-line-amount {
    grid-column: 1;
  }

  .finance-category-line-comment {
    grid-column: 1 / -1;
  }

  .finance-category-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-category-readonly-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .finance-category-readonly-row > strong:last-child {
    justify-self: start;
  }
}
