:root {
  --settlement-bg: #bebebe;
  --settlement-paper: #f9fbfd;
  --settlement-paper-strong: #ffffff;
  --settlement-line: rgba(89, 73, 55, 0.22);
  --settlement-ink: #161411;
  --settlement-muted: rgba(95, 86, 80, 0.74);
  --settlement-accent: #f18f01;
  --settlement-accent-deep: #cf7300;
  --settlement-soft: rgba(241, 143, 1, 0.13);
  --settlement-shadow: 0 16px 28px rgba(82, 60, 46, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Malgun Gothic", "IBM Plex Sans KR", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.22), transparent 24%),
    linear-gradient(180deg, #c2c2c2 0%, #b6b6b6 100%);
  color: var(--settlement-ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.24;
}

body.settlement-guard { visibility: hidden; }
body.settlement-guard.is-ready { visibility: visible; }

.settlement-page {
  --portal-frame-width: min(1760px, calc(100vw - 24px));
  width: min(1840px, calc(100% - 12px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.panel,
.summary-card {
  border: 1px solid var(--settlement-line);
  background: linear-gradient(180deg, var(--settlement-paper-strong), var(--settlement-paper));
  box-shadow: var(--settlement-shadow);
}

.panel {
  margin-top: 14px;
  padding: 16px;
  border-radius: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.wide-panel > .panel-head h2 {
  order: 1;
}

.settlement-verify-button {
  order: 2;
  display: none;
  margin-left: auto;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(180, 35, 24, 0.28);
  background: #fff;
  color: #b42318;
  font-size: 12px;
  font-weight: 900;
}

body.settlement-verify-mode .settlement-verify-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.verify-mismatch,
.verify-mismatch .sales-breakdown-button,
.verify-mismatch .sales-breakdown-value,
.verify-mismatch .sales-amount-button,
.verify-mismatch .sales-amount-value,
.verify-mismatch .profit-amount-button,
.verify-mismatch .profit-amount-value {
  color: #b42318 !important;
}

.collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.collapsible-panel details {
  width: 100%;
}

.collapsible-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 18px;
  color: var(--settlement-ink);
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.collapsible-panel summary::-webkit-details-marker {
  display: none;
}

.toggle-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--settlement-line);
  border-radius: 0;
  background: var(--settlement-paper-strong);
  color: var(--settlement-accent-deep);
  font-size: 0;
  font-weight: 900;
}

.toggle-mark::before {
  content: "+";
  font-size: 18px;
  line-height: 1;
}

.collapsible-panel details[open] .toggle-mark::before {
  content: "-";
}

.collapsible-body {
  padding: 0 18px 18px;
}

.settlement-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.settlement-tab {
  border: 1px solid var(--settlement-line);
  background: var(--settlement-paper-strong);
  color: var(--settlement-muted);
  min-height: 36px;
  padding: 0 16px;
  border-radius: 0;
  font-weight: 700;
  cursor: pointer;
}

.settlement-tab.is-active {
  border-color: var(--settlement-accent);
  background: var(--settlement-accent);
  color: #fff;
}

.settlement-tab-panel { display: none; }
.settlement-tab-panel.is-active { display: block; }

.settlement-controls,
.expense-row,
.foreign-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.settlement-export-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--settlement-line);
}

.settlement-export-controls input[type="month"] { width: 165px; }
.settlement-export-separator { align-self: flex-end; padding-bottom: 8px; color: var(--settlement-muted); }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--settlement-muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-field {
  flex-direction: row;
  align-items: center;
}

input,
select {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--settlement-line);
  border-radius: 0;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.99);
  color: var(--settlement-ink);
  font: inherit;
}

input[type="number"] {
  width: 96px;
}

#settlementPreviousCarry[readonly] {
  background: #f2f4f6;
  color: var(--settlement-muted);
  cursor: default;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  width: 18px;
  height: 34px;
}

button,
.primary-action,
.secondary-action {
  min-height: 36px;
  border-radius: 0;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-action {
  background: var(--settlement-accent);
  color: #fff;
}

.secondary-action {
  background: var(--settlement-paper-strong);
  border-color: var(--settlement-line);
  color: var(--settlement-ink);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.secondary-action.is-calculating,
.primary-action.is-calculating,
.expense-edit-button.is-calculating,
.expense-delete-button.is-calculating,
.exclude-button.is-calculating,
.excluded-pill button.is-calculating {
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: rgba(241, 143, 1, 0.35);
  background: rgba(255, 244, 230, 0.92);
  color: var(--settlement-accent-deep);
  cursor: progress;
  opacity: 1;
}

.expense-edit-button.is-saved {
  color: var(--settlement-accent-deep);
  border-color: var(--settlement-accent);
  background: var(--settlement-soft);
}

.settlement-loading-label {
  white-space: nowrap;
}

.usage-adjustment-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 24px; margin: 10px 0; font-size: 13px; }
.usage-adjustment-status:empty { display: none; }
.usage-adjustment-status[data-tone="success"] { color: #247341; }
.usage-adjustment-status[data-tone="error"] { color: #b33636; }
.card-fee-confirm-button { background: transparent; color: inherit; border: 0; border-bottom: 1px dotted currentColor; padding: 3px 0; font: inherit; cursor: pointer; }
.card-fee-confirm-dialog { width: min(430px, calc(100vw - 32px)); max-width: 100%; box-sizing: border-box; border: 1px solid #ddd; padding: 22px; background: white; color: #252525; }
.card-fee-confirm-dialog::backdrop { background: #0006; }
.card-fee-confirm-form { display: grid; gap: 14px; }
.card-fee-confirm-form h2, .card-fee-confirm-form p { margin: 0; }
.card-fee-confirm-form p { font-size: 13px; line-height: 1.6; }
.card-fee-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.card-fee-confirm-status { color: #a33636; font-size: 13px; }
@media (prefers-reduced-motion: reduce) {
  .usage-adjustment-panel .settlement-loading-bar,
  .usage-adjustment-panel .settlement-loading-dots span { animation: none; }
}

.settlement-loading-track {
  position: relative;
  width: 58px;
  height: 6px;
  overflow: hidden;
  border: 1px solid rgba(241, 143, 1, 0.28);
  background: rgba(255, 244, 230, 0.72);
}

.settlement-loading-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -44%;
  width: 44%;
  background: linear-gradient(90deg, rgba(241, 143, 1, 0), rgba(241, 143, 1, 0.88), rgba(241, 143, 1, 0));
  animation: settlement-loading-sweep 1.15s ease-in-out infinite;
}

.settlement-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.settlement-loading-dots span {
  width: 5px;
  height: 5px;
  background: var(--settlement-accent);
  opacity: 0.25;
  animation: settlement-loading-tick 1.05s ease-in-out infinite;
}

.settlement-loading-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.settlement-loading-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes settlement-loading-sweep {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(330%);
  }
}

@keyframes settlement-loading-tick {
  0%,
  100% {
    opacity: 0.25;
  }
  45% {
    opacity: 0.95;
  }
}

.query-month-display {
  min-width: 140px;
  font-size: 17px;
  font-weight: 800;
}

.settlement-status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--settlement-muted);
  font-weight: 700;
}

.settlement-status[data-tone="success"] { color: var(--settlement-accent-deep); }
.settlement-status[data-tone="error"] { color: #b42318; }

.monthly-db-refresh-warning {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(180, 35, 24, 0.28);
  background: rgba(255, 244, 242, 0.92);
  color: #b42318;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

.monthly-db-refresh-warning[hidden],
.monthly-db-refresh-warning:empty {
  display: none !important;
}

.settlement-confirm-button {
  border-color: rgba(47, 109, 75, 0.28);
  background: #2f6d4b;
}

.settlement-confirm-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid var(--settlement-line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--settlement-muted);
  font-size: 13px;
  font-weight: 900;
}

.settlement-confirm-status[data-tone="success"] {
  border-color: rgba(47, 109, 75, 0.28);
  background: rgba(247, 255, 249, 0.92);
  color: #2f6d4b;
}

.settlement-history-panel {
  margin-top: 12px;
}

.settlement-history {
  display: grid;
  gap: 8px;
}

.settlement-history-list {
  display: grid;
  gap: 7px;
}

.settlement-history-item {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(240px, 1fr) 160px;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(109, 96, 86, 0.14);
  background: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

.settlement-history-main {
  display: grid;
  gap: 3px;
}

.settlement-history-main strong {
  color: var(--settlement-ink);
  font-size: 13px;
}

.settlement-history-main span,
.settlement-history-item time {
  color: var(--settlement-muted);
  font-size: 12px;
  font-weight: 800;
}

.settlement-history-values {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 900;
}

.settlement-history-values span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.settlement-history-values b {
  color: var(--settlement-accent-deep);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.summary-card {
  min-height: 74px;
  padding: 13px;
  border-radius: 0;
}

.summary-card span {
  display: block;
  color: var(--settlement-muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.expense-note-field {
  flex: 1 1 320px;
}

.expense-note-field input {
  width: 100%;
}

.expense-groups {
  display: grid;
  gap: 14px;
}

.expense-box {
  padding: 12px;
  border: 1px solid rgba(109, 96, 86, 0.16);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.99);
}

.expense-box .expense-list {
  margin-top: 12px;
}

.expense-box h3 {
  margin: 0 0 10px;
  color: var(--settlement-muted);
  font-size: 14px;
}

.expense-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.expense-box-head h3 {
  margin: 0;
}

.expense-box-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.expense-money-input {
  width: 132px;
  text-align: right;
}

.expense-box:not(.salary-expense-box) .expense-row {
  width: 50%;
  min-width: 520px;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
}

.expense-box:not(.salary-expense-box) .expense-row .field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.expense-box:not(.salary-expense-box) .expense-row .field span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.expense-box:not(.salary-expense-box) .expense-note-field {
  flex: 0 1 320px;
}

.expense-box:not(.salary-expense-box) .expense-note-field input {
  width: 260px;
}

.expense-box:not(.salary-expense-box) .expense-money-input {
  width: 112px;
}

.expense-row button {
  align-self: center;
}

.salary-expense-row .field {
  flex: 0 0 auto;
}

.salary-expense-rows {
  display: grid;
  gap: 8px;
}

.salary-expense-draft-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.15fr) repeat(9, minmax(86px, 1fr)) auto;
  gap: 7px;
  align-items: end;
}

.expense-inline-editor {
  display: grid;
  grid-template-columns: 58px minmax(180px, 1fr) minmax(112px, 0.35fr) auto;
  gap: 7px;
  align-items: end;
  width: 100%;
}

.salary-inline-editor {
  grid-template-columns: 58px minmax(130px, 1.15fr) repeat(9, minmax(82px, 1fr)) auto;
}

.salary-expense-draft-row {
  padding: 11px 12px;
  border: 1px solid rgba(109, 96, 86, 0.12);
  background: rgba(249, 251, 253, 0.9);
}

.salary-expense-draft-row .expense-money-input,
.expense-inline-editor .expense-money-input {
  width: 100%;
  min-width: 0;
}

.salary-tone-1,
.salary-tone-2,
.salary-tone-3,
.salary-tone-4 {
  background: #ffffff;
}

.salary-expense-box .field,
.expense-item.is-salary .field,
.payroll-adjustment-panel .field {
  gap: 3px;
}

.salary-expense-box .field span,
.expense-item.is-salary .field span,
.payroll-adjustment-panel .field span {
  font-size: 11px;
  letter-spacing: 0;
}

.salary-expense-box .field,
.expense-item.is-salary .field {
  text-align: center;
}

.salary-expense-box .field > span,
.expense-item.is-salary .field > span {
  text-align: center;
}

.salary-expense-box .expense-money-input,
.expense-item.is-salary .expense-money-input {
  text-align: center;
}

.salary-expense-draft-row .salary-expense-card-field {
  grid-column: 10;
  grid-row: 1;
}

.salary-expense-draft-row .salary-expense-total {
  grid-column: 10;
  grid-row: 2;
}

.salary-expense-draft-row .salary-draft-remove-button {
  grid-column: 11;
  grid-row: 1 / 3;
}

.salary-inline-editor .salary-expense-card-field {
  grid-column: 11;
  grid-row: 1;
}

.salary-inline-editor .salary-expense-total {
  grid-column: 11;
  grid-row: 2;
}

.salary-inline-editor .expense-item-actions {
  grid-column: 12;
  grid-row: 1 / 3;
}

.salary-expense-total {
  display: block;
  margin-top: 3px;
  color: var(--settlement-text);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  align-self: start;
}

.salary-expense-box input,
.expense-item.is-salary input,
.expense-item.is-salary select,
.payroll-adjustment-panel input {
  border-width: 0 0 1px;
  border-color: rgba(82, 68, 58, 0.35);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.salary-expense-box input:focus,
.expense-item.is-salary input:focus,
.expense-item.is-salary select:focus,
.payroll-adjustment-panel input:focus {
  outline: none;
  border-color: var(--settlement-accent-deep);
  background: rgba(255, 255, 255, 0.5);
}

.salary-draft-remove-button {
  align-self: end;
  min-height: 36px;
}

.final-adjustment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.final-editor-box {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(109, 96, 86, 0.16);
  background: rgba(255, 255, 255, 0.99);
  overflow-x: auto;
}

.final-editor-box h3 {
  margin: 0;
  color: var(--settlement-muted);
  font-size: 14px;
}

.payroll-grid {
  display: grid;
  grid-template-columns: 72px repeat(8, minmax(82px, 1fr)) minmax(104px, 0.75fr);
  gap: 8px;
  align-items: end;
  min-width: 1060px;
}

.payroll-grid .field {
  align-items: stretch;
  text-align: center;
}

.payroll-grid .field > span {
  text-align: center;
}

.payroll-name {
  align-self: center;
  justify-self: stretch;
  text-align: center;
  color: var(--settlement-accent-deep);
  font-weight: 900;
}

.payroll-total {
  display: grid;
  align-content: end;
  justify-items: end;
  min-height: 58px;
  padding: 7px 6px;
  color: var(--settlement-muted);
  font-weight: 700;
  text-align: right;
}

.payroll-total span {
  font-size: 11px;
  font-weight: 900;
}

.payroll-total strong {
  color: var(--settlement-accent-deep);
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.transfer-input-row,
.other-profit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.collection-profit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(44, 99, 116, 0.16);
  border-radius: 8px;
  background: #ffffff;
}

.collection-profit-row div {
  display: grid;
  gap: 3px;
}

.collection-profit-row span {
  color: var(--settlement-muted);
  font-size: 12px;
  font-weight: 800;
}

.collection-profit-row strong {
  color: var(--settlement-accent-deep);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.collection-profit-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.collection-profit-breakdown div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(109, 96, 86, 0.14);
  border-radius: 8px;
  background: #ffffff;
}

.collection-profit-breakdown span {
  color: var(--settlement-muted);
  font-size: 12px;
  font-weight: 800;
}

.collection-profit-breakdown strong {
  color: var(--settlement-text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.collection-profit-breakdown .is-total {
  border-color: rgba(44, 99, 116, 0.22);
  background: #ffffff;
}

.collection-profit-breakdown .is-total strong {
  color: var(--settlement-accent-deep);
  font-weight: 900;
}

.other-profit-label {
  flex: 1 1 220px;
}

.settlement-money-input {
  width: 132px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.payroll-grid .settlement-money-input {
  width: 100%;
  min-width: 0;
  text-align: center;
}

.payroll-grid > label,
.payroll-grid > .payroll-name {
  min-height: 58px;
  padding: 7px 6px;
}

.payroll-grid > .payroll-name {
  display: flex;
  align-items: center;
  justify-content: center;
}

.settlement-adjustment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(109, 96, 86, 0.14);
}

.settlement-adjustment-row .field {
  min-width: 180px;
}

.settlement-adjustment-row .settlement-money-input {
  width: 180px;
  text-align: right;
}

.settlement-adjustment-row button {
  min-height: 38px;
}

.usage-adjustment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.usage-adjustment-row .usage-adjustment-label {
  flex: 1 1 320px;
}

.usage-adjustment-row .settlement-money-input {
  width: 180px;
}

.usage-adjustment-row button {
  min-height: 38px;
}

.usage-adjustment-list {
  margin-top: 10px;
}

.usage-adjustment-list .expense-item {
  width: min(100%, 720px);
}

.final-summary-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.final-summary-column {
  min-width: 0;
}

.final-summary-column h3 {
  margin: 0 0 10px;
  color: var(--settlement-ink);
  font-size: 16px;
}

.previous-comparison-status {
  margin: 0 0 10px;
  color: var(--settlement-muted);
  font-size: 13px;
}

.final-summary-table {
  display: grid;
  grid-template-columns: minmax(180px, 0.65fr) minmax(180px, 0.35fr);
  gap: 0;
  width: 100%;
  border: 1px solid rgba(109, 96, 86, 0.16);
  background: rgba(255, 255, 255, 0.99);
}

.final-summary-table div {
  display: contents;
}

.final-summary-table span,
.final-summary-table strong {
  min-height: 36px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(24, 34, 48, 0.08);
}

.final-summary-table span {
  color: var(--settlement-muted);
  font-weight: 800;
}

.final-summary-table strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.final-summary-table .is-result span,
.final-summary-table .is-result strong,
.final-summary-table .is-total span,
.final-summary-table .is-total strong {
  border-top: 2px solid var(--settlement-accent);
  color: var(--settlement-ink);
  font-weight: 900;
}

.final-summary-table .is-total span,
.final-summary-table .is-total strong {
  background: #ffffff;
  border-bottom: 0;
}

.kim-allowance-grid {
  display: grid;
  grid-template-columns: 140px minmax(180px, 1fr) minmax(180px, 1fr);
  gap: 10px;
  align-items: end;
}

.kim-allowance-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--settlement-border);
  background: #fffaf2;
}

.kim-allowance-result span {
  color: var(--settlement-muted);
  font-size: 12px;
  font-weight: 800;
}

.kim-allowance-result strong {
  color: #111827;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.kim-allowance-result.is-total {
  border-color: rgba(241, 143, 1, 0.36);
  background: rgba(255, 244, 230, 0.92);
}

.kim-allowance-result.is-total strong {
  color: var(--settlement-accent-deep);
}

.kim-allowance-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.kim-allowance-targets span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid rgba(241, 143, 1, 0.18);
  background: #ffffff;
  color: #374151;
  font-size: 11px;
  font-weight: 800;
}

.kim-allowance-targets span.is-missing {
  border-color: #e5e7eb;
  color: #9ca3af;
}

.kim-allowance-targets strong {
  color: #111827;
  font-variant-numeric: tabular-nums;
}

.expense-list {
  display: grid;
  gap: 7px;
}

.staff-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.staff-summary-item {
  appearance: none;
  display: inline-grid;
  grid-template-columns: auto auto auto auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--settlement-line);
  border-radius: 0;
  background: var(--settlement-paper-strong);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.staff-summary-item.is-static {
  cursor: default;
}

.staff-summary-item:hover {
  border-color: var(--settlement-accent);
}

.staff-summary-item.is-static:hover {
  border-color: var(--settlement-line);
}

.staff-summary-item strong {
  color: var(--settlement-accent-deep);
  font-size: 13px;
}

.staff-summary-item span,
.staff-summary-item small {
  color: var(--settlement-muted);
  font-size: 12px;
  font-weight: 800;
}

.staff-summary-item em {
  color: var(--settlement-ink);
  font-style: normal;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--settlement-line);
  border-radius: 0;
  background: var(--settlement-paper-strong);
}

.expense-item.is-editable {
  display: block;
}

.expense-list .expense-item {
  background: #ffffff;
}

.expense-list .expense-item.is-general {
  justify-self: start;
  width: min(100%, 720px);
}

.expense-item.is-salary {
  border-color: rgba(109, 96, 86, 0.14);
}

.expense-item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
}

.expense-link-panel {
  display: grid;
  gap: 6px;
  width: 100%;
  margin-top: 2px;
  font-size: 12px;
}

.expense-inline-editor .expense-link-panel {
  grid-column: 2 / -1;
}

.expense-link-summary,
.expense-link-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.expense-link-fields.is-hidden {
  display: none;
}

.expense-inline-editor .expense-type-chip {
  align-self: end;
  justify-content: center;
  min-height: 36px;
}

.expense-inline-editor .expense-item-actions {
  align-self: end;
  min-height: 36px;
}

.expense-inline-editor .field {
  min-width: 0;
}

.expense-inline-editor input {
  width: 100%;
  min-width: 0;
}

.expense-link-current {
  color: var(--settlement-accent-deep);
  font-weight: 900;
}

.expense-link-panel select {
  width: 220px;
  height: 28px;
  font-size: 12px;
}

.expense-link-button,
.expense-link-toggle,
.expense-unlink-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.expense-link-toggle {
  border-color: rgba(24, 121, 78, 0.22);
  background: rgba(255, 255, 255, 0.72);
  color: var(--settlement-green);
}

.expense-link-button {
  border-color: rgba(24, 121, 78, 0.25);
  background: #ffffff;
  color: var(--settlement-green);
}

.expense-unlink-button {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff5f4;
  color: #b42318;
}

.expense-link-helper {
  color: var(--settlement-muted);
  font-weight: 800;
}

.expense-type-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 0;
  background: var(--settlement-soft);
  color: #ba5d00;
  font-size: 12px;
}

.expense-item-detail {
  color: var(--settlement-muted);
  font-weight: 700;
}

.expense-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.expense-edit-button,
.expense-delete-button {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.expense-edit-button {
  border-color: rgba(24, 121, 78, 0.25);
  background: #ffffff;
  color: var(--settlement-green);
}

.expense-delete-button {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff5f4;
  color: #b42318;
}

body.settlement-query-mode .bottom-action-row,
body.settlement-query-mode .expense-box-actions,
body.settlement-query-mode .salary-expense-rows,
body.settlement-query-mode .expense-box:not(.salary-expense-box) > .expense-row,
body.settlement-query-mode .other-profit-row,
body.settlement-query-mode .usage-adjustment-row,
body.settlement-query-mode .expense-item-actions,
body.settlement-query-mode .expense-link-panel select,
body.settlement-query-mode .expense-link-button,
body.settlement-query-mode .expense-unlink-button,
body.settlement-query-mode .expense-delete-button,
body.settlement-query-mode .expense-edit-button,
body.settlement-query-mode .exclude-button,
body.settlement-query-mode [data-restore-row],
body.settlement-query-mode [data-delete-foreign],
body.settlement-query-mode [data-delete-staff],
body.settlement-query-mode #settlementFinalAdjustmentSaveButton,
body.settlement-query-mode #settlementCollectionProfitRecalcButton,
body.settlement-query-mode #settlementSpecialProductProfitRecalcButton,
body.settlement-query-mode .foreign-editor,
body.settlement-query-mode .misc-settings-panel {
  display: none !important;
}

body.settlement-query-mode .expense-panel .panel-head h2::after,
body.settlement-query-mode .final-adjustment-panel .panel-head h2::after {
  content: "조회";
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 8px;
  padding: 0 8px;
  border: 1px solid rgba(241, 143, 1, 0.24);
  background: #ffffff;
  color: var(--settlement-accent-deep);
  font-size: 12px;
  font-weight: 900;
}

body.settlement-query-mode input:disabled,
body.settlement-query-mode select:disabled {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--settlement-ink);
  opacity: 1;
  cursor: default;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  pointer-events: none;
}

body.settlement-query-mode input:disabled {
  padding-inline: 0;
}

body.settlement-query-mode .field {
  color: rgba(95, 86, 80, 0.62);
}

body.settlement-query-mode .expense-panel,
body.settlement-query-mode .final-adjustment-panel,
body.settlement-query-mode .final-summary-panel,
body.settlement-query-mode .staff-summary-panel {
  background: linear-gradient(180deg, #ffffff, #fbfcfd);
}

body.settlement-query-mode .expense-list {
  gap: 8px;
}

body.settlement-query-mode .expense-item {
  min-height: 34px;
  border-color: rgba(109, 96, 86, 0.14);
  background: rgba(255, 255, 255, 0.74);
}

body.settlement-query-mode .expense-list .expense-item {
  background: rgba(255, 255, 255, 0.74);
}

body.settlement-query-mode .staff-no-cost {
  display: none;
}

body.settlement-query-mode .expense-link-panel {
  width: auto;
  margin-top: 0;
}

body.settlement-query-mode .expense-link-current {
  color: var(--settlement-muted);
}

body.settlement-query-mode .sales-breakdown-button,
body.settlement-query-mode .sales-amount-button,
body.settlement-query-mode .profit-amount-button {
  cursor: default;
  pointer-events: none;
}

body.settlement-query-mode .sales-breakdown-button:hover,
body.settlement-query-mode .sales-amount-button:hover,
body.settlement-query-mode .profit-amount-button:hover {
  text-decoration: none;
}

.table-wrap {
  max-height: calc(100vh - 110px);
  overflow: auto;
  border: 1px solid var(--settlement-line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.99);
}

#settlementTable {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 13px;
}

#settlementTable th,
#settlementTable td {
  padding: 8px 7px;
  border-bottom: 1px solid rgba(24, 34, 48, 0.08);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

#settlementTable thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  color: var(--settlement-muted);
  font-size: 12px;
  text-align: center;
  box-shadow: 0 1px 0 rgba(24, 34, 48, 0.12);
}

#settlementTable thead th:last-child,
#settlementTable td:has(.exclude-button) {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -1px 0 0 rgba(24, 34, 48, 0.12);
}

#settlementTable td:has(.exclude-button) {
  z-index: 2;
}

.amount-cell {
  font-size: 12px;
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.name-cell {
  max-width: 132px;
  min-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 800;
}

.jeong-period-allocation-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.jeong-period-allocation-button:hover {
  text-decoration: none;
}

.company-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 0;
  background: var(--settlement-soft);
  color: #ba5d00;
  font-size: 11px;
  font-weight: 800;
}

.company-chip.taeyang {
  background: #e9f5ff;
  color: #0369a1;
}

.allocation-cell,
.staff-cell {
  vertical-align: middle;
}

.settlement-row-saving {
  opacity: 0.82;
}

.settlement-row-saving .staff-cell {
  position: relative;
}

.row-saving-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 2px 5px;
  border: 1px solid rgba(241, 143, 1, 0.24);
  background: rgba(255, 244, 230, 0.92);
  color: var(--settlement-accent-deep);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.row-saving-indicator .settlement-loading-track {
  width: 34px;
  height: 5px;
}

.row-saving-indicator .settlement-loading-dots span {
  width: 4px;
  height: 4px;
}

.staff-split-row {
  display: grid;
  grid-template-columns: 70px 92px 60px 72px;
  align-items: center;
  gap: 4px;
}

.staff-split-row + .staff-split-row {
  margin-top: 4px;
}

.allocation-cell {
  width: 164px;
  max-width: 164px;
}

.allocation-grid {
  display: grid;
  grid-template-columns: repeat(3, 29px) 64px;
  align-items: center;
  gap: 2px;
}

.allocation-mini {
  display: grid;
  grid-template-rows: 13px 24px;
  gap: 2px;
  color: var(--settlement-muted);
  font-size: 9px;
  font-weight: 800;
  text-align: center;
}

.allocation-mini input,
.staff-cell input,
.staff-cell select,
.collect-amount-input,
.card-usage-input {
  height: 24px;
  border-radius: 0;
  padding: 0 5px;
  font-size: 10px;
}

.collect-amount-input {
  width: 92px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.estimated-card-fee {
  color: #9ca3af;
  font-weight: 500;
}

.allocation-mini input {
  width: 29px;
  padding: 0 1px;
  font-size: 10px;
  text-align: center;
}

.allocation-mini input::-webkit-inner-spin-button,
.allocation-mini input::-webkit-outer-spin-button,
.card-usage-input::-webkit-inner-spin-button,
.card-usage-input::-webkit-outer-spin-button,
.staff-percent-input::-webkit-inner-spin-button,
.staff-percent-input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.allocation-mini input,
.card-usage-input,
.staff-percent-input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.allocation-result {
  display: inline-block;
  min-width: 64px;
  min-height: 24px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  text-align: right;
  font-size: 12px;
  font-weight: 800;
  color: var(--settlement-accent-deep);
  cursor: pointer;
  font-family: inherit;
}

.sales-breakdown-button,
.sales-breakdown-value,
.sales-amount-button,
.sales-amount-value,
.profit-amount-button,
.profit-amount-value {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.sales-breakdown-button,
.sales-amount-button,
.profit-amount-button {
  cursor: pointer;
}

.sales-breakdown-button:hover,
.sales-amount-button:hover,
.profit-amount-button:hover,
.allocation-result:hover {
  text-decoration: underline;
}

.allocation-result.is-overridden,
.sales-amount-button.is-overridden,
.sales-amount-value.is-overridden,
.profit-amount-button.is-overridden,
.profit-amount-value.is-overridden {
  color: #b45309;
}

.card-usage-input {
  width: 88px;
  text-align: right;
}

.card-usage-stack {
  display: grid;
  gap: 3px;
}

.linked-expense-badge {
  display: inline-flex;
  justify-content: flex-end;
  color: var(--settlement-accent-deep);
  font-size: 10px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.staff-cell select {
  width: 70px;
}

.staff-cell .staff-type-select {
  width: 92px;
  padding: 0 3px;
  border: 1px solid #f18f01;
  background: #fff4e6;
  color: #9a4d00;
  font-size: 10px;
  font-weight: 900;
}

.staff-percent-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-self: start;
}

.staff-cell .staff-percent-input {
  width: 38px;
  padding: 0 2px;
  text-align: center;
  justify-self: start;
}

.staff-no-cost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 24px;
  cursor: pointer;
}

.staff-no-cost input {
  width: 13px;
  height: 13px;
  margin: 0;
  padding: 0;
}

.staff-result {
  min-width: 72px;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--settlement-accent-deep);
  font-size: 10px;
  font-weight: 800;
  text-align: right;
  justify-self: end;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  cursor: pointer;
}

.staff-result.is-secondary {
  color: var(--settlement-accent-deep);
}

.settlement-amount {
  color: var(--settlement-accent-deep);
  font-size: 12px;
  font-weight: 900;
}

.settlement-amount-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  text-align: right;
  cursor: pointer;
}

.formula-trigger:hover {
  text-decoration: underline;
}

.note-input {
  width: 130px;
  padding: 0 5px;
  font-size: 10px;
}

.exclude-button {
  min-height: 28px;
  padding: 0 9px;
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff5f4;
  color: #b42318;
  font-size: 11px;
}

.excluded-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-inline {
  color: var(--settlement-muted);
  font-weight: 700;
}

.excluded-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--settlement-line);
  border-radius: 0;
  background: var(--settlement-paper-strong);
  font-size: 13px;
}

.excluded-pill strong {
  color: var(--settlement-accent-deep);
}

.excluded-pill button {
  min-height: 23px;
  padding: 0 8px;
  border-radius: 0;
  background: var(--settlement-soft);
  color: var(--settlement-accent-deep);
  font-size: 12px;
}

.empty-row {
  height: 72px;
  text-align: center !important;
  color: var(--settlement-muted);
}

.settlement-total-row td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: #ffffff;
  color: var(--settlement-ink);
  font-weight: 900;
  border-top: 2px solid var(--settlement-accent);
  border-bottom: 0;
}

.foreign-editor input {
  width: min(420px, 100%);
}

.foreign-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.bottom-action-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.foreign-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--settlement-line);
  border-radius: 0;
  background: var(--settlement-paper-strong);
  font-size: 13px;
  font-weight: 700;
}

.foreign-pill em {
  color: var(--settlement-muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.foreign-pill button {
  min-height: 22px;
  padding: 0 7px;
  border-radius: 0;
  background: #f5f1ec;
  color: var(--settlement-muted);
  font-size: 12px;
}

@media (max-width: 1000px) {
  .final-summary-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .settlement-page {
    width: min(100% - 16px, 1280px);
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .final-adjustment-grid,
  .expense-inline-editor,
  .collection-profit-breakdown,
  .final-summary-table,
  .kim-allowance-grid {
    grid-template-columns: 1fr;
  }

  .payroll-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: 0;
  }

  .payroll-grid > .payroll-name,
  .payroll-total {
    grid-column: 1 / -1;
  }

  .payroll-total {
    justify-items: center;
    text-align: center;
  }

  .salary-expense-draft-row,
  .salary-inline-editor {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .salary-expense-draft-row .salary-expense-card-field,
  .salary-inline-editor .salary-expense-card-field {
    grid-column: auto;
    grid-row: auto;
  }

  .salary-expense-draft-row .salary-expense-total,
  .salary-inline-editor .salary-expense-total {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-self: end;
    width: auto;
    margin-top: 0;
  }

  .salary-expense-draft-row .salary-draft-remove-button,
  .salary-inline-editor .expense-item-actions {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .salary-expense-name-field,
  .salary-draft-remove-button,
  .salary-inline-editor .expense-type-chip,
  .salary-inline-editor .expense-inline-label,
  .salary-inline-editor .expense-item-actions,
  .salary-inline-editor .expense-link-panel {
    grid-column: 1 / -1;
  }

  .expense-box:not(.salary-expense-box) .expense-row {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
  }

  .expense-box:not(.salary-expense-box) .expense-note-field input {
    width: min(260px, 100%);
  }

  .expense-list .expense-item.is-general {
    width: 100%;
  }

  .final-summary-table div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .final-summary-table span,
  .final-summary-table strong {
    min-height: 34px;
  }

  .settlement-controls {
    align-items: stretch;
  }

  .settlement-history-item {
    grid-template-columns: 1fr;
  }
}

/* Only the month controls are shown until the user explicitly queries. */
.settlement-awaiting-query .settlement-page > section:not(.control-panel) {
  display: none !important;
}
.settlement-month-confirmation {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(95, 86, 80, .25);
  border-radius: 8px;
  background: #f5f3f0;
  color: var(--settlement-muted);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.settlement-month-confirmation[data-tone="confirmed"] {
  border-color: var(--settlement-accent);
  background: var(--settlement-soft);
  color: var(--settlement-accent-deep);
}

.settlement-history-confirmation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-left: 3px solid var(--settlement-accent);
  background: var(--settlement-soft);
  color: var(--settlement-accent-deep);
  font-size: 15px;
}
.settlement-history-confirmation time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
