* {
  box-sizing: border-box;
}


/* ================================
   기본
================================ */

body {
  margin: 0;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Noto Sans KR",
    sans-serif;

  background: #f4f6f8;
  color: #1f2937;
}


.container {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}


/* ================================
   Header / Footer
================================ */

.app-header {
  background: #1f2937;
  color: white;
  padding: 32px 0;
}


.app-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
}


.app-header p {
  margin: 0;
  opacity: 0.8;
}


.header-row {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 16px;
}


.header-row .secondary-button {
  background: transparent;

  border-color: rgba(255, 255, 255, 0.4);

  color: white;

  flex-shrink: 0;
}


.header-row .secondary-button:hover {
  background: rgba(255, 255, 255, 0.1);
}


.app-footer {
  padding: 24px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}


main.container {
  padding: 28px 0 50px;
}


/* ================================
   로그인 화면
================================ */

.login-screen {
  min-height: 100vh;

  display: flex;

  align-items: center;

  justify-content: center;

  padding: 20px;
}


.login-card {
  background: white;

  border-radius: 12px;

  padding: 32px;

  width: 100%;

  max-width: 360px;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.06);
}


.login-card h1 {
  margin: 0 0 6px;

  font-size: 20px;
}


.login-card > p {
  margin: 0 0 20px;

  color: #6b7280;

  font-size: 14px;
}


.login-card .input-group {
  margin-bottom: 16px;
}


.login-card input {
  width: 100%;

  padding: 12px;

  border: 1px solid #d1d5db;

  border-radius: 8px;

  font-size: 16px;
}


.login-card .primary-button {
  width: 100%;

  margin-top: 4px;
}


/* ================================
   공통 카드
================================ */

.card {
  background: white;

  border-radius: 12px;

  padding: 24px;

  margin-bottom: 20px;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.06);
}


/* ================================
   탭
================================ */

.tabs {
  display: flex;

  gap: 8px;

  margin-bottom: 20px;
}


.tab-button {
  border: 1px solid #d1d5db;

  background: white;

  color: #374151;

  padding: 10px 18px;

  border-radius: 8px;

  cursor: pointer;

  font-size: 14px;

  font-weight: 600;

  transition: 0.15s;
}


.tab-button:hover {
  border-color: #93c5fd;
}


.tab-button.active {
  background: #2563eb;

  border-color: #2563eb;

  color: white;
}


/* ================================
   카드 제목
================================ */

.section-title {
  margin-bottom: 20px;
}


.section-title h2 {
  margin: 0 0 6px;
  font-size: 20px;
}


.section-title p {
  margin: 0;

  color: #6b7280;

  font-size: 14px;
}


/* ================================
   입력 영역
================================ */

.input-grid,
.yield-grid {
  display: grid;

  grid-template-columns:
    repeat(3, 1fr);

  gap: 18px;
}


.input-grid-2 {
  grid-template-columns:
    repeat(2, 1fr);
}


.mode-toggle {
  margin-bottom: 18px;
}


/* ================================
   생산 조건 (자석 / GBDP 공정 구분)
================================ */

.production-columns {
  display: grid;

  grid-template-columns:
    1fr 1px 1fr;

  align-items: stretch;

  gap: 28px;
}


.production-column {
  display: grid;

  gap: 18px;

  min-width: 0;
}


.production-vertical-divider {
  width: 1px;

  background: #e5e7eb;
}


.input-group {
  display: flex;

  flex-direction: column;

  gap: 8px;
}


.input-group label {
  font-size: 14px;

  font-weight: 600;
}


.input-with-unit {
  display: flex;

  align-items: center;

  border: 1px solid #d1d5db;

  border-radius: 8px;

  overflow: hidden;

  background: white;
}


.input-with-unit input {
  width: 100%;

  border: 0;

  outline: none;

  padding: 12px;

  font-size: 16px;
}


.input-with-unit span {
  padding-right: 12px;

  color: #6b7280;

  white-space: nowrap;
}


/* ================================
   원재료 선택 영역
================================ */

.selection-columns {
  display: grid;

  grid-template-columns:
    1fr 1px 2fr;

  align-items: center;

  gap: 28px;
}


.selection-column {
  min-width: 0;
}


.selection-label {
  display: flex;

  align-items: baseline;

  gap: 8px;

  margin-bottom: 12px;
}


.selection-label strong {
  font-size: 14px;

  color: #374151;
}


.selection-label span {
  font-size: 12px;

  color: #9ca3af;
}


.selection-vertical-divider {
  width: 1px;

  height: 55px;

  background: #e5e7eb;
}


/* ================================
   희토류 버튼
================================ */

.element-selector {
  display: flex;

  gap: 8px;
}


.element-option {
  cursor: pointer;
}


.element-option input {
  display: none;
}


.element-box {
  display: flex;

  align-items: center;

  justify-content: center;

  width: 70px;

  height: 40px;

  border: 1px solid #d1d5db;

  border-radius: 8px;

  background: white;

  transition: 0.15s;
}


.element-box strong {
  font-size: 15px;

  color: #374151;
}


.element-box small {
  display: none;
}


.element-option:hover .element-box {
  border-color: #93c5fd;
}


.element-option input:checked + .element-box {
  background: #2563eb;

  border-color: #2563eb;

  color: white;
}


.element-option input:checked + .element-box strong {
  color: white;
}


/* ================================
   확산재 버튼
================================ */

.material-selector {
  display: flex;

  gap: 8px;

  flex-wrap: wrap;
}


.material-selector label {
  cursor: pointer;
}


.material-selector input {
  display: none;
}


.material-selector span {
  display: flex;

  align-items: center;

  justify-content: center;

  height: 40px;

  padding: 0 16px;

  border: 1px solid #d1d5db;

  border-radius: 8px;

  background: white;

  color: #374151;

  font-size: 14px;

  font-weight: 500;

  transition: 0.15s;
}


.material-selector span small {
  display: none;
}


.material-selector label:hover span {
  border-color: #93c5fd;
}


.material-selector input:checked + span {
  background: #2563eb;

  border-color: #2563eb;

  color: white;
}




/* ================================
   결과 카드
================================ */

.result-cards {
  display: grid;

  grid-template-columns:
    repeat(auto-fit, minmax(150px, 1fr));

  gap: 12px;
}


.result-card {
  padding: 18px;

  border-radius: 10px;

  background: #f8fafc;

  border: 1px solid #e5e7eb;
}


.result-card.highlight {
  border: 2px solid #2563eb;

  background: #eff6ff;
}


.result-card span {
  display: block;

  font-size: 13px;

  color: #6b7280;

  margin-bottom: 8px;
}


.result-card strong {
  display: block;

  font-size: 22px;
}


.result-card small {
  color: #6b7280;
}


/* ================================
   공정 흐름
================================ */

.process-flow {
  display: flex;

  align-items: center;

  justify-content: center;

  gap: 10px;

  overflow-x: auto;

  padding: 15px 0;
}


.process-node {
  min-width: 150px;

  padding: 18px;

  text-align: center;

  border: 1px solid #d1d5db;

  border-radius: 10px;

  background: #f8fafc;
}


.process-node strong {
  display: block;

  margin-bottom: 8px;
}


.process-node span {
  font-size: 14px;

  color: #6b7280;
}


.process-node.highlight {
  border: 2px solid #2563eb;

  background: #eff6ff;
}


.process-arrow {
  min-width: 70px;

  text-align: center;

  font-size: 24px;

  color: #6b7280;
}


.process-arrow small {
  display: block;

  font-size: 12px;
}


/* ================================
   전체 수율 (공정 흐름 카드 내)
================================ */

.section-divider {
  border: none;

  border-top: 1px solid #e5e7eb;

  margin: 20px 0;
}


.subsection-title {
  font-size: 15px;

  font-weight: 600;

  color: #374151;

  margin-bottom: 12px;
}


.subsection-title:not(:first-child) {
  margin-top: 24px;
}


.overall-yield-grid {
  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 12px;
}


/* ================================
   결과 테이블
================================ */

.table-wrapper {
  overflow-x: auto;
}


.result-table {
  width: 100%;

  border-collapse: collapse;
}


.result-table th,
.result-table td {
  padding: 13px;

  border-bottom: 1px solid #e5e7eb;

  text-align: right;
}


.result-table th:first-child,
.result-table td:first-child {
  text-align: left;
}


/*
 * rowspan으로 첫 칸(구분)이 비어있는 행에서는
 * 단위 칸이 :first-child가 되어 좌측 정렬되므로 되돌린다.
 */
.result-table td.unit-cell {
  text-align: right;
}


.result-table tr.highlight-row td {
  background: #eff6ff;

  font-weight: 600;
}


/*
 * 기간별 상세 표: 구분 / 단위 칸은 내용 길이만큼만 차지하게 하고
 * (연간~일간 칸이 남는 폭을 가져감), 단위는 구분 쪽에 붙여
 * 하나의 항목처럼 보이게 한다.
 */
.period-table th:first-child,
.period-table td:first-child,
.period-table th:nth-child(2),
.period-table td.unit-cell {
  width: 1%;

  white-space: nowrap;
}


.period-table td.unit-cell {
  padding-left: 4px;

  color: #6b7280;
}


.result-table th {
  background: #f8fafc;

  font-size: 14px;
}


.result-table th small {
  display: block;

  margin-top: 2px;

  color: #9ca3af;

  font-weight: 400;

  font-size: 11px;
}


.mix-table .input-with-unit {
  max-width: 130px;

  margin-left: auto;
}


.working-days-display {
  margin: 16px 0 0;

  font-size: 14px;

  color: #374151;
}


details summary {
  cursor: pointer;

  font-weight: 600;
}


.line-layout-details {
  margin-bottom: 20px;
}


.line-layout-image {
  display: block;

  width: 100%;

  height: auto;

  margin-top: 12px;

  border: 1px solid #e5e7eb;

  border-radius: 8px;
}


.slurry-detail {
  padding: 14px 0;

  border-bottom: 1px solid #e5e7eb;
}


.slurry-detail summary {
  display: flex;

  align-items: center;

  gap: 8px;
}


.slurry-detail summary::-webkit-details-marker {
  display: none;
}


.slurry-detail summary::before {
  content: "▸";

  color: #9ca3af;

  font-size: 12px;

  transition: transform 0.15s;
}


.slurry-detail[open] summary::before {
  transform: rotate(90deg);
}


.slurry-summary-value {
  margin-left: auto;

  color: #6b7280;

  font-weight: 400;

  font-size: 13px;
}


.selected-badge {
  display: inline-block;

  margin-left: 8px;

  padding: 2px 8px;

  border-radius: 999px;

  background: #2563eb;

  color: white;

  font-size: 11px;

  font-weight: 600;

  vertical-align: middle;
}


.bottleneck-badge {
  display: inline-block;

  margin-left: 8px;

  padding: 2px 8px;

  border-radius: 999px;

  background: #fffbeb;

  color: #b45309;

  font-size: 11px;

  font-weight: 600;

  vertical-align: middle;
}


.slurry-detail:last-child {
  border-bottom: 0;
}


.slurry-detail .table-wrapper {
  margin-top: 12px;
}


details > .table-wrapper {
  margin-top: 16px;
}


.info-icon {
  display: inline-flex;

  align-items: center;

  justify-content: center;

  width: 15px;

  height: 15px;

  margin-left: 4px;

  border-radius: 50%;

  background: #e5e7eb;

  color: #6b7280;

  font-size: 10px;

  font-weight: 700;

  cursor: help;

  vertical-align: middle;
}


/*
 * 표의 overflow-x: auto 영역에 있는 아이콘도 잘리지 않도록
 * 뷰포트 기준 고정 위치로 별도 렌더링한다 (app.js에서 위치 계산)
 */
.tooltip-popup {
  position: fixed;

  background: #1f2937;

  color: white;

  padding: 8px 10px;

  border-radius: 6px;

  font-size: 12px;

  font-weight: 400;

  line-height: 1.5;

  max-width: 240px;

  white-space: pre-line;

  z-index: 1000;

  pointer-events: none;
}


/* ================================
   메시지
================================ */

.message {
  padding: 14px 18px;

  border-radius: 8px;

  margin-bottom: 20px;
}


.message p {
  margin: 0 0 12px;
}


.message p:last-child {
  margin-bottom: 0;
}


.error-message {
  background: #fef2f2;

  border: 1px solid #fecaca;

  color: #b91c1c;
}


.info-message {
  background: #eff6ff;

  border: 1px solid #bfdbfe;

  color: #1d4ed8;
}


/* ================================
   설비 부하율 배지
================================ */

.load-badge {
  display: inline-block;

  padding: 2px 10px;

  border-radius: 999px;

  font-size: 12px;

  font-weight: 600;
}


.load-ok {
  background: #f0fdf4;

  color: #15803d;
}


.load-warning {
  background: #fffbeb;

  color: #b45309;
}


.load-danger {
  background: #fef2f2;

  color: #b91c1c;
}


/* ================================
   기타
================================ */

.hidden {
  display: none !important;
}


/* ================================
   버튼
================================ */

.button-area {
  display: flex;

  justify-content: flex-end;

  gap: 10px;

  margin-bottom: 30px;
}


.secondary-button {
  border: 1px solid #d1d5db;

  background: white;

  padding: 10px 18px;

  border-radius: 8px;

  cursor: pointer;

  font-weight: 600;
}


.secondary-button:hover {
  background: #f3f4f6;
}


.primary-button {
  border: 1px solid #2563eb;

  background: #2563eb;

  color: white;

  padding: 10px 18px;

  border-radius: 8px;

  cursor: pointer;

  font-weight: 600;
}


.primary-button:hover {
  background: #1d4ed8;
}


/* ================================
   태블릿
================================ */

@media (max-width: 900px) {

  .input-grid,
  .yield-grid {
    grid-template-columns:
      repeat(2, 1fr);
  }

}


/* ================================
   모바일
================================ */

@media (max-width: 600px) {

  .container {
    width: calc(100% - 20px);
  }


  .card {
    padding: 18px;
  }


  .input-grid,
  .yield-grid {
    grid-template-columns: 1fr;
  }


  .overall-yield-grid {
    grid-template-columns: 1fr;
  }


  .tabs {
    flex-wrap: wrap;
  }


  .tab-button {
    flex: 1 1 auto;

    text-align: center;
  }


  .button-area {
    flex-wrap: wrap;
  }


  .button-area button {
    width: 100%;
  }



@media (max-width: 600px) {

  .selection-columns {
    grid-template-columns: 1fr;

    gap: 20px;
  }


  .selection-vertical-divider {
    width: 100%;

    height: 1px;
  }


  .production-columns {
    grid-template-columns: 1fr;

    gap: 20px;
  }


  .production-vertical-divider {
    width: 100%;

    height: 1px;
  }

}


  /* 선택 버튼 */

  .option-list {
    display: grid;

    grid-template-columns:
      repeat(2, 1fr);
  }


  .option span {
    width: 100%;

    min-width: 0;
  }


  .process-flow {
    justify-content: flex-start;
  }

}