/* 한빛식품 MES 공통 스타일 */
:root {
  --navy: #1F3864; --navy-l: #D9E2F3; --line: #d5dbe5; --bg: #eef1f6; --text: #222; --muted: #777;
  --ok: #2E7D32; --ng: #C62828; --warn: #EF6C00; --info: #1565C0; --gray: #78909C;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Malgun Gothic', '맑은 고딕', 'Noto Sans KR', sans-serif; font-size: 13px; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }

/* 상단 */
.hb-top { height: 46px; background: var(--navy); color: #fff; display: flex; align-items: center; padding: 0 18px; gap: 16px; position: sticky; top: 0; z-index: 10; }
.hb-logo { font-weight: 700; font-size: 15px; }
.hb-logo small { font-weight: 400; opacity: .7; font-size: 12px; margin-left: 4px; }
.hb-sp { flex: 1; }
.hb-alarm { background: var(--ng); border-radius: 12px; padding: 3px 10px; font-size: 12px; font-weight: 700; animation: hb-blink 1.6s infinite; }
@keyframes hb-blink { 50% { opacity: .55; } }
.hb-user small { opacity: .75; }
.hb-logout { opacity: .85; font-size: 12px; border: 1px solid rgba(255,255,255,.4); border-radius: 3px; padding: 3px 9px; }
.hb-logout:hover { opacity: 1; background: rgba(255,255,255,.1); }

/* 메뉴 */
.hb-wrap { display: flex; min-height: calc(100vh - 46px); }
.hb-side { width: 236px; flex: none; background: #fff; border-right: 1px solid var(--line); padding: 8px 0 20px; }
.hb-side .hb-g { padding: 12px 16px 4px; font-weight: 700; color: var(--navy); font-size: 12.5px; }
.hb-side .hb-m, .hb-side .hb-m-home { display: block; padding: 6px 16px 6px 26px; color: #444; font-size: 12.5px; border-left: 3px solid transparent; }
.hb-side .hb-m-home { padding-left: 16px; font-weight: 700; color: var(--navy); }
.hb-side a.hb-m:hover { background: #f3f6fb; }
.hb-side .on { background: var(--navy-l); color: var(--navy); font-weight: 700; border-left-color: var(--navy); }
.hb-side .off { color: #b0b6c0; cursor: default; }
.hb-side .off em { white-space: nowrap; font-style: normal; font-size: 10.5px; border: 1px solid #d5d9e0; border-radius: 8px; padding: 0 5px; margin-left: 2px; }

/* 본문 */
.hb-main { flex: 1; min-width: 0; padding: 16px 20px 30px; }
.hb-title { margin-bottom: 12px; }
.hb-title h1 { font-size: 18px; color: var(--navy); }
.hb-crumb { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.hb-panel { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; margin-bottom: 12px; }
.hb-ph { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--navy); margin-bottom: 10px; }
.hb-empty { color: var(--muted); padding: 18px; text-align: center; }

/* 요약 카드 */
.hb-cards { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.hb-card { flex: 1; min-width: 150px; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 12px 16px; }
.hb-card .l { color: var(--muted); font-size: 12px; }
.hb-card .v { font-size: 24px; font-weight: 700; color: var(--navy); margin-top: 3px; }
.hb-card .v.ng { color: var(--ng); }

/* 조회조건 */
.hb-search .hb-sgrid { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.hb-search.closed .hb-sgrid { display: none; }
.hb-sf { display: flex; align-items: center; gap: 6px; }
.hb-sf > label { color: #555; font-size: 12px; min-width: 54px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  border: 1px solid #c3cad6; border-radius: 3px; height: 28px; padding: 0 8px; font: inherit; background: #fff; color: var(--text); }
textarea { height: auto; padding: 6px 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9db6e0; outline-offset: -1px; }
input[readonly] { background: #f3f4f7; color: #666; }

/* 버튼 */
.btn { display: inline-block; border: 1px solid var(--navy); color: var(--navy); background: #fff; border-radius: 3px; padding: 5px 13px; font: inherit; font-size: 12.5px; cursor: pointer; }
.btn:hover { background: #f1f4fa; }
.btn.p { background: var(--navy); color: #fff; }
.btn.p:hover { background: #2a4a80; }
.btn.d { border-color: var(--ng); color: var(--ng); }
.hb-btns { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 10px; }

/* 그리드 */
.hb-grid { border-collapse: collapse; width: 100%; }
.hb-grid th { background: #e8edf5; color: var(--navy); font-weight: 700; border: 1px solid var(--line); padding: 6px 7px; font-size: 12px; white-space: nowrap; }
.hb-grid td { border: 1px solid #e1e5ec; padding: 6px 7px; font-size: 12.5px; }
.hb-grid td.num { text-align: right; }
.hb-grid tr.ng td { background: #fdecec; }
.hb-grid tbody tr:hover td { background: #f3f7fd; }
.hb-grid tr.sel td { background: #dbe7fb; }

/* 배지 */
.b { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: 11px; font-weight: 700; color: #fff; background: var(--gray); }
.b.OK, .b.RUN, .b.SUCCESS { background: var(--ok); }
.b.NG, .b.CRIT, .b.ERROR, .b.TIMEOUT, .b.FAIL { background: var(--ng); }
.b.WARN, .b.OFFLINE { background: var(--warn); }
.b.ACTIVE, .b.INFO { background: var(--info); }

/* 알림 */
#hb-toast { position: fixed; top: 58px; right: 18px; z-index: 50; display: flex; flex-direction: column; gap: 6px; }
#hb-toast div { background: #263238; color: #fff; padding: 9px 14px; border-radius: 4px; box-shadow: 0 3px 10px rgba(0,0,0,.2); font-size: 12.5px; }
#hb-toast div.err { background: var(--ng); }

/* 로그인 */
.hb-login-body { display: grid; place-items: center; background: linear-gradient(135deg, #1F3864 0%, #2e5596 100%); }
.hb-login { display: flex; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.25); width: 720px; max-width: calc(100vw - 32px); }
.hb-login-brand { flex: 1; background: #f4f6fa; padding: 48px 36px; display: flex; flex-direction: column; justify-content: center; }
.hb-login-mark { width: 54px; height: 54px; border-radius: 12px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; margin-bottom: 18px; }
.hb-login-brand h1 { font-size: 24px; color: var(--navy); }
.hb-login-brand p { color: var(--muted); margin-top: 6px; }
.hb-login-form { flex: 1; padding: 48px 36px; display: flex; flex-direction: column; gap: 14px; }
.hb-login-form label { display: flex; flex-direction: column; gap: 5px; color: #555; font-size: 12.5px; }
.hb-login-form input { height: 38px; font-size: 14px; }
.hb-login-form .btn { height: 40px; font-size: 14px; margin-top: 4px; }
.hb-login-err { background: #fdecec; color: var(--ng); padding: 8px 10px; border-radius: 4px; font-size: 12.5px; }
.hb-login-help { color: var(--muted); font-size: 11.5px; }
@media (max-width: 640px) { .hb-login { flex-direction: column; } .hb-login-brand, .hb-login-form { padding: 28px 24px; } }

/* 안내 페이지 */
.hb-center { min-height: 100vh; display: grid; place-items: center; }
.hb-msgbox { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 30px 36px; text-align: center; max-width: 420px; }
.hb-msgbox h2 { color: var(--navy); margin-bottom: 8px; }
.hb-msgbox p { color: #555; margin-bottom: 16px; }

/* 비전검사 화면 */
.hb-row { display: flex; gap: 12px; align-items: flex-start; }
.hb-col { flex: 1; min-width: 0; }
.hb-preview { width: 430px; flex: none; position: sticky; top: 58px; }
.hb-preview canvas { width: 100%; height: auto; border-radius: 4px; display: block; background: #2b2f36; }
.hb-kv { margin-top: 10px; }
.hb-kv th { width: 34%; text-align: left; }
.hb-scroll { overflow-x: auto; }
.hb-grid td.c { text-align: center; }
.hb-grid td.mono { font-family: Consolas, monospace; }
.hb-grid td.ngtxt { color: var(--ng); font-weight: 700; }
.hb-grid tbody tr[data-id] { cursor: pointer; }
.hb-pager { text-align: center; margin-top: 10px; color: var(--muted); font-size: 12px; }
.hb-pager a { display: inline-block; min-width: 26px; padding: 3px 6px; margin: 0 1px; border-radius: 3px; color: #444; }
.hb-pager a:hover { background: #eef2f8; }
.hb-pager a.on { background: var(--navy); color: #fff; font-weight: 700; }
.hb-pager span { margin-left: 8px; }
.hb-note { color: var(--warn); font-size: 12px; margin-top: 8px; }
.hb-search .hb-sp { flex: 1; }
.hb-ph .hb-toggle { font-weight: 400; color: var(--muted); font-size: 12px; cursor: pointer; }
@media (max-width: 1400px) { .hb-preview { width: 360px; } }

/* 탭 */
.hb-tabs { display: flex; gap: 2px; }
.hb-tab { padding: 7px 18px; background: #e1e6ef; border-radius: 4px 4px 0 0; color: #555; font-weight: 700; }
.hb-tab.on { background: var(--navy); color: #fff; }
.hb-muted { color: var(--muted); font-weight: 400; font-size: 12px; }

/* 모니터링 대시보드 */
.mo-bar { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 10px; }
.mo-bar .hb-sp { flex: 1; }
.mo-clock { color: var(--muted); font-size: 12px; margin-right: 6px; align-self: center; }
.mo-job { display: flex; gap: 28px; align-items: center; font-size: 13.5px; }
.mo-chart { display: flex; align-items: flex-end; gap: 6px; height: 210px; padding: 0 4px; border-bottom: 1px solid var(--line); }
.mo-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.mo-bar-b { width: 70%; max-width: 46px; background: var(--ng); border-radius: 3px 3px 0 0; min-height: 1px; transition: height .4s; }
.mo-bar-v { font-size: 12px; font-weight: 700; color: var(--ng); margin-bottom: 2px; }
.mo-bar-l { font-size: 11px; color: #555; margin-top: 4px; }
.mo-bar-p { font-size: 10px; color: var(--muted); height: 13px; }
.mo-ng { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.mo-thumb { cursor: pointer; text-align: center; font-size: 11.5px; color: #444; }
.mo-thumb canvas { width: 100%; height: auto; border-radius: 4px; display: block; margin-bottom: 4px; }
.mo-thumb:hover canvas { outline: 3px solid var(--info); }
.mo-side { width: 320px; flex: none; }
.mo-dev { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; border-bottom: 1px dashed #e3e7ee; }
.mo-dev small { color: var(--muted); }
/* 전체화면(현장 모니터) */
.hb-kiosk .hb-top, .hb-kiosk .hb-side, .hb-kiosk .hb-title { display: none; }
.hb-kiosk .hb-wrap { min-height: 100vh; }
.hb-kiosk .hb-card .v { font-size: 34px; }
@media (max-width: 1500px) { .mo-ng { grid-template-columns: repeat(3, 1fr); } }

/* 이력·통계·장비·알람 화면 */
.hb-grid tr.warn td { background: #fff3e0; }
.hb-grid tr.dim td { color: #9aa1ab; }
.hb-grid tr.chg td { font-weight: 700; }
.hb-grid td.small { font-size: 11px; color: #777; }
.hb-grid tfoot th { background: #f1f4f9; }
.hb-grid tfoot th.num { text-align: right; }
.hb-card .v.ok { color: var(--ok); }
.hb-card .v.warn { color: var(--warn); }
.hb-radio { display: inline-flex; align-items: center; gap: 3px; margin-right: 8px; font-size: 12.5px; color: #444; }
.hb-chart { width: 100%; height: auto; display: block; }
.hb-chart .grid { stroke: #e6e9ef; stroke-width: 1; }
.hb-chart .ax { font-size: 10.5px; fill: #777; }
.hb-chart .val { font-size: 11px; fill: #333; font-weight: 700; }
.hb-chart .ln { fill: none; stroke: var(--info); stroke-width: 2.5; }
.hb-chart .pt { fill: var(--info); }
.hb-chart .cum { fill: none; stroke: var(--ng); stroke-width: 2; stroke-dasharray: 4 3; }
.hb-chart a rect:hover { opacity: .8; }
.ds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.ds-card { display: block; border: 1px solid var(--line); border-left: 5px solid var(--gray); border-radius: 4px; padding: 10px 12px; background: #fff; }
.ds-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.ds-card.sel { outline: 2px solid var(--info); }
.ds-RUN { border-left-color: var(--ok); }
.ds-ERROR { border-left-color: var(--ng); background: #fff6f6; }
.ds-OFFLINE { border-left-color: var(--warn); background: #fffaf3; }
.ds-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ds-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.ds-metric { margin-top: 6px; font-size: 12px; color: #333; }
.ds-msg { margin-top: 4px; font-size: 12px; color: var(--ng); }
.ngtxt { color: var(--ng); font-weight: 700; }
