/* WLF IoT 云平台 v3 · 独立演示站 */
:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #17233d;
  --text-2: #5b6b83;
  --muted: #8a97ad;
  --border: #e3e9f2;
  --primary: #2f6bff;
  --primary-2: #1e4fd6;
  --primary-grad: linear-gradient(135deg, #2f6bff, #4f8cff);
  --green: #16a34a;
  --red: #e5484d;
  --amber: #f59e0b;
  --purple: #7c5cff;
  --cyan: #0ea5b7;
  --pink: #ec4899;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 40, 80, .05), 0 1px 4px rgba(20, 40, 80, .05);
  --shadow: 0 4px 14px rgba(20, 40, 80, .08);
  --shadow-lg: 0 18px 50px rgba(20, 40, 80, .2);
  --sidebar-w: 232px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c6cfdd; border-radius: 8px; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; outline: none; }

#login-page, #app-page { display: none; }
body.mode-login #login-page { display: flex; }
body.mode-app #app-page { display: flex; }

#login-page {
  position: relative; min-height: 100vh;
  align-items: center; justify-content: center; overflow: hidden;
  background: #071428;
}
.login-bg {
  position: absolute; inset: 0;
  background: url("../img/login-bg.jpg?v=5") center center / cover no-repeat;
  pointer-events: none;
}
.login-bg::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(105deg, rgba(6,16,40,.7) 0%, rgba(6,16,40,.38) 46%, rgba(6,16,40,.52) 100%),
    linear-gradient(180deg, rgba(6,16,40,.18) 0%, rgba(6,16,40,.12) 48%, rgba(6,16,40,.42) 100%);
}
.login-wrap {
  position: relative; z-index: 2; display: flex; gap: 72px;
  align-items: center; justify-content: center;
  width: 100%; max-width: 920px; padding: 48px 28px;
}
.login-brand { color: #fff; max-width: 360px; text-shadow: 0 2px 16px rgba(0,0,0,.35); }
.brand-kicker {
  font-size: 11px; letter-spacing: .32em; text-transform: uppercase;
  color: rgba(255,255,255,.52); margin-bottom: 12px; font-weight: 500;
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, #5fb889, #3d7dff);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff;
  box-shadow: 0 8px 18px rgba(63,125,255,.28); margin: 0;
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 15px; }
.login-brand h1 {
  font-size: 36px; margin-bottom: 14px; font-weight: 650; letter-spacing: .16em;
}
.login-brand h1::after {
  content: ""; display: block; width: 40px; height: 2px; margin-top: 16px;
  border-radius: 2px; background: linear-gradient(90deg, #8ed4ad, #6ea2ff);
}
.login-brand p { color: rgba(255,255,255,.78); font-size: 14px; letter-spacing: .06em; }
.login-card-brand {
  display: none; letter-spacing: .28em; font-size: 13px; font-weight: 700;
  color: var(--primary); margin-bottom: 10px;
}
.login-card {
  background: rgba(255,255,255,.94); width: 380px; padding: 34px 32px 26px;
  border-radius: 20px; box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.55);
  backdrop-filter: blur(10px);
}
.login-head { text-align: center; margin-bottom: 24px; }
.login-head-icon {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px;
  background: #eef4ff; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.login-head h2 { font-size: 20px; }
.login-head .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }
input, select, textarea {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 13px; font-size: 14px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,107,255,.14);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; line-height: 1;
}
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 12px rgba(47,107,255,.3); }
.btn-block { width: 100%; padding: 12px; letter-spacing: 4px; }
.btn-ghost { background: #f1f4fa; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost.danger:hover { color: var(--red); background: #fef0f0; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.icon-btn { background: none; border: none; color: var(--text-2); padding: 8px; border-radius: 10px; }

.badge { display: inline-flex; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.soft-blue { background: #e9f0ff; color: #2f6bff; }
.soft-green { background: #e6f8ec; color: #16a34a; }
.soft-amber { background: #fdf3e2; color: #b97908; }
.soft-purple { background: #f1ecff; color: #7c5cff; }
.soft-cyan { background: #e3f7fa; color: #0e94a5; }
.soft-gray { background: #eef1f6; color: var(--muted); }
.text-green { color: var(--green); }
.text-muted { color: var(--muted); }
.ml-auto { margin-left: auto; }
.muted { color: var(--muted); }
.msg { margin-top: 14px; font-size: 13.5px; border-radius: 10px; }
.msg:empty { display: none; }
.msg-error { background: #fdecec; color: #c12d32; padding: 10px 14px; }
.msg-success { background: #e6f8ec; color: #13863f; padding: 10px 14px; }

#app-page { min-height: 100vh; }
#sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #101b3c 0%, #0d1730 100%);
  color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 50;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-text b { display: block; font-size: 16px; }
.brand-text span { color: rgba(255,255,255,.5); font-size: 11px; }
.side-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 3px; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,.72); padding: 11px 14px; border-radius: 10px;
  font-size: 14px; cursor: pointer;
}
.side-link svg { width: 18px; height: 18px; }
.side-link.active { background: linear-gradient(135deg, #2f6bff, #4f8cff); color: #fff; }
.side-foot { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.07); color: rgba(255,255,255,.45); font-size: 11.5px; line-height: 1.8; }
.side-status { color: #7fe3ac; display: flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3dd68c; display: inline-block; }
#side-mask { display: none; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  position: sticky; top: 0; z-index: 40;
}
#menu-btn { display: none; }
.page-title-wrap h1 { font-size: 18px; font-weight: 700; }
.page-title-wrap span { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.site-wordmark {
  font-size: 11px; letter-spacing: .22em; color: var(--muted);
  font-weight: 600; margin-bottom: 2px;
}
.top-actions { margin-left: auto; display: flex; gap: 10px; }
main { flex: 1; padding: 22px 24px 40px; max-width: 1360px; width: 100%; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px; margin-bottom: 18px;
  border: 1px solid rgba(227,233,242,.7);
}
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel-head h3 { font-size: 15.5px; font-weight: 700; }
.panel-head .badge { margin-left: auto; }
.panel-head.sub-head { margin-top: 26px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 .panel { margin-bottom: 0; }

.stat-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(227,233,242,.7);
  display: flex; gap: 12px; align-items: center;
}
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon.blue { background: #e9f0ff; color: #2f6bff; }
.stat-icon.green { background: #e6f8ec; color: #16a34a; }
.stat-icon.cyan { background: #e3f7fa; color: #0e94a5; }
.stat-icon.purple { background: #f1ecff; color: #7c5cff; }
.stat-icon.amber { background: #fdf3e2; color: #b97908; }
.stat-icon.pink { background: #fdebf3; color: #d4488d; }
.stat-num { font-size: 22px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 3px; }

.chart-box { width: 100%; height: 280px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }

.overview-list { display: flex; flex-direction: column; }
.ov-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.ov-device { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.ov-right { margin-left: auto; }
.ov-last { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 26px 0; }

.device-form { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.device-form input, .device-form select { flex: 1; min-width: 150px; }
.monitor-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; display: flex; gap: 14px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; padding: 10px 12px; color: var(--muted); background: #f7f9fc; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.key-cell { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: #f1f4fa; padding: 3px 8px; border-radius: 6px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.online { background: #e6f8ec; color: #16a34a; }
.status-badge.wait { background: #fff6e5; color: #c27803; }
.status-badge.offline { background: #eef1f6; color: var(--muted); }
.mcp-lead { margin: -6px 0 16px; line-height: 1.7; }
.mcp-form input#mcp-endpoint { flex: 2; min-width: 240px; }
.badge.soft-green { background: #e6f8ec; color: #16a34a; }
.badge.soft-gray { background: #eef1f6; color: var(--muted); }
.op-btn { background: none; border: 1px solid var(--border); padding: 5px 11px; border-radius: 8px; font-size: 12.5px; margin-right: 6px; color: var(--text-2); }
.op-btn.danger:hover { color: var(--red); }

.metric-rows { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.metric-row { background: #fbfcff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.metric-row-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 0 2px 8px; }
.metric-row-title span { font-weight: 400; color: var(--muted); }
.latest-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.latest-card { background: #f8faff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 10px; text-align: center; min-width: 0; }
.lc-label { color: var(--muted); font-size: 11.5px; }
.lc-value { font-size: 21px; font-weight: 800; margin: 5px 0 3px; font-family: ui-monospace, Consolas, monospace; }
.lc-unit, .lc-time { color: var(--muted); font-size: 11px; }
.latest-empty { color: var(--muted); text-align: center; padding: 20px 0; }
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 8px; }
.chart-card { background: #fbfcff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 10px 8px; }
.chart-subtitle { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 0 4px 4px; }
.chart-sm { height: 220px; }

.live-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.live-switch input { display: none; width: auto; }
.live-track { width: 40px; height: 22px; border-radius: 22px; background: #d6deeb; position: relative; flex: 0 0 40px; }
.live-track::after {
  content: ""; position: absolute; top: 2.5px; left: 3px; width: 17px; height: 17px;
  background: #fff; border-radius: 50%; transition: transform .2s;
}
.live-switch input:checked + .live-track { background: var(--green); }
.live-switch input:checked + .live-track::after { transform: translateX(17px); }
.live-text { font-size: 13.5px; color: var(--text-2); }

.ctl-info-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.ctl-info-row span { color: var(--muted); }
.ctl-info-row b.online { color: var(--green); }
.ctl-log-panel { display: flex; flex-direction: column; min-height: 0; }
.ctl-msg {
  height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.ctl-msg .log { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.log-t { color: var(--muted); font-size: 11.5px; }
.log-body.ok { color: var(--green); }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.action-btn {
  border: 1px solid var(--border); background: #fbfcff; border-radius: 12px;
  padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.action-btn .mini { font-size: 11px; color: var(--muted); font-weight: 400; }
.custom-ctl { display: grid; grid-template-columns: 200px 1fr auto; gap: 10px; }
.custom-ctl textarea { resize: vertical; min-height: 42px; }

.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.guide-grid .panel { margin-bottom: 0; }
.guide-text p, .guide-text li { line-height: 1.7; color: var(--text-2); margin-bottom: 8px; }
.guide-text ul { padding-left: 20px; }
code { background: #f1f4fa; border-radius: 5px; padding: 1px 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
pre {
  background: #0e1526; color: #d7e3ff; padding: 14px 16px; border-radius: 10px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.7; overflow-x: auto;
}
.settings-form { max-width: 420px; }
.tips { padding-left: 18px; }
.tips li { margin-bottom: 9px; color: var(--text-2); line-height: 1.6; }
.about-list { display: flex; flex-direction: column; }
.about-row { display: flex; justify-content: space-between; padding: 11px 2px; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.about-row span { color: var(--muted); }

.modal {
  display: none;
  position: fixed; inset: 0; background: rgba(13,23,48,.55);
  z-index: 100; align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.modal-card {
  background: #fff; border-radius: 18px; padding: 26px; width: 460px; max-width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.modal-head h3 { font-size: 18px; }
.modal-icon.success {
  width: 42px; height: 42px; border-radius: 50%; background: #e6f8ec; color: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.modal-card .muted { font-size: 13.5px; line-height: 1.7; margin-bottom: 16px; }
.key-box { margin-bottom: 12px; }
.key-box label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 6px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, Consolas, monospace; background: #f8faff; }
.modal-foot { margin-top: 18px; text-align: right; }

.toast {
  display: none; position: fixed; top: 22px; left: 50%; transform: translateX(-50%);
  background: #0f1a35; color: #fff; padding: 11px 22px; border-radius: 12px;
  font-size: 13.5px; z-index: 200; max-width: 90vw;
}
.toast.show { display: flex; }
.toast.ok { background: #13863f; }
.toast.err { background: #c12d32; }

@media (max-width: 1180px) { .stat-cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1024px) {
  .grid-2, .guide-grid { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  #sidebar { position: fixed; transform: translateX(-100%); transition: transform .25s; }
  body.side-open #sidebar { transform: translateX(0); }
  #side-mask { display: block; position: fixed; inset: 0; background: rgba(13,23,48,.45); z-index: 45; opacity: 0; pointer-events: none; }
  body.side-open #side-mask { opacity: 1; pointer-events: auto; }
  #menu-btn { display: inline-flex; }
  .login-wrap { flex-direction: column; padding: 40px 18px; }
  .login-brand { display: none; }
  .login-card-brand { display: block; }
}
@media (max-width: 640px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .custom-ctl { grid-template-columns: 1fr; }
}
