/* 万物物联 · 统一视觉 */
:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #fafbf9;
  --ink: #1a211d;
  --ink-2: #414a45;
  --muted: #77817b;
  --line: #e3e8e2;
  --line-2: #eff2ee;
  --accent: #0f7a62;
  --accent-dark: #0a5c4a;
  --accent-soft: #e6f4ef;
  --warn: #b2690b;
  --warn-soft: #fdf3e2;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ok: #14795f;
  --ok-soft: #e7f5ef;
  --blue: #2563eb;
  --blue-soft: #eaf0fd;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 32, 26, .04), 0 8px 24px rgba(20, 32, 26, .06);
  --shadow-lg: 0 24px 64px rgba(15, 30, 24, .22);
  --sidebar: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── 布局 ───────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: #10231e;
  color: #dfe9e4;
  padding: 22px 14px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #2fb391, #0f7a62);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 12px rgba(47, 179, 145, .35);
}
.brand-title { font-size: 15px; font-weight: 650; letter-spacing: .02em; color: #fff; }
.brand-sub { font-size: 11px; color: #8fa79d; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-label {
  font-size: 10px; letter-spacing: .14em; color: #6d857b; text-transform: uppercase;
  padding: 10px 12px 4px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px; color: #c4d4cc; font-size: 13.5px;
  transition: background .16s, color .16s;
}
.nav a .ico { width: 18px; text-align: center; opacity: .8; font-size: 14px; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(47, 179, 145, .16); color: #fff; }
.nav a.active .ico { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .hint { font-size: 11px; color: #7d938a; line-height: 1.5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; background: rgba(244, 246, 243, .86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.page-title { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12.5px; color: var(--ink-2);
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent-dark); display: grid; place-items: center; font-weight: 650; font-size: 12px;
}
.content { padding: 24px 28px 56px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ── 通用组件 ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0; gap: 12px;
}
.card-title { font-size: 14.5px; font-weight: 650; }
.card-hint { font-size: 12px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  font-size: 13px; font-weight: 520; white-space: nowrap;
  transition: transform .08s, background .16s, border-color .16s, box-shadow .16s;
}
.btn:hover { background: var(--surface-2); border-color: #d5ddd6; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--danger-soft); border-color: #f5c9c2; color: var(--danger); }
.btn-danger:hover { background: #fbdcd7; }
.btn-warn { background: var(--warn-soft); border-color: #ecd3a8; color: var(--warn); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: #9cc9bd; box-shadow: 0 0 0 3px rgba(15,122,98,.1);
}
.textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 560; }
.field .help { font-size: 11.5px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 560; line-height: 1.7; white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: #f0f2f0; color: #7c8680; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }

/* ── KPI ───────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .k-label { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.kpi .k-value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; }
.kpi .k-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi .k-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.kpi .k-accent { position: absolute; right: -18px; top: -18px; width: 76px; height: 76px; border-radius: 50%; background: var(--accent-soft); opacity: .7; }
.kpi.warn .k-accent { background: var(--warn-soft); }
.kpi.danger .k-accent { background: var(--danger-soft); }

/* ── 表格 ───────────────────────────────────────────── */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
  text-align: left; font-weight: 560; color: var(--muted); font-size: 11.5px;
  letter-spacing: .04em; padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap;
}
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #fcfdfb; }
.t-main { font-weight: 560; color: var(--ink); }
.t-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }

.empty {
  padding: 44px 20px; text-align: center; color: var(--muted); font-size: 13px;
}
.empty .big { font-size: 24px; opacity: .5; display: block; margin-bottom: 8px; }
.loading { padding: 36px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ── 接口文档 ─────────────────────────────────────── */
.api-code {
  margin: 0; padding: 12px 14px; border-radius: 10px;
  background: #0f1a16; color: #d7e7df;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px; line-height: 1.7; overflow: auto;
}
.table code { font-size: 11.5px; color: var(--accent-dark); }

/* ── 图表/分布 ─────────────────────────────────────── */
.mode-bars { display: flex; flex-direction: column; gap: 12px; }
.mode-row { display: grid; grid-template-columns: 128px 1fr 40px; gap: 10px; align-items: center; font-size: 12px; }
.mode-row .bar { height: 9px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.mode-row .bar i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.mode-row .bar i.external { background: #4b8bd6; }
.mode-row .bar i.mechanical { background: #b7bdb9; }
.mode-row .bar i.danger { background: var(--danger); }
.mode-row .bar i.warn { background: var(--warn); }
.mode-row .bar i.info { background: #4b8bd6; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding: 8px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; }
.chart .bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #36b294, #0f7a62); border-radius: 6px 6px 3px 3px; min-height: 3px; transition: height .3s; }
.chart .lbl { font-size: 10.5px; color: var(--muted); }
.chart .val { font-size: 10.5px; color: var(--ink-2); }

/* ── 弹窗 ───────────────────────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 30, 24, .42); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 64px); overflow: auto;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  animation: pop .18s ease-out;
}
.modal.wide { width: min(820px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-title { font-size: 16px; font-weight: 650; }
.modal-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 18px 22px 8px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; border-radius: 6px; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

/* ── 提示 ───────────────────────────────────────────── */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #16241f; color: #fff; padding: 10px 14px; border-radius: 10px;
  font-size: 12.5px; box-shadow: var(--shadow-lg); max-width: 380px;
  animation: slide .18s ease-out;
}
.toast.error { background: #7d241b; }
.toast.ok { background: #0d5c48; }
@keyframes slide { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.flashes { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; font-size: 12.5px; background: var(--accent-soft); color: var(--accent-dark); border: 1px solid #cfe8df; }
.flash.error { background: var(--danger-soft); color: var(--danger); border-color: #f3cac4; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 20px; }
.tab { padding: 10px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line-2);
}
.toolbar .left, .toolbar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { width: 240px; }
.muted { color: var(--muted); }
.section-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 12.5px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--ink); word-break: break-all; }
.notice { padding: 11px 13px; border-radius: 10px; background: var(--warn-soft); color: #7a4c09; font-size: 12px; border: 1px solid #f0dcb8; }
.notice.info { background: var(--blue-soft); color: #1f4fa8; border-color: #d3e0fb; }
.notice.danger { background: var(--danger-soft); color: var(--danger); border-color: #f3cac4; }
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }

/* ── 登录页 ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: #0f211c;
}
.login-side {
  padding: 56px; color: #e6efea; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 500px at 0% 20%, rgba(47,179,145,.22), transparent 60%),
              radial-gradient(800px 400px at 100% 100%, rgba(47,179,145,.12), transparent 60%);
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { width: 40px; height: 40px; font-size: 17px; }
.login-headline { font-size: 34px; line-height: 1.25; font-weight: 640; letter-spacing: -.02em; max-width: 520px; }
.login-headline em { font-style: normal; color: #5fd0ae; }
.login-points { display: flex; flex-direction: column; gap: 12px; font-size: 13px; color: #a9beb4; max-width: 460px; }
.login-points div { display: flex; gap: 10px; }
.login-points span { color: #5fd0ae; }
.login-panel {
  background: #f7f9f6; display: flex; align-items: center; justify-content: center; padding: 40px;
}
.login-card { width: min(380px, 100%); }
.login-card h1 { font-size: 23px; margin: 0 0 6px; letter-spacing: -.02em; }
.login-card p { color: var(--muted); font-size: 12.5px; margin: 0 0 26px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { height: 42px; }
.login-foot { margin-top: 22px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* ── 响应式 ─────────────────────────────────────────── */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar: 72px; }
  .brand-title, .brand-sub, .nav a span:not(.ico), .nav-label, .sidebar-foot { display: none; }
  .nav a { justify-content: center; padding: 11px 8px; }
  .nav a .ico { font-size: 17px; }
  .brand { justify-content: center; padding: 0; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar { height: auto; padding-top: 12px; padding-bottom: 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .modal-body { padding: 14px 16px 6px; }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
}

/* ── 注册页验证码 ───────────────────────────────────── */
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row .input { flex: 1; }
.captcha-row img { border-radius: 8px; border: 1px solid var(--line); cursor: pointer; background: #eef4f0; }
