/* 기본 스타일 — 이시도르 컬러 테마 (메인 #800000, 보조 #9fa0a0, 강조 #ffab40) */

:root {
  --primary: #800000;
  --primary-dark: #5a0000;
  --primary-light: #a52a2a;
  --secondary: #9fa0a0;
  --accent: #ffab40;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #6c757d;
  --border: #e1e3e5;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* App shell — 뷰포트 고정 + 본문만 내부 스크롤 (사이드바는 오버레이 슬라이드) */
.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.app-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

/* Header */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.app-header .brand strong { font-size: 16px; }

/* 브랜드 로고 (로그인·회원가입 카드 안에만 노출) — 폭 3cm, 흰 배경 */
.brand-logo {
  width: 3cm;
  height: auto;
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  display: block;
  margin: 0 auto 12px;
}
.app-header .client-tag {
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.app-header .header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-header .user-info {
  font-size: 13px;
  opacity: 0.9;
}
.logout-form { margin: 0; }
.btn-logout {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.25); }

/* 햄버거 메뉴 토글 버튼 */
.btn-menu {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  margin-right: 12px;
  transition: background 0.12s ease;
}
.btn-menu:hover { background: rgba(255, 255, 255, 0.25); }
.btn-menu[aria-expanded="true"] { background: rgba(255, 255, 255, 0.3); }

.app-header .brand { display: flex; align-items: center; }

/* Sidebar — 좁은 화면: 오버레이 슬라이드(기본 닫힘), 넓은 화면: 정적 고정 표시 */
.sidebar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 240px;
  background: #2c3e50;
  color: #ecf0f1;
  padding: 16px 0;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.22s ease-out;
  z-index: 20;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}
.sidebar.open { transform: translateX(0); }

/* 넓은 화면(≥1024px): 사이드바가 본문 옆에 기본 표시. 'collapsed' 클래스 시 좌측으로 슬라이드 아웃 */
@media (min-width: 1024px) {
  .sidebar {
    position: static;
    transform: none;
    box-shadow: none;
    flex: 0 0 240px;
    margin-left: 0;
    transition: margin-left 0.22s ease-out;
  }
  .sidebar.collapsed { margin-left: -240px; }
}
.sidebar .nav-item {
  display: block;
  padding: 11px 20px;
  color: #bdc3c7;
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.sidebar .nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.sidebar .nav-item.active {
  background: rgba(128, 0, 0, 0.25);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}

/* Main content */
.main-content {
  flex: 1 1 auto;
  padding: 24px 32px;
  overflow-y: auto;
  background: var(--bg);
}
.page-header { margin-bottom: 18px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; color: var(--primary-dark); }
.page-header .hint { margin: 0; color: var(--text-light); font-size: 13px; }

.card {
  background: var(--card);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--primary-dark);
}
.muted { color: var(--text-light); font-size: 13px; font-weight: 400; }

/* Dashboard stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border-left: 4px solid var(--primary);
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.1;
}
.stat-card .stat-value .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
}
.stat-card .stat-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}
.stat-card .stat-link:hover { text-decoration: underline; }

/* Placeholder card */
.placeholder-card {
  text-align: center;
  color: var(--text-light);
  padding: 40px 20px;
}

/* Form */
.required-notice {
  margin: 0 0 12px;
  color: var(--text-light);
  font-size: 12px;
}
.req { color: var(--danger); font-weight: 700; margin: 0 2px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  gap: 4px;
}
.form-grid label.full-width { grid-column: 1 / -1; }
.form-grid > .full-width { grid-column: 1 / -1; }
.form-grid input,
.form-grid select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  background: #fff;
  transition: border-color 0.12s ease;
}
.form-grid input:focus,
.form-grid select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.1);
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

/* Microsoft Excel 색상 톤 — 전체자료 엑셀 다운로드 등 엑셀 산출물 버튼 */
.btn-excel {
  background: #107C41;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-excel:hover { background: #0E6B39; }
.btn-excel .excel-icon { flex: 0 0 auto; }
.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
  display: inline-block;
}
.btn-outline:hover { background: #f7f7f8; }

/* 사업장명 같은 행 링크 — primary 컬러 강조 */
.row-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.row-link:hover { text-decoration: underline; }

/* 사이트 상세 정보 grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 16px;
}
.info-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.info-label {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead {
  background: #faf3f3;
  border-bottom: 2px solid var(--primary);
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: #fafafb; }
.empty {
  color: var(--text-light);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* Login page */
.login-body {
  margin: 0;
  height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5a0000 0%, #800000 60%, #a52a2a 100%);
}
.login-wrap {
  width: min(380px, 90vw);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.login-card h1 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--primary-dark);
}
.login-sub {
  margin: 0 0 24px;
  color: var(--text-light);
  font-size: 13px;
  letter-spacing: 0.5px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}
.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.1);
}
.login-btn {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
}
.login-error {
  color: var(--danger);
  background: #fdecea;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 0 14px;
}
.login-info {
  color: #1e8449;
  background: #e8f8f0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 0 14px;
}
.login-foot {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: #555;
}
.login-foot a {
  color: var(--primary, #800000);
  text-decoration: none;
  font-weight: 600;
}
.login-foot a:hover { text-decoration: underline; }

/* 작은 버튼 + 위험 액션 */
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-danger {
  background: #c0392b;
  color: #fff;
  border: 1px solid #c0392b;
}
.btn-danger:hover { background: #a93226; }

.action-cell {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

/* 신규 등록 details 토글 — 목록 카드 안 우하단 배치 */
.register-section {
  margin-top: 12px;
  text-align: right;
}
.register-section > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 15px;
  background: #bfbfbf;
  color: #ffffff;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
  transition: background 0.12s ease;
}
.register-section > summary::-webkit-details-marker { display: none; }
.register-section > summary::before {
  content: "+";
  display: inline-block;
  width: 10px;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
}
.register-section[open] > summary { background: #a8a8a8; }
.register-section[open] > summary::before { content: "−"; }
.register-section > summary:hover { background: #a8a8a8; }

/* 펼쳐졌을 때 표시되는 입력 패널 (카드 내부에서 좌정렬·미세 톤 차이) */
.register-panel {
  margin-top: 12px;
  padding: 16px;
  background: #fafafa;
  border: 1px solid #ececec;
  border-radius: 6px;
  text-align: left;
}
.register-panel > .form-grid:first-child { margin-top: 0; }

/* 인증스콥 다중선택 체크박스 그룹 */
.scope-field { padding: 6px 0; }
.scope-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}
.scope-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: #f3f3f3;
  border: 1px solid #d8d8d8;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.scope-chip input[type="checkbox"] { margin: 0; }
.scope-chip:has(input:checked) {
  background: #e3eefb;
  border-color: #6c8db3;
  color: #1f3858;
}

/* 표·기본 정보에 표시되는 정적 스콥 칩 */
.scope-chip-static {
  display: inline-block;
  padding: 1px 7px;
  margin-right: 4px;
  background: #eef2f7;
  border: 1px solid #d0d8e2;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #2c3e50;
}

/* SD 접수 — GHG 컴포넌트별 '기본값' 토글 행 */
.ghg-comp-row {
  display: grid;
  grid-template-columns: 70px 1fr 100px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.ghg-comp-name { font-weight: 600; color: var(--primary-dark); }
.ghg-dv-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-light);
  user-select: none;
}
.ghg-dv-toggle input[type="checkbox"] { width: auto; margin: 0; }
.ghg-comp-row input[type="number"]:disabled {
  background: #f5f5f5;
  color: #9aa0a6;
}

/* 사업장 등록 — 인증 카드 다중 입력 영역 */
.cert-section {
  margin-top: 10px;
  padding: 14px;
  background: #f3f5f8;
  border: 1px solid #dde2ea;
  border-radius: 6px;
}
.cert-section-title {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--primary-dark);
  font-weight: 700;
}
.cert-section .hint { margin: 0 0 10px; font-size: 12px; }
#cert-list { display: flex; flex-direction: column; gap: 12px; }
.cert-card {
  background: #ffffff;
  border: 1px solid #d8dde5;
  border-radius: 5px;
  padding: 12px;
}
.cert-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: #444;
}
.btn-remove-cert {
  background: transparent;
  color: #c0392b;
  border: 1px solid #e3b1ac;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.btn-remove-cert:hover:not(:disabled) { background: #fdecea; }
.btn-remove-cert:disabled { opacity: 0.4; cursor: not-allowed; }
.cert-add-row { margin-top: 10px; text-align: right; }

/* 사업장 행 — 인증 현황 셀의 한 줄 인증 정보 */
.cert-line { padding: 2px 0; font-size: 12px; }
.cert-line .cert-no { color: #2c3e50; font-weight: 600; }
.cert-line .cert-scopes { margin-left: 4px; }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: #e8f8f0; color: #1e8449; }
.badge-yellow { background: #fef9e7; color: #b7950b; }
.badge-red    { background: #fdecea; color: #c0392b; }
.badge-blue   { background: #eaf2f8; color: #2471a3; }
.badge-gray   { background: #f2f3f4; color: #7f8c8d; }
/* 의미 별칭 */
.badge-ok   { background: #e8f8f0; color: #1e8449; }
.badge-warn { background: #fef9e7; color: #b7950b; }
.badge-err  { background: #fdecea; color: #c0392b; }

/* 체크박스 + 라벨 한 줄 (NC 종료 처리 등) */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ─── GHG E 토글 (헤더 클릭 시 좌우 8개 컴포넌트 컬럼 펼침) ─── */
.data-table th.ghg-toggle {
  cursor: pointer;
  user-select: none;
  background: #faf3f3;
  white-space: nowrap;
}
.data-table th.ghg-toggle::after {
  content: " ▸";
  font-size: 10px;
  opacity: 0.7;
  margin-left: 4px;
}
.data-table.ghg-expanded th.ghg-toggle::after { content: " ▾"; }
.data-table th.ghg-toggle:hover { background: #f1e6e6; }

/* hidden 컴포넌트 컬럼 — 기본 숨김 */
.data-table th.ghg-comp,
.data-table td.ghg-comp { display: none; }
/* 토글 시 노출 */
.data-table.ghg-expanded th.ghg-comp,
.data-table.ghg-expanded td.ghg-comp { display: table-cell; }

/* GHG 컴포넌트 입력 폼 영역 */
.ghg-section {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
}
.ghg-section h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--primary-dark);
}
.ghg-section .ghg-formula {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--text-light);
  font-family: 'Menlo', 'Consolas', monospace;
}
.ghg-section .form-grid label { font-size: 11px; }
.ghg-section .ghg-hint {
  color: var(--text-light);
  font-weight: 400;
  font-size: 10px;
  margin-left: 2px;
}
.ghg-total-cell input {
  background: #eef5fb;
  font-weight: 700;
  color: var(--primary-dark);
}

/* SD/PoS 모드 토글 라디오 카드 */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.mode-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
}
.mode-option:hover { border-color: var(--primary-light); }
.mode-option.selected { border-color: var(--primary); background: #faf3f3; }
.mode-option strong { font-size: 13px; }
.mode-option small { color: var(--text-light); font-size: 11px; line-height: 1.4; }

/* Inline error row */
.form-error td {
  background: #fdecea;
  color: var(--danger);
  font-size: 13px;
}
.error-badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 700;
}

/* 아이템 코드 — SD 접수·주원료·제품 행에 모노스페이스로 노출 */
.item-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--text);
  white-space: nowrap;
}

/* 제조레시피 영역 — 제품 카드 하위 서브섹션 */
.recipe-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.recipe-section h3 {
  font-size: 15px;
  margin: 0 0 4px 0;
  color: var(--primary);
}

/* 카드 내 인라인 가로 나열 — 운송단계·제조레시피용 */
.inline-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.inline-grid label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.inline-grid label::after { content: ":"; margin-right: 2px; }
.inline-grid input,
.inline-grid select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  background: #fff;
  min-width: 90px;
}
.inline-grid input.wide { min-width: 160px; }

/* GHG 수식 아래 컴포넌트 가로 나열 */
.ghg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 6px;
  font-size: 12px;
}
.ghg-row .ghg-sign { font-weight: 700; color: var(--text); padding: 0 2px; }
.ghg-row .ghg-input {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ghg-row .ghg-input small { font-size: 10px; color: var(--text-light); }
.ghg-row .ghg-input input {
  width: 64px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  text-align: right;
  background: #fff;
}
/* 위·아래 화살표(spinner) 제거 — 직접 숫자 입력 전용 */
.ghg-row input[type="number"]::-webkit-outer-spin-button,
.ghg-row input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ghg-row input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.ghg-row .ghg-total {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ghg-row .ghg-total input {
  width: 90px;
  padding: 3px 6px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  background: #faf3f3;
  color: var(--primary);
}

/* 공정 라인 카드 — 좌측 라벨 + 입력란 + 삭제 버튼 모두 한 줄 */
.line-card .inline-grid { align-items: center; }
.line-card .line-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  margin-right: 4px;
}
.line-card .btn-remove-cert { margin-left: auto; }

/* 대시보드 상단 — 달력 + 다가오는 일정 2열 */
.dashboard-top {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.4fr);
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 900px) {
  .dashboard-top { grid-template-columns: 1fr; }
}

/* 달력 */
.calendar-card .calendar {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.calendar-card .calendar th {
  padding: 6px 4px;
  font-weight: 700;
  font-size: 11px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.calendar-card .calendar th.sun { color: var(--primary); }
.calendar-card .calendar th.sat { color: #2c5aa0; }
.calendar-card .calendar td {
  height: 44px;
  vertical-align: top;
  padding: 4px;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}
.calendar-card .calendar td.empty { background: #fafafa; }
.calendar-card .calendar td.sun .day-num { color: var(--primary); }
.calendar-card .calendar td.sat .day-num { color: #2c5aa0; }
.cf-cell .cf-line { font-size: 12px; line-height: 1.6; white-space: nowrap; }
.cf-cell .cf-line strong { color: var(--primary); }
.calendar-card .calendar td.other-month { background: #fafafa; }
.calendar-card .calendar td.other-month .day-num { color: #c8c8c8; font-weight: 400; }
.calendar-card .calendar td.other-month.sun .day-num { color: #e0b8b8; }
.calendar-card .calendar td.other-month.sat .day-num { color: #b8c6dc; }
.calendar-card .calendar td.today {
  background: rgba(128, 0, 0, 0.08);
}
.calendar-card .calendar td.today .day-num {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-weight: 700;
}
.calendar-card .calendar .day-num { font-size: 13px; font-weight: 500; }
.calendar-card .calendar .event-dot {
  display: block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin: 4px auto 0;
}

/* 다가오는 일정 */
.upcoming-card .upcoming-list {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 360px;
  overflow-y: auto;
}
.upcoming-item {
  display: flex;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.upcoming-item:last-child { border-bottom: none; }
.upcoming-item .up-date {
  flex: 0 0 72px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
.upcoming-item .up-date strong { font-size: 14px; color: var(--text); }
.upcoming-item .up-dday {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #eee;
  color: var(--text-light);
}
.upcoming-item .up-dday.near {
  background: rgba(192, 57, 43, 0.12);
  color: var(--danger);
  font-weight: 700;
}
.upcoming-item .up-dday.soon {
  background: rgba(255, 171, 64, 0.18);
  color: #a06800;
  font-weight: 600;
}
.upcoming-item .up-dday.past {
  background: #e7e7e7;
  color: var(--text-light);
  text-decoration: line-through;
}
.upcoming-item .up-body { flex: 1 1 auto; font-size: 13px; }
.upcoming-item .up-note { font-size: 11px; margin-top: 2px; }

/* 카드 헤더 — 제목 + 우측 액션 버튼 라인 */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.card-header-row h2 { margin: 0; }
.upcoming-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
}
.btn.btn-sm.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.btn-sm.btn-outline:hover { background: #f7f7f8; }

/* number input 위·아래 화살표 제거 — 직접 숫자 입력 전용 */
input.no-spinner[type="number"]::-webkit-outer-spin-button,
input.no-spinner[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input.no-spinner[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* 매스밸런스 공정도 */
.mb-block h2 { display: flex; align-items: center; gap: 8px; }
.mb-flow {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: wrap;
}
.mb-col { flex: 1 1 240px; min-width: 240px; display: flex; flex-direction: column; gap: 8px; }
.mb-col-title { font-size: 12px; font-weight: 700; color: var(--text-light); text-transform: uppercase; }
.mb-arrow {
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--secondary); padding: 0 4px;
}
.mb-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  padding: 10px 12px;
  font-size: 13px;
}
.mb-box .mb-name { font-weight: 700; color: var(--text); }
.mb-box .mb-sub { font-size: 11px; }
.mb-box .mb-num { font-size: 13px; color: var(--primary); }
.mb-box .mb-row { padding: 4px 0; border-top: 1px dashed #ececec; margin-top: 4px; }
.mb-box .mb-label { color: var(--text-light); font-size: 11px; margin-right: 4px; }
.mb-process { background: #f7eded; border-color: var(--primary-light); text-align: center; }
.mb-raw summary, .mb-prod summary, .mb-box details > summary {
  cursor: pointer;
  list-style: none;
}
.mb-raw summary::-webkit-details-marker, details > summary::-webkit-details-marker { display: none; }
.mb-formula {
  margin-top: 6px;
  padding: 6px 8px;
  background: #fffbe8;
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  line-height: 1.6;
}
.mb-warehouse {
  margin-top: 6px;
  padding: 4px 8px;
  background: #eef3f9;
  border-left: 3px solid #2c5aa0;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
}
.mb-available { background: #f3faf3; border-radius: 4px; padding: 4px 8px; }
.mb-credit {
  margin-top: 8px;
  padding: 6px 10px;
  background: #faf3e8;
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
}
.mb-warn { border-color: var(--danger); }
.mb-alert {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fdecea;
  border: 1px solid var(--danger);
  border-radius: 4px;
  font-size: 13px;
  color: var(--danger);
  font-weight: 600;
}
@media (max-width: 800px) {
  .mb-arrow { transform: rotate(90deg); }
}

/* 대시보드 달력 헤더 (이전·다음 월) */
.calendar-card .calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.calendar-card .calendar-header h2 { margin: 0; }
.calendar-card .cal-nav {
  text-decoration: none;
  font-size: 16px;
  color: var(--primary);
  background: #faf3f3;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 10px;
  line-height: 1.6;
  font-weight: 700;
}
.calendar-card .cal-nav:hover { background: var(--primary); color: #fff; }
.calendar-card .cal-today { margin-left: 6px; }

/* 상세 페이지 인라인 수정 폼 토글 */
.edit-toggle > summary {
  list-style: none;
  cursor: pointer;
  display: inline-block;
}
.edit-toggle > summary::-webkit-details-marker { display: none; }
.edit-toggle .edit-form {
  margin-top: 12px;
  padding: 14px;
  background: #faf3f3;
  border: 1px dashed var(--primary);
  border-radius: 6px;
}

.mb-badge-pass { color: #15803d; font-weight: 700; }
.mb-badge-fail { color: #b91c1c; font-weight: 700; }

/* 5단계 잉여 뱃지 — 본문보다 2pt 크게 강조 */
.mb-excess-badge { font-size: 1.05rem; padding: 4px 12px; border-radius: 14px; }
.mb-warn {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fff7ed;
  border: 1px solid #ffab40;
  border-left: 4px solid #ffab40;
  border-radius: 4px;
  color: #7c2d12;
  font-size: 0.92rem;
}

/* 대시보드 — 인증현황 카드 그리드 (인증서 종이 모양) */
.cert-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.cert-card {
  position: relative;
  display: block;
  background: linear-gradient(180deg, #fffdf7 0%, #fff 100%);
  border: 1px solid #d6b88a;
  border-radius: 4px;
  padding: 14px 16px 12px;
  text-decoration: none;
  color: #1f2937;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  overflow: hidden;
  min-height: 150px;
}
.cert-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.06);
}
/* 종이 모서리 접힘 효과 (우상단) */
.cert-card-corner {
  position: absolute;
  top: 0; right: 0;
  width: 22px; height: 22px;
  background: linear-gradient(225deg, #f3e8c8 0%, #f3e8c8 50%, transparent 50%);
  border-left: 1px solid #d6b88a;
  border-bottom: 1px solid #d6b88a;
}
.cert-card-scheme {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 2px;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.cert-card-no {
  font-family: ui-monospace, monospace;
  font-size: 0.92rem;
  font-weight: 600;
  color: #111;
  word-break: break-all;
  margin-bottom: 10px;
}
.cert-card-holder {
  font-size: 0.92rem;
  line-height: 1.4;
  margin-bottom: 12px;
}
.cert-card-holder .muted { font-size: 0.78rem; }
.cert-card-expiry {
  border-top: 1px dashed #d6b88a;
  padding-top: 8px;
  margin-top: auto;
}
.cert-expiry-date { font-size: 0.82rem; color: #4b5563; margin-bottom: 4px; }

/* 대시보드 — 재고 잔량 (Live Stock) 저장탱크 모양 카드 */
.stock-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px 18px;
  margin-top: 24px;  /* 상단 캡 공간 */
  padding-bottom: 14px;  /* 하단 그림자 공간 */
}
.stock-card {
  position: relative;
  background:
    linear-gradient(90deg,
      #c8ccd2 0%,
      #e8ebef 14%,
      #fafbfc 36%,
      #ffffff 50%,
      #fafbfc 64%,
      #e8ebef 86%,
      #c8ccd2 100%);
  border: 1px solid #a8aeb6;
  border-radius: 18px;
  padding: 20px 18px 22px;
  box-shadow:
    inset 0 4px 8px rgba(0,0,0,0.07),
    inset 0 -6px 10px rgba(0,0,0,0.10),
    0 4px 10px rgba(0,0,0,0.12);
}
/* 탱크 상부 — 둥근 캡 */
.stock-card::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 10%; right: 10%;
  height: 16px;
  background: linear-gradient(180deg, #b8bdc5 0%, #e0e3e8 100%);
  border: 1px solid #a8aeb6;
  border-bottom: 0;
  border-radius: 50% 50% 6px 6px / 80% 80% 6px 6px;
}
/* 탱크 하부 — 받침 그림자 (타원형) */
.stock-card::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 14%; right: 14%;
  height: 10px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.05) 60%, transparent 80%);
  filter: blur(1px);
}
.stock-card-head { margin-bottom: 10px; }
.stock-card .stock-name {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #111;
  line-height: 1.3;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.stock-card .stock-code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;   /* 제품명 대비 ~2pt 작게 */
  font-weight: 400;    /* 볼드 아님 */
  color: #000;
}
.stock-card .stock-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.stock-card .stock-site-row {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.stock-card .stock-site-name { font-weight: 600; font-size: 0.95rem; }
.stock-card .stock-qty { font-size: 1.1rem; }
.stock-card .stock-qty strong { color: var(--primary); }

/* 대시보드 '다가오는 일정' 도움말 details */
.upcoming-help { margin-top: 6px; margin-bottom: 10px; }
.upcoming-help > summary {
  cursor: pointer;
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.82rem;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  color: #374151;
  list-style: none;
}
.upcoming-help > summary::-webkit-details-marker { display: none; }
.upcoming-help > summary:hover { background: #e5e7eb; }
.upcoming-help[open] > summary { background: #e5e7eb; }
.upcoming-help ul { margin: 8px 0 6px; padding-left: 22px; font-size: 0.9rem; line-height: 1.6; }
.upcoming-help ul ul { margin: 4px 0; }
.upcoming-help code { background: #fff; padding: 1px 4px; border: 1px solid #e5e7eb; border-radius: 3px; font-size: 0.85em; }

/* 매스밸런스 단계별 '계산과정 보기' 토글 */
.calc-explain { margin-top: 14px; text-align: right; }
.calc-explain > summary {
  cursor: pointer;
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.85rem;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: #374151;
  list-style: none;
}
.calc-explain > summary::-webkit-details-marker { display: none; }
.calc-explain > summary:hover { background: #e5e7eb; }
.calc-explain[open] > summary { background: #e5e7eb; }
.calc-explain-body {
  text-align: left;
  margin-top: 10px;
  padding: 14px 18px;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: 1.55;
}
.calc-explain-body h4 { margin: 0 0 8px; color: var(--primary); font-size: 0.95rem; }
.calc-explain-body code { background: #fff; padding: 1px 5px; border: 1px solid #e5e7eb; border-radius: 3px; font-size: 0.88em; }
.calc-explain-body .formula { background: #fff; padding: 8px 12px; border-left: 3px solid #ffab40; margin: 6px 0; font-family: ui-monospace, monospace; font-size: 0.88em; }
.calc-explain-body ul { margin: 6px 0; padding-left: 20px; }
.calc-explain-body .pair { margin: 4px 0; padding: 4px 0; border-bottom: 1px dashed #e5e7eb; }
.calc-explain-body .pair:last-child { border-bottom: 0; }

/* 엑셀 다운로드 모달 */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 8px;
  max-width: 600px; width: 92%; max-height: 88vh;
  padding: 22px 26px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  overflow-y: auto;
}
.modal-box h3 { margin: 0 0 14px; color: var(--primary); }
.modal-box .modal-actions { margin-top: 18px; display: flex; gap: 8px; justify-content: flex-end; }
.modal-box .sheet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 8px; margin-top: 6px; }
.modal-box .sheet-list label { display: flex; gap: 6px; padding: 6px 10px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.modal-box .sheet-list label:hover { background: #f3f4f6; }
.modal-box .select-shortcut { font-size: 0.85rem; color: var(--primary); cursor: pointer; background: none; border: none; padding: 0; margin-right: 8px; }
.modal-box .export-period {
  border: 1px solid #d1d5db;
  border-radius: 5px;
  padding: 10px 14px 6px;
  margin-bottom: 14px;
}
.modal-box .export-period legend { padding: 0 6px; font-weight: 600; font-size: 0.88rem; color: var(--primary); }
.modal-box .export-period label { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: 0.9rem; }
.modal-box .export-period input[type=month] { padding: 4px 6px; font-size: 0.9rem; }
.modal-box .export-period .hint { margin: 6px 0 0; font-size: 0.82rem; }

/* 공정 라인 수량 분모 (가동단위) 표시 */
.per-unit-suffix { color: #6b7280; font-size: 0.9rem; align-self: end; padding-bottom: 6px; white-space: nowrap; }
.per-unit-suffix .per-unit-text { font-weight: 600; color: var(--primary); }
.per-unit-input-wrap { margin-left: 12px; font-size: 0.85em; font-weight: normal; }
.per-unit-input-wrap select { padding: 2px 6px; font-size: 0.9em; }
.per-unit-label { display: inline-flex; align-items: center; gap: 4px; }

/* 자식 엔티티 행 액션 */
.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions form { margin: 0; display: inline; }
.row-actions .btn-icon {
  padding: 2px 8px;
  font-size: 0.85rem;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 3px;
  cursor: pointer;
}
.row-actions .btn-icon.danger { color: #b91c1c; border-color: #fecaca; }
.row-actions .btn-icon:hover { background: #f3f4f6; }
.inline-edit-row > td { background: #fafafa; padding: 12px 14px; }
.inline-edit-row .form-grid { gap: 8px; }
.add-child-section { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #d1d5db; }
.add-child-section summary { cursor: pointer; font-weight: 600; color: var(--primary); }

.page-eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  background: var(--primary);
  padding: 3px 10px;
  border-radius: 3px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

/* 목록 collapsible — 5행 초과 시 6번째부터 접기 */
tr.list-hidden { display: none; }
tr.list-collapse-toggle td {
  text-align: center;
  padding: 8px 12px;
  background: #fafafa;
  border-top: 1px dashed #d1d5db;
}
.btn-collapse {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 4px 16px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.12s ease, color 0.12s ease;
}
.btn-collapse:hover { background: var(--primary); color: #fff; }

/* 하단 문의 footer */
.app-footer {
  margin-top: 48px;
  padding: 12px 0 24px;
  color: #9ca3af;
  font-size: 12px;
  text-align: center;
}
.app-footer a { color: #9ca3af; }

.btn-report-error {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  color: #6b7280;
  text-decoration: none;
  margin-bottom: 8px;
}
.btn-report-error:hover { border-color: #9ca3af; color: #374151; }
.app-footer-contact { display: block; margin-top: 4px; }
.app-footer-contact a { color: #9ca3af; }

.header-clock {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  font-family: 'SUIT', sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  margin-right: 4px;
}
