:root {
  --bg: #f6f7f9;
  --surface-1: #ffffff;
  --line: #e3e6ea;
  --grid: #eef0f2;
  --text-primary: #191919;
  --text-secondary: #666666;
  --accent: #1f4e8c;
  --series-1: #257de0; /* UPS류 */
  --series-2: #f47230; /* CCTV류 */
  --series-3: #00b894;
  --good: #0a7d2c;
  --critical: #c62828;
  --radius: 10px;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: var(--text-primary);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

/* 사이드바 */
.side { background: #142a4a; color: #dfe7f2; display: flex; flex-direction: column; padding: 20px 0; position: sticky; top: 0; height: 100vh; }
.brand { padding: 0 20px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-title { font-size: 18px; font-weight: 700; color: #fff; }
.brand-sub { font-size: 12px; opacity: .7; margin-top: 4px; }
#nav { display: flex; flex-direction: column; padding: 12px 0; flex: 1; }
#nav a { padding: 9px 20px; cursor: pointer; color: #dfe7f2; text-decoration: none; border-left: 3px solid transparent; }
#nav a:hover { background: rgba(255,255,255,.06); }
#nav a.active { background: rgba(255,255,255,.1); border-left-color: #7fb2ff; color: #fff; font-weight: 600; }
.nav-group { font-size: 11px; opacity: .5; padding: 14px 20px 4px; letter-spacing: .05em; }
.side-foot { font-size: 11px; opacity: .6; padding: 0 20px; }

/* 본문 */
main { padding: 28px 32px 60px; max-width: 1280px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.page-sub { color: var(--text-secondary); margin: 0 0 24px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid2 > .card { margin-bottom: 0; }
.row-gap { margin-bottom: 20px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .k { color: var(--text-secondary); font-size: 12px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.note { background: #f1f5fb; border: 1px solid #d6e2f3; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #33465f; margin-bottom: 16px; }
.todo { background: #fff8e6; border-color: #f2dfa8; color: #6b5310; }

/* 표 */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: right; white-space: nowrap; }
th { background: #f8f9fb; color: var(--text-secondary); font-weight: 600; position: sticky; top: 0; }
td:first-child, th:first-child { text-align: left; }
td.l, th.l { text-align: left; }
tr.sum td { font-weight: 700; background: #fafbfc; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #eef2f7; color: #33465f; }
.tag.ok { background: #e6f4ea; color: var(--good); }
.tag.err { background: #fdecea; color: var(--critical); }
.tag.seed { background: #f1f1f1; color: #555; }

/* 버튼·입력 */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
select, input[type=number], input[type=text] { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

/* 업로드 */
.drop { border: 2px dashed #b9c6d8; border-radius: var(--radius); padding: 36px; text-align: center; background: #fbfcfe; cursor: pointer; }
.drop.over { border-color: var(--accent); background: #eef4fc; }
.drop b { font-size: 15px; }
.bar { height: 6px; background: #edf0f3; border-radius: 3px; overflow: hidden; width: 140px; display: inline-block; vertical-align: middle; }
.bar > i { display: block; height: 100%; background: var(--series-1); width: 0; transition: width .2s; }
details.errs summary { cursor: pointer; color: var(--critical); font-size: 12px; }
details.errs ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; text-align: left; white-space: normal; }

/* 차트 */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-size: 11px; fill: var(--text-secondary); font-family: inherit; }
.chart .axis line { stroke: var(--line); }
.chart .grid line { stroke: var(--grid); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-primary); margin-bottom: 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: fixed; pointer-events: none; background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.1); border-radius: 8px; padding: 8px 10px; font-size: 12px; z-index: 50; min-width: 140px; }
.tip .t { font-weight: 700; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* 보고서 인쇄 */
.report h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.report .meta { text-align: center; color: var(--text-secondary); margin-bottom: 24px; }
.report h3 { font-size: 15px; border-left: 4px solid var(--accent); padding-left: 8px; margin: 24px 0 10px; }
@media print {
  .side, .toolbar, .no-print { display: none !important; }
  .app { display: block; }
  main { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
  th { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .grid2, .kpis { grid-template-columns: 1fr 1fr; }
}

/* 로그인 */
.login { position: fixed; inset: 0; background: #142a4a; display: grid; place-items: center; z-index: 100; }
.login[hidden] { display: none; }
.login-box { background: #fff; border-radius: 14px; padding: 32px; width: 340px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-box label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; }
.login-box input { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; color: var(--text-primary); }
.side-foot button { background: transparent; color: #dfe7f2; border-color: rgba(255,255,255,.25); padding: 3px 10px; font-size: 11px; margin-top: 6px; }
