/* 배치 생산 종료 계산기 — 화면 스타일
   생산 라인에서 장갑 낀 한 손으로 쓰도록: 큰 터치 영역(56px+), 큰 숫자, 높은 대비. */

:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #8993a4;
  --line: #e3e8f0;
  --line-2: #cfd6e4;
  --accent: #1f55f5;
  --accent-soft: #e8efff;
  --navy: #101b33;
  --navy-2: #1b2a4a;
  --ok: #0a8f5c;
  --warn: #c2410c;
  --danger: #c02626;
  --radius: 18px;
  --tap: 56px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0; font-weight: 700; }

/* ───────── 상단 바 ───────── */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-t);
  background: var(--navy);
  color: #fff;
}
.appbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 var(--pad);
}
.appbar-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #2b3f6b;
  color: #cfe0ff;
}
.appbar h1 { font-size: 17px; letter-spacing: -0.02em; flex: 1; }
.appbar-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #8ea6d6;
  border: 1px solid #33486f;
  border-radius: 6px;
  padding: 3px 7px;
}

/* ───────── 본문/탭 ───────── */

main {
  padding: var(--pad) var(--pad) calc(var(--tabbar-h) + var(--safe-b) + 24px);
  max-width: 640px;
  margin: 0 auto;
}
.pane { display: none; }
.pane.is-active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 18px -12px rgba(16, 24, 40, 0.18);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2 { font-size: 15px; color: var(--ink-2); letter-spacing: 0; }
.unit { font-size: 12px; color: var(--ink-3); font-weight: 600; }

.hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
}
.hint b { color: var(--ink-2); }

/* ───────── 결과 카드 ───────── */

.result {
  background: linear-gradient(160deg, #17253f 0%, var(--navy) 55%, #0c1526 100%);
  color: #fff;
  border-radius: 22px;
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  box-shadow: 0 10px 30px -14px rgba(13, 24, 45, 0.55);
}
.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.result-label {
  font-size: 13px;
  font-weight: 600;
  color: #9db1d6;
  letter-spacing: 0;
}
.result-badge {
  font-size: 11px;
  font-weight: 700;
  color: #cfe0ff;
  background: rgba(120, 160, 255, 0.16);
  border: 1px solid rgba(140, 175, 255, 0.28);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.result-main {
  margin-top: 4px;
  font-size: 38px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.result-main.is-warn { color: #ffb27a; }
.result-sub {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #a9bcdc;
  font-variant-numeric: tabular-nums;
}
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.result-cell {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 9px 11px;
}
.result-cell span {
  display: block;
  font-size: 11.5px;
  color: #93a8cd;
  letter-spacing: 0;
}
.result-cell b {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.result-cell b i {
  display: block;
  margin-top: 1px;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  color: #8fa4c9;
  letter-spacing: 0;
}
.result-status {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 12.5px;
  color: #a9bcdc;
  font-weight: 600;
}
.result-status b { color: #fff; }

/* ───────── 폼 ───────── */

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field { display: block; }
.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 5px;
  letter-spacing: 0;
}
.field input,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 13px;
  font-size: 17px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: #f6f8fc;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus,
.field textarea:focus { border-color: var(--accent); background: #fff; }
.field input[type="date"],
.field input[type="time"] { text-align: left; padding-right: 8px; }
.field-area textarea {
  min-height: 118px;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
}
.field.is-hidden { display: none; }
.field + .field { margin-top: 10px; }

/* iOS 사파리 date/time 아이콘 정렬 */
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* 세그먼트 */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  padding: 5px;
  background: #f1f4fa;
  border-radius: 14px;
  margin-bottom: 12px;
}
.seg button {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.seg button span {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.seg button.is-on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.14);
}
.seg button.is-on span { color: var(--accent); }

/* 스위치 */
.switch-list { display: grid; gap: 8px; }
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 8px 14px;
  background: #f6f8fc;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.switch.is-on { border-color: var(--accent); background: var(--accent-soft); }
.switch-text { display: flex; flex-direction: column; }
.switch-text b { font-size: 15.5px; font-weight: 700; }
.switch-text em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.switch.is-on .switch-text em { color: #3f63c9; }
.switch-knob {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #cdd5e3;
  transition: background 0.15s;
}
.switch-knob::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.3);
  transition: transform 0.15s;
}
.switch.is-on .switch-knob { background: var(--accent); }
.switch.is-on .switch-knob::after { transform: translateX(20px); }

/* 빠른 버튼 */
.qty-hint { margin: 8px 0 0; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); }
.qty-hint b { color: var(--accent); }
.quick {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  margin-top: 10px;
}
.quick button {
  min-height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}
.quick button:active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* 칩 */
.chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1.5px solid var(--line-2);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 버튼 */
.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 1.5px solid var(--line-2);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn:active { transform: scale(0.995); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: #f4f6fb; }
.btn-danger { color: var(--danger); border-color: #f0c9c9; background: #fff7f7; }
.btn-stack { display: grid; gap: 8px; }

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #f1f4fa;
  color: var(--ink-2);
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
}

/* ───────── 배치별 종료 예정 ───────── */

.plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.plan-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  background: #f6f8fc;
  border-radius: 12px;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}
.plan-list li.is-current { background: var(--accent-soft); }
.plan-list .pl-name { font-weight: 700; color: var(--ink); }
.plan-list .pl-name small { font-weight: 600; color: var(--ink-3); margin-left: 6px; font-size: 12px; }
.plan-list .pl-time { font-weight: 700; color: var(--ink-2); text-align: right; }
.plan-list .pl-time small { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }

/* ───────── 달력 ───────── */

.cal-card { padding-bottom: 14px; }
.cal-head { margin-bottom: 8px; }
.cal-head h2 { font-size: 17px; color: var(--ink); }
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.cal-week .sun { color: #d05a5a; }
.cal-week .sat { color: #4a6ec9; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-cell {
  position: relative;
  min-height: 52px;
  padding: 6px 4px 5px;
  border: 0;
  border-radius: 11px;
  background: #f7f9fc;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
}
.cal-cell.is-empty { background: transparent; pointer-events: none; }
.cal-cell .cc-day {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.cal-cell.is-sun .cc-day { color: #cf5555; }
.cal-cell.is-sat .cc-day { color: #4361b5; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.is-selected { background: var(--navy); }
.cal-cell.is-selected .cc-day { color: #fff; }
.cal-cell.is-selected .cc-badge { background: rgba(255, 255, 255, 0.18); color: #fff; }
.cal-cell.has-memo::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f0a020;
}
.cc-bar {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: transparent;
}
.cc-bar.b-base { background: #4a86f7; }
.cc-bar.b-ot { background: #f2994a; }
.cc-bar.b-sat { background: #8b6cd8; }
.cc-bar.b-off { background: #d5dbe6; }
.cc-badge {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 5px;
  background: #e6ecf7;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
}
.cal-legend span { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.dot-base { background: #4a86f7; }
.dot-ot { background: #f2994a; }
.dot-sat { background: #8b6cd8; }
.dot-off { background: #d5dbe6; }
.dot-memo { background: #f0a020; border-radius: 50%; }

/* 날짜 패널 */
.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.day-head h2 { font-size: 18px; }
.day-head .day-mode {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2fa;
  color: var(--ink-2);
}
.day-mode.m-base { background: #e8efff; color: #2559d6; }
.day-mode.m-ot { background: #fdf0e3; color: #a35a13; }
.day-mode.m-sat { background: #f1ecff; color: #6a4bc4; }
.day-mode.m-off { background: #f0f2f6; color: #7b8598; }

.day-hours {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin: 0 0 12px;
}
.mode-picks {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 4px;
}
.mode-picks button {
  min-height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
}
.mode-picks button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.batch-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.batch-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  background: #f6f8fc;
  border: 1.5px solid transparent;
  border-radius: 12px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.batch-row.has-memo { border-color: #f5d9a8; background: #fffbf2; }
.batch-row .br-name { display: block; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.batch-row .br-time { display: block; margin-top: 1px; font-size: 12.5px; color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.batch-row .br-memo {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: #96660f;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.batch-row .br-edit { font-size: 12px; color: var(--ink-3); font-weight: 700; white-space: nowrap; }
.empty-note {
  padding: 14px;
  border-radius: 12px;
  background: #f7f9fc;
  color: var(--ink-3);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}

/* ───────── 설정 ───────── */

.timetable { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.timetable th {
  text-align: left;
  font-weight: 700;
  color: var(--ink-2);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  width: 90px;
}
.timetable td { padding: 8px 0 8px 8px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.timetable tr:last-child th, .timetable tr:last-child td { border-bottom: 0; }

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--ink-3); font-weight: 600; }
.kv b { font-weight: 700; font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.steps { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); line-height: 1.65; }
.steps b { color: var(--ink); }

.foot { text-align: center; font-size: 12px; color: var(--ink-3); margin: 18px 0 0; }

/* ───────── 하단 탭 바 ───────── */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #98a2b3;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.tab.is-active { color: var(--accent); }
.tab svg { display: block; }

/* ───────── 메모 시트 ───────── */

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-wrap.is-hidden { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 16, 30, 0.45);
  backdrop-filter: blur(2px);
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-b));
  box-shadow: 0 -8px 30px rgba(9, 16, 30, 0.25);
  animation: sheet-up 0.18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-grabber {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: #d9dfe9;
  margin: 0 auto 10px;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.sheet-head h3 { font-size: 17px; }
.sheet-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.sheet #sheet-batch-field { margin-bottom: 10px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 16px; }

/* ───────── 토스트 ───────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  transform: translate(-50%, 12px);
  z-index: 80;
  max-width: 88vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.92);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  .result-main { font-size: 32px; }
  .quick button { font-size: 13px; min-height: 44px; }
  .mode-picks button { font-size: 12px; }
}

@media (prefers-color-scheme: dark) {
  /* 생산 라인 조명이 어두운 곳에서도 보이도록: 배경만 살짝 어둡게 */
  :root {
    --bg: #0b1220;
    --card: #131c2e;
    --ink: #f2f5fb;
    --ink-2: #c2ccdf;
    --ink-3: #8b97ad;
    --line: #24304a;
    --line-2: #33415f;
    --accent: #4d80ff;
    --accent-soft: #1b2b4d;
  }
  .field input, .field textarea, .switch, .plan-list li, .batch-row, .empty-note,
  .seg, .chip, .btn, .icon-btn, .cal-cell, .quick button, .mode-picks button,
  .tabbar { background-color: #182233; }
  .seg button.is-on { background: #24314a; }
  .cal-cell.is-selged { background: var(--navy); }
  .batch-row.has-memo { background: #2a2113; border-color: #6b5220; }
  .tabbar { background: rgba(15, 23, 38, 0.94); }
  .sheet { background: #131c2e; }
  .btn-danger { background: #2a1518; border-color: #5d2a2a; }
}
