:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #e0ecff 0%, #f8fafc 55%, #e2f4f0 100%); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 16px; padding: 36px; box-shadow: 0 18px 50px rgba(15, 23, 42, .12); }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand .logo { width: 46px; height: 46px; border-radius: 12px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .4px; }
.field { display: block; margin-bottom: 18px; }
.field span { display: block; margin-bottom: 8px; font-weight: 600; }
.field input, .modal input[type=text], .modal select, .modal textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); }
.field input:focus, .modal input:focus, .modal select:focus, .modal textarea:focus { outline: 2px solid rgba(37,99,235,.2); border-color: var(--primary); }
.form-error { min-height: 20px; color: var(--danger); margin-bottom: 6px; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.block { width: 100%; padding: 12px; font-size: 15px; }
.btn.link { border: none; background: transparent; color: var(--primary); padding: 4px 6px; }
.btn.link:hover { background: #eff6ff; }

/* 整体布局：左侧导航 + 右侧内容 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex: 0 0 220px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.side-brand { height: 62px; flex: 0 0 62px; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.08); color: #fff; }
.side-brand .logo { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; }
.side-brand strong { display: block; font-size: 15px; }
.side-brand small { display: block; font-size: 10px; opacity: .5; letter-spacing: .6px; }
.side-nav { flex: 1; padding: 16px 10px; overflow-y: auto; }
.side-group { padding: 6px 12px 10px; font-size: 11px; letter-spacing: 1px; color: #64748b; }
.side-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; margin-bottom: 4px; border-radius: 8px; color: #cbd5e1; font-size: 14px; text-decoration: none; }
.side-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-item.active { background: var(--primary); color: #fff; }
.side-icon { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px; background: rgba(255,255,255,.1); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.side-item.active .side-icon { background: rgba(255,255,255,.2); }
.side-foot { padding: 14px 18px; font-size: 11px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }
.app-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 62px; flex: 0 0 62px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 10; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-badge { color: var(--muted); }
.main { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 26px 28px 40px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 2px 8px rgba(15,23,42,.04); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); }
.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input { width: 260px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
.search input[type=date] { width: 140px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: 13px; }
.date-sep { color: var(--muted); font-size: 12px; }

/* 统计卡片与标签页 */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card b { font-size: 24px; line-height: 1.1; }
.stat-card b.ok { color: var(--success); }
.stat-card b.warn { color: var(--warn); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { border: none; background: transparent; padding: 10px 18px; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; }
td { font-size: 13px; }
tr:hover td { background: #fafcff; }
.ops { text-align: right; }
td.ops { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eff6ff; color: var(--primary-dark); font-size: 12px; margin: 1px 3px 1px 0; }
.tag.off { background: #f1f5f9; color: var(--muted); }
.status-on { color: var(--success); }
.status-off { color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.pill.ok { background: #dcfce7; color: #15803d; }
.pill.warn { background: #fef3c7; color: #b45309; }
.table-foot { padding: 12px 16px; color: var(--muted); font-size: 12px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: #fff; border-radius: 14px; padding: 24px; box-shadow: 0 24px 60px rgba(15,23,42,.25); }
.modal.wide { max-width: 760px; }
.modal h3 { margin: 0 0 20px; font-size: 18px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-grid .full { grid-column: 1 / -1; }
.modal label { display: block; }
.modal label > span { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
.topics-box { display: flex; flex-wrap: wrap; gap: 8px; max-height: 180px; overflow-y: auto; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.topic-check { display: inline-flex !important; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; background: #f8fafc; font-size: 13px; cursor: pointer; }
.topic-check input { margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.modal-error { color: var(--danger); min-height: 18px; margin-top: 10px; }
.code-box { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px; font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 8px 0 16px; }
.info-row { display: flex; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.info-row .k { color: var(--muted); flex: 0 0 82px; }
.info-row .v { flex: 1; word-break: break-all; }
.dist { display: flex; flex-wrap: wrap; gap: 8px; }
.dist-item { background: #eff6ff; color: var(--primary-dark); border-radius: 999px; padding: 5px 11px; font-size: 12px; }

/* 提示 */
.toast { position: fixed; right: 26px; bottom: 26px; max-width: 420px; padding: 13px 18px; border-radius: 10px; background: #0f172a; color: #fff; box-shadow: 0 12px 30px rgba(15,23,42,.25); z-index: 100; line-height: 1.5; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .sidebar { width: 64px; flex-basis: 64px; }
  .side-brand { padding: 0 15px; }
  .side-brand > div, .side-group, .side-foot, .side-item span:not(.side-icon) { display: none; }
  .side-item { justify-content: center; padding: 11px 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .toolbar, .search, .toolbar-actions { width: 100%; }
  .search input { flex: 1; width: auto; }
  .modal-grid { grid-template-columns: 1fr; }
  .main { padding: 18px 14px 30px; }
  .topbar { padding: 0 14px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
