:root {
  --bg: #0e1116; --bg2: #161b22; --bg3: #1c2330; --line: #2a3140;
  --fg: #e6edf3; --muted: #8b98a9; --accent: #3b82f6; --accent2: #2563eb;
  --ok: #22c55e; --warn: #f59e0b; --err: #ef4444; --chip: #263041;
}
* { box-sizing: border-box; }
/* hidden 속성이 항상 이기도록. (.modal/.login-wrap 등이 display 를 지정해 [hidden] 을 덮는 것 방지) */
[hidden] { display: none !important; }
body { margin: 0; font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg); color: var(--fg); font-size: 14px; }
button { cursor: pointer; font: inherit; border: none; border-radius: 6px;
  background: var(--accent); color: #fff; padding: 8px 14px; }
button:hover { background: var(--accent2); }
button.ghost { background: var(--bg3); color: var(--fg); border: 1px solid var(--line); }
button.ghost:hover { background: var(--chip); }
button.small { padding: 4px 10px; font-size: 12px; }
button.danger { background: var(--err); }
button.danger:hover { background: #dc2626; }
input, select { background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; font: inherit; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
a { color: var(--accent); }
.err { color: var(--err); min-height: 18px; }
.hint { color: var(--muted); font-size: 12px; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { display: flex; flex-direction: column; gap: 14px; width: 320px; }
.login-card h1 { margin: 0 0 6px; font-size: 20px; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }

/* 상단바 */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 18px; height: 54px;
  background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; letter-spacing: .5px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { background: transparent; color: var(--muted); padding: 8px 14px; }
.tabs button:hover { color: var(--fg); background: var(--bg3); }
.tabs button.active { color: var(--fg); background: var(--bg3); border-bottom: 2px solid var(--accent); border-radius: 6px 6px 0 0; }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); }

main { padding: 18px; max-width: none; margin: 0 auto; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar input { flex: 1; max-width: 340px; }

/* 테이블 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; white-space: nowrap; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { background: var(--bg3); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
tbody tr:hover { background: var(--bg3); }
td.mono, .mono { font-family: "Consolas", monospace; font-size: 12px; }
td .rowbtns { display: flex; gap: 6px; flex-wrap: wrap; }

/* 사용자 탭: 하단 가로 스크롤바 제거 — 넓어진 레이아웃에 맞춰 셀을 줄바꿈해 폭 안에 맞춘다 */
#tab-users .table-wrap { overflow-x: visible; }
#tab-users table { white-space: normal; table-layout: auto; }
#tab-users td.mono { word-break: break-all; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--chip); color: var(--muted); }
.chip.ok { background: rgba(34,197,94,.15); color: var(--ok); }
.chip.warn { background: rgba(245,158,11,.15); color: var(--warn); }
.chip.err { background: rgba(239,68,68,.15); color: var(--err); }

/* 토큰 발급 */
.issue-card { margin-bottom: 16px; }
.issue-card h3 { margin: 0 0 12px; }
.issue-card .row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.issue-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.issue-card input { width: 120px; }
.issue-result { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.issue-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.issue-result pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; margin: 0; max-height: 240px; overflow: auto; font-family: Consolas, monospace; }

/* 모니터링 */
.monitor-grid { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.online-head, .screen-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.online-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.online-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.online-list li:hover { background: var(--bg3); }
.online-list li.active { border-color: var(--accent); background: var(--bg3); }
.online-list li.no-consent { opacity: .55; }
.online-list .li-right { display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.ws-status { margin-top: 10px; font-size: 12px; color: var(--muted); }
.screen-view { position: relative; background: #000; border-radius: 8px; overflow: hidden;
  min-height: 360px; display: grid; place-items: center; }
.screen-view img { max-width: 100%; max-height: 70vh; display: block; }
.placeholder { position: absolute; color: var(--muted); }
.fps { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: right; }
.screen-head-btns { display: flex; align-items: center; gap: 8px; }
.control-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: rgba(239,68,68,.15); color: var(--err); border: 1px solid var(--err); }

/* 파일 전송 */
#ftToggleBtn.active { border-color: var(--accent); color: var(--accent); }
.ft-panel { margin-bottom: 10px; }
.ft-dual { display: flex; gap: 10px; }
.ft-pane { flex: 1; min-width: 0; display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.ft-pane-head { display: flex; align-items: center; gap: 8px; padding: 8px;
  border-bottom: 1px solid var(--line); font-weight: 600; }
.ft-pane-title { flex: 1; }
.ft-pane-nav { display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.ft-breadcrumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-family: Consolas, monospace; }
.ft-pane-cols { display: grid; grid-template-columns: 1fr 90px 78px 132px; gap: 8px;
  padding: 4px 8px; font-size: 11px; color: var(--muted); background: var(--bg3);
  border-bottom: 1px solid var(--line); }
.ft-tree { max-height: 40vh; overflow: auto; padding: 4px; }
.ft-row { display: grid; grid-template-columns: 1fr 90px 78px 132px; gap: 8px;
  align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.ft-row:hover { background: var(--bg3); }
.ft-row.selected { background: rgba(59,130,246,.18); outline: 1px solid var(--accent); }
.ft-icon { margin-right: 6px; }
.ft-name, .ft-type, .ft-size, .ft-mtime { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-type, .ft-size, .ft-mtime { color: var(--muted); font-size: 12px; font-family: Consolas, monospace; }
.ft-pane-head button:disabled, .ft-pane-nav button:disabled { opacity: .4; cursor: not-allowed; }
.ft-transfer { display: flex; align-items: center; gap: 10px; padding: 8px; border-top: 1px solid var(--line); }
.ft-transfer #ftTransferLabel { flex: none; max-width: 40%; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-transfer progress { flex: 1; height: 10px; accent-color: var(--accent); }

@media (max-width: 900px) {
  .ft-dual { flex-direction: column; }
  .ft-tree { max-height: 28vh; }
}

/* 모달 / 토스트 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 20; }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 22px; width: 360px; }
/* 넓은 모달(이용 로그 등): 화면 폭을 크게 쓰고, 내용이 길면 세로 스크롤 */
.modal-card.wide { width: min(1150px, 94vw); }
.modal-card.wide #modalBody { max-height: 68vh; overflow-y: auto; padding-right: 4px; }
.modal-card.wide #modalBody h4 { margin: 18px 0 6px; color: var(--fg); font-size: 13px; border-left: 3px solid var(--accent, #5b9); padding-left: 8px; }
.modal-card.wide #modalBody h4:first-child { margin-top: 2px; }
.modal-card.wide table { font-size: 12.5px; }
.modal-card.wide table td, .modal-card.wide table th { padding: 7px 10px; }
.nowrap { white-space: nowrap; }
.modal-card h3 { margin: 0 0 14px; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--line); padding: 12px 18px; border-radius: 8px; z-index: 30; }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }

.twofa-secret { font-size: 18px; letter-spacing: 2px; text-align: center; padding: 10px; margin: 10px 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-family: Consolas, monospace; user-select: all; }
.twofa-uri { font-size: 10px; color: var(--muted); word-break: break-all; margin-bottom: 10px; user-select: all; }

/* 대시보드 */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.kpi-num { font-size: 30px; font-weight: 700; line-height: 1; }
.kpi-num.ok { color: var(--ok); } .kpi-num.warn { color: var(--warn); } .kpi-num.err { color: var(--err); }
.kpi-lbl { color: var(--muted); font-size: 12px; margin-top: 8px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.dash-grid .card h3 { margin: 0 0 14px; font-size: 14px; }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 170px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar-v { font-size: 10px; color: var(--muted); height: 14px; }
.bar { width: 68%; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; }
.bar-x { font-size: 9px; color: var(--muted); margin-top: 5px; white-space: nowrap; }
.mini-list { display: flex; flex-direction: column; max-height: 220px; overflow: auto; }
.mini-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.mini-row:last-child { border-bottom: none; }
