/* ─────────────────────────────────────────────────────────────
   생산현황 관리 시스템 — MES/POP 계열 화면 디자인
   어두운 좌측 내비 + 밝은 작업영역, 숫자가 먼저 읽히는 조밀한 표.
   ───────────────────────────────────────────────────────────── */
:root {
  --bg: #f4f5ef;
  --panel: #ffffff;
  --panel-2: #f7f8f3;
  --line: #dfe5dc;
  --line-strong: #c3cec0;
  --text: #18231f;
  --muted: #6e7973;
  --accent: #166b52;
  --accent-soft: #e5f1e9;
  --lime: #d7f34a;
  --nav: #10241d;
  --nav-2: #18392d;
  --nav-text: #c9d7ce;
  --ok: #167052;
  --ok-soft: #e4f4e9;
  --warn: #b45309;
  --warn-soft: #fff3e2;
  --danger: #c0271f;
  --danger-soft: #fdecea;
  --radius: 9px;
  --shadow: 0 1px 2px rgba(16, 45, 32, .05), 0 8px 24px rgba(16, 45, 32, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Pretendard', 'Malgun Gothic', '맑은 고딕', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

/* ── 전체 뼈대: 좌측 내비 + 본문 ───────────────────────────── */
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } }

.sidebar {
  background: linear-gradient(180deg, var(--nav) 0%, var(--nav-2) 100%);
  color: var(--nav-text); padding: 16px 12px; position: sticky; top: 0; height: 100vh;
}
@media (max-width: 900px) { .sidebar { position: static; height: auto; } }
.sidebar .brand {
  display: flex; align-items: center; gap: 9px; color: #fff;
  font-weight: 800; font-size: 15px; letter-spacing: -.3px; padding: 6px 8px 14px;
}
.sidebar .brand img { height: 34px; width: auto; display: block; }
.sidebar .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px rgba(215,243,74,.7); }
.sidebar .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #64748b; padding: 12px 10px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 8px;
  color: var(--nav-text); font-size: 13.5px; font-weight: 600; margin-bottom: 2px; transition: .12s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.on { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(22, 107, 82, .35); }
.sidebar .foot { margin-top: 18px; padding: 10px; font-size: 11.5px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

.main { min-width: 0; display: flex; flex-direction: column; }

/* ── 상단바 ────────────────────────────────────────────────── */
header.top {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
header.top h1 { font-size: 16px; margin: 0; font-weight: 800; letter-spacing: -.3px; }
header.top .spacer { flex: 1; }
header.top nav { display: flex; align-items: center; gap: 14px; }
header.top nav a { color: var(--muted); font-size: 13.5px; font-weight: 600; }
header.top nav a:hover { color: var(--accent); }

.wrap { max-width: 1800px; margin: 0 auto; padding: 18px 22px 40px; width: 100%; }

/* ── 버튼 ──────────────────────────────────────────────────── */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  padding: 8px 14px; transition: .12s; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(22,107,82,.25); }
.btn-primary:hover { background: #0f573f; border-color: #0f573f; color: #fff; }
.btn-danger { color: var(--danger); border-color: #f0c5c1; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ── 입력 ──────────────────────────────────────────────────── */
input[type=text], input[type=password], input[type=date], input[type=number], textarea, select {
  font: inherit; width: 100%; padding: 8px 11px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
input[readonly] { background: var(--panel-2); color: var(--muted); }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 700; }
.field { margin-bottom: 14px; }

/* ── 카드 ──────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: -.2px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }

/* ── 상태 표시 ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.badge.gray { background: #edf0e9; color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
code { background: #edf0e9; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ── 목록(보고) ────────────────────────────────────────────── */
.meeting-list { display: flex; flex-direction: column; gap: 5px; }
.meeting-item {
  display: flex; align-items: center; gap: 14px; min-width: 0;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  transition: .12s;
}
.meeting-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.meeting-item h3 {
  margin: 0; font-size: 14.5px; color: var(--text); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46%;
}
.meeting-item .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meeting-item .grow { flex: 1; min-width: 0; }
.row-del {
  border: none; background: transparent; color: var(--muted);
  padding: 4px 8px; border-radius: 6px; font-size: 15px; line-height: 1; opacity: 0; transition: .12s;
}
.meeting-item:hover .row-del, .row-del:focus { opacity: 1; }
.row-del:hover { background: var(--danger-soft); color: var(--danger); }
@media (max-width: 700px) {
  .row-del { opacity: 1; }
  .meeting-item { flex-wrap: wrap; gap: 6px 10px; }
  .meeting-item h3 { max-width: 100%; width: 100%; }
}

/* ── 새 보고 폼 ────────────────────────────────────────────── */
.new-meeting {
  display: grid; grid-template-columns: minmax(0, 3fr) 180px 190px;
  grid-template-areas: "title date submit" "attendees attendees submit";
  gap: 12px; align-items: start;
}
.new-meeting .field { margin: 0; }
.new-meeting .f-title { grid-area: title; }
.new-meeting .f-date { grid-area: date; }
.new-meeting .f-attendees { grid-area: attendees; }
.new-meeting .f-attendees textarea { resize: vertical; min-height: 62px; line-height: 1.5; }
.new-meeting .f-submit {
  grid-area: submit; align-self: stretch; justify-content: center; text-align: center;
  font-size: 15px; line-height: 1.45; margin-top: 21px;
}
@media (max-width: 760px) {
  .new-meeting { grid-template-columns: 1fr 1fr;
    grid-template-areas: "title title" "date date" "attendees attendees" "submit submit"; }
  .new-meeting .f-submit { margin-top: 0; padding: 14px; }
}

/* ── 사진 검토 화면 ────────────────────────────────────────── */
.workspace { display: grid; grid-template-columns: 190px minmax(340px, 1.1fr) minmax(360px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .workspace { grid-template-columns: 1fr; } }

.thumbs { display: flex; flex-direction: column; gap: 10px; max-height: 78vh; overflow-y: auto; }
@media (max-width: 1100px) { .thumbs { flex-direction: row; overflow-x: auto; } }
.thumb { border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--panel); cursor: pointer; position: relative; flex: 0 0 auto; }
.thumb.active { border-color: var(--accent); }
.thumb img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.thumb .n { position: absolute; top: 4px; left: 4px; background: rgba(15,29,51,.75); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.thumb .st { position: absolute; bottom: 4px; right: 4px; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,.92); }

.viewer { position: relative; background: #131c2b; border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 300px; }
.viewer img { max-width: 100%; max-height: 72vh; display: block; }
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.editor { display: flex; flex-direction: column; gap: 10px; }
.editor textarea { min-height: 26vh; max-height: 42vh; font-family: 'D2Coding', 'Consolas', 'Malgun Gothic', monospace; font-size: 13.5px; line-height: 1.75; resize: vertical; }

.issues { display: flex; flex-direction: column; gap: 6px; max-height: 26vh; overflow-y: auto; }
.issue { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13.5px; }
.issue:hover { border-color: var(--accent); }
.issue .from { color: var(--warn); font-weight: 700; }
.issue .to { color: var(--ok); font-weight: 700; }
.issue .why { color: var(--muted); font-size: 12px; flex: 1; }
.issue.kind-broken { background: var(--warn-soft); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); background: var(--panel); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.fold > summary { list-style: none; cursor: pointer; padding: 11px 16px; display: flex; align-items: center; gap: 10px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: '▾'; color: var(--muted); transition: .15s; }
.fold:not([open]) > summary::before { transform: rotate(-90deg); }
.fold > summary h2 { margin: 0; font-size: 14px; font-weight: 800; }
.fold > summary .spacer { flex: 1; }
.fold[open] > summary { border-bottom: 1px solid var(--line); }

/* ── 알림 / 로딩 ───────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #16202e; color: #fff; padding: 11px 18px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.28); opacity: 0; pointer-events: none; transition: .2s;
  z-index: 100; max-width: 90vw; font-size: 13.5px; font-weight: 600;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.btn .spinner, button .spinner { border-color: rgba(22,107,82,.25); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 모달 ──────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(12,20,34,.6); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 22px; max-width: 380px; width: 100%; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.modal-box img { border: 1px solid var(--line); border-radius: 8px; }
.modal-box .field { text-align: left; }

.login-box { max-width: 360px; margin: 14vh auto; }

/* ── 생산현황판 ────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
@media (max-width: 1250px) { .layout { grid-template-columns: 1fr; } }
.side { position: sticky; top: 74px; }
.side .card + .card { margin-top: 12px; }

.tabs { display: flex; gap: 4px; margin: 4px 0 0; flex-wrap: wrap; }
.tab {
  padding: 9px 18px; border: 1px solid var(--line); border-bottom: none;
  border-radius: 9px 9px 0 0; background: #e3e8f0; cursor: pointer; font-weight: 700;
  color: var(--muted); font-size: 13.5px;
}
.tab.on { background: var(--panel); color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.tab .n { font-weight: 500; font-size: 11.5px; margin-left: 6px; opacity: .8; }

.sum { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.sum .d {
  border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px;
  padding: 8px 11px; background: var(--panel); box-shadow: var(--shadow);
}
  .sum .d b { display: block; font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.sum .d .v { font-size: 20px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.sum .d .s { font-size: 11.5px; color: var(--muted); }
.sum .d.low { border-left-color: var(--danger); }
.sum .d.low .v { color: var(--danger); }
.sum .d.none { border-left-color: var(--line-strong); }
.sum .d.none .v { color: #9aa6b8; font-weight: 600; font-size: 16px; }

.board-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
table.board { border-collapse: separate; border-spacing: 0; font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.board th, table.board td { border-right: 1px solid #e6ebf2; border-bottom: 1px solid #eef1f6; padding: 4px 7px; text-align: center; }
table.board thead th { background: #edf1e9; position: sticky; top: 0; z-index: 2; font-size: 11.5px; font-weight: 800; color: #315044; border-bottom: 1px solid var(--line-strong); }
table.board thead tr:first-child th { background: #e4ebe1; }
table.board tbody tr:nth-child(even) { background: #fafbfd; }
table.board tbody tr:hover { background: var(--accent-soft); }
table.board .eq { position: sticky; left: 0; width:72px; min-width:72px; background: #f2f5fa; font-weight: 800; z-index: 3; text-align: left; cursor: pointer; }
table.board tbody tr:hover .eq { background: #e5f1e9; color: var(--accent); }
table.board .who { position: sticky; left: 72px; width:92px; min-width:92px; background: #f7f9fc; z-index: 3; color: var(--muted); white-space:nowrap; }
table.board tbody tr:hover .who { background: #eaf1ff; }
table.board td.item { text-align: left; max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: #3b4a61; }
table.board td.miss { color: #c3cbd8; }
table.board td.under { color: var(--danger); font-weight: 800; background: rgba(192,39,31,.06); }
table.board td.over { color: var(--ok); font-weight: 800; }
table.board tr.sep td, table.board tr.sep th { border-top: 2px solid var(--line-strong); }
/* 보드 한 장에 표가 두 덩어리인 경우(LP-QC-RT)의 구분 줄 */
table.board tr.band td { background: var(--head-bg, #eef2f7); color: var(--ink, #33445c); font-weight: 700;
  text-align: left; padding: 6px 10px; border-top: 2px solid var(--line-strong); }
table.board .daygroup { border-left: 2px solid var(--line-strong); }

.photos { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 0; }
.photos figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); width: 260px; box-shadow: var(--shadow); }
.photos img { width: 100%; display: block; cursor: zoom-in; aspect-ratio: 4/3; object-fit: cover; }
.photos figcaption { padding: 6px 9px; font-size: 12px; color: var(--muted); }

#zoom { position: fixed; inset: 0; background: rgba(8,12,20,.94); display: none; align-items: center; justify-content: center; z-index: 80; }
#zoom.on { display: flex; }
#zoom img { max-width: 96vw; max-height: 92vh; }

/* ── 우측 관리 패널 ────────────────────────────────────────── */
.ptabs { display: flex; gap: 4px; margin-bottom: 12px; }
.ptab {
  flex: 1; text-align: center; padding: 8px 6px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--panel-2); cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.ptab.on { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(22,107,82,.3); }
.kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi div { border: 1px solid var(--line); border-radius: 9px; padding: 9px 8px; text-align: center; background: var(--panel-2); }
.kpi b { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.kpi span { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .short { background: var(--danger-soft); border-color: #f3cfcb; }
.kpi .short span { color: var(--danger); }
.plist { max-height: 46vh; overflow-y: auto; font-size: 12.5px; border: 1px solid var(--line); border-radius: 8px; }
.plist table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.plist th { position: sticky; top: 0; background: #edf1e9; font-size: 11px; padding: 6px; text-align: right; font-weight: 800; color: #315044; }
.plist th:first-child, .plist td:first-child { text-align: left; }
.plist td { padding: 5px 6px; border-bottom: 1px solid #eef1f6; text-align: right; }
.plist tr:nth-child(even) td { background: #fafbfd; }
.plist td.short { color: var(--danger); font-weight: 800; }
.plist td.ok { color: var(--ok); }
.plist input { width: 68px; padding: 3px 6px; font-size: 12.5px; text-align: right; }

/* ── 세로가 짧은 화면 ──────────────────────────────────────── */
@media (max-height: 850px) {
  .editor textarea { min-height: 19vh; max-height: 30vh; }
  .issues { max-height: 19vh; }
  .workspace .card-head { padding: 8px 14px; }
  .viewer img { max-height: 52vh; }
  .toolbar { margin-bottom: 8px; }
}
@media (max-width: 700px) {
  header.top { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  header.top h1 { font-size: 15px; }
  header.top nav { width: 100%; gap: 12px; }
  .wrap { padding: 12px; }
  .card-body { padding: 14px; }
  .sum { grid-template-columns: repeat(3, 1fr); }
  button, .btn { padding: 10px 13px; }
}

/* ── 참고 화면 스타일: 짙은 그린 + 라임 포인트 ─────────────── */
.settings-tab.active, .subtab.active { box-shadow: inset 0 -3px 0 var(--lime); }
.tab.on { box-shadow: inset 0 3px 0 var(--lime); }
.sum .d { border-left-color: var(--accent); }
table.board thead th { background: #edf1e9; color: #315044; }
table.board thead tr:first-child th { background: #e4ebe1; }
table.board tbody tr:nth-child(even) { background: #fbfcf9; }
.plist th { background: #edf1e9; color: #315044; }
