:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2d3d;
  --muted: #6b7a90;
  --line: #e6ebf1;
  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --gray: #94a3b8;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
#app { min-height: 100vh; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a, #2563eb); }
.login-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.login-card input, .login-card select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--brand); }
.btn { cursor: pointer; border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600; }
.btn-primary { background: var(--brand); color: #fff; width: 100%; margin-top: 18px; }
.btn-primary:hover { background: var(--brand-d); }
.hint { margin-top: 16px; font-size: 12px; color: var(--muted); background: #f1f5f9; padding: 10px; border-radius: 8px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; }
.sidebar .logo { padding: 18px 20px; display: flex; align-items: center; border-bottom: 1px solid #1e293b; font-weight: 700; color: #fff; font-size: 15px; gap: 8px; }
.sidebar .logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); display: inline-block; }
.sidebar .nav { padding: 12px 0; flex: 1; }
.sidebar .nav .item { padding: 12px 20px; color: #cbd5e1; cursor: pointer; font-size: 14px; }
.sidebar .nav .item.active { background: #1e293b; color: #fff; border-left: 3px solid var(--brand); }
.sidebar .foot { padding: 16px 20px; font-size: 12px; color: #64748b; border-top: 1px solid #1e293b; }
.main { flex: 1; margin-left: 220px; padding: 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h2 { margin: 0; font-size: 18px; }
.topbar .user { display: flex; align-items: center; gap: 12px; }
.topbar .link { color: var(--brand); cursor: pointer; font-size: 13px; }
.topbar .link:hover { text-decoration: underline; }

/* ---------- 统计卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card .label { font-size: 13px; color: var(--muted); }
.stat-card .num.red { color: var(--red); }
.stat-card .num.green { color: var(--green); }
.stat-card .num.brand { color: var(--brand); }

/* ---------- 表格 ---------- */
.panel { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; }
.panel .panel-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f8fafc; }
tr:hover td { background: #f8fafc; }
tr.expiring td { background: #fef2f2; }
tr.expiring:hover td { background: #fee2e2; }
tr.converted td { color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.online { background: #dcfce7; color: var(--green); }
.badge.offline { background: #fee2e2; color: var(--red); }
.badge.expiring { background: #fee2e2; color: var(--red); }
.badge.normal { background: #e0e7ff; color: var(--brand); }
.badge.converted { background: #e2e8f0; color: #475569; }
.badge.formal { background: #dcfce7; color: #15803d; }
.badge.soon { background: #fef3c7; color: var(--amber); }
.op-btn { cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 4px 10px; font-size: 12px; margin-right: 6px; }
.op-btn:hover { border-color: var(--brand); color: var(--brand); }
.op-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.op-btn.primary:hover { background: var(--brand-d); }
.op-btn.danger { border-color: #fecaca; color: var(--red); }
.op-btn.danger:hover { background: #fef2f2; }
.op-btn:disabled { opacity: .5; cursor: not-allowed; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* ---------- 弹窗 ---------- */
.mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.modal input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.modal input:focus { border-color: var(--brand); }
.modal .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-ghost { background: #f1f5f9; color: var(--ink); }
.btn-ghost:hover { background: #e2e8f0; }
.msg { margin-top: 12px; font-size: 13px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }
.dl-link { display: inline-block; margin-top: 8px; color: var(--brand); font-weight: 600; text-decoration: none; }
.dl-link:hover { text-decoration: underline; }
.tip { font-size: 12px; color: var(--muted); }

/* ---------- v2 扩展样式 ---------- */
.sidebar .nav .item:hover { background: #1e293b; color: #fff; }
.badge.gray { background: #f1f5f9; color: #64748b; }
.badge.offline { background: #fee2e2; color: var(--red); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.inst-sel { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; background: #fff; min-width: 160px; }
.modal select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; background: #fff; }
.modal textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; resize: vertical; font-family: inherit; }
.modal textarea:focus, .modal select:focus { border-color: var(--brand); }
.modal-lg { width: 780px; max-width: 94vw; max-height: 88vh; overflow: auto; }
.btn.danger-solid { background: var(--red); color: #fff; }
.btn.danger-solid:hover { background: #b91c1c; }
.toast-global { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #1f2d3d; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 999; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast-global.ok { background: var(--green); }
.toast-global.err { background: var(--red); }
.remote-body { margin-top: 4px; overflow-x: auto; }
table.mini { font-size: 12px; }
table.mini th, table.mini td { padding: 6px 8px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; background: #f8fafc; border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.kv div span { color: var(--muted); display: inline-block; min-width: 60px; }
.note-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.note-item { border-bottom: 1px dashed var(--line); padding: 8px 0; }
.note-item:last-child { border-bottom: none; }
.note-head { font-size: 12px; color: var(--muted); }
.note-body { margin-top: 3px; white-space: pre-wrap; word-break: break-all; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb-item { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: zoom-in; background: #f8fafc; }
.thumb-item img { width: 100%; height: 90px; object-fit: cover; display: block; }
.thumb-item img:hover { opacity: .85; }
.thumb-meta { font-size: 11px; color: var(--muted); padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big-photo { text-align: center; }
.big-photo img { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.bar { display: inline-block; width: 120px; height: 8px; background: #eef2f7; border-radius: 4px; vertical-align: middle; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 2px solid var(--line); }
.tabs .tab { padding: 8px 18px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); }

