* { box-sizing: border-box; font-family: -apple-system, "Malgun Gothic", sans-serif; }
body { margin: 0; background: #f5f6f8; color: #222; }
.topbar { display: flex; align-items: center; gap: 20px; background: #1f2937; color: #fff; padding: 10px 20px; flex-wrap: wrap; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.topbar .brand { font-weight: bold; margin-right: auto; }
.topbar a { color: #fff; margin-right: 12px; text-decoration: none; }
.logout-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.logout-form button { cursor: pointer; }
.container { max-width: 960px; margin: 20px auto; background: #fff; padding: 20px; border-radius: 6px; }
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: #1f2937; }
.login-box { background: #fff; padding: 30px; border-radius: 8px; width: 320px; display: flex; flex-direction: column; gap: 8px; }
.login-box h1 { font-size: 18px; margin-bottom: 10px; }
.login-box input, .form input, .form select { padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.login-box button, .form button { padding: 10px; background: #2563eb; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.error { color: #d33; }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { border-bottom: 1px solid #eee; padding: 8px; text-align: left; }
.form { display: flex; flex-direction: column; gap: 8px; max-width: 700px; }
.hint { color: #666; font-size: 13px; }
.filter-bar a { margin-right: 10px; padding: 4px 10px; border: 1px solid #ccc; border-radius: 4px; text-decoration: none; color: #333; }
.filter-bar a.active { background: #2563eb; color: #fff; border-color: #2563eb; }
#std-material-table { max-width: 500px; margin: 10px 0; }
#add-row { align-self: flex-start; margin-bottom: 10px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.section-box { border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px; margin: 6px 0; }
.actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.inline-form { display: flex; gap: 6px; margin: 0; }

.container { max-width: 1100px; }
.card-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0 20px; }
.card { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px 20px; min-width: 110px; text-align: center; }
.card-num { font-size: 26px; font-weight: bold; color: #1f2937; }
.card-label { font-size: 13px; color: #666; margin-top: 4px; }
.badge-warn { background: #fee2e2; color: #b91c1c; border-radius: 12px; padding: 2px 10px; font-size: 12px; margin-left: 8px; }
.low-stock td { background: #fef2f2; }
.chart-table td { vertical-align: middle; }
.bar-wrap { position: relative; background: #f1f5f9; border-radius: 4px; height: 20px; min-width: 90px; }
.bar { background: #2563eb; height: 100%; border-radius: 4px; }
.bar-value { position: absolute; right: 6px; top: 0; font-size: 12px; line-height: 20px; color: #333; }
.site-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.site-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #eee; }
.site-status { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eee; color: #555; }
.status-ok { background: #dcfce7; color: #15803d; }
.status-error { background: #fee2e2; color: #b91c1c; }
.status-unknown { background: #f1f5f9; color: #64748b; }

.report-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.report-list li a { display: inline-block; padding: 10px 14px; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; text-decoration: none; color: #1f2937; }
.report-list li a:hover { background: #eef2ff; }
.btn-excel { display: inline-block; padding: 6px 12px; background: #15803d; color: #fff; border-radius: 4px; text-decoration: none; font-size: 13px; }
.btn-excel:hover { background: #166534; }
.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 12px 16px; border-radius: 6px; margin: 12px 0; }
.error-box ul { margin: 6px 0 0; padding-left: 20px; }
.success-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 10px 16px; border-radius: 6px; margin: 12px 0; }

/* ── 반응형: PC 우선, 태블릿(~1024px) 대응 ──
   이 환경에는 실제 브라우저가 없어 시각적으로 직접 확인하지는 못했다(코드 리뷰 기준).
   NAS 배포 후 실제 태블릿/좁은 창에서 한 번 확인할 것을 권장한다. */
@media (max-width: 1024px) {
  .container { max-width: 100%; margin: 12px; padding: 14px; }
}

@media (max-width: 768px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 14px; }
  .topbar .brand { margin-right: 0; }
  .logout-form { justify-content: space-between; }
  .container { margin: 8px; padding: 12px; }

  /* 표는 가로 스크롤로 전환(얇은 화면에서도 열이 깨지지 않도록) */
  table.grid { display: block; overflow-x: auto; white-space: nowrap; }
  table.grid thead, table.grid tbody, table.grid tr { display: table; width: 100%; table-layout: fixed; }

  .form { max-width: 100%; }
  .card-row { gap: 8px; }
  .card { min-width: 90px; padding: 12px 14px; flex: 1 1 auto; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .section-box { padding: 8px; }
}

/* ── 2026-10-10 수정사항: 공통 UI ── */
/* 숫자 열/입력 우측 정렬 */
.grid th.num, .grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
input.num-input { text-align: right; font-variant-numeric: tabular-nums; }
/* 체크박스: 라벨 옆에 배치 */
.form input[type="checkbox"] { width: auto; align-self: flex-start; margin: 0; }
.check-label { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; cursor: pointer; }
/* 검색형 선택(Combo) */
.combo { position: relative; display: flex; flex-direction: column; }
.combo-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; max-height: 280px; overflow-y: auto;
  margin: 2px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid #cbd5e1; border-radius: 4px;
  box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.combo-item { padding: 7px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.combo-item small { color: #64748b; }
.combo-item.active, .combo-item:hover { background: #eef2ff; }
.combo-empty { padding: 7px 10px; color: #94a3b8; font-size: 13px; }
/* 정비접수 연계 선택 팝업 */
dialog.picker { border: none; border-radius: 8px; padding: 18px 20px; width: min(560px, 92vw); box-shadow: 0 12px 32px rgba(0,0,0,.25); }
dialog.picker::backdrop { background: rgba(15,23,42,.45); }
dialog.picker h3 { margin: 0 0 6px; }
.picker-list { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.picker-list button { width: 100%; text-align: left; padding: 10px 12px; background: #f8fafc; color: #1f2937; border: 1px solid #e5e7eb; border-radius: 6px; cursor: pointer; }
.picker-list button:hover, .picker-list button:focus { background: #eef2ff; border-color: #c7d2fe; }
.picker-actions { display: flex; justify-content: flex-end; }
.picker-actions button { padding: 8px 14px; background: #fff; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; }

/* ── 2026-10-12: 업로드 안내 ── */
.import-help p { margin: 6px 0; }
.import-help .req { color: #b91c1c; }
.grid.import-cols { max-width: 520px; margin: 6px 0 10px; font-size: 13px; }
.grid.import-cols td, .grid.import-cols th { padding: 4px 8px; }

/* ── 2026-10-13: 삭제 버튼 ── */
.delete-form { display: inline-flex; margin: 0; }
.btn-delete { padding: 2px 8px; font-size: 13px; background: #fff; color: #b91c1c; border: 1px solid #fca5a5; border-radius: 4px; cursor: pointer; }
.btn-delete:hover { background: #fef2f2; }
.row-actions { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.form-actions-danger { margin-top: 18px; padding-top: 12px; border-top: 1px dashed #e5e7eb; }
