/* 제조 현장 관리 시연 — 재고·자재 현황판 + 휴대폰 작업일보 + 납기 알림.
   공통 바탕(4개 시연이 같은 값을 쓴다) → 이 시연의 화면 순서. 클래스에 ce- 접두사는 쓰지 않는다. */

:root {
  --canvas: #eef1f5;
  --surface: #ffffff;
  --sunken: #f6f8fa;
  --ink: #172033;
  --ink-2: #3a4457;
  --muted: #5e6878;
  --line: #dce1e8;
  --line-2: #ebeef3;
  --accent: #2457e6;
  --accent-deep: #1a43b8;
  --accent-soft: #e8eefd;
  --bad: #c8281c;
  --bad-bg: #fde8e6;
  --warn: #9a5706;
  --warn-bg: #fef1d6;
  --ok: #0b7a47;
  --ok-bg: #ddf5e7;
  --kakao: #fee500;
  --chat: #bacbdc;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  letter-spacing: -0.01em;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── 앱 머리 ───────────────────────────── */
.app-head {
  display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(14px, 2.4vw, 28px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 15px;
}
.brand-mark i { display: block; width: 14px; height: 14px; border: 3px solid #fff; border-radius: 3px; transform: rotate(45deg); }
.brand strong { display: block; font-size: 15px; font-weight: 750; line-height: 1.2; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.app-title { font-size: 15px; font-weight: 650; color: var(--ink-2); padding-left: 14px; border-left: 1px solid var(--line); }
.app-date { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* 처음 보는 사람을 위한 한 줄 안내 */
.guide {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 14px clamp(14px, 2.4vw, 28px) 0;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid #c8d6fb;
  border-radius: var(--r-md);
  color: #1d2f66;
  font-size: 13.5px;
}
.guide b { flex: none; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; }
.guide button { margin-left: auto; flex: none; border: 0; background: none; color: #1d2f66; font-size: 12.5px; text-decoration: underline; padding: 2px 4px; }

/* ── 화면 배치 ─────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  gap: 16px;
  padding: 14px clamp(14px, 2.4vw, 28px) 28px;
  align-items: start;
}
.main-col, .side-col { display: grid; gap: 16px; min-width: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-width: 0;
}
.panel-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; padding: 14px 16px 10px; }
.panel-head h2 { font-size: 16px; font-weight: 750; }
.panel-head p { font-size: 12.5px; color: var(--muted); }
.panel-head .seg { margin-left: auto; }

/* 오늘 요약: 칸 넷이 한 줄 띠 */
.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  margin: 0; padding: 0; list-style: none;
}
.kpis li { padding: 12px 16px; border-left: 1px solid var(--line-2); min-width: 0; }
.kpis li:first-child { border-left: 0; }
.kpis span { display: block; font-size: 12.5px; color: var(--muted); }
.kpis strong { display: block; font-size: 24px; font-weight: 750; line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpis small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpis .is-bad strong { color: var(--bad); }
.kpis .is-warn strong { color: var(--warn); }

/* ── 입고·출고 입력 ───────────────────── */
.move-form {
  display: flex; flex-wrap: wrap; align-items: end; gap: 10px;
  margin: 0 16px 12px; padding: 12px;
  background: var(--sunken); border: 1px solid var(--line-2); border-radius: var(--r-md);
  position: relative;
}
.field { display: grid; gap: 4px; min-width: 0; }
.field > span, .field legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0; }
.field select, .field input {
  height: 40px; padding: 0 10px; min-width: 0;
  border: 1px solid #cbd2dc; border-radius: var(--r-sm); background: #fff;
}
.field input[type="number"] { font-variant-numeric: tabular-nums; }
.field select:focus-visible, .field input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--bad); background: #fff8f7; }
.f-item { flex: 1 1 200px; }
.f-qty { flex: 0 1 120px; }
.f-qty input { width: 100%; text-align: right; }
.form-msg { flex-basis: 100%; font-size: 12.5px; min-height: 0; }
.form-msg:empty { display: none; }
.form-msg.is-error { color: var(--bad); }

/* 입고/출고 고르기 */
.seg { display: inline-flex; border: 1px solid #cbd2dc; border-radius: var(--r-sm); background: #fff; padding: 3px; gap: 2px; margin: 0; }
.seg label, .seg button { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span, .seg button {
  display: block; padding: 0 14px; height: 32px; line-height: 32px; border-radius: 5px; border: 0; background: none;
  font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.seg input:checked + span, .seg button[aria-selected="true"] { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 1px; }
fieldset.seg { min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: #fff; border-color: #cbd2dc; color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--ink-2); }

/* 처음 사용자 강조: 눌러 볼 곳에 링 */
.coach-ring { box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(36, 87, 230, .55); animation: ring 1.6s ease-in-out infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 3px #fff, 0 0 0 9px rgba(36, 87, 230, .18); } }

/* ── 재고 표 ───────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r-md); }
.table-wrap:focus-visible { outline-offset: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
thead th { background: var(--sunken); font-size: 12px; font-weight: 650; color: var(--muted); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.kind { display: inline-block; font-size: 11.5px; font-weight: 650; color: var(--muted); padding: 1px 7px; border-radius: 5px; background: var(--line-2); }
.kind.is-product { background: #eae6fb; color: #4a3aa7; }
.qty-cell strong { font-size: 15px; font-weight: 750; }
.qty-cell small { color: var(--muted); margin-left: 3px; font-size: 12px; }
.meter { display: block; width: 92px; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width .5s cubic-bezier(.2,.7,.2,1); }
.is-warn .meter i { background: #d98a0b; }
.is-bad .meter i { background: var(--bad); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
tr.flash td, tr.flash th { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { background: #fff6c2; } 100% { background: transparent; } }

/* 최근 입출고 기록 */
.log { list-style: none; margin: 10px 16px 14px; padding: 0; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.log li { display: flex; gap: 8px; align-items: baseline; }
.log time { flex: none; width: 40px; font-variant-numeric: tabular-nums; }
.log li > span:first-of-type { flex: none; white-space: nowrap; }
.log b { color: var(--ink-2); font-weight: 650; }
.log .in { color: var(--accent); font-weight: 700; }
.log .out { color: #7a3e9d; font-weight: 700; }
.log .auto { color: var(--ok); font-weight: 700; }

/* ── 생산 집계 ─────────────────────────── */
.sum-body { padding: 0 16px 16px; }
.sum-body table { border: 1px solid var(--line-2); border-radius: var(--r-md); border-collapse: separate; border-spacing: 0; overflow: hidden; }
.chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; height: 190px; padding: 18px 6px 0; border-bottom: 1px solid var(--line); margin: 0; list-style: none; }
.chart li { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart .val { font-size: 12px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.chart .bar { width: min(44px, 100%); display: flex; flex-direction: column-reverse; border-radius: 6px 6px 0 0; overflow: hidden; transition: height .6s cubic-bezier(.2,.7,.2,1); background: #c7d5f8; }
.chart .bar .good { background: #9db4ef; flex: 1 1 auto; }
.chart .bar .bad { background: var(--bad); flex: none; }
.chart li.is-today .bar .good { background: var(--accent); }
.chart-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; padding: 6px 6px 0; margin: 0; list-style: none; font-size: 12px; color: var(--muted); text-align: center; }
.chart-days .is-today { color: var(--ink); font-weight: 750; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.rate-bad { color: var(--bad); font-weight: 700; }

/* ── 휴대폰 틀 (작업일보) ─────────────── */
.phone-wrap { display: grid; justify-items: center; gap: 8px; }
.phone-cap { font-size: 12.5px; color: var(--muted); text-align: center; }
.phone {
  width: 322px; border-radius: 42px; padding: 10px;
  background: #1c2230;
  box-shadow: 0 1px 0 #3b4558 inset, 0 24px 48px -18px rgba(23, 32, 51, .45), 0 2px 6px rgba(23, 32, 51, .2);
}
.screen { position: relative; border-radius: 33px; overflow: hidden; background: #f4f6f9; min-height: 540px; display: flex; flex-direction: column; }
.status { display: flex; justify-content: space-between; align-items: center; padding: 12px 22px 4px; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.status svg { width: 42px; height: 11px; }
.notch { position: absolute; top: 9px; left: 50%; width: 82px; height: 22px; margin-left: -41px; border-radius: 12px; background: #1c2230; }
.m-head { padding: 8px 18px 10px; }
.m-head h3 { font-size: 19px; font-weight: 800; }
.m-head p { font-size: 12px; color: var(--muted); }
.m-form { display: grid; gap: 12px; padding: 4px 16px 16px; flex: 1; }
.m-card { background: #fff; border-radius: 14px; padding: 12px; display: grid; gap: 12px; box-shadow: 0 1px 2px rgba(23,32,51,.06); }
.m-form .field select { height: 42px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stepper { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; border: 1px solid #cbd2dc; border-radius: var(--r-sm); background: #fff; overflow: hidden; }
.stepper button { border: 0; background: var(--sunken); font-size: 18px; font-weight: 600; color: var(--ink-2); height: 42px; }
.stepper input { border: 0; height: 42px; width: 100%; text-align: center; font-weight: 700; font-size: 16px; padding: 0; border-radius: 0; }
.stepper input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: -2px; }
.workers { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.workers legend { margin-bottom: 6px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips span { display: block; padding: 7px 12px; border-radius: 999px; border: 1px solid #cbd2dc; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chips input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.m-save { width: 100%; height: 48px; border-radius: 12px; font-size: 15.5px; }
.m-recent { margin: 0; padding: 0 2px; list-style: none; font-size: 12px; color: var(--muted); display: grid; gap: 3px; }
.m-recent b { color: var(--ink-2); }
.m-toast {
  position: absolute; left: 14px; right: 14px; bottom: 16px;
  padding: 11px 14px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600;
  transform: translateY(14px); opacity: 0; transition: transform .25s, opacity .25s; pointer-events: none;
}
.m-toast.show { transform: none; opacity: 1; }

/* ── 납기 알림 (카톡 알림톡 미리보기) ──── */
.talk { border-radius: var(--r-lg); overflow: hidden; border: 1px solid #a9bccf; background: var(--chat); }
.talk-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #a9bdd1; font-size: 13.5px; font-weight: 700; color: #1d2633; }
.talk-head small { margin-left: auto; font-weight: 500; font-size: 11.5px; color: #3f4c5c; }
.talk-body { padding: 12px 10px 14px; display: grid; gap: 10px; max-height: 420px; overflow-y: auto; }
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; align-items: start; }
.avatar { width: 34px; height: 34px; border-radius: 12px; background: var(--ink); display: grid; place-items: center; }
.avatar i { width: 12px; height: 12px; border: 2.5px solid #fff; border-radius: 3px; transform: rotate(45deg); }
.msg-name { font-size: 11.5px; color: #33404f; margin-bottom: 3px; }
.card-msg { background: #fff; border-radius: 4px 12px 12px 12px; overflow: hidden; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.card-msg h3 { background: var(--kakao); padding: 8px 12px; font-size: 13px; font-weight: 800; color: #2a2300; }
.card-msg .msg-text { padding: 10px 12px 4px; font-size: 13px; line-height: 1.55; }
.card-msg dl { margin: 6px 12px 10px; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; }
.card-msg dt { color: var(--muted); }
.card-msg dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.card-msg .short { color: var(--bad); }
.card-msg .done { color: var(--ok); }
.card-msg .go { display: block; margin: 0 10px 10px; padding: 8px; border-radius: 6px; background: #f1f2f4; text-align: center; font-size: 12.5px; font-weight: 650; color: #2a2f38; }
.msg-time { font-size: 10.5px; color: #4a5868; margin-top: 3px; }
.msg.new .card-msg { animation: pop .45s cubic-bezier(.2,.8,.2,1.2); }
@keyframes pop { from { transform: translateY(8px) scale(.97); opacity: 0; } }

/* ── 반응형 ────────────────────────────── */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr) 330px; }
  .phone { width: 310px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
@media (max-width: 680px) {
  .app-title { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis li:nth-child(3) { border-left: 0; }
  .kpis li:nth-child(n+3) { border-top: 1px solid var(--line-2); }
  .side-col { grid-template-columns: minmax(0, 1fr); }
  .move-form .seg { flex: 1 1 100%; }
  .move-form .seg label { flex: 1; text-align: center; }
  .move-form .btn { flex: 1 1 100%; height: 44px; }
  .f-item { flex: 1 1 100%; }
  .f-qty { flex: 1 1 100%; }
  .chart { gap: 6px; height: 170px; }
  .chart-days { gap: 6px; }
  .guide { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .phone { width: 100%; max-width: 330px; padding: 8px; border-radius: 38px; }
  .screen { min-height: 0; }
  .app-date { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
