:root { --navy: #1e2b4a; }
body { background: #f4f6fa; font-size: .92rem; }
.bg-navy { background: var(--navy); }
.sidebar { width: 210px; min-height: calc(100vh - 56px); background: #fff; border-right: 1px solid #e5e7eb; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; } }
.sidebar .nav-link { color: #334155; padding: .35rem .6rem; border-radius: .35rem; font-size: .9rem; }
.sidebar .nav-link:hover { background: #eef2ff; }
.sidebar .nav-link.active { background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.sidebar .nav-link.disabled { color: #9ca3af; }
.sidebar .nav-link .badge { font-size: .65rem; font-weight: 400; }
.nav-group { font-size: .72rem; color: #64748b; font-weight: 700; margin: .8rem .6rem .2rem; letter-spacing: .03em; }
.main { min-width: 0; }
.page-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid #e5e7eb; border-radius: .6rem; padding: .9rem 1rem; height: 100%; }
.stat .label { color: #64748b; font-size: .8rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; }
.card { border-color: #e5e7eb; }
.table-sm td, .table-sm th { white-space: nowrap; vertical-align: middle; }
.table thead th { background: #f8fafc; font-weight: 600; color: #475569; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.site-list { max-height: calc(100vh - 220px); overflow-y: auto; }
.site-list .list-group-item { padding: .35rem .6rem; font-size: .85rem; }
.badge-verify-verified { background: #dcfce7; color: #166534; }
.badge-verify-review { background: #fee2e2; color: #991b1b; }
.badge-verify-unverified { background: #f1f5f9; color: #475569; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e2b4a, #2f4a7d); padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.row-protect { background: #fffbeb; }

/* 현장 신호등 */
.signal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.signal-card { display: block; background: #fff; border: 1px solid #e5e7eb; border-left: 5px solid #cbd5e1;
  border-radius: .5rem; padding: .55rem .7rem; color: inherit; text-decoration: none; min-width: 0; }
.signal-card:hover { box-shadow: 0 2px 6px rgba(15, 23, 42, .08); }
.signal-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; flex: none; margin-top: 5px; }
.signal-red { border-left-color: #dc2626; } .signal-red .signal-dot { background: #dc2626; } .signal-red .signal-reason { color: #b91c1c; }
.signal-yellow { border-left-color: #f59e0b; } .signal-yellow .signal-dot { background: #f59e0b; } .signal-yellow .signal-reason { color: #b45309; }
.signal-green { border-left-color: #16a34a; } .signal-green .signal-dot { background: #16a34a; } .signal-green .signal-reason { color: #15803d; }
.signal-done { border-left-color: #64748b; opacity: .75; }
.signal-idle .signal-reason { color: #64748b; }
.signal-border-red { border-left: 5px solid #dc2626; } .signal-border-yellow { border-left: 5px solid #f59e0b; }
.signal-border-green { border-left: 5px solid #16a34a; }
.prod-table .col-in { width: 92px; background: #f8fbff; }
.prod-table input.qty { text-align: right; padding: .1rem .35rem; }
.prod-table input.qty.is-dirty { background: #fef9c3; border-color: #eab308; }
.status-requested { background: #e0e7ff; color: #3730a3; }
.status-approved { background: #dcfce7; color: #166534; }
.status-shipped { background: #e2e8f0; color: #334155; }
.status-cancelled, .invoice-cancelled { background: #fee2e2; color: #991b1b; }
.invoice-issued { background: #dcfce7; color: #166534; }
.invoice-sheet { max-width: 860px; }
.sign-box { border: 1px solid #94a3b8; height: 56px; margin: 4px auto 0; max-width: 160px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; }

@media print {
  .navbar, .sidebar, .no-print, .alert { display: none !important; }
  body { background: #fff; }
  .main { padding: 0 !important; }
}

/* 생산계획 */
.plan-draft { background: #e0e7ff; color: #3730a3; }
.plan-active { background: #dcfce7; color: #166534; }
.plan-archived { background: #e2e8f0; color: #475569; }
.plan-items tr.change-major td:first-child { box-shadow: inset 3px 0 0 #dc2626; }
.plan-items tr.change-new td:first-child { box-shadow: inset 3px 0 0 #2563eb; }
.plan-items tr.change-minor td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.wo-grid td { min-width: 130px; font-size: .82rem; vertical-align: top; }
.cell-major { background: #fee2e2 !important; }
.cell-minor { background: #fef9c3 !important; }
.legend-box { display: inline-block; width: 12px; height: 12px; border: 1px solid #cbd5e1; vertical-align: middle; }
@media print {
  .work-order { font-size: 11px; }
  .work-order .stat { padding: .3rem .5rem; }
  .work-order .stat .value { font-size: 1.1rem; }
  .wo-grid td { min-width: 0; }
  .cell-major, .cell-minor { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* 자재 청구 상태 */
.req-requested { background: #e0e7ff; color: #3730a3; }
.req-ordered { background: #fef3c7; color: #92400e; }
.req-partial { background: #ffedd5; color: #9a3412; }
.req-received { background: #dcfce7; color: #166534; }
.req-cancelled { background: #fee2e2; color: #991b1b; }

/* 들어온 문서 */
.doc-uploaded { background: #e0e7ff; color: #3730a3; }
.doc-reading { background: #e0f2fe; color: #075985; }
.doc-read { background: #fef3c7; color: #92400e; }
.doc-failed { background: #fee2e2; color: #991b1b; }
.doc-applied { background: #dcfce7; color: #166534; }
.doc-discarded { background: #e2e8f0; color: #64748b; }
.doc-preview { overflow: hidden; }
.doc-preview img { width: 100%; display: block; }
.doc-preview iframe { width: 100%; height: 75vh; border: 0; }
.doc-lines td { vertical-align: top; }
body.mobile { font-size: 1rem; }

/* 보고서·차트 (dataviz 기본 팔레트: 1번 파랑, 2번 주황 — 검증 통과) */
.viz-root { --surface-1: #fcfcfb; --text-secondary: #52514e; --text-muted: #8a8984; --grid: #e7e6e2;
  --series-1: #2a78d6; --series-2: #eb6834; --plan: #52514e; }
.viz-chart { width: 100%; height: auto; display: block; }
.viz-grid { stroke: var(--grid); stroke-width: 1; }
.viz-base { stroke: #b9b8b2; }
.viz-tick { font-size: 11px; fill: var(--text-secondary); }
.viz-weekend { fill: #b42318; }
.viz-produced { fill: var(--series-1); }
.viz-shipped { fill: var(--series-2); }
.viz-plan { stroke: var(--plan); stroke-width: 2; stroke-dasharray: 4 2; }
.viz-hit { fill: transparent; }
.viz-hit:hover { fill: rgba(42, 120, 214, .06); }
.viz-legend { display: flex; gap: 14px; color: var(--text-secondary); }
.viz-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.viz-key.viz-produced { background: var(--series-1); }
.viz-key.viz-shipped { background: var(--series-2); }
.viz-key.viz-plan-key { height: 0; border-top: 2px dashed var(--plan); border-radius: 0; vertical-align: 3px; }
.viz-progress { flex: 1; min-width: 80px; height: 8px; background: #edece8; border-radius: 4px; overflow: hidden; }
.viz-progress span { display: block; height: 100%; background: #2a78d6; border-radius: 4px; }
.print-only { display: none; }
.report-note { white-space: pre-wrap; border: 1px solid #cbd5e1; padding: .5rem; min-height: 3rem; }
@media print {
  .print-only { display: block; }
  .report-sheet { font-size: 11px; }
  .report-sheet .stat { padding: .3rem .5rem; }
  .report-sheet .stat .value { font-size: 1.1rem; }
  .viz-root, .viz-progress, .viz-progress span { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-days { break-before: page; }
}

/* 부재 화면 현장 목록: 이름 클릭 = 고르기, 연필 = 수정(관리자) */
.site-row { display: flex; align-items: center; gap: .4rem; }
.site-row > a.stretched-link { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-row .site-edit { position: relative; z-index: 2; color: #64748b; padding: 0 .2rem; font-size: .8rem; }
.site-row .site-edit:hover { color: #1d4ed8; }
.site-row.active .site-edit { color: #fff; }

/* 안전서류 상태 */
.safety-red { background: #fee2e2; color: #991b1b; }
.safety-yellow { background: #fef3c7; color: #92400e; }
.safety-gray { background: #e2e8f0; color: #475569; }
.safety-green { background: #dcfce7; color: #166534; }

/* 9단계: 컷팅 막대, 몰드 단면 */
.cut-bar { display: flex; min-width: 260px; height: 20px; border-radius: 3px; overflow: hidden; gap: 2px; background: #fff; }
.cut-bar span { background: #2a78d6; color: #fff; font-size: 10px; line-height: 20px; text-align: center; overflow: hidden; white-space: nowrap; }
.cut-bar .cut-left { background: repeating-linear-gradient(45deg, #e7e6e2 0 4px, #f4f3ef 4px 8px); }
.mold-product { fill: #e7e6e2; stroke: #8a8984; }
.mold-mold { fill: #2a78d6; stroke: #1e5aa3; }
.mold-rib { fill: #a9cbf2; stroke: #2a78d6; }
.mold-bed { fill: #52514e; stroke: #333; }
@media print { .cut-bar span, .cut-bar .cut-left { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* 10단계: 판독 상태 */
.reading-pending { background: #fef3c7; color: #92400e; }
.reading-review { background: #fee2e2; color: #991b1b; }
.reading-applied { background: #dcfce7; color: #166534; }
.reading-rejected { background: #e2e8f0; color: #64748b; }
.zone-map { background: #fcfcfb; border: 1px solid #e7e6e2; border-radius: .4rem; }
