.settlement-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.settlement-period { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.settlement-period label { margin: 0; min-width: 150px; }
.ledger-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}
.ledger-toolbar-top {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 2px;
}
.ledger-toolbar-top #print-settlement-ledger,
.ledger-toolbar-top #download-settlement-ledger-pdf {
  width: auto;
  min-width: 116px;
  min-height: 44px;
}
.ledger-toolbar .ledger-period { grid-column: 1; }
.ledger-party-filters {
  grid-column: 1;
  display: grid;
  grid-template-columns: minmax(150px, .7fr) minmax(220px, 1.3fr);
  gap: 10px;
  width: min(560px, 100%);
}
.ledger-party-filters label { margin: 0; min-width: 0; }
.ledger-party-filters select { width: 100%; min-width: 0; }
.ledger-toolbar .settlement-toolbar-actions {
  grid-column: 2;
  align-self: end;
}
.ledger-toolbar .ledger-query-actions {
  grid-row: 2 / span 2;
}
.ledger-toolbar .ledger-result-message { grid-column: 1 / -1; margin: 0; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; font-size: 18px; }
.panel-heading small { color: #708094; }
.settlement-candidates { margin-bottom: 90px; }
.settlement-candidates table { min-width: 1120px; }
.settlement-candidates input[type="checkbox"] { width: 20px; height: 20px; }
.money-input { width: 105px; min-width: 90px; text-align: right; }
.note-input { min-width: 150px; }
.amount-cell { white-space: nowrap; font-weight: 700; }
.settlement-create-bar { position: sticky; z-index: 8; bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -68px 0 22px; padding: 14px 16px; border: 1px solid #cbd7e2; border-radius: 12px; background: rgba(255,255,255,.96); box-shadow: 0 10px 30px rgba(20,45,68,.18); backdrop-filter: blur(8px); }
#settlement-selection-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; color: #607184; font-size: 13px; }
#settlement-selection-summary .final { color: #173650; font-size: 15px; }
.positive { color: #16705a; }
.negative { color: #b42318; }
.settlement-paid { background: #e5f5ef; color: #17624f; }
.settlement-awaiting_payment { background: #fff3d6; color: #8a5a00; }
.settlement-draft { background: #edf2f7; color: #58697b; }
.settlement-detail-dialog { width: min(1100px, calc(100vw - 28px)); }
.settlement-detail-head { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.settlement-detail-head > div { display: grid; gap: 5px; padding: 13px; border-radius: 10px; background: #f4f7fa; }
.settlement-detail-head small { color: #708094; }
.settlement-detail-head strong { overflow-wrap: anywhere; }
.settlement-detail-dialog .table-panel { overflow: auto; }
.settlement-detail-dialog table { min-width: 800px; }

@media (max-width: 760px) {
  .settlement-toolbar, .settlement-create-bar { align-items: stretch; flex-direction: column; }
  .settlement-period { display: grid; grid-template-columns: 1fr 1fr; }
  .settlement-period label:last-child { grid-column: 1 / -1; }
  .ledger-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }
  .ledger-toolbar .ledger-period {
    grid-column: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }
  .ledger-toolbar .ledger-period label,
  .ledger-toolbar .ledger-period label:last-child {
    grid-column: auto;
    min-width: 0;
  }
  .ledger-toolbar .ledger-period input {
    width: 100%;
    min-width: 0;
    font-size: 14px;
  }
  .ledger-party-filters {
    grid-column: 1;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    width: 100%;
    gap: 8px;
  }
  .ledger-toolbar-top {
    grid-column: 1;
    margin-bottom: 0;
  }
  .ledger-toolbar-top #print-settlement-ledger,
  .ledger-toolbar-top #download-settlement-ledger-pdf {
    width: auto;
    min-width: 112px;
    min-height: 42px;
  }
  .ledger-toolbar .settlement-toolbar-actions {
    grid-column: 1;
    grid-row: auto;
  }
  .ledger-toolbar .ledger-query-actions {
    display: block;
  }
  .ledger-toolbar .ledger-query-actions #load-settlement-ledger {
    width: 100%;
  }
  .ledger-toolbar .ledger-result-message { grid-column: 1; }
  .settlement-detail-head { grid-template-columns: 1fr 1fr; }
  .settlement-create-bar { bottom: 8px; }
}


@media (max-width: 760px) {
  .content { overflow-x: hidden; }
  .settlement-toolbar { padding: 14px; }
  .settlement-period { width: 100%; gap: 10px; }
  .settlement-period label { min-width: 0; width: 100%; }
  .settlement-period input,
  .settlement-period select { width: 100%; min-width: 0; }
  .ledger-toolbar label { font-size: 12px; }
  .ledger-toolbar input,
  .ledger-toolbar select { min-height: 44px; padding-left: 10px; padding-right: 10px; }
  .settlement-toolbar > button { width: 100%; min-height: 46px; }

  .settlement-candidates { padding: 0; border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .settlement-candidates .panel-heading { align-items: flex-start; flex-direction: column; padding: 0 2px; }
  .settlement-candidates .panel-heading h2 { white-space: nowrap; font-size: 20px; }
  .settlement-candidates .panel-heading small { line-height: 1.45; }
  .settlement-candidates table,
  .settlement-candidates tbody { display: block; width: 100%; min-width: 0; }
  .settlement-candidates thead { display: none; }
  .settlement-candidates tr[data-candidate-row] {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    width: 100%;
    margin-bottom: 12px;
    border: 1px solid #d8e0e7;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(20,45,68,.06);
    overflow: hidden;
  }
  .settlement-candidates tr[data-candidate-row] td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: auto;
    min-width: 0;
    padding: 11px 14px;
    border: 0;
    border-top: 1px solid #edf1f4;
    white-space: normal;
  }
  .settlement-candidates tr[data-candidate-row] td:first-child {
    grid-row: 1 / span 3;
    grid-column: 1;
    display: grid;
    place-items: center;
    padding: 12px;
    border-top: 0;
    border-right: 1px solid #edf1f4;
    background: #f7f9fb;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(2),
  .settlement-candidates tr[data-candidate-row] td:nth-child(3),
  .settlement-candidates tr[data-candidate-row] td:nth-child(4) {
    grid-column: 2;
    grid-template-columns: 1fr;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(n+5) {
    grid-column: 1 / -1;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(5)::before { content: "기본금액"; color: #708094; font-size: 12px; }
  .settlement-candidates tr[data-candidate-row] td:nth-child(6)::before { content: "추가금"; color: #708094; font-size: 12px; }
  .settlement-candidates tr[data-candidate-row] td:nth-child(7)::before { content: "공제금"; color: #708094; font-size: 12px; }
  .settlement-candidates tr[data-candidate-row] td:nth-child(8)::before { content: "세액"; color: #708094; font-size: 12px; }
  .settlement-candidates tr[data-candidate-row] td:nth-child(9)::before { content: "조정 사유"; color: #708094; font-size: 12px; }
  .settlement-candidates [data-tax-cell] small { display: block; color: #708094; font-size: 10px; }
  .settlement-candidates .money-input,
  .settlement-candidates .note-input { width: 100%; min-width: 0; }
  .settlement-candidates td small { display: block; margin-top: 4px; }

  .settlement-create-bar { margin: 0 0 20px; padding: 14px; }
  #settlement-selection-summary { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  #settlement-selection-summary .final { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid #e3e9ee; }
  .settlement-create-bar > button { width: 100%; min-height: 48px; }

  .settlement-detail-head { grid-template-columns: 1fr; }
}


@media (max-width: 760px) {
  .settlement-candidates tr[data-candidate-row] {
    position: relative;
    display: block;
    padding: 0;
  }
  .settlement-candidates tr[data-candidate-row] td {
    display: block;
    width: 100%;
    padding: 12px 16px;
  }
  .settlement-candidates tr[data-candidate-row] td:first-child {
    position: absolute;
    z-index: 2;
    top: 13px;
    right: 13px;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .settlement-candidates tr[data-candidate-row] td:first-child input {
    width: 24px;
    height: 24px;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(2) {
    padding: 17px 64px 13px 16px;
    border-top: 0;
    background: #f7f9fb;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(2) strong {
    color: #173650;
    font-size: 17px;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(3),
  .settlement-candidates tr[data-candidate-row] td:nth-child(4) {
    padding-top: 11px;
    padding-bottom: 11px;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(3)::before {
    content: "정산처 · 작업기사";
    display: block;
    margin-bottom: 5px;
    color: #708094;
    font-size: 11px;
    font-weight: 700;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(4)::before {
    content: "고객 · 제품";
    display: block;
    margin-bottom: 5px;
    color: #708094;
    font-size: 11px;
    font-weight: 700;
  }
  .settlement-candidates tr[data-candidate-row] td:nth-child(n+5) {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }
}


.settlement-select-control { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
.settlement-select-control input { width: 18px; height: 18px; margin: 0; accent-color: #173650; }
.settlement-select-control span { color: #526476; font-size: 12px; font-weight: 800; }

@media (max-width: 760px) {
  .settlement-candidates tr[data-candidate-row] td:first-child {
    top: 14px !important;
    right: 14px !important;
    width: auto !important;
    min-width: 0 !important;
    height: 36px !important;
  }
  .settlement-select-control {
    height: 34px;
    padding: 0 10px;
    border: 1px solid #b9c7d3;
    border-radius: 999px;
    background: #fff;
  }
  .settlement-select-control:has(input:checked) {
    border-color: #173650;
    background: #173650;
  }
  .settlement-select-control:has(input:checked) span { color: #fff; }
  .settlement-select-control input { width: 17px !important; height: 17px !important; }
  .settlement-candidates tr[data-candidate-row] td:nth-child(2) { padding-right: 100px; }
}


.settlement-row-actions { white-space: nowrap; }
.settlement-row-actions button + button { margin-left: 5px; }
.settlement-detail-dialog { padding: 0; overflow: hidden; }
.settlement-detail-dialog > .dialog-heading { margin: 0; padding: 16px 18px; border-bottom: 1px solid #dce4eb; }
#settlement-detail-body { max-height: min(72vh, 680px); padding: 18px; overflow: auto; }

@media (max-width: 760px) {
  .settlement-history {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .settlement-history .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    padding: 0 2px;
  }
  .settlement-history .panel-heading h2 { font-size: 20px; }
  .settlement-history table,
  .settlement-history tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .settlement-history thead { display: none; }
  .settlement-history tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid #d8e0e7;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(20,45,68,.06);
    overflow: hidden;
  }
  .settlement-history tbody td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 10px 15px;
    border: 0;
    border-top: 1px solid #edf1f4;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .settlement-history tbody td::before {
    content: attr(data-label);
    color: #708094;
    font-size: 11px;
    font-weight: 800;
  }
  .settlement-history tbody td:first-child {
    display: block;
    padding: 16px 15px;
    border-top: 0;
    background: #f7f9fb;
  }
  .settlement-history tbody td:first-child::before { display: none; }
  .settlement-history tbody td:first-child strong {
    display: block;
    color: #173650;
    font-size: 16px;
  }
  .settlement-history tbody td:first-child small { display: block; margin-top: 5px; }
  .settlement-row-actions { display: flex !important; align-items: center; gap: 7px; }
  .settlement-row-actions::before { flex: 0 0 82px; }
  .settlement-row-actions button { flex: 1 1 auto; min-height: 40px; margin: 0 !important; }
  .settlement-detail-dialog {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: 88vh;
    border-radius: 14px;
  }
  .settlement-detail-dialog > .dialog-heading h2 { font-size: 20px; }
  #settlement-detail-body { max-height: calc(88vh - 66px); padding: 14px; }
}


/* Compact horizontal settlement history cards on mobile */
@media (max-width: 760px) {
  .settlement-history tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "header header"
      "technician count"
      "period period"
      "base tax"
      "additional deduction"
      "final final"
      "status status"
      "actions actions";
    margin-bottom: 10px;
    border: 1px solid #d8e0e7;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    overflow: hidden;
  }
  .settlement-history tbody td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 9px 12px;
    border: 0;
    border-top: 1px solid #edf1f4;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .settlement-history tbody td::before {
    display: block;
    margin-bottom: 3px;
    color: #788797;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
  }
  .settlement-history tbody td:first-child {
    grid-area: header;
    padding: 12px;
    border-top: 0;
    background: #f5f7f9;
  }
  .settlement-history tbody td:first-child strong {
    font-size: 15px;
    letter-spacing: -.02em;
  }
  .settlement-history tbody td:first-child small { margin-top: 3px; }
  .settlement-history tbody td:nth-child(2) { grid-area: technician; }
  .settlement-history tbody td:nth-child(3) { grid-area: period; }
  .settlement-history tbody td:nth-child(4) { grid-area: count; border-left: 1px solid #edf1f4; }
  .settlement-history tbody td:nth-child(5) { grid-area: base; }
  .settlement-history tbody td:nth-child(6) { grid-area: additional; }
  .settlement-history tbody td:nth-child(7) { grid-area: deduction; border-left: 1px solid #edf1f4; }
  .settlement-history tbody td:nth-child(8) { grid-area: tax; border-left: 1px solid #edf1f4; }
  .settlement-history tbody td:nth-child(8) small { display: block; margin-top: 2px; font-size: 9px; }
  .settlement-history tbody td:nth-child(9) { grid-area: final; }
  .settlement-history tbody td:nth-child(9) strong {
    color: #173650;
    font-size: 15px;
    letter-spacing: -.03em;
  }
  .settlement-history tbody td:nth-child(10) { grid-area: status; }
  .settlement-history tbody td:nth-child(11) { grid-area: actions; }
  .settlement-history tbody td.settlement-row-actions {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    align-items: stretch;
    gap: 7px;
    padding: 9px 12px;
    overflow: visible;
    white-space: normal;
  }
  .settlement-history tbody td.settlement-row-actions::before {
    display: none !important;
    content: none;
  }
  .settlement-history tbody td.settlement-row-actions button {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    margin: 0 !important;
    padding: 7px 6px;
    font-size: 11px;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.settlement-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settlement-ledger { margin-bottom: 22px; }
.settlement-ledger > .table-panel { margin: 0; padding: 0; overflow: auto; border: 0; box-shadow: none; }
.settlement-ledger table { min-width: 1420px; }
.settlement-ledger td { white-space: nowrap; }
.settlement-ledger td small { display: block; margin-top: 3px; color: #738396; }
.settlement-ledger-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.ledger-summary-group {
  overflow: hidden;
  min-width: 0;
  border: 1px solid #d5dee6;
  background: #fff;
}
.ledger-summary-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  background: #eef3f6;
  color: #173650;
}
.ledger-summary-title strong { font-size: 14px; }
.ledger-summary-title span {
  color: #607184;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.ledger-summary-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.ledger-summary-values > div {
  min-width: 0;
  padding: 12px;
}
.ledger-summary-values > div + div { border-left: 1px solid #e1e7ec; }
.ledger-summary-values small {
  display: block;
  color: #708094;
  font-size: 11px;
}
.ledger-summary-values strong {
  display: block;
  margin-top: 5px;
  color: #173650;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.ledger-summary-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-top: 1px solid #e1e7ec;
  background: #f8fafb;
}
.ledger-summary-total small {
  color: #607184;
  font-size: 12px;
  font-weight: 800;
}
.ledger-summary-total strong {
  color: #173650;
  font-size: 17px;
  white-space: nowrap;
}
.ledger-income-total {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0;
  border: 1px solid #c9ddd5;
  background: #eef6f3;
}
.ledger-income-item {
  min-width: 0;
  padding: 14px 16px;
}
.ledger-income-item + .ledger-income-item {
  border-left: 1px solid #c9ddd5;
}
.ledger-income-total small {
  display: block;
  color: #365b50;
  font-size: 13px;
  font-weight: 800;
}
.ledger-income-total strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  overflow-wrap: anywhere;
}
.ledger-profit { color: #17624f !important; }

@media (max-width: 1000px) {
  .settlement-ledger-summary { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .settlement-toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .settlement-toolbar-actions #select-visible-settlements { grid-column: 1 / -1; }
  .settlement-toolbar-actions button { width: 100%; min-height: 44px; }
  .settlement-ledger { padding: 14px; }
  .settlement-ledger .panel-heading { align-items: flex-start; }
  .settlement-ledger-summary { grid-template-columns: 1fr; gap: 8px; }
  .ledger-summary-title { padding: 10px 12px; }
  .ledger-summary-values > div { padding: 11px 12px; }
  .ledger-summary-values strong { font-size: 15px; }
  .ledger-summary-total { padding: 10px 12px; }
  .ledger-summary-total strong { font-size: 16px; }
  .ledger-income-total { grid-template-columns: 1fr; padding: 0; }
  .ledger-income-item { padding: 13px 12px; }
  .ledger-income-item + .ledger-income-item { border-left: 0; border-top: 1px solid #c9ddd5; }
  .ledger-income-total strong { font-size: 20px; }
}

.settlement-section-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 18px; border: 1px solid #c8d3dc; background: #fff; }
.settlement-section-tabs button { min-height: 52px; border: 0; border-radius: 0; background: #fff; color: #647587; font-size: 16px; font-weight: 800; }
.settlement-section-tabs button + button { border-left: 1px solid #c8d3dc; }
.settlement-section-tabs button.active { background: #173650; color: #fff; }
[data-settlement-panel][hidden] { display: none !important; }

@media (max-width: 760px) {
  .settlement-section-tabs { position: sticky; z-index: 7; top: 0; margin: 0 0 14px; }
  .settlement-section-tabs button { min-height: 48px; font-size: 15px; }
  [data-settlement-panel="company"] .settlement-period { grid-template-columns: 1fr 1fr; }
  [data-settlement-panel="company"] .settlement-toolbar-actions { grid-template-columns: 1fr 1fr; }
}

#settlement-notice:empty { display: none; }
.settlement-section-tabs { margin-bottom: 12px; }
.settlement-section-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  line-height: 1;
  text-align: center;
}
.settlement-history-heading { align-items: center; }
.settlement-status-filter-wrap {
  display: grid;
  gap: 7px;
  min-width: min(100%, 420px);
}
.settlement-status-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.settlement-status-filters button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #c8d3dc;
  border-radius: 0;
  background: #fff;
  color: #607184;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}
.settlement-status-filters button.active { border-color: #173650; background: #173650; color: #fff; }
.settlement-status-filters span { display: inline-grid; place-items: center; min-width: 18px; margin-left: 4px; padding: 2px 4px; background: rgba(112,128,148,.14); font-size: 10px; }
.settlement-status-filters button.active span { background: rgba(255,255,255,.18); }

@media (max-width: 760px) {
  .settlement-section-tabs { position: static; margin-bottom: 10px; }
  .settlement-section-tabs button { height: 42px; min-height: 42px; padding: 0 8px; font-size: 14px; }
  [data-settlement-panel] > .settlement-toolbar { margin-bottom: 12px; padding: 11px; }
  .settlement-period { gap: 7px; }
  .settlement-period label { gap: 5px; font-size: 12px; }
  .settlement-period input, .settlement-period select { min-height: 42px; padding-top: 8px; padding-bottom: 8px; }
  .settlement-toolbar-actions button { min-height: 40px; padding-top: 7px; padding-bottom: 7px; font-size: 12px; }
  .settlement-candidates { margin-bottom: 10px; }
  .settlement-candidates .panel-heading { margin-bottom: 8px; }
  .settlement-candidates .panel-heading h2,
  .settlement-history .panel-heading h2 { font-size: 18px; }
  .settlement-create-bar { margin: 0 0 12px; padding: 10px; }
  .settlement-history-heading { gap: 9px; margin-bottom: 10px; }
  .settlement-status-filter-wrap { width: 100%; min-width: 0; gap: 6px; }
  .settlement-status-filters { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); width: 100%; gap: 4px; }
  .settlement-status-filters button { width: 100%; min-height: 32px; padding: 5px 2px; font-size: 10px; white-space: nowrap; }
  .settlement-status-filters span { min-width: 15px; margin-left: 2px; padding: 1px 3px; font-size: 9px; }
}

.ledger-result-message { width: 100%; min-height: 18px; margin: 7px 0 0; color: #24658f; font-size: 12px; font-weight: 700; text-align: right; }
.ledger-result-message:empty { display: none; }
#settlement-print-frame { position: fixed; left: -10000px; top: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }
@media (max-width: 760px) {
  .ledger-result-message { grid-column: 1 / -1; margin-top: 2px; text-align: center; }
}

/* Technician settlement query controls */
.settlement-query-period {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}
.settlement-query-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.settlement-query-actions #load-settlement-candidates,
.settlement-query-actions #reset-settlement-candidates {
  min-width: 86px;
}
.settlement-query-result {
  width: 100%;
  margin: 2px 0 0;
  color: #65778a;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.settlement-query-result:empty { display: none; }

@media (max-width: 900px) {
  .settlement-query-period {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 560px) {
  .settlement-query-period {
    grid-template-columns: 1fr 1fr;
  }
  .settlement-query-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .settlement-query-actions #select-visible-settlements {
    grid-column: 1 / -1;
  }
  .settlement-query-result { text-align: left; }
}

/* Company settlement quick date ranges */
.ledger-period-wrap {
  grid-column: 1;
  display: grid;
  gap: 8px;
  width: max-content;
  max-width: 100%;
}
.ledger-toolbar .ledger-period-wrap .ledger-period {
  grid-column: auto;
}
.ledger-range-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ledger-range-presets > span {
  margin-right: 2px;
  color: #65778a;
  font-size: 12px;
  font-weight: 700;
}
.ledger-range-presets button {
  width: auto;
  min-width: 72px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #c8d3dc;
  background: #fff;
  color: #52687b;
  font-size: 12px;
  font-weight: 800;
}
.ledger-range-presets button.active {
  border-color: #173650;
  background: #173650;
  color: #fff;
}

@media (max-width: 760px) {
  .ledger-period-wrap {
    grid-column: 1;
    width: 100%;
  }
  .ledger-toolbar .ledger-period-wrap .ledger-period {
    grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  }
  .ledger-range-presets {
    display: grid;
    grid-template-columns: auto repeat(4, minmax(0,1fr));
    width: 100%;
  }
  .ledger-range-presets button {
    width: 100%;
    min-width: 0;
  }
}


/* Settlement query responsive layout v2 */
[data-settlement-panel="technician"] > .settlement-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "filters actions"
    "result result";
  align-items: end;
  gap: 12px 18px;
}

[data-settlement-panel="technician"] .settlement-query-period {
  grid-area: filters;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  width: 100%;
}

[data-settlement-panel="technician"] .settlement-query-period label {
  min-width: 0;
  width: 100%;
}

[data-settlement-panel="technician"] .settlement-query-period input,
[data-settlement-panel="technician"] .settlement-query-period select {
  width: 100%;
  min-width: 0;
}

[data-settlement-panel="technician"] .settlement-query-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(2, minmax(104px, 1fr));
  gap: 8px;
  width: 230px;
}

[data-settlement-panel="technician"] .settlement-query-actions #select-visible-settlements {
  grid-column: 1 / -1;
}

[data-settlement-panel="technician"] .settlement-query-result {
  grid-area: result;
  margin: 0;
  text-align: right;
}

[data-settlement-panel="company"] .ledger-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "period print"
    "party query"
    "result result";
  align-items: end;
  gap: 12px 20px;
}

[data-settlement-panel="company"] .ledger-toolbar-top {
  grid-area: print;
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 8px;
  margin: 0;
}

[data-settlement-panel="company"] .ledger-period-wrap {
  grid-area: period;
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 720px;
}

[data-settlement-panel="company"] .ledger-period {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 220px));
  gap: 10px;
  width: max-content;
  max-width: 100%;
}

[data-settlement-panel="company"] .ledger-period label {
  min-width: 0;
  width: 100%;
}

[data-settlement-panel="company"] .ledger-period input {
  width: 100%;
  min-width: 0;
}

[data-settlement-panel="company"] .ledger-range-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

[data-settlement-panel="company"] .ledger-party-filters {
  grid-area: party;
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(240px, 420px);
  gap: 10px;
  width: min(670px, 100%);
}

[data-settlement-panel="company"] .ledger-query-actions {
  grid-area: query;
  display: block;
  width: 150px;
}

[data-settlement-panel="company"] .ledger-query-actions #load-settlement-ledger {
  width: 100%;
  min-height: 44px;
}

[data-settlement-panel="company"] .ledger-result-message {
  grid-area: result;
  margin: 0;
  text-align: right;
}

@media (max-width: 1100px) and (min-width: 761px) {
  [data-settlement-panel="technician"] .settlement-query-period {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  [data-settlement-panel="company"] .ledger-party-filters {
    grid-template-columns: minmax(150px, .8fr) minmax(210px, 1.2fr);
  }
}

@media (max-width: 760px) {
  [data-settlement-panel="technician"] > .settlement-toolbar,
  [data-settlement-panel="company"] .ledger-toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "filters"
      "actions"
      "result";
    gap: 10px;
    padding: 12px;
  }

  [data-settlement-panel="technician"] .settlement-query-period {
    grid-area: filters;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  [data-settlement-panel="technician"] .settlement-query-period label:nth-child(3),
  [data-settlement-panel="technician"] .settlement-query-period label:nth-child(4) {
    grid-column: auto;
  }

  [data-settlement-panel="technician"] .settlement-query-actions {
    grid-area: actions;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  [data-settlement-panel="technician"] .settlement-query-actions #select-visible-settlements {
    grid-column: 1 / -1;
  }

  [data-settlement-panel="technician"] .settlement-query-result {
    grid-area: result;
    text-align: left;
  }

  [data-settlement-panel="company"] .ledger-toolbar {
    grid-template-areas:
      "print"
      "period"
      "party"
      "query"
      "result";
  }

  [data-settlement-panel="company"] .ledger-toolbar-top {
    grid-area: print;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  [data-settlement-panel="company"] .ledger-toolbar-top #print-settlement-ledger,
  [data-settlement-panel="company"] .ledger-toolbar-top #download-settlement-ledger-pdf {
    width: 100%;
    min-width: 0;
  }

  [data-settlement-panel="company"] .ledger-period-wrap {
    grid-area: period;
    width: 100%;
    max-width: none;
  }

  [data-settlement-panel="company"] .ledger-period {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  [data-settlement-panel="company"] .ledger-range-presets {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  [data-settlement-panel="company"] .ledger-range-presets > span {
    grid-column: 1 / -1;
    margin: 0;
  }

  [data-settlement-panel="company"] .ledger-range-presets button {
    width: 100%;
    min-width: 0;
    padding-left: 6px;
    padding-right: 6px;
  }

  [data-settlement-panel="company"] .ledger-party-filters {
    grid-area: party;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 8px;
  }

  [data-settlement-panel="company"] .ledger-query-actions {
    grid-area: query;
    width: 100%;
  }

  [data-settlement-panel="company"] .ledger-result-message {
    grid-area: result;
    text-align: left;
  }
}

@media (max-width: 480px) {
  [data-settlement-panel="technician"] .settlement-query-period,
  [data-settlement-panel="company"] .ledger-period,
  [data-settlement-panel="company"] .ledger-party-filters {
    grid-template-columns: 1fr;
  }

  [data-settlement-panel="company"] .ledger-range-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
