:root {
  --ink: #152033;
  --ink-2: #1f2d45;
  --accent: #2f6fed;
  --accent-soft: #eaf1ff;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #e6ebf2;
  --text: #1c2434;
  --muted: #6b778c;
  --ok: #14804a;
  --ok-bg: #e9f8ef;
  --warn: #b76a00;
  --warn-bg: #fff4e5;
  --danger: #d14343;
  --shadow: 0 8px 24px rgba(21, 32, 51, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.error { color: var(--danger); min-height: 20px; }
.pill {
  background: var(--accent-soft);
  color: #2856c8;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  background: #eef2f7;
  color: #334155;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #2159d8; }
.btn.ghost {
  background: #fff;
  color: #334155;
  border: 1px solid var(--line);
}
.btn.ghost:hover { border-color: #c9d4e4; background: #f8fafc; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.icon-btn {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #94a3b8;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 10% -10%, #dbe7ff 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e8eef8 0%, transparent 50%),
    linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.login-brand {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  padding: 5px 10px;
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}
.login-card h1 { margin: 0 0 8px; font-size: 22px; color: var(--ink); }
.login-card label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #d7deea;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
}
.side-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
  padding: 0 8px;
  color: #fff;
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}
.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #a8b3c7;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 14px;
}
.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-item.active {
  background: rgba(47, 111, 237, 0.22);
  color: #fff;
}
.side-foot { margin-top: auto; padding: 8px; }
.who { font-size: 12px; margin-bottom: 10px; color: #9aa6bb; }
.side-foot .btn.ghost {
  border-color: rgba(255, 255, 255, 0.14);
  color: #d7deea;
  background: transparent;
}

.main { flex: 1; padding: 22px 28px 40px; overflow: auto; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.topbar h2 { margin: 0 0 4px; font-size: 22px; color: var(--ink); }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input,
.filters select,
.form-grid input,
.form-grid select,
.login-card input,
.dlg input,
.dlg select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
}
.filters input { min-width: 260px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.stat {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}
.stat .sub { margin-top: 6px; font-size: 12px; color: #94a3b8; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.card.soft { padding: 16px; margin-bottom: 14px; }
.card.soft h4 { margin: 0 0 12px; }
.panel-head { padding: 14px 16px 0; }
.panel-head h3 { margin: 0; font-size: 15px; color: var(--ink); }
.panel-body { padding: 12px 16px 16px; font-size: 13px; }
.list-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
}
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.status.ONLINE, .status.ok { background: var(--ok-bg); color: var(--ok); }
.status.OFFLINE, .status.bad { background: #f1f5f9; color: #64748b; }
.status.REFILL { background: var(--warn-bg); color: var(--warn); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(760px, 96vw);
  height: 100vh;
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 48px rgba(15, 23, 42, 0.14);
}
.drawer-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-head h3 { margin: 0; color: var(--ink); }
.drawer-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.tab.active {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.drawer-body { padding: 18px 20px 28px; overflow: auto; flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select { width: 100%; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.channel-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  background: #fcfdff;
}
.channel-card img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: #f1f5f9;
}
.role-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.role-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.role-card strong { display: block; margin-bottom: 6px; color: var(--ink); }

dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(560px, 94vw);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.42); }
.dlg { padding: 22px; }
.dlg h3 { margin: 0 0 14px; color: var(--ink); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  opacity: 0;
  transition: .2s;
  z-index: 99;
  pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 1100px) {
  .stat-grid, .split, .role-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  nav { display: flex; flex-wrap: wrap; gap: 6px; }
  .stat-grid, .split, .role-cards, .form-grid { grid-template-columns: 1fr; }
}
