/* 기본 리셋 */
body {
  margin: 0;
  font-family: "NanumSquareRound", Arial, sans-serif;
  background-color: #f5f6f8;
}

/* 메인 영역 (사이드바 밀기 핵심) */
.main-container {
  margin-left: 255px; /* 사이드바 width + 여백 */
  padding: 30px;
}

/* 상단 제어 패널 */
.control-panel {
  background: #ffffff;
  border: 1px solid #d7dde5;
  border-radius: 10px;
  margin-bottom: 22px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  overflow: hidden;
}

.control-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  border-bottom: 1px solid #e5e7eb;
}

.control-row:last-child {
  border-bottom: none;
}

.control-label {
  display: flex;
  align-items: center;
  padding: 16px 14px;
  background-color: #f8fafc;
  border-right: 1px solid #e5e7eb;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.control-content {
  padding: 10px 14px;
  background-color: #fff;
}

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

.control-inline-grid {
  display: grid;
  grid-template-columns: 180px max-content max-content;
  gap: 10px;
  align-items: end;
}

.control-inline-grid #quickKeyword {
  width: 420px;
  max-width: 420px;
}

.inline-button-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
}

.control-row:not(.detail-condition-row) .field-block {
  max-width: 260px;
}

.detail-condition-primary-row .control-grid {
  grid-template-columns: repeat(2, max-content);
  gap: 12px;
}

.detail-condition-primary-row .field-block {
  max-width: 220px;
}

.detail-condition-row .field-block {
  max-width: 220px;
}

.detail-condition-row .control-grid {
  grid-template-columns: repeat(4, max-content);
  gap: 10px;
}

.control-input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid #d7dde5;
  border-radius: 6px;
  background-color: #fff;
  color: #111827;
  font-size: 14px;
  box-sizing: border-box;
}

.control-row:not(.detail-condition-row) .control-input {
  max-width: 260px;
}

.detail-condition-primary-row .control-input {
  width: 220px;
  max-width: 220px;
}

.detail-condition-row .control-input {
  display: block;
  height: 30px !important;
  min-height: 30px !important;
  line-height: 30px;
  width: 220px;
  max-width: 220px;
  padding-top: 0;
  padding-bottom: 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.control-file {
  padding: 7px 10px;
}

.upload-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-form .control-file {
  width: 360px;
  max-width: 100%;
}

.upload-meta {
  font-size: 13px;
  color: #64748b;
}

.upload-meta strong {
  color: #1f2937;
}

.primary-button,
.secondary-button,
.ghost-button {
  height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.primary-button {
  border: none;
  background-color: #2563eb;
  color: #fff;
}

.secondary-button {
  border: 1px solid #cbd5e1;
  background-color: #fff;
  color: #111827;
}

.ghost-button {
  border: 1px solid #e5e7eb;
  background-color: #f8fafc;
  color: #475569;
}

.filter-result-text {
  font-size: 13px;
  color: #64748b;
}

/* 결과 박스 */
.result-box {
  background: #ffffff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}

.result-box h2 {
  margin-bottom: 15px;
}

.pagination-summary {
  display: flex;
  gap: 14px;
  margin: 0;
  font-size: 14px;
  color: #475569;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
}

.per-page-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #475569;
}

.compact-select {
  width: 88px !important;
  max-width: 88px !important;
}

/* 테이블 */
.result-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

#resultTable {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  table-layout: fixed;
}

#resultTable thead {
  background-color: #e5e7eb;
}

#resultTable th,
#resultTable td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-row {
  cursor: pointer;
}

.summary-row:hover {
  background-color: #f8fafc;
}

.summary-row.is-expanded {
  background-color: #eff6ff;
}

.sort-header {
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.sort-header:focus {
  outline: 2px solid #9ca3af;
  outline-offset: -2px;
}

.sort-header::after {
  content: " ↕";
  font-size: 12px;
  color: #6b7280;
}

.sort-header[data-sort-direction="asc"]::after {
  content: " ↑";
  color: #111827;
}

.sort-header[data-sort-direction="desc"]::after {
  content: " ↓";
  color: #111827;
}

.status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
}

.status-dot.is-true {
  background-color: #16a34a;
}

.status-dot.is-false {
  background-color: #dc2626;
}

.detail-row[hidden] {
  display: none;
}

.detail-cell {
  padding: 0 !important;
  background-color: #eef4f8;
}

.detail-panel {
  padding: 10px 12px;
  min-width: 1040px;
}

.detail-list {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.detail-option-row {
  display: grid;
  grid-template-columns: var(--detail-grid-template, 44px 220px 48px 70px auto);
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-size: 12px;
  color: #334155;
  background-color: #f7fbfd;
  border-bottom: 1px solid #dbe7ef;
}

.detail-option-row:nth-child(even) {
  background-color: #f1f7fb;
}

.detail-quantity-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
}

.detail-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
}

.detail-option-out {
  background-color: #d7dee7 !important;
  color: #1f2937;
}

.detail-loading,
.detail-error,
.detail-empty {
  padding: 12px 10px;
  font-size: 12px;
  color: #475569;
}

.detail-error {
  color: #b91c1c;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background-color: #fff;
  color: #334155;
  text-decoration: none;
  font-size: 13px;
}

.pagination-link.is-active {
  border-color: #2563eb;
  background-color: #dbeafe;
  color: #1d4ed8;
  font-weight: 600;
}

.pagination-link.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}

/* 반응형 (사이드바 대응) */
@media (max-width: 768px) {
  .main-container {
    margin-left: 0;
  }

  .control-row {
    grid-template-columns: 1fr;
  }

  .control-label {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }

  .control-grid,
  .control-inline-grid {
    grid-template-columns: 1fr;
  }

  .upload-form {
    flex-direction: column;
    align-items: stretch;
  }
}

.upload-status {
  min-height: 0;
  margin: 0;
  font-size: 13px;
  color: #374151;
}

.upload-status:empty {
  display: none;
}

.upload-status:not(:empty) {
  display: block;
  margin-top: 6px;
}

.upload-status.success {
  color: #047857;
}

.upload-status.error,
.error-message {
  color: #b91c1c;
}

.empty-message {
  text-align: center !important;
  color: #6b7280;
}
