:root {
  --bg: #f4f6f9; --panel: #fff; --ink: #1f2937; --muted: #6b7280;
  --line: #e5e7eb; --brand: #2563eb;
  --ok: #16a34a; --warn: #dc2626; --offline: #9ca3af; --nodata: #cbd5e1;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--ink); }
.muted { color: var(--muted); font-size: 0.85rem; }
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

/* topbar */
.topbar { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 700; font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.back { color: var(--brand); margin-right: 6px; }

/* buttons */
.btn { border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.danger { background: #fff; color: var(--warn); border-color: var(--warn); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* banner */
.banner { margin: 12px 18px; padding: 12px 14px; border-radius: 10px;
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; font-weight: 600; }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px; padding: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--nodata);
  border-radius: 12px; padding: 14px; display: block; transition: transform .05s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.card.status-ok { border-left-color: var(--ok); }
.card.status-warn { border-left-color: var(--warn); }
.card.status-offline { border-left-color: var(--offline); }
.card.status-nodata { border-left-color: var(--nodata); }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.dname { font-weight: 700; }
.did { margin-top: 2px; }
.metrics { display: flex; gap: 16px; margin: 10px 0 4px; }
.metrics .temp { font-size: 1.7rem; font-weight: 700; color: #e0564a; }
.metrics .humi { font-size: 1.7rem; font-weight: 700; color: #3b82c4; }

/* badges */
.badge { padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; color: #fff; }
.b-ok { background: var(--ok); } .b-warn { background: var(--warn); }
.b-offline { background: var(--offline); } .b-nodata { background: var(--nodata); color: #374151; }

.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* WF-07 승인 대기 패널 */
.pending-panel { margin: 12px 18px; padding: 12px 14px; border-radius: 10px;
  background: #fffbeb; border: 1px solid #fde68a; }
.pending-panel h2 { margin: 0 0 8px; font-size: 0.95rem; color: #92400e; }
.pending-item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid #fde68a; flex-wrap: wrap; }
.pending-item:first-of-type { border-top: none; }
.pending-actions { display: flex; gap: 6px; }

/* detail */
.detail { padding: 18px; display: flex; flex-direction: column; gap: 16px; max-width: 900px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 1rem; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; }
.current { text-align: right; }
.current span { display: inline-block; margin-left: 12px; font-size: 1.6rem; font-weight: 700; }
#curT { color: #e0564a; } #curH { color: #3b82c4; }
.ranges { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.range.active { background: var(--brand); color: #fff; }

/* forms */
label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 4px; flex: 1; }
input[type=text], input[type=password], input[type=number], .modal input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; color: var(--ink); }
.row { display: flex; gap: 12px; margin-bottom: 10px; }
.chk { flex-direction: row; align-items: center; gap: 8px; margin: 8px 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* alerts */
.alerts { display: flex; flex-direction: column; gap: 6px; }
.alert-item { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.a-kind { font-weight: 700; font-size: 0.72rem; padding: 2px 6px; border-radius: 6px; text-align: center; color: #fff; background: #dc2626; }
.k-OFFLINE { background: var(--offline); } .k-LOW_TEMP, .k-LOW_HUMI { background: #2563eb; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-card h1 { margin: 0; font-size: 1.3rem; text-align: center; }
.login-card .sub { margin: 0 0 8px; text-align: center; color: var(--muted); font-size: 0.85rem; }
.error-msg { color: var(--warn); font-size: 0.85rem; min-height: 1em; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 420px; max-width: 100%;
  display: flex; flex-direction: column; gap: 8px; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 6px; }
.token-box { background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 0.85rem; }
.token { font-family: monospace; word-break: break-all; background: #111827; color: #a7f3d0;
  padding: 8px; border-radius: 6px; margin: 8px 0; }

/* 하단 고정 버전 푸터 */
.app-footer { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  text-align: center; font-size: 0.72rem; color: var(--muted);
  background: rgba(255,255,255,.92); border-top: 1px solid var(--line);
  padding: 4px 8px; backdrop-filter: blur(2px); }
body { padding-bottom: 26px; } /* 고정 푸터 겹침 방지 */

/* 파일함 (WF-09) */
.upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.file-list { display: flex; flex-direction: column; }
.file-item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.file-item:first-child { border-top: none; }
.file-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-name { font-weight: 600; word-break: break-all; }
.file-actions { display: flex; gap: 6px; align-items: center; }

/* toast */
.toast { position: fixed; bottom: 38px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 60; background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0;
  pointer-events: none; transition: all .25s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--warn); }

@media (max-width: 520px) { .row { flex-direction: column; } .metrics .temp, .metrics .humi { font-size: 1.4rem; } }
