/* terra-server 웹 콘솔 공용 스타일 — index.html(메인) · beta.html(베타 테스터) · live.html(라이브 대시보드)
 * 페이지별 전용 규칙(차트, 타일 등)은 각 HTML 의 <style> 에. 여기엔 세 페이지가 같이 쓰는 것만. */
:root {
  color-scheme: dark;
  --bg: #0f1115; --panel: #181b21; --panel-2: #1f232b; --line: #2a2f3a;
  --text: #e8eaf0; --muted: #8a92a3; --accent: #5aaaff; --accent-2: #2a4a6a;
  --good: #5fd38a; --warn: #f3b760; --bad: #ff7b7b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; padding: 16px; line-height: 1.5; }
h1 { font-size: 18px; margin: 0 0 16px; color: var(--accent); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 .docs-links { margin-left: auto; font-size: 12px; font-weight: normal; }
h1 .docs-links a, .topnav .docs-links a { color: var(--muted); text-decoration: none; margin-left: 8px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 4px; }
h1 .docs-links a:hover, .topnav .docs-links a:hover { color: #9cf; border-color: var(--accent); }
h2 { font-size: 14px; margin: 12px 0 8px; color: var(--accent); letter-spacing: .5px; }
h3 { font-size: 12px; margin: 8px 0 4px; color: var(--muted); font-weight: normal; text-transform: uppercase; letter-spacing: .5px; }
.wrap { max-width: 960px; margin: 0 auto; }
.wrap.wide { max-width: 1400px; }
.panel { background: var(--panel); padding: 16px; border-radius: 10px; margin-bottom: 12px; border: 1px solid var(--line); }
.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.row label { flex: 0 0 100px; font-size: 12px; color: #bbb; }
input, select, textarea { padding: 6px 8px; background: #222631; color: var(--text); border: 1px solid #3a4050; border-radius: 6px; font-size: 13px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=text], input[type=email], input[type=password] { flex: 1; }
button { padding: 6px 12px; background: var(--accent-2); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1.3; }
button:hover { background: #355c80; }
button.danger { background: #6a2a2a; }
button.danger:hover { background: #803535; }
button.ghost { background: transparent; border: 1px solid var(--line); color: #c8cdd8; }
button.ghost:hover { border-color: var(--accent); color: #fff; background: rgba(90,170,255,.08); }
button.primary { background: #2f7ad6; }
button.primary:hover { background: #3b8ae8; }
button.sm { font-size: 11px; padding: 3px 8px; border-radius: 5px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { background: #222; color: #888; flex: 1; }
.tabs button.active { background: var(--accent-2); color: #fff; }
.muted { color: var(--muted); font-size: 12px; }
.bad { color: var(--bad); }
.good { color: var(--good); }
.warn { color: var(--warn); }
pre { background: #0a0a0a; padding: 10px; border-radius: 6px; overflow: auto; font-size: 11px; max-height: 200px; color: #9f9; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95em; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: normal; font-size: 11px; text-transform: uppercase;  white-space: nowrap; }
.token-once { background: #3a3000; color: #fc9; padding: 8px; border-radius: 4px; font-family: monospace; font-size: 11px; word-break: break-all; margin: 4px 0; border: 1px solid #885500; }
.hidden { display: none !important; }
.toast { position: fixed; top: 16px; right: 16px; background: var(--accent-2); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.4); z-index: 9999; max-width: min(420px, 90vw); }
.toast.bad { background: #6a2a2a; }
.toast.good { background: #2a6a3a; }
small { color: var(--muted); font-size: 11px; }
hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }

/* 상단 네비 — 세 페이지 공통. renderTopNav() 가 그린다. */
.topnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: -4px 0 14px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.topnav .brand { font-weight: 600; color: var(--accent); font-size: 14px; margin-right: 8px; white-space: nowrap; }
.topnav a.nav { color: #c8cdd8; text-decoration: none; font-size: 13px; padding: 5px 11px; border-radius: 6px; white-space: nowrap; }
.topnav a.nav:hover { background: rgba(90,170,255,.1); color: #fff; }
.topnav a.nav.active { background: var(--accent-2); color: #fff; }
.topnav .spacer { flex: 1; }
.topnav .env { font-family: ui-monospace, Menlo, monospace; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.topnav .env.prod { color: var(--good); border-color: #2d5a3c; }
.topnav .env.local { color: var(--warn); border-color: #5a4a2d; }
.topnav .docs-links { font-size: 12px; }

/* 상태 점·칩 — 온라인/오프라인, 펌웨어 버전 등 작은 라벨 */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #555; vertical-align: middle; margin-right: 4px; }
.dot.on { background: var(--good); box-shadow: 0 0 6px rgba(95,211,138,.6); }
.dot.off { background: #4a4f5a; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: #c8cdd8; white-space: nowrap; }
.chip.good { color: var(--good); border-color: #2d5a3c; }
.chip.bad { color: var(--bad); border-color: #5a2d2d; }
.chip.warn { color: var(--warn); border-color: #5a4a2d; }
.chip code { font-size: 11px; }

/* 요약 통계 줄 — 페이지 상단 "계정 10 · 기기 12 · 카메라 11" */
.stats { display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline; }
.stats .stat { display: flex; flex-direction: column; min-width: 72px; }
.stats .stat b { font-size: 20px; font-weight: 600; color: var(--text); line-height: 1.1; }
.stats .stat span { font-size: 11px; color: var(--muted); }

/* 로그인·첫 설정 카드 — 세 페이지 같은 모양(가운데 480px). index 인증 패널, beta/live 게이트·설정 패널 */
.auth-card { max-width: 480px; margin: 40px auto; }
.auth-card h2 { margin-top: 0; }

/* 접이식 설정 섹션 */
details.cfg { border: 1px dashed var(--line); border-radius: 8px; padding: 6px 12px; margin-top: 8px; }
details.cfg summary { cursor: pointer; color: var(--muted); font-size: 12px; user-select: none; }
details.cfg[open] summary { margin-bottom: 8px; }

/* 모달 — 라이브(index)·OTA(index/beta) 공용 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 10px; padding: 16px; max-width: 800px; width: 100%; max-height: 95vh; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); }
.modal h2 { margin: 0; font-size: 13px; }
.modal-header { display: flex; align-items: center; gap: 8px; }
.modal-header button { margin-left: auto; }
.live-status { font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding: 6px 10px; border-radius: 4px; background: #080808; color: #9f9; word-break: break-all; min-height: 1.4em; }
.live-status.warn { color: #fc9; }
.live-status.bad { color: #f99; }

/* 표 — 패널 밖으로 삐져나오지 않게 가로 스크롤 (enableTableLabels 가 감싼다) */
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
td.nw, th.nw { white-space: nowrap; }
/* 제어·관리 버튼 묶음 — 한 셀 안에서 줄바꿈되는 두 그룹 */
.actions-cell { min-width: 280px; }
.act-group { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.act-group + .act-group { margin-top: 4px; }
.legend { display: block; margin-top: 6px; line-height: 1.6; }

/* 모바일 (≤600px) — 좁은 화면 보정 */
@media (max-width: 600px) {
  body { padding: 8px; }
  .wrap { max-width: 100%; }
  .panel { padding: 12px; }
  h1 { font-size: 15px; gap: 6px; }
  h1 .docs-links { margin-left: 0; width: 100%; text-align: right; }
  h1 .docs-links a { font-size: 10px; padding: 1px 5px; margin-left: 4px; }
  h2 { font-size: 13px; }
  .row { gap: 4px; }
  .row label { flex: 0 0 100%; font-size: 11px; margin-bottom: 2px; }
  input, select { font-size: 13px; padding: 8px 10px; }   /* 모바일 터치 친화 + 16px 미만이면 iOS 자동 줌 회피 위해 13px */
  input[type=text], input[type=email], input[type=password] { flex: 1 1 100% !important; min-width: 0; }   /* 인라인 flex:2 등도 한 줄 차지 */
  button { padding: 8px 12px; font-size: 13px; }   /* 터치 영역 확대 */
  button.sm { padding: 5px 9px; font-size: 11px; }
  .topnav .docs-links { display: none; }
  .topnav .env { display: none; }
  .topnav { gap: 2px; padding: 6px; }
  .topnav .brand { display: none; }
  .topnav a.nav { font-size: 12px; padding: 6px 8px; flex: 1; text-align: center; }

  /* 표 → 카드: 행 하나가 카드, 셀은 "라벨 값" 한 줄 (data-label 은 enableTableLabels 가 채움) */
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; background: var(--panel-2); }
  .table-wrap td { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: none; white-space: normal !important; min-height: 0; }
  .table-wrap td::before { content: attr(data-label); flex: 0 0 74px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
  .table-wrap td[data-label=""]::before, .table-wrap td:not([data-label])::before { display: none; }
  .table-wrap td[data-label=""] { flex-wrap: wrap; padding-top: 6px; }
  .table-wrap td > small, .table-wrap td > span, .table-wrap td > code { min-width: 0; }
  .table-wrap select { max-width: 100% !important; }
  .actions-cell { min-width: 0; }
  .act-group { width: 100%; }
}
