/* 统一服务门户 - 前端样式
 * 响应式：桌面端 TAB 在顶部，手机端 TAB 固定底部（NFR-C3） */
:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel2: #1e2740;
  --line: #2a3550;
  --text: #e8ecf5;
  --muted: #8b96ad;
  --accent: #4f7cff;
  --accent2: #3b63d6;
  --ok: #34c07a;
  --warn: #e0a83c;
  --err: #e05c5c;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
button {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 16px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent2); }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 13px; }
button.big { padding: 12px 22px; font-size: 16px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select {
  font: inherit; color: var(--text); background: #0c111c;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }

.msg { min-height: 20px; color: var(--warn); font-size: 13px; margin: 8px 0; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin: 16px 0;
}
.tip { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ---------- 登录页 ---------- */
#loginView {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card { width: 360px; max-width: 100%; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card h1 small { color: var(--muted); font-weight: normal; font-size: 13px; margin-left: 8px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-card .foot-tip { margin-top: 18px; }

/* ---------- 外壳 ---------- */
#shellView { display: flex; flex-direction: column; height: 100vh; }
header.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  flex: none;
}
header.topbar .brand { font-weight: 600; font-size: 17px; }
header.topbar .brand small { color: var(--muted); font-weight: normal; margin-left: 6px; font-size: 12px; }
header.topbar .spacer { flex: 1; }
.user-chip { color: var(--muted); font-size: 13px; }

/* TAB 栏：桌面顶部 */
nav#tabbar {
  display: flex; gap: 4px; padding: 8px 12px 0; background: var(--panel);
  border-bottom: 1px solid var(--line); overflow-x: auto; flex: none;
}
nav#tabbar button.tab-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 10px 16px; border-radius: 10px 10px 0 0; font-size: 15px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav#tabbar button.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); background: var(--bg); }
nav#tabbar button.tab-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
nav#tabbar button.tab-btn .dot.online { background: var(--ok); }
nav#tabbar button.tab-btn .dot.offline { background: var(--err); }

main#content { flex: 1; min-height: 0; position: relative; background: var(--bg); }
.svc-pane { position: absolute; inset: 0; display: none; }
.svc-pane.active { display: block; }
.svc-pane iframe { width: 100%; height: 100%; border: 0; display: block; }
.svc-pane .term-wrap { width: 100%; height: 100%; padding: 6px; }
.svc-offline {
  position: absolute; inset: 0; z-index: 5; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 10px;
  background: rgba(15, 20, 32, .92); text-align: center; padding: 20px;
}
.svc-offline.show { display: flex; }
.svc-offline h3 { margin: 0; }
.svc-offline .icon-big { font-size: 40px; }

/* 内网设备地址栏（admin 专属 builtin 面板） */
.lan-ui { width: 100%; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.lan-bar {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.lan-bar .lan-label { color: var(--muted); font-size: 13px; flex: none; }
.lan-addr { flex: 1; min-width: 220px; max-width: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.lan-msg { font-size: 13px; color: var(--muted); min-height: 18px; }
.lan-msg.err { color: var(--err); }
.lan-chips {
  flex: none; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.lan-chips:empty { display: none; }
.lan-frames { flex: 1; min-height: 0; position: relative; }
.lan-frame { position: absolute; inset: 0; }
.lan-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.lan-tab { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lan-tab.active { border-color: var(--accent); }
.lan-tab.active > button:first-child { color: var(--accent); }
.lan-tab-x {
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 2px 6px; font-size: 12px; line-height: 1; border-left: 1px solid var(--line);
}
.lan-tab-x:hover { color: var(--err); }

/* 手机端：TAB 固定底部（NFR-C3） */
@media (max-width: 720px) {
  nav#tabbar {
    order: 9; border-top: 1px solid var(--line); border-bottom: none;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0));
    position: sticky; bottom: 0; margin-top: auto;
  }
  nav#tabbar button.tab-btn { flex: 1; flex-direction: column; gap: 3px; font-size: 12px; padding: 6px 4px; border-radius: 8px; }
  nav#tabbar button.tab-btn.active { border-bottom: none; background: var(--panel2); }
  header.topbar { padding: 8px 12px; }
  header.topbar .brand small { display: none; }
}

/* ---------- 管理页 ---------- */
#adminView { padding: 16px; max-width: 1100px; margin: 0 auto; width: 100%; overflow-y: auto; height: 100vh; }
#adminView.hidden, .hidden { display: none !important; }
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-head h2 { margin: 0; font-size: 20px; flex: 1; }
nav.adm-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
nav.adm-tabs button { padding: 6px 14px; font-size: 14px; }
nav.adm-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { color: var(--muted); font-weight: 500; white-space: nowrap; }
table.grid tr:hover td { background: rgba(79, 124, 255, .05); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.err { color: var(--err); border-color: var(--err); }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.tag.acc { color: var(--accent); border-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dialog-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.dialog-mask.show { display: flex; }
.dialog {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; width: 480px; max-width: 100%; max-height: 90vh; overflow-y: auto;
}
.dialog h3 { margin: 0 0 14px; }
.dialog form { display: flex; flex-direction: column; gap: 10px; }
.dialog .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
pre.code {
  background: #0c111c; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-size: 12.5px; overflow-x: auto; color: #b6c2dc;
}
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.flex-col { display: flex; flex-direction: column; gap: 10px; }
.stat-line { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }

/* 修改密码视图 */
#pwdView { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
#pwdView .card { width: 400px; max-width: 100%; }
#pwdView form { display: flex; flex-direction: column; gap: 12px; }

/* 终端样式弹层（hermes/nuc-term 工具栏"样式"按钮） */
.term-style-pop {
  position: absolute; top: 40px; right: 12px; z-index: 7;
  background: #0f1a2e; border: 1px solid #2b3b58; border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  font-size: 13px; color: #cbd5e1; box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.term-style-pop.hidden { display: none; }
.term-style-pop .tsp-row { display: flex; align-items: center; gap: 6px; }
.term-style-pop .tsp-row > span { min-width: 32px; color: #8ea0bd; }
.term-style-pop .tsp-size { min-width: 24px; text-align: center; color: #f59e0b; }

/* NUC 终端「文件」面板（工具栏"文件"按钮）：主目录浏览/上传/下载 */
.term-files-pop {
  position: absolute; top: 44px; right: 12px; z-index: 7;
  width: 420px; max-width: calc(100% - 24px);
  background: #0f1a2e; border: 1px solid #2b3b58; border-radius: 10px;
  font-size: 13px; color: #cbd5e1; box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; overflow: hidden;
}
.term-files-pop.hidden { display: none; }
.term-files-pop .tf-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid #22304d; flex-wrap: wrap;
}
.term-files-pop .tf-crumbs {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: #8ea0bd;
}
.term-files-pop .tf-seg { cursor: pointer; color: #f59e0b; }
.term-files-pop .tf-seg:hover { text-decoration: underline; }
.term-files-pop .tf-seg.cur { color: #e2e8f0; cursor: default; }
.term-files-pop .tf-seg.cur:hover { text-decoration: none; }
.term-files-pop .tf-list { max-height: 46vh; overflow: auto; }
.term-files-pop .tf-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-bottom: 1px solid #16223a;
}
.term-files-pop .tf-row:hover { background: #16223a; }
.term-files-pop .tf-dir { cursor: pointer; }
.term-files-pop .tf-dir .tf-name { color: #93c5fd; }
.term-files-pop .tf-ico { flex: none; }
.term-files-pop .tf-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.term-files-pop .tf-size { flex: none; color: #8ea0bd; font-size: 12px; min-width: 56px; text-align: right; }
.term-files-pop .tf-dl { flex: none; }
.term-files-pop .tf-empty { padding: 18px 10px; text-align: center; color: #8ea0bd; }
.term-files-pop .tf-foot {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-top: 1px solid #22304d;
}
.term-files-pop .tf-bar {
  flex: none; width: 120px; height: 6px; border-radius: 3px; background: #22304d; overflow: hidden;
}
.term-files-pop .tf-bar b { display: block; height: 100%; width: 0; background: #f59e0b; transition: width .15s; }
.term-files-pop .tf-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cbd5e1; }
