* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: #f4f6f9;
  color: #1f2937;
}
a { color: #2563eb; text-decoration: none; }
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  background: #111827;
  color: #fff;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a { color: #e5e7eb; }
.userbox { display: flex; gap: 0.8rem; align-items: center; font-size: 0.9rem; }
.userbox a { color: #93c5fd; }
.work-tabs-wrap {
  background: #e5e7eb;
  border-bottom: 1px solid #cbd5e1;
  padding: 0.35rem 0.6rem 0;
}
.work-tabs-bar {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.work-tab {
  display: flex;
  align-items: center;
  max-width: 220px;
  background: #d1d5db;
  border: 1px solid #9ca3af;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
}
.work-tab.is-active {
  background: #f3f4f6;
  border-color: #94a3b8;
  position: relative;
  z-index: 1;
}
.work-tab-link {
  display: block;
  padding: 0.42rem 0.35rem 0.42rem 0.75rem;
  color: #1f2937;
  text-decoration: none;
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.work-tab.is-active .work-tab-link { font-weight: 600; }
.work-tab-close {
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.2rem 0.45rem 0.35rem 0.15rem;
  cursor: pointer;
  border-radius: 4px;
}
.work-tab-close:hover { background: rgba(0,0,0,.08); color: #111827; }
.amount-recovered { text-decoration: line-through; color: #9ca3af; font-weight: 500; }
.amount-remaining { margin-left: 0.25rem; }
.container { max-width: 1200px; margin: 1.2rem auto; padding: 0 1rem; }
h1 { margin-top: 0; }
.page-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.25rem;
  margin-bottom: 1rem;
}
.page-title-row h1 {
  margin: 0;
}
.clawback-deposit-account {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.clawback-deposit-account:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.clawback-deposit-label {
  color: #1d4ed8;
  font-weight: 700;
}
.clawback-deposit-text {
  font-weight: 600;
}
.clawback-deposit-copy-icon {
  font-size: 0.78rem;
  line-height: 1;
  opacity: 0.85;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card { background: #fff; border-radius: 10px; padding: 1rem 1.2rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card-label { color: #6b7280; font-size: 0.9rem; }
.card-value { font-size: 2rem; font-weight: 700; margin-top: 0.3rem; }
.panel { background: #fff; border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { border-bottom: 1px solid #e5e7eb; padding: 0.55rem 0.4rem; text-align: left; }
th { background: #f9fafb; }
.muted { color: #6b7280; }
.warn { color: #dc2626; font-weight: 600; }
.ok { color: #059669; font-weight: 600; }
.total td { font-weight: 700; background: #f9fafb; }
.btn, button {
  display: inline-block;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
}
.btn.primary, button.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.danger, button.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.danger-zone { border: 1px solid #fecaca; background: #fffafa; }
.danger-zone h2 { color: #991b1b; font-size: 1rem; margin-top: 0; }
.table-scroll { overflow-x: auto; margin-top: 0.5rem; }
.actions-cell { white-space: nowrap; }
.actions-cell a { margin-right: 0.6rem; }
.inline-delete { display: inline; margin: 0; }
.link-btn { background: none; border: none; padding: 0; cursor: pointer; font: inherit; }
.link-btn.danger-text { color: #dc2626; }
.link-btn.danger-text:hover { text-decoration: underline; }
.pagination { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 1rem; }
.page-current {
  display: inline-block;
  padding: 0.45rem 0.7rem;
  background: #2563eb;
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
}
.page-num { min-width: 2.2rem; text-align: center; }
.actions { display: flex; gap: 0.6rem; margin: 0.8rem 0 1rem; flex-wrap: wrap; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  align-items: end;
}
.grid-form.wide label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; grid-column: 1 / -1; }
.check-col { width: 2.8rem; min-width: 2.8rem; text-align: center; vertical-align: middle; }
.check-col input[type="checkbox"] { width: 1.1rem; height: 1.1rem; cursor: pointer; accent-color: #2563eb; }
.list-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}
.list-header-row h2 { margin: 0; }
.list-header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}
.list-date-search { align-items: flex-end; margin-bottom: 0; }
.list-date-search label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; }
.contract-add-btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 600;
  border-radius: 8px;
}
.contract-create-panel { width: min(720px, 96vw); }
.form-actions-span {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
}
.checkbox-label input[type="checkbox"] { width: auto; }
.contract-list-search {
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e5e7eb;
}
.contract-list-search .search-type-label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; }
.contract-list-search input[type="text"] { min-width: 12rem; }
.contract-premium-total {
  font-size: 0.9rem;
  color: #374151;
  align-self: center;
  white-space: nowrap;
}
.contract-premium-total strong { color: #111827; }
.gcode-viewer-table { margin-top: 1rem; }
.gcode-viewer-table input[type="text"] {
  width: 100%;
  min-width: 7rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-sizing: border-box;
}
.filter-label { font-size: 0.85rem; color: #374151; align-self: center; }
.settlement-filter-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.gcode-search-wrap { position: relative; }
.gcode-search { position: relative; }
.gcode-search-input { width: 100%; padding: 0.45rem 0.55rem; border: 1px solid #d1d5db; border-radius: 8px; }
.gcode-search-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.gcode-search-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: #fff;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  font: inherit;
}
.gcode-search-item:hover { background: #eff6ff; }
.month-nav { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.month-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.month-divider td { background: #f3f4f6; font-size: 0.95rem; padding-top: 0.75rem; }
.bulk-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.bulk-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0; }
.bulk-actions .hint { margin: 0; font-size: 0.85rem; }
.settlement-filter-form { margin-bottom: 0; margin-left: auto; }
.balance-link { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.balance-link:hover { color: #2563eb; }
.clawback-detail-btn.warn { color: #dc2626; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.clawback-detail-btn.warn:hover { color: #991b1b; }
.commission-detail-btn { color: #2563eb; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.commission-detail-btn:hover { color: #1d4ed8; }
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.modal-panel {
  position: relative;
  width: min(920px, 96vw);
  max-height: 85vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  padding: 1rem 1.1rem 1.1rem;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.4rem; }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-close {
  border: none;
  background: #f3f4f6;
  color: #374151;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: #e5e7eb; }
.modal-table-wrap { overflow-x: auto; margin-top: 0.6rem; }
.modal-table-wrap table { font-size: 0.88rem; }
.clawback-modal-entry { margin: 0.35rem 0 0.5rem; overflow: hidden; max-width: 100%; }
.clawback-entry-form {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  max-width: 100%;
}
.clawback-entry-table-wrap {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  overflow: hidden;
}
.clawback-entry-table-wrap table {
  table-layout: fixed;
}
.clawback-entry-table-wrap th:nth-child(1),
.clawback-entry-table-wrap td:nth-child(1) { width: 10%; }
.clawback-entry-table-wrap th:nth-child(2),
.clawback-entry-table-wrap td:nth-child(2) { width: 8%; }
.clawback-entry-table-wrap th:nth-child(3),
.clawback-entry-table-wrap td:nth-child(3) { width: 9%; }
.clawback-entry-table-wrap th:nth-child(4),
.clawback-entry-table-wrap td:nth-child(4) { width: 10%; }
.clawback-entry-table-wrap th:nth-child(5),
.clawback-entry-table-wrap td:nth-child(5) { width: 8%; }
.clawback-entry-table-wrap th:nth-child(6),
.clawback-entry-table-wrap td:nth-child(6) { width: auto; }
.clawback-entry-table-wrap input,
.clawback-entry-table-wrap select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: inherit;
  color: inherit;
  box-sizing: border-box;
}
.clawback-entry-table-wrap input:focus,
.clawback-entry-table-wrap select:focus {
  outline: none;
  box-shadow: inset 0 -1px 0 #2563eb;
}
.clawback-entry-table-wrap input[type="date"] {
  font-size: inherit;
}
.clawback-entry-submit {
  flex: 0 0 auto;
  white-space: nowrap;
  margin-bottom: 0.55rem;
}
.clawback-entry-hint { margin: 0.35rem 0 0; }
.clawback-detail-btn:not(.warn) { color: #6b7280; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.clawback-detail-btn:not(.warn):hover { color: #374151; }
#clawback-modal .modal-panel { width: min(920px, 96vw); overflow-x: hidden; overflow-y: auto; }
#clawback-modal .modal-table-wrap { overflow-x: auto; max-width: 100%; }
.summary-table { width: auto; min-width: 280px; }
.summary-table th { text-align: left; padding-right: 1.5rem; font-weight: 500; color: #64748b; }
.summary-table td { font-weight: 600; }
.grid-form input, .grid-form select, .inline-form input, .inline-form select {
  padding: 0.45rem 0.55rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}
.inline-form { display: flex; gap: 0.6rem; align-items: end; margin-bottom: 1rem; flex-wrap: wrap; }
.alert { background: #fee2e2; color: #991b1b; padding: 0.7rem 0.9rem; border-radius: 8px; margin-bottom: 1rem; }
.alert.ok { background: #dcfce7; color: #166534; }
.import-duplicate-banner { margin-top: -0.5rem; }
.import-duplicate-link {
  color: #14532d;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.import-duplicate-link:hover { color: #052e16; }
.import-duplicate-hint { color: #166534; }
.duplicate-skip-details {
  background: #ecfdf5;
  color: #166534;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  margin: -0.5rem 0 1rem;
  border: 1px solid #bbf7d0;
  font-size: 0.9rem;
}
.duplicate-skip-details ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.duplicate-skip-details li { margin: 0.2rem 0; }
.hint { color: #6b7280; font-size: 0.88rem; }
.warn-text { color: #dc2626; font-size: 0.92rem; margin-top: 0.5rem; }
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(380px, 92vw);
  background: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.login-card h1 { margin: 0 0 0.2rem; font-size: 1.4rem; }
.login-card form { display: grid; gap: 0.6rem; margin-top: 1rem; }
.login-card input { padding: 0.55rem; border: 1px solid #d1d5db; border-radius: 8px; }
.login-card button { margin-top: 0.4rem; background: #2563eb; color: #fff; border: none; padding: 0.6rem; border-radius: 8px; }
.deposit-correction-panel {
  margin-top: 1rem;
  border: 2px solid #bfdbfe;
  background: #f8fbff;
}
.deposit-correction-panel h2 { margin-top: 0; }
.settlement-gcode-search-panel { padding: 0.85rem 1.2rem; }
.settlement-gcode-search label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.settlement-gcode-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.settlement-gcode-search-row input[type="search"] {
  flex: 1 1 14rem;
  min-width: 12rem;
  max-width: 24rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}
.settlement-gcode-search-row .btn { white-space: nowrap; }
.settlement-gcode-search-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
}
.settlement-gcode-search-footer .hint {
  margin: 0;
  flex: 1 1 auto;
}
#settlement-missing-contract-open {
  flex-shrink: 0;
  font-size: 1.35rem;
  line-height: 1;
  min-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0.35rem 0.55rem;
}
tr.settlement-line-row.settlement-line-search-hit > td {
  background-color: #bfdbfe !important;
  box-shadow: inset 4px 0 0 #2563eb;
}
tr.settlement-line-row.settlement-line-search-hit > td.ok {
  color: #1d4ed8 !important;
}
tr.settlement-line-row.settlement-line-search-hit > td.warn {
  color: #b45309 !important;
}
tr.settlement-line-row.settlement-line-search-hit .link-btn {
  background-color: transparent;
}
.correction-voided td { text-decoration: line-through; color: #9ca3af; }
.correction-voided td.correction-actions { text-decoration: none; }
.correction-voided td.correction-gcode-cell { text-decoration: none; color: #6b7280; }
.correction-voided .ok { color: #9ca3af !important; }
.correction-replacement td { background: #eff6ff; color: #1e40af; }
.correction-replacement .ok { color: #15803d !important; }
.correction-gcode-col { min-width: 7.5rem; white-space: nowrap; }
.correction-gcode-cell { white-space: nowrap; }
.deposit-correction-notices {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.5rem 0 0.85rem;
}
.deposit-correction-notice {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
}
.deposit-correction-notice .correction-gcode-label { color: #b45309; }
.correction-gcode-label { color: #1d4ed8; font-weight: 700; }
.settlement-correction-outbound td {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.88rem;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  border-top: 1px dashed #fcd34d;
}
.settlement-correction-outbound .correction-gcode-label { color: #b45309; }
.correction-outbound-badge {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #fde68a;
  color: #92400e;
  font-size: 0.75rem;
  font-weight: 700;
}
.correction-voided td.actions-cell,
.correction-voided td.check-col,
.correction-voided .correction-badge { text-decoration: none; }
.contract-list .correction-replacement td { background: #eff6ff; color: #1e40af; }
.contract-list .correction-replacement .ok { color: #15803d !important; }
.correction-badge-in { background: #dbeafe; color: #1e40af; }
.correction-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.25rem;
}
.commission-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.commission-modal-toolbar .hint { margin: 0; }
.correction-actions { white-space: nowrap; }
.btn-icon {
  min-width: 2rem;
  padding: 0.2rem 0.55rem;
  font-size: 1.1rem;
  line-height: 1.2;
}
.action-col { width: 5rem; text-align: center; }
