/* 생산일정 — 공장 게시판처럼 한눈에. 기계(행) × 날짜(열) 격자, 칸 안의 일정은 공정 색 띠로 구분.
   색: 차가운 강철 회색 바탕 + 동원바이오 클로버 초록 하나. 공정 색은 의미 색이라 강조색과 따로 둡니다. */
:root {
  --bg: #f3f5f4;
  --panel: #ffffff;
  --line: #d9dfdc;
  --line-strong: #b9c3bf;
  --fg: #17201c;
  --muted: #5d6b65;
  --accent: #2e7d4f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1e8;
  --today: #fff8e1;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(20, 35, 28, .08), 0 4px 14px rgba(20, 35, 28, .06);

  /* 공정 색 */
  --t-weigh: #c77d12;   /* 칭량 */
  --t-mix: #2f6fb5;     /* 혼합 */
  --t-tablet: #2e7d4f;  /* 타정 */
  --t-pack: #7a4fb0;    /* 포장·충전 */
  --t-clean: #4f8a8b;   /* 청소 */
  --t-fix: #b3442e;     /* 정비 */
  --t-etc: #7b8580;

  --f-body: "IBM Plex Sans KR", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, "Consolas", monospace;
  --machine-col: 150px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --panel: #1a211e; --line: #2c3632; --line-strong: #3d4a45;
    --fg: #e6ece9; --muted: #95a39d; --accent: #5fbf86; --accent-ink: #0d1a12; --accent-soft: #1f3529;
    --today: #2b2716; --danger: #ef7d73; --shadow: 0 1px 2px rgba(0,0,0,.4);
    --t-weigh: #e0a24a; --t-mix: #6aa2e0; --t-tablet: #5fbf86; --t-pack: #b08ae0; --t-clean: #7fbcbd; --t-fix: #e57a62; --t-etc: #9aa49f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111614; --panel: #1a211e; --line: #2c3632; --line-strong: #3d4a45;
  --fg: #e6ece9; --muted: #95a39d; --accent: #5fbf86; --accent-ink: #0d1a12; --accent-soft: #1f3529;
  --today: #2b2716; --danger: #ef7d73; --shadow: 0 1px 2px rgba(0,0,0,.4);
  --t-weigh: #e0a24a; --t-mix: #6aa2e0; --t-tablet: #5fbf86; --t-pack: #b08ae0; --t-clean: #7fbcbd; --t-fix: #e57a62; --t-etc: #9aa49f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--f-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 24px;
}
h1, h2 { margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }
.grow { flex: 1; }
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.err { color: var(--danger); margin: 0; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 34px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .entry:focus-visible, .cell:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 28px; padding: 0 8px; font-size: 12px; }
.btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.date { padding: 0 8px; }
.seg { display: inline-flex; }
.seg > .btn { border-radius: 0; margin-left: -1px; }
.seg > .btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg > .btn:last-child { border-radius: 0 6px 6px 0; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.view { background: var(--line); color: var(--muted); }

/* 접속 */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 28px; }
.login-card .muted { margin: -6px 0 4px; }

/* 입력 */
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field small { font-weight: 400; }
.field input, .field select, .field textarea, .stepper input {
  width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel);
}
.field textarea { resize: vertical; }
.field.inline { display: inline-flex; align-items: center; gap: 6px; }
.field.inline input { width: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 머리 */
.top { padding-block: 14px 10px; display: grid; gap: 10px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background:
  radial-gradient(circle at 30% 30%, var(--accent) 0 28%, transparent 29%),
  radial-gradient(circle at 70% 30%, var(--accent) 0 28%, transparent 29%),
  radial-gradient(circle at 30% 70%, var(--accent) 0 28%, transparent 29%),
  radial-gradient(circle at 70% 70%, var(--accent) 0 28%, transparent 29%), var(--accent-soft); }
.brand h1 { font-size: 20px; }
.brand h1 .num { font-family: var(--f-num); font-weight: 600; }
.who { display: flex; align-items: center; gap: 8px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 2px 0 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* 격자 */
/* 표 안에서 위아래로도 굴러가야 날짜 머리가 붙어 있습니다 (overflow 가 있으면 페이지 기준 sticky 가 안 먹음) */
.board-wrap { overflow: auto; max-height: calc(100vh - 150px); min-height: 320px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.board { display: grid; min-width: max-content; }
.board .hcell, .board .mcell, .board .cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.hcell { position: sticky; top: 0; background: var(--panel); padding: 8px 10px; z-index: 2; }
.hcell.corner { left: 0; z-index: 3; display: flex; align-items: flex-end; font-size: 12px; color: var(--muted); font-weight: 600; }
.hcell .dow { font-size: 12px; color: var(--muted); font-weight: 600; }
.hcell .dnum { font-family: var(--f-num); font-size: 17px; font-weight: 600; }
.hcell .crew { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hcell .crew b { color: var(--fg); font-family: var(--f-num); }
.hcell.today { background: var(--today); }
.hcell.today .dow::after { content: " · 오늘"; color: var(--accent); }
.hcell.weekstart, .cell.weekstart { border-left: 2px solid var(--line-strong); }
.hcell.sat .dow { color: var(--t-mix); }
.mcell {
  position: sticky; left: 0; z-index: 1; background: var(--panel); padding: 10px; display: flex; flex-direction: column; justify-content: center;
  width: var(--machine-col);
}
.mcell b { font-size: 14px; }
.mcell span { font-size: 11px; color: var(--muted); }
.cell { padding: 6px; min-height: 84px; display: flex; flex-direction: column; gap: 5px; cursor: pointer; position: relative; min-width: 0; }
.cell.today { background: color-mix(in srgb, var(--today) 55%, transparent); }
.cell.can-edit:hover { background: var(--accent-soft); }
.cell.can-edit:hover:empty::after, .cell.can-edit:hover .add-hint { opacity: 1; }
.cell .add-hint { opacity: 0; font-size: 12px; color: var(--accent); margin-top: auto; }
.cell.can-edit:empty::after { content: "＋ 적기"; opacity: 0; font-size: 12px; color: var(--accent); margin: auto; }
.cell.drop { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--accent-soft); }

/* 일정 한 개 */
.entry {
  --c: var(--t-etc);
  text-align: left; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 5px;
  background: var(--panel); padding: 5px 7px; display: grid; gap: 1px; cursor: pointer; width: 100%;
}
.entry:hover { border-color: var(--c); }
.entry .ep { font-weight: 600; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.entry .et { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.entry .et .task { color: var(--c); font-weight: 700; }
.entry .et .crew { margin-left: auto; font-family: var(--f-num); font-size: 11px; color: var(--muted); white-space: nowrap; }
.entry .em { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.entry .st { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 3px; border: 1px solid currentColor; }
.entry.s-진행 { box-shadow: inset 0 0 0 1px var(--c); }
.entry.s-진행 .st { color: var(--accent); }
.entry.s-완료 { opacity: .55; }
.entry.s-완료 .ep { text-decoration: line-through; text-decoration-thickness: 1px; }
.entry.s-보류 { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--line) 6px 7px), var(--panel); }
.entry.s-보류 .st { color: var(--danger); }
.entry.dragging { opacity: .4; }
.t-칭량 { --c: var(--t-weigh); } .t-혼합 { --c: var(--t-mix); } .t-타정 { --c: var(--t-tablet); }
.t-포장 { --c: var(--t-pack); } .t-청소 { --c: var(--t-clean); } .t-정비 { --c: var(--t-fix); }

/* 휴대폰: 날짜별 목록 */
.day-list { display: none; gap: 12px; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.day.today { border-color: var(--accent); }
.day-head { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.day.today .day-head { background: var(--today); }
.day-head b { font-family: var(--f-num); font-size: 16px; }
.day-head .crew { margin-left: auto; font-size: 12px; color: var(--muted); }
.day-row { display: grid; grid-template-columns: 92px 1fr; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); align-items: start; }
.day-row:last-child { border-bottom: 0; }
.day-row .mn { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 4px; }
.day-row .items { display: grid; gap: 5px; min-width: 0; }
.day-row .add { justify-self: start; }
.day-empty { padding: 12px; color: var(--muted); font-size: 13px; }

.foot { margin-top: 10px; }

/* 대화상자 */
.dlg { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(540px, calc(100vw - 24px)); background: var(--panel); color: var(--fg); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(10, 20, 15, .45); }
.dlg-head, .dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.dlg-head { border-bottom: 1px solid var(--line); justify-content: space-between; }
.dlg-head h2 { font-size: 17px; }
.dlg-foot { border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-body { padding: 14px 16px; display: grid; gap: 12px; max-height: calc(100vh - 160px); overflow: auto; }
.range-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.chip { --c: var(--t-etc); border: 1px solid var(--line-strong); background: var(--panel); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.chip::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; }
.chip[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--panel)); font-weight: 600; }
.stepper { display: flex; }
.stepper .btn { border-radius: 0; min-width: 38px; }
.stepper .btn:first-child { border-radius: 6px 0 0 6px; }
.stepper .btn:last-child { border-radius: 0 6px 6px 0; }
.stepper input { border-radius: 0; text-align: center; font-family: var(--f-num); border-left: 0; border-right: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.status-seg { flex-wrap: wrap; }
.status-seg .btn { padding: 0 10px; }

.mach-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mach-list li { display: grid; grid-template-columns: auto 1fr 1fr auto auto auto; gap: 6px; align-items: center; }
.mach-list .mfac { min-height: 34px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); }
.factory-tabs .btn { min-width: 64px; font-weight: 600; }
.empty-factory { padding: 32px 16px; margin: 0; text-align: center; }
@media (display-mode: standalone) {
  .top, .login { padding-top: calc(env(safe-area-inset-top) + 12px); }
}
.mach-list li input[type="text"] { min-height: 34px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); min-width: 0; width: 100%; }
.mach-list li.off input[type="text"] { opacity: .5; }
.mach-list .mv { display: flex; flex-direction: column; }
.mach-list .mv .btn { min-height: 17px; padding: 0 6px; font-size: 10px; border-radius: 3px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

@media (max-width: 760px) {
  .board-wrap { display: none; }
  .day-list { display: grid; }
  .two { grid-template-columns: 1fr; }
  .mach-list li { grid-template-columns: auto 1fr auto; }
  .mach-list li .mnote { grid-column: 2 / 4; }
  .mach-list li .mfac { grid-column: 2; }
  .top-row { flex-wrap: wrap; }
  .factory-tabs { order: 3; width: 100%; }
  .factory-tabs .btn { flex: 1; min-height: 40px; font-size: 15px; }
  .foot { display: none; }
  #printBtn { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .entry, .cell, .btn { transition: background-color .12s, border-color .12s, opacity .12s; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  :root { --bg: #fff; --panel: #fff; --shadow: none; --today: #fff; }
  body { padding: 0; font-size: 11px; }
  .toolbar, .who, .foot, .day-list, .legend .hint, .factory-tabs { display: none !important; }
  .top { position: static; padding: 0 0 6px; }
  .board-wrap { display: block !important; overflow: visible; max-height: none; border-color: #999; box-shadow: none; }
  .board { min-width: 0; }
  .hcell, .mcell { position: static; }
  .cell { min-height: 60px; }
  .cell.can-edit:empty::after { content: none; }
  .entry { break-inside: avoid; }
}
