/* ─────────────────────────────────────────────────────────────
   금형 MES 웹 - 관리자 화면 (PC 먼저, 태블릿도 됨)
   색은 VB 프로그램과 맞춤 : 머리 #34495e, 입력칸 연노랑, 읽기 회색
   ───────────────────────────────────────────────────────────── */
:root {
  --head: #34495e; --head-dark: #2c3e50; --bg: #f3f5f8; --line: #d5dbe3; --text: #1f2933; --muted: #5f6b7a;
  --primary: #2962af; --edit: #fffff0; --ro: #f0f0f0; --sel: #cfe2ff; --dirty: #fff5d6; --new: #e9f7ef; --del: #fde2e1;
  --radius: 6px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "맑은 고딕", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 14px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f4f7fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: bold; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.55); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.12); }
.btn.extra { color: #00468c; border-color: #9fb8d8; }
.btn.icon { font-size: 18px; min-width: 38px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, .menu button:focus-visible { outline: 3px solid #f1c40f; outline-offset: 1px; }

.app { display: grid; grid-template-columns: 210px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.top { grid-column: 1 / 3; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; background: var(--head); color: #fff; padding: 6px 12px; }
.brand { font-size: 17px; white-space: nowrap; }
.brand small { font-weight: normal; opacity: .8; margin-left: 4px; }
.spacer { flex: 1; }
.user { font-weight: bold; white-space: nowrap; }
#menuToggle { display: none; background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }

.menu { background: #fff; border-right: 1px solid var(--line); padding: 0 0 8px; overflow-y: auto; position: sticky; top: 46px; height: calc(100vh - 46px); }
/* 메뉴 묶음 제목 : 붉은 띠로 하위 메뉴와 구분 (경신정공 웹과 같은 모양) */
.menu h3 { margin: 8px 0 2px; padding: 7px 16px; font-size: 14px; font-weight: bold; color: #fff; background: #b3261e; border-left: 4px solid #7f1d1d; letter-spacing: 1px; }
.menu h3:first-child { margin-top: 0; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 14px 8px 26px; cursor: pointer; font-size: 14px; color: var(--text, #222); }
.menu button:hover { background: #f0f3f8; }
.menu button[aria-current="page"] { background: #e3ecf8; font-weight: bold; color: #00468c; box-shadow: inset 3px 0 0 var(--primary); }

.content { min-width: 0; padding: 10px 14px 24px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.toolbar .title { font-size: 18px; font-weight: bold; margin-right: 10px; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 8px 0 2px; }
.filters label { font-weight: bold; }
.filters select, .filters input[type=search], .filters input[type=date] { min-height: 32px; padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.filters select { min-width: 220px; }
.chk { display: inline-flex; gap: 4px; align-items: center; font-weight: normal !important; }
.help { color: var(--muted); margin: 4px 0 8px; font-size: 13px; }

/* ── 편집 표 ── */
.grid-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-height: calc(100vh - 210px); }
.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.grid th, .grid td { border-right: 1px solid #e3e7ed; border-bottom: 1px solid #e3e7ed; padding: 0; height: 30px; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--head); color: #fff; font-weight: bold; padding: 4px 6px; cursor: pointer; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid thead th.req::after { content: " *"; color: #ffd36b; }
.grid thead th.sorted-asc::after { content: " ▲"; font-size: 10px; }
.grid thead th.sorted-desc::after { content: " ▼"; font-size: 10px; }
.grid thead th.req.sorted-asc::after { content: " * ▲"; }
.grid thead th.req.sorted-desc::after { content: " * ▼"; }
.grid .c-sel { width: 30px; text-align: center; }
.grid td.ro { background: var(--ro); padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid td.num, .grid td .num { text-align: right; }
.grid td input, .grid td select { width: 100%; height: 29px; border: 0; background: var(--edit); padding: 0 5px; border-radius: 0; }
.grid td input:focus, .grid td select:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: #fff; }
.grid td input[type=checkbox] { width: 18px; height: 18px; display: block; margin: 0 auto; background: none; }
.grid tr.cur td { box-shadow: inset 0 2px 0 var(--primary), inset 0 -2px 0 var(--primary); }
.grid tr.st-새 td.c-sel { background: var(--new); }
.grid tr.st-수정 td.c-sel { background: var(--dirty); }
.grid tr.st-삭제 td { text-decoration: line-through; opacity: .5; }
.grid tr.colored td input, .grid tr.colored td select { background: transparent; }
.grid tbody tr:hover td.ro { filter: brightness(.97); }
.grid-foot { display: flex; gap: 12px; padding: 6px 2px; color: var(--muted); font-size: 13px; }

/* ── 공정계획 / 작업지시 ── */
.split { display: grid; grid-template-columns: minmax(380px, 40%) 1fr; gap: 10px; align-items: start; }
.panel-title { font-weight: bold; padding: 6px 8px; background: #e9eef5; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.list { border-collapse: collapse; width: 100%; background: #fff; }
.list th { position: sticky; top: 0; background: var(--head); color: #fff; padding: 5px 6px; white-space: nowrap; text-align: center; }
.list td { border-bottom: 1px solid #e3e7ed; padding: 5px 6px; }
.list td.num { text-align: right; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: #f4f7fb; }
.list tbody tr.cur { background: var(--sel); }
.list tbody tr.no-rout td { color: #c0392b; }
.list tbody tr.all-done { background: #e2efda; }
.list-wrap { max-height: calc(100vh - 230px); overflow: auto; border: 1px solid var(--line); }

/* ── 대화상자 ── */
.dlg { border: 0; border-radius: 10px; padding: 0; width: min(460px, calc(100vw - 24px)); }
.dlg.wide { width: min(760px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg-body { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.dlg-body h2 { margin: 0; font-size: 18px; }
.dlg-msg { margin: 0; color: var(--muted); white-space: pre-line; }
.fields { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; align-items: center; }
.fields label { text-align: right; font-weight: bold; }
.fields input, .fields select { min-height: 34px; padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.fields input[type=checkbox] { justify-self: start; width: 20px; height: 20px; min-height: 0; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; font-family: Consolas, monospace; font-size: 13px; }
.dlg-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 60; max-width: min(520px, calc(100vw - 36px)); padding: 10px 16px; border-radius: 8px; color: #fff; background: #1e6b3a; box-shadow: 0 4px 14px rgba(0,0,0,.2); font-weight: bold; }
.toast.err { background: #b03a2e; }
.loading { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); z-index: 50; background: rgba(0,0,0,.75); color: #fff; padding: 6px 16px; border-radius: 999px; }

/* ── 좁은 화면 (태블릿 세로·휴대폰) : 메뉴를 접음 ── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  #menuToggle { display: inline-flex; }
  .menu { position: fixed; top: 46px; left: 0; bottom: 0; width: 240px; height: auto; z-index: 30; box-shadow: 4px 0 16px rgba(0,0,0,.2); transform: translateX(-105%); transition: transform .15s; }
  .menu.open { transform: none; }
  .split { grid-template-columns: 1fr; }
  .brand small, #userName { display: none; }
}
.list td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* ── 3차 화면 ── */
.ro-badge { background: #fff2cc; color: #7a5b00; border: 1px solid #f0d27a; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: bold; }
.sum-line { margin: 6px 2px; font-weight: bold; }
.gap { margin-top: 10px; }
.help.pad { padding: 14px; }
.list td.c, .list th.c { text-align: center; }
.list td.b, .b { font-weight: bold; }
.list .red, .red, .list tr.red td { color: #c0392b; }
.list .orange { color: #c86b00; }
.list tr.muted td { color: #8a94a3; }
.list-wrap.mid { max-height: calc(55vh - 60px); }
.list-wrap.short { max-height: 34vh; }
.sum-boxes { display: grid; grid-template-columns: repeat(5, minmax(110px, 170px)); gap: 8px; margin: 4px 0 10px; }
.sum-box { padding: 8px 10px; border-radius: 8px; background: #e8eef7; text-align: center; font-weight: bold; border: 1px solid #d0d9e6; }
.sum-box b { display: block; font-size: 22px; }
.sum-box.late { background: #f8cbad; } .sum-box.risk { background: #fff2cc; }
.pbar { position: relative; width: 120px; height: 18px; background: #fff; border: 1px solid #b8c0ca; border-radius: 4px; overflow: hidden; }
.pbar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: #4c91d6; }
.pbar .fill.r-지연 { background: #cd5c5c; } .pbar .fill.r-위험 { background: #f0a030; }
.pbar .tline { position: absolute; top: 0; bottom: 0; width: 2px; background: #000; }
.pbar span { position: absolute; inset: 0; text-align: center; font-size: 11px; font-weight: bold; line-height: 17px; }
.list tr[data-mold] { cursor: pointer; }

.try-top { display: grid; grid-template-columns: 1fr 340px; gap: 10px; align-items: start; }
.try-top .grid-wrap { max-height: 46vh; }
.photo-panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.photo { height: 300px; display: flex; align-items: center; justify-content: center; background: #f5f5f5; overflow: hidden; }
.photo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-btns { display: flex; gap: 6px; padding: 6px; flex-wrap: wrap; }

.gantt { display: flex; border: 1px solid var(--line); background: #fff; max-height: calc(100vh - 210px); overflow-y: auto; }
.g-left { flex: 0 0 260px; position: sticky; left: 0; background: #fff; border-right: 1px solid #b8c0ca; z-index: 1; }
.g-head { height: 40px; background: var(--head); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: bold; position: sticky; top: 0; }
.g-label { height: 26px; display: flex; gap: 8px; align-items: center; padding: 0 6px; border-bottom: 1px solid #eceef2; white-space: nowrap; overflow: hidden; font-size: 13px; }
.g-label b { flex: 0 0 auto; font-weight: normal; } .g-label span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.g-label.grp { background: #eef2f7; } .g-label.grp b { font-weight: bold; }
.g-right { flex: 1; overflow-x: auto; overflow-y: hidden; }
.g-right .bar { cursor: pointer; }

.perm-split { grid-template-columns: minmax(320px, 36%) 1fr; }
.perm-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 8px 0; }
.list.perm td { padding: 6px 8px; }
.list.perm input[type=checkbox] { width: 18px; height: 18px; }
@media (max-width: 900px) { .try-top { grid-template-columns: 1fr; } }
.try-top > div, .split > div { min-width: 0; }   /* 넓은 표가 옆 칸(사진)을 밀어내지 않게 - 표 안에서 가로 스크롤 */

/* 개발자요청 게시판 (경신정공 웹과 같은 모양) */
.req-mail { margin: 0 0 6px; color: var(--muted); }
.req-mail.notice { color: #b45309; font-weight: bold; }
.list.req-list td.req-title { max-width: 420px; }
.list td.st-new, .st.st-new { color: #b3261e; font-weight: bold; }
.list td.st-seen, .st.st-seen { color: #1546b3; font-weight: bold; }
.list td.st-doing, .st.st-doing { color: #b45309; font-weight: bold; }
.list td.st-done, .st.st-done { color: #15803d; font-weight: bold; }
.list td.st-hold { color: var(--muted); }
.req-dlg .dlg-body { max-height: calc(100vh - 40px); overflow-y: auto; }
.req-form { display: grid; grid-template-columns: 90px 1fr 90px 1fr; gap: 8px 10px; align-items: center; }
.req-form label { text-align: right; font-weight: bold; }
.req-form label small { font-weight: normal; color: var(--muted); }
.req-form .wide-i { grid-column: 2 / 5; }
.req-form input, .req-form select, .req-form textarea, .req-dlg textarea { min-height: 34px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; width: 100%; }
.req-form textarea { resize: vertical; }
.star { color: #c62828; }
.fld-head { margin-top: 4px; }
.fld-head small { color: var(--muted); }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed #b8c2cf; border-radius: 10px;
  padding: 16px; cursor: pointer; color: var(--muted); background: #fff; text-align: center; }
.drop:hover, .drop.over { border-color: var(--primary); background: #f3f7fd; }
.drop.has { border-style: solid; border-color: #15803d; background: #f2fbf4; color: var(--text); }
.drop-ico { font-size: 22px; color: var(--primary); }
.drop-text b { color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn.big { padding: 6px 24px; font-size: 15px; }
.btn.danger { color: #b03a2e; border-color: #e0a59e; }
.req-view { border-collapse: collapse; width: 100%; }
.req-view th { width: 110px; text-align: left; background: #f1f4f8; padding: 6px 10px; border: 1px solid var(--line); }
.req-view td { padding: 6px 10px; border: 1px solid var(--line); }
.req-h { font-size: 15px; margin: 8px 0 0; }
.req-body { white-space: pre-wrap; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: #fbfcfe; min-height: 60px; }
.req-ans-top { display: flex; gap: 8px; align-items: center; }
.req-ans-top select { min-height: 32px; border: 1px solid var(--line); border-radius: var(--radius); padding: 2px 6px; }
@media (max-width: 700px) {
  .req-form { grid-template-columns: 80px 1fr; }
  .req-form .wide-i { grid-column: 2; }
}
