.hmwb {
  max-width: 1100px;
  margin: 0 auto;
}

.hmwb * {
  box-sizing: border-box;
}

.hmwb-intro {
  margin-bottom: 22px;
}

.hmwb-upload-grid,
.hmwb-work-area,
.hmwb-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.hmwb-upload-card,
.hmwb-transaction-card,
.hmwb-matches-card,
.hmwb-panel,
.hmwb-result-grid section {
  border: 1px solid #d9d9d9;
  border-radius: 10px;
  padding: 20px;
  background: #fff;
}

.hmwb-upload-card h3,
.hmwb-panel h3,
.hmwb-result-grid h4 {
  margin-top: 0;
}

.hmwb-small,
.hmwb-help,
.hmwb-match-meta,
.hmwb-file-info {
  color: #666;
  font-size: 0.94rem;
}

.hmwb-drop {
  display: flex;
  min-height: 130px;
  border: 2px dashed #aaa;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  padding: 18px;
  text-align: center;
}

.hmwb-upload-card input[type="file"] {
  position: absolute;
  left: -9999px;
}

.hmwb-file-info {
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.hmwb-start-row,
.hmwb-actions,
.hmwb-review-header,
.hmwb-missing-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}

.hmwb button {
  border: 0;
  border-radius: 7px;
  padding: 11px 17px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.hmwb button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hmwb button:not(.hmwb-secondary):not(.hmwb-preview-btn) {
  background: #222;
  color: #fff;
}

.hmwb-secondary,
.hmwb-preview-btn {
  background: #ececec;
  color: #222;
}

.hmwb-primary-action {
  flex: 1;
}

.hmwb-actions > button {
  min-height: 54px;
}

.hmwb-key {
  display: inline-block;
  min-width: 22px;
  margin-right: 4px;
}

.hmwb-progress-wrap {
  margin: 22px 0;
}

.hmwb-progress-wrap progress {
  width: 100%;
  height: 14px;
  margin-top: 8px;
}

.hmwb-panel {
  margin-top: 20px;
}

.hmwb-counter {
  font-weight: 700;
  font-size: 1.1rem;
}

.hmwb-work-area {
  margin-top: 15px;
}

.hmwb-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  color: #777;
  font-weight: 700;
  margin-bottom: 12px;
}

.hmwb-date {
  font-size: 1rem;
  color: #555;
}

.hmwb-description {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 6px;
}

.hmwb-amount {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 14px;
}

.hmwb-reference {
  margin-top: 8px;
  color: #555;
  overflow-wrap: anywhere;
}

.hmwb-matches {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hmwb-match {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}

.hmwb-match.is-selected {
  outline: 3px solid rgba(0,0,0,.18);
  border-color: #555;
}

.hmwb-match-info {
  min-width: 0;
}

.hmwb-match-info strong {
  overflow-wrap: anywhere;
}

.hmwb-match-side {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.hmwb-score {
  font-weight: 800;
  white-space: nowrap;
}

.hmwb-preview-btn {
  padding: 7px 10px !important;
  font-size: .9rem !important;
}

.hmwb-empty {
  padding: 18px;
  border: 1px dashed #bbb;
  border-radius: 8px;
  color: #666;
}

.hmwb-help {
  margin-top: 10px;
}

.hmwb-result-grid {
  margin-top: 18px;
}

.hmwb textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  line-height: 1.45;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 7px;
  margin-bottom: 10px;
}

.hmwb-missing-panel {
  position: fixed;
  z-index: 99998;
  right: 20px;
  bottom: 20px;
  width: min(520px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
}

.hmwb-missing-head {
  margin-top: 0;
  margin-bottom: 12px;
}

.hmwb-missing-head h3 {
  margin: 0;
}

.hmwb-modal {
  position: fixed;
  z-index: 99999;
  inset: 0;
  padding: 20px;
  background: rgba(0,0,0,.58);
}

.hmwb-modal-inner {
  width: min(1000px, 100%);
  height: calc(100vh - 40px);
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hmwb-modal-head {
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #ddd;
}

.hmwb-preview-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #f3f3f3;
}

.hmwb-preview-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.hmwb-preview-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: auto;
}

@media (max-width: 760px) {
  .hmwb-upload-grid,
  .hmwb-work-area,
  .hmwb-result-grid {
    grid-template-columns: 1fr;
  }

  .hmwb-actions {
    flex-direction: column;
  }

  .hmwb-actions > button {
    width: 100%;
  }

  .hmwb-review-header {
    align-items: flex-start;
  }

  .hmwb-match {
    align-items: flex-start;
  }

  .hmwb-match-side {
    flex-direction: column;
    align-items: flex-end;
  }
}


.hmwb-balance-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.hmwb-balance-inputs label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

.hmwb-balance-inputs input {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 7px;
  padding: 10px;
  font: inherit;
  background: #fff;
}

.hmwb-balance-check {
  max-width: 620px;
  margin: 18px 0;
  border: 1px solid #ddd;
  border-radius: 9px;
  padding: 14px 16px;
  background: #fafafa;
}

.hmwb-balance-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 0;
}

.hmwb-balance-row strong {
  white-space: nowrap;
}

.hmwb-balance-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  font-weight: 700;
}

.hmwb-balance-status.is-ok {
  background: #e8f5e9;
  color: #1b5e20;
}

.hmwb-balance-status.is-error {
  background: #fff3e0;
  color: #8a4b08;
}

@media (max-width: 560px) {
  .hmwb-balance-inputs {
    grid-template-columns: 1fr;
  }
}

.hmwb-control-title {
  margin-top: 18px;
  font-weight: 800;
}

.hmwb-control-inputs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hmwb-control-inputs label:nth-child(3) {
  grid-column: 1 / -1;
}

@media (max-width: 560px) {
  .hmwb-control-inputs {
    grid-template-columns: 1fr;
  }

  .hmwb-control-inputs label:nth-child(3) {
    grid-column: auto;
  }
}

.hmwb-unused-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
}

.hmwb-unused-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.hmwb-unused-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.hmwb-unused-empty {
  padding: 12px;
  border: 1px dashed #bbb;
  border-radius: 8px;
  color: #666;
}

@media (max-width: 560px) {
  .hmwb-unused-row {
    align-items: flex-start;
  }

  .hmwb-unused-row .hmwb-preview-btn {
    flex-shrink: 0;
  }
}
