.allocation-layout .content {
  padding-bottom: 48px;
}

.allocation-hero {
  margin-bottom: 16px;
}

.allocation-hero-panel {
  display: grid;
  gap: 16px;
  background: linear-gradient(135deg, #f9fbfe 0%, #eef4fb 100%);
}

.allocation-hero-copy {
  display: grid;
  gap: 6px;
}

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

.allocation-toolbar-card {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 0;
}

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

.allocation-control-grid label {
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.allocation-control-full {
  grid-column: 1 / -1;
}

.allocation-control-grid input,
.allocation-control-grid select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid #d8e0e7;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.allocation-control-grid input:focus,
.allocation-control-grid select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
}

.allocation-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.allocation-preview-btn {
  width: 100%;
  margin-bottom: 10px;
}

.allocation-submit-card {
  background: linear-gradient(180deg, #fcfefd 0%, #f7fbf9 100%);
  min-height: 0;
}

.allocation-submit-btn {
  width: 100%;
  height: 42px;
}

.preview-panel {
  display: grid;
  gap: 14px;
}

.preview-summary {
  margin-top: -2px;
}

.preview-table-wrap {
  overflow-x: auto;
  margin-top: 16px;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.preview-table-wrap .simple-table th,
.preview-table-wrap .simple-table td {
  padding: 6px 8px !important;
}

.preview-table-wrap .simple-table th:first-child { width: 40px; }
.preview-table-wrap .simple-table th:nth-child(2) { width: 28%; }
.preview-table-wrap .simple-table th:nth-child(3) { width: 52%; }
.preview-table-wrap .simple-table th:nth-child(4) { width: 20%; }

.preview-table-wrap .simple-table td {
  white-space: normal;
}

.preview-st-name {
  width: auto;
  max-width: 200px;
  color: var(--text-secondary);
  flex: 1 1 auto;
  min-width: 40px;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis;
  font-size: 12px;
}

.preview-st-amt {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text);
  width: 90px;
  text-align: right;
}

.preview-st-fee {
  color: var(--text-muted);
  font-size: 11px;
  width: 80px;
  flex-shrink: 0;
  text-align: right;
}

.preview-subtasks {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
  background: #f8fafb;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.preview-subtask-item:nth-child(even) {
  background: #f2f5f7;
}

.preview-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.preview-status.ok {
  color: var(--success);
  background: var(--success-soft);
}

.preview-status.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.preview-errors {
  color: var(--danger);
  font-size: 12px;
}

.allocation-input {
  width: 120px;
  height: 12px;
  padding: 0 4px;
  font-size: 10px;
  border: 1px solid #d8e0e7;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

.allocation-summary {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  line-height: 1.3;
  align-items: center;
}

.allocation-chip {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid rgba(228, 233, 238, 0.95);
  color: var(--text-secondary);
  font-size: 12px;
}

.allocation-chip.ok {
  background: #e9fbf1;
  color: var(--success);
  border-color: transparent;
}

.allocation-chip.warn {
  background: #fff7e6;
  color: var(--warning);
  border-color: transparent;
}

.allocation-chip.danger {
  background: #fff1f0;
  color: var(--danger);
  border-color: transparent;
}

.allocation-board {
  overflow-x: hidden;
  border: 1px solid rgba(228, 233, 238, 0.95);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.allocation-table td strong {
  font-size: 13px;
}

.matrix-table {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.matrix-table th,
.matrix-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid #eef2f6;
  vertical-align: middle;
}

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

.matrix-table tbody tr:hover td {
  background: #f5f7fa;
}

.matrix-table input {
  width: 100%;
  min-width: 0;
  padding: 6px 2px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}

.matrix-table input[type="number"]::-webkit-outer-spin-button,
.matrix-table input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.matrix-table input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.matrix-table input:focus {
  outline: none;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--primary);
  border-radius: 3px;
}

.matrix-lead-head,
.matrix-summary-head {
  vertical-align: middle !important;
  font-size: 11px;
  font-weight: 600;
  color: #5a6a7a;
  padding: 6px 4px !important;
}

.matrix-header-cell {
  padding: 8px 4px;
  vertical-align: top;
}

.matrix-value-cell.selected {
  background: #e8f0fe;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.matrix-value-cell.selected .matrix-cell-input {
  background: transparent;
}

.matrix-table .matrix-total-input {
  width: 100%;
  text-align: center;
}

.matrix-customer-select {
  width: 100%;
  height: 24px;
  border: 1px solid #d8e0e7;
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font-size: 11px;
  padding: 0 2px;
}

.matrix-customer-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(7, 193, 96, 0.1);
}

.matrix-table .matrix-date-input {
  width: 96px;
}

.matrix-column-head {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: center;
  align-items: stretch;
}

.matrix-column-caption {
  display: none;
}

.matrix-merchant-select {
  width: 100%;
  height: 26px;
  border: 1px solid #d8e0e7;
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
  padding: 0 2px;
}

.matrix-column-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.matrix-column-actions .secondary,
.matrix-column-actions .danger {
  width: 100%;
  height: 28px;
  padding: 0;
  font-size: 11px;
  min-width: 0;
}

.matrix-actions-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
}

.matrix-actions-cell .secondary,
.matrix-actions-cell .danger {
  height: 28px;
  padding: 0 8px;
  min-width: 0;
  font-size: 11px;
}

.matrix-total-cell,
.matrix-date-cell {
  background: #fcfdff;
}

.matrix-summary-cell {
  padding-top: 16px !important;
  font-weight: 600;
  vertical-align: middle !important;
  font-size: 12px;
}

.matrix-allocated-cell,
.matrix-remaining-cell,
.matrix-meta-row th {
  white-space: nowrap;
}

.matrix-table .matrix-column-left-btn,
.matrix-table .matrix-column-right-btn {
  display: none;
}

.matrix-ok {
  color: #149053;
  font-weight: 600;
}

.matrix-bad {
  color: #cc4b4b;
  font-weight: 600;
}

.matrix-table thead tr:first-child th {
  background: #f5f7fa;
  font-weight: 600;
  font-size: 11px;
  color: #5a6a7a;
  border-bottom: 1px solid #dce3ec;
}

.matrix-meta-row th {
  background: #fafbfc;
  color: #8a9aa8;
  font-weight: 400;
  font-size: 10px;
  padding: 2px 4px;
  line-height: 1.6;
  border-bottom: 1px solid #eef2f6;
}

.matrix-total-row td {
  position: sticky;
  bottom: 0;
  z-index: 91;
  background: #f5f7fa;
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  vertical-align: middle;
  border-top: 2px solid #dce3ec;
}

.matrix-sticky-col {
  position: sticky;
  left: 0;
  z-index: 10;
  background: inherit;
  vertical-align: middle !important;
}

.matrix-sticky-col-2 {
  position: sticky;
  left: 18px;
  z-index: 10;
  background: inherit;
  vertical-align: middle !important;
}

.matrix-sticky-col-3 {
  position: sticky;
  left: 73px;
  z-index: 10;
  background: inherit;
  vertical-align: middle !important;
}

.matrix-table thead tr:first-child .matrix-sticky-col,
.matrix-table thead tr:first-child .matrix-sticky-col-2,
.matrix-table thead tr:first-child .matrix-sticky-col-3,
.matrix-table thead tr:first-child .matrix-sticky-right-1,
.matrix-table thead tr:first-child .matrix-sticky-right-2,
.matrix-table thead tr:first-child .matrix-sticky-action {
  z-index: 14;
  background: #f5f7fa;
}

.matrix-meta-row .matrix-sticky-col,
.matrix-meta-row .matrix-sticky-col-2,
.matrix-meta-row .matrix-sticky-col-3,
.matrix-meta-row .matrix-sticky-right-1,
.matrix-meta-row .matrix-sticky-right-2,
.matrix-meta-row .matrix-sticky-action {
  z-index: 13;
  background: #fafbfc;
}

.matrix-table tbody .matrix-sticky-col,
.matrix-table tbody .matrix-sticky-col-2,
.matrix-table tbody .matrix-sticky-col-3,
.matrix-total-row .matrix-sticky-col,
.matrix-total-row .matrix-sticky-col-2,
.matrix-total-row .matrix-sticky-col-3 {
  z-index: 11;
}
.matrix-table tbody .matrix-sticky-right-1,
.matrix-table tbody .matrix-sticky-right-2,
.matrix-table tbody .matrix-sticky-action,
.matrix-total-row .matrix-sticky-right-1,
.matrix-total-row .matrix-sticky-right-2,
.matrix-total-row .matrix-sticky-action {
  z-index: 12;
}

.matrix-sticky-action {
  position: sticky;
  right: 0;
  z-index: 12;
  background: inherit;
  box-shadow: none !important;
  background-clip: padding-box;
}

.matrix-sticky-right-1 {
  position: sticky;
  right: 60px;
  z-index: 12;
  background: inherit;
  box-shadow: none !important;
  background-clip: padding-box;
}

.matrix-sticky-right-2 {
  position: sticky;
  right: 168px;
  z-index: 7;
  background: inherit;
}

.matrix-cell-auto-readonly {
  background: transparent !important;
  color: var(--text, #333) !important;
  cursor: default;
  border-color: transparent !important;
}

.matrix-value-auto {
  background: var(--surface-muted, #f6f7fa);
  position: relative;
}

.matrix-value-unchecked {
  background: var(--surface-muted, #f0f0f0) !important;
  opacity: 0.5;
}

.matrix-value-unchecked .matrix-auto-check-label {
  opacity: 0.6;
}

.matrix-auto-check-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-bottom: 2px;
  cursor: pointer;
}

.matrix-auto-check-label input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: var(--primary);
  cursor: pointer;
}

.matrix-regenerate-btn {
  font-size: 11px !important;
  padding: 2px 8px !important;
  white-space: nowrap;
}

.matrix-index-cell {
  font-weight: 600;
  color: #8a9aa8;
  min-width: 18px;
  background: #fafbfc;
}

.matrix-customer-cell,
.matrix-sticky-col-2,
.matrix-total-cell,
.matrix-sticky-col-3 {
  background: #fff;
}

.reconciliation-matrix-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 10px;
  flex-wrap: wrap;
}

.reconciliation-legend-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
}

.reconciliation-legend-chip.is-reviewed {
  background: #e8f7ee;
  border-color: #b8e0c3;
  color: #1d6b3f;
}

.reconciliation-legend-chip.is-sent {
  background: #fff5cf;
  border-color: #ead89b;
  color: #8c6300;
}

.reconciliation-matrix-summary-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.reconciliation-matrix-summary-row .card {
  min-width: 0;
}

.reconciliation-matrix-wrapper {
  margin-top: 10px;
  overflow-x: auto;
}

.reconciliation-matrix-table {
  width: 100%;
  table-layout: fixed;
}

.reconciliation-matrix-table th,
.reconciliation-matrix-table td {
  white-space: nowrap;
  text-align: center;
  min-width: 0;
  padding: 10px 8px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reconciliation-matrix-table th:first-child,
.reconciliation-matrix-table td.reconciliation-sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left;
  width: 104px;
  min-width: 104px;
  max-width: 104px;
}

.reconciliation-matrix-table th:not(:first-child):not(:last-child),
.reconciliation-matrix-table td:not(.reconciliation-sticky-col):not(.reconciliation-row-total):not(.reconciliation-col-total) {
  width: 96px;
}

.reconciliation-matrix-table th:last-child,
.reconciliation-row-total,
.reconciliation-col-total {
  width: 92px;
}

.reconciliation-matrix-table thead th:first-child,
.reconciliation-matrix-table tfoot td.reconciliation-sticky-col {
  z-index: 3;
}

.reconciliation-matrix-cell.is-reviewed {
  background: #e8f7ee;
  color: #1d6b3f;
  font-weight: 700;
}

.reconciliation-matrix-cell.is-sent {
  background: #fff5cf;
  color: #8c6300;
  font-weight: 700;
}

.reconciliation-row-total,
.reconciliation-col-total {
  background: #f7fafc;
  font-weight: 700;
}

.allocation-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: 12px;
}

.allocation-config-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  flex-wrap: wrap;
}

.config-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.config-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.config-group input, 
.config-group select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}

.config-divider {
  width: 1px;
  height: 20px;
  background: #e2e8f0;
}

.config-spacer {
  flex: 1;
}

.allocation-summary-inline {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  line-height: 1.3;
}

.allocation-summary-inline .allocation-chip {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.allocation-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.actions-left, .actions-right {
  display: flex;
  gap: 8px;
}

.allocation-board-modern {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #fdfefe 0%, #f7fbf9 100%);
  max-height: calc(100vh - 300px);
  padding: 10px;
}

.matrix-header-scroll {
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid #dce3ec;
  border-radius: 6px 6px 0 0;
  border-bottom: none;
  background: #fff;
}

.matrix-body-scroll {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  background: #fff;
  border: 1px solid #dce3ec;
  border-top: none;
  border-radius: 0 0 6px 6px;
}

.matrix-scroll-wrap {
  display: block;
  width: max-content;
  min-width: 100%;
}

.allocation-board-modern::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.allocation-board-modern::-webkit-scrollbar-thumb {
  background: rgba(104, 120, 146, 0.5);
  border: 2px solid #fff;
  border-radius: 999px;
}

.allocation-board-modern::-webkit-scrollbar-track {
  background: rgba(226, 232, 240, 0.55);
}

.matrix-column-head-modern {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.matrix-column-ctrls {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.matrix-column-name-row {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.matrix-column-remove-row {
  display: flex;
  justify-content: center;
  line-height: 1;
  margin: 1px 0;
}

.matrix-column-name-row .matrix-merchant-select {
  flex: 1;
  min-width: 0;
}

.btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 4px;
}

.matrix-row-error-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff1f0;
  color: #c53f3f;
  border: 1px solid rgba(197, 63, 63, 0.18);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}


