/* ==========================================================================
   安护 · 后台管理  ——  设计系统
   配色沿用 App 端品牌色（主色 #0e7c6b），保证与 C 端观感一致
   ========================================================================== */

:root {
  --brand: #0e7c6b;
  --brand-dark: #0a5d50;
  --brand-light: #e7f3f0;
  --brand-border: #bcdcd5;

  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e8eb;
  --border-strong: #d3d9de;

  --text: #16232b;
  --text-2: #46565f;
  --muted: #7d8b93;

  --gold: #b5863c;
  --gold-light: #f9f2e4;
  --danger: #c0392b;
  --danger-light: #fbeceb;
  --blue: #1f6fb2;
  --blue-light: #e9f2fa;
  --gray: #7d8b93;
  --gray-light: #eef1f4;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 35, 43, .04), 0 4px 16px rgba(22, 35, 43, .05);
  --shadow-lg: 0 8px 40px rgba(22, 35, 43, .14);
  --sidebar-w: 232px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.6;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }

/* ==========================================================================
   登录页
   ========================================================================== */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(14,124,107,.20), transparent 60%),
    radial-gradient(800px 400px at 100% 100%, rgba(31,111,178,.14), transparent 60%),
    #0f1a20;
  padding: 24px;
}
.login-screen.on { display: flex; }
.login-card {
  width: 100%; max-width: 392px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.4);
  padding: 36px 34px 30px;
  animation: rise .38s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.login-logo {
  width: 54px; height: 54px; border-radius: 15px;
  background: linear-gradient(140deg, var(--brand), #17a08a);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px; box-shadow: 0 6px 18px rgba(14,124,107,.32);
}
.login-logo svg { width: 28px; height: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.2px; }
.login-card .sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,124,107,.12);
}
.login-hint {
  margin-top: 18px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--brand-light); border: 1px solid var(--brand-border);
  color: var(--brand-dark); font-size: 12.5px; line-height: 1.7;
}
.login-err {
  margin: 0 0 14px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--danger-light); border: 1px solid #f0c4bf;
  color: var(--danger); font-size: 13px;
}

/* ==========================================================================
   布局
   ========================================================================== */
.layout { display: none; min-height: 100%; }
.layout.on { display: flex; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: #101d24; color: #c3d0d6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 18px 16px; display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: linear-gradient(140deg, var(--brand), #17a08a);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-brand .mark svg { width: 19px; height: 19px; }
.sidebar-brand b { color: #fff; font-size: 15px; display: block; letter-spacing: .3px; }
.sidebar-brand span { font-size: 11px; color: #7e929c; }
.nav { padding: 12px 10px; flex: 1; }
.nav-group { margin-bottom: 4px; }
.nav-label {
  padding: 12px 10px 6px; font-size: 10.5px; letter-spacing: 1.2px;
  color: #64777f; text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: #b8c6cd; font-size: 13.5px; cursor: pointer;
  transition: background .15s, color .15s; margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 500; }
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .85; }
.nav-item .count {
  margin-left: auto; background: rgba(255,255,255,.12);
  padding: 1px 7px; border-radius: 9px; font-size: 11px;
}
.nav-item .count:empty { display: none; }
.nav-item.active .count { background: rgba(255,255,255,.25); }
.sidebar-foot {
  padding: 12px 16px 16px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px; color: #64777f;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-light);
  color: var(--brand); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.content { padding: 22px 24px 40px; flex: 1; }

/* ==========================================================================
   组件
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .desc { color: var(--muted); font-size: 12.5px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #a5302a; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.grid { display: grid; gap: 16px; align-items: start; }
.grid.k2 { grid-template-columns: repeat(2, 1fr); }
.grid.k3 { grid-template-columns: repeat(3, 1fr); }
.grid.k4 { grid-template-columns: repeat(4, 1fr); }
.grid.k21 { grid-template-columns: 2fr 1fr; }
.grid.k12 { grid-template-columns: 1fr 2fr; }

.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; right: -22px; top: -22px;
  width: 76px; height: 76px; border-radius: 50%; background: var(--brand-light); opacity: .5;
}
.kpi .k-label { color: var(--muted); font-size: 12.5px; position: relative; z-index: 1; }
.kpi .k-value {
  font-size: 26px; font-weight: 650; letter-spacing: -.6px; margin-top: 5px;
  position: relative; z-index: 1; line-height: 1.2;
}
.kpi .k-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { font-size: 12px; color: var(--muted); margin-top: 7px; position: relative; z-index: 1; }
.kpi .k-foot b { color: var(--brand); font-weight: 600; }
.kpi.gold::after { background: var(--gold-light); }
.kpi.blue::after { background: var(--blue-light); }
.kpi.danger::after { background: var(--danger-light); }
.kpi.gray::after { background: var(--gray-light); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); color: var(--muted);
  font-weight: 500; font-size: 12px; white-space: nowrap; position: sticky; top: 0;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid #f0f2f4; vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.t-title { font-weight: 500; color: var(--text); }
.t-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.t-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty svg { width: 40px; height: 40px; opacity: .3; margin-bottom: 10px; }

/* 标签 */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 500;
  background: var(--gray-light); color: var(--gray); white-space: nowrap;
}
.pill.green { background: var(--brand-light); color: var(--brand-dark); }
.pill.gold { background: var(--gold-light); color: var(--gold); }
.pill.red { background: var(--danger-light); color: var(--danger); }
.pill.blue { background: var(--blue-light); color: var(--blue); }
.pill.dot::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tagline { display: flex; gap: 5px; flex-wrap: wrap; }

/* 筛选栏 */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.filters input, .filters select {
  padding: 7px 11px; font-size: 13px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,124,107,.1); }
.filters input { min-width: 230px; }
.filters .spacer { flex: 1; }

/* 分页 */
.pager {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted);
}
.pager .spacer { flex: 1; }
.pager button {
  padding: 4px 10px; font-size: 12.5px; border: 1px solid var(--border-strong);
  background: var(--surface); border-radius: 6px; cursor: pointer; color: var(--text-2);
}
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16,29,36,.45); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .18s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .22s cubic-bezier(.2,.8,.3,1);
}
.modal.wide { max-width: 780px; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-head .x {
  margin-left: auto; border: none; background: none; font-size: 20px;
  color: var(--muted); cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2);
}

/* 详情键值 */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 9px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); word-break: break-all; }

/* Toast */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #16232b; color: #fff; padding: 10px 16px; border-radius: 9px;
  font-size: 13px; box-shadow: var(--shadow-lg); animation: slide .22s;
  max-width: 380px;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--brand); }
@keyframes slide { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

/* 图表 */
.chart { width: 100%; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; }
.legend-item b { font-weight: 600; color: var(--text); }

/* 列表条目（动态 / 日志） */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid #f0f2f4;
  font-size: 13px; align-items: flex-start;
}
.list-item:last-child { border-bottom: none; }
.list-item .li-ico {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 28px;
  background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.list-item .li-ico svg { width: 14px; height: 14px; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* 模板卡片 */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.tpl-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; background: var(--surface); position: relative;
  transition: box-shadow .18s, transform .18s;
}
.tpl-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.tpl-card .tpl-ico {
  width: 38px; height: 38px; border-radius: 11px; display: flex;
  align-items: center; justify-content: center; margin-bottom: 11px;
}
.tpl-card .tpl-ico svg { width: 20px; height: 20px; }
.tpl-card h4 { margin: 0 0 3px; font-size: 14.5px; }
.tpl-card .tpl-cat { font-size: 11.5px; color: var(--muted); }
.tpl-card .tpl-scene {
  font-size: 12.5px; color: var(--text-2); margin-top: 9px; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tpl-card .tpl-foot {
  display: flex; align-items: center; gap: 10px; margin-top: 13px;
  padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.tpl-card .tpl-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
.tpl-card .off { opacity: .55; }

/* 进度条 */
.bar { height: 6px; border-radius: 4px; background: var(--gray-light); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }

/* 安全提醒横幅 */
.sec-banner{
  display:flex;gap:11px;align-items:flex-start;padding:12px 15px;margin-bottom:16px;
  border-radius:var(--radius);border:1px solid #f0d3a8;background:var(--gold-light);color:#8a5f18;
}
.sec-banner .ic{width:19px;height:19px;flex:0 0 19px;margin-top:1px}
.sec-banner b{display:block;font-size:13.5px;font-weight:600;color:#8a5f18}
.sec-banner span{display:block;font-size:12.5px;line-height:1.65;margin-top:2px;color:#8a5f18;opacity:.9}

/* 加载态 */
.loading { padding: 50px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner {
  width: 22px; height: 22px; border: 2px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .grid.k4 { grid-template-columns: repeat(2, 1fr); }
  .grid.k3, .grid.k21, .grid.k12 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .grid.k2, .grid.k4 { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}
