/* 管理后台 · 深色 + 橙色主题 */
:root {
  --bg: #0d0f13; --panel: #151a23; --panel2: #1a2130; --line: #263042;
  --text: #e8ecf3; --muted: #9aa5b8; --faint: #6b7688;
  --orange: #ff8a24; --orange-dim: #b46a1e; --orange-bg: rgba(255,138,36,.12);
  --green: #2ebd85; --red: #f6465d; --blue: #4f9cf7;
  --radius: 10px; --topbar-h: 56px; --sidebar-w: 220px; --sidebar-wc: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button { font: inherit; }

/* 登录 */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(600px 400px at 50% 20%, #1a2333, var(--bg)); }
.login-card { width: 360px; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 36px 32px; }
.login-logo { width: 52px; height: 52px; border: 2px solid var(--orange); color: var(--orange); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; margin-bottom: 16px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.err { color: var(--red); font-size: 13px; margin: 12px 0 0; }

/* 通用表单/按钮 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; background: #0f141d; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--orange); }
.btn { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px 16px; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--orange); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1a1005; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 8px; border-radius: 8px; position: relative; }
.icon-btn:hover { color: var(--text); background: var(--panel2); }
.badge { position: absolute; top: 4px; right: 4px; background: var(--red); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* 顶栏 */
.topbar { height: var(--topbar-h); background: #10151e; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 16px; position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 32px; height: 32px; border: 1.5px solid var(--orange); color: var(--orange); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.brand-name { font-weight: 600; font-size: 15px; white-space: nowrap; }
.top-search { flex: 1; max-width: 380px; margin-left: 12px; }
.top-search input { width: 100%; background: #0c1119; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 13px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-sel { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 7px 8px; font-size: 13px; }
.admin-info { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.role-tag { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-dim); border-radius: 6px; padding: 2px 8px; font-size: 11px; }

/* 布局 */
.layout { display: flex; padding-top: var(--topbar-h); min-height: 100dvh; }
.sidebar { width: var(--sidebar-w); background: #11161f; border-right: 1px solid var(--line); position: fixed; top: var(--topbar-h); bottom: 0; left: 0; overflow-y: auto; transition: width .2s, margin .2s; z-index: 90; }
.sidebar.collapsed { width: var(--sidebar-wc); }
.sidebar.collapsed .nav-label, .sidebar.collapsed .nav-group-title { display: none; }
.workspace { flex: 1; margin-left: var(--sidebar-w); padding: 20px 24px 60px; min-width: 0; transition: margin .2s; }
.sidebar.collapsed ~ .workspace { margin-left: var(--sidebar-wc); }

/* 侧栏导航 */
.nav-group { padding: 12px 8px 4px; }
.nav-group-title { font-size: 11px; color: var(--faint); padding: 8px 12px 4px; letter-spacing: 1px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 14px; border-left: 3px solid transparent; margin: 2px 4px; white-space: nowrap; }
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item.active { background: var(--orange-bg); color: var(--orange); border-left-color: var(--orange); font-weight: 600; }
.nav-item .nav-icon { font-size: 17px; width: 24px; text-align: center; flex-shrink: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }

/* 面包屑 + 模块头 */
.crumb { color: var(--faint); font-size: 12px; margin-bottom: 8px; }
.crumb b { color: var(--muted); font-weight: 400; }
.module-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.module-head h1 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.module-head .desc { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

/* 卡片 / 统计 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-card .k { font-size: 12px; color: var(--muted); }
.stat-card .v { font-size: 24px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.stat-card .s { font-size: 11px; color: var(--faint); }
.stat-card .v.up { color: var(--green); } .stat-card .v.down { color: var(--red); } .stat-card .v.warn { color: var(--orange); }

/* 筛选区 */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { background: #0f141d; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.filter-bar input { min-width: 180px; }

/* 表格 */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { background: #1a2230; color: #a9b6c8; font-weight: 600; text-align: left; padding: 10px 12px; white-space: nowrap; position: sticky; top: 0; }
table.grid td { padding: 10px 12px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover { background: rgba(255,255,255,.03); }
table.grid .num { text-align: right; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.tag.green { color: var(--green); border-color: var(--green); background: rgba(46,189,133,.1); }
.tag.red { color: var(--red); border-color: var(--red); background: rgba(246,70,93,.1); }
.tag.orange { color: var(--orange); border-color: var(--orange-dim); background: var(--orange-bg); }
.tag.blue { color: var(--blue); border-color: var(--blue); background: rgba(79,156,247,.1); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 4px; font-size: 13px; color: var(--muted); }

/* 抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: -480px; width: 460px; max-width: 94vw; height: 100dvh; background: var(--panel); border-left: 1px solid var(--line); z-index: 201; transition: right .25s; display: flex; flex-direction: column; }
.drawer.open { right: 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv .k { color: var(--muted); } .kv .v { text-align: right; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.tabs button.active { color: var(--orange); border-bottom-color: var(--orange); font-weight: 600; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1e2634; border: 1px solid var(--line); color: var(--text); padding: 12px 20px; border-radius: 10px; z-index: 300; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.toast.err { border-color: var(--red); color: var(--red); }

/* 空状态 */
.empty { text-align: center; padding: 48px 20px; color: var(--faint); }
.loading { text-align: center; padding: 48px 20px; color: var(--muted); }
.risk-note { background: rgba(246,70,93,.08); border: 1px solid var(--red); color: #ff8f9d; border-radius: 8px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }

/* H5 */
.sidebar-mask { display: none; }
@media (max-width: 900px) {
  .top-search { display: none; }
  .brand-name { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; width: var(--sidebar-w); }
  .sidebar.open { transform: none; }
  .sidebar.collapsed { width: var(--sidebar-w); }
  .sidebar.collapsed .nav-label, .sidebar.collapsed .nav-group-title { display: block; }
  .workspace { margin-left: 0 !important; padding: 14px 12px 60px; }
  .sidebar-mask { display: block; position: fixed; inset: 0; top: var(--topbar-h); background: rgba(0,0,0,.5); z-index: 85; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-mask.open { opacity: 1; pointer-events: auto; }
  .admin-info #adminName { display: none; }
  /* 表格转卡片 */
  table.grid.card-table thead { display: none; }
  table.grid.card-table, table.grid.card-table tbody, table.grid.card-table tr, table.grid.card-table td { display: block; width: 100%; }
  table.grid.card-table tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 8px 4px; background: var(--panel); }
  table.grid.card-table td { border: 0; display: flex; justify-content: space-between; padding: 6px 12px; }
  table.grid.card-table td::before { content: attr(data-th); color: var(--muted); font-size: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
