/* ============================================================
   UltraBot 授权管理后台 — 设计系统 (自包含, 无外部依赖)
   风格：浅色 + 深石板侧边栏，单一克制强调色（teal），语义色仅用于状态
   ============================================================ */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --sidebar-1: #0f172a;
  --sidebar-2: #15213b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-dim: #7c8aa5;
  --sidebar-active-bg: rgba(20, 184, 166, 0.14);
  --sidebar-active-bar: #14b8a6;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --border: #e7ebf1;
  --border-strong: #d6dce6;

  --primary: #0d9488;
  --primary-600: #0f766e;
  --primary-700: #115e59;
  --primary-50: #e6f7f5;
  --primary-100: #ccfbf1;

  --success: #16a34a;  --success-bg: #e8f6ec;  --success-bd: #b6e3c2;
  --warning: #c2740a;  --warning-bg: #fdf3e3;  --warning-bd: #f4d9a8;
  --danger:  #dc2626;  --danger-bg:  #fdecec;  --danger-bd:  #f6c9c9;
  --info:    #2563eb;  --info-bg:    #eaf1fe;  --info-bd:    #c3d6fb;
  --neutral: #64748b;  --neutral-bg: #eef1f6;  --neutral-bd: #d8dee8;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md: 0 8px 28px rgba(15,23,42,.09);
  --shadow-pop: 0 12px 40px rgba(15,23,42,.16);
  --ring: 0 0 0 3px rgba(13,148,136,.18);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 256px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4,h5,h6 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
code, .mono { font-family: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace; }

/* ---------- 布局骨架 ---------- */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: 40;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar__logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--sidebar-active-bar), #2dd4bf);
  display: grid; place-items: center; color: #042f2a; flex: 0 0 auto;
  box-shadow: 0 4px 14px rgba(20,184,166,.35);
}
.sidebar__brand h1 { font-size: 15px; color: #fff; font-weight: 700; line-height: 1.2; }
.sidebar__brand small { display: block; color: var(--sidebar-text-dim); font-size: 11px; font-weight: 500; letter-spacing: .04em; }

.sidebar__nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar__section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-text-dim); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  position: relative; transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.is-active {
  background: var(--sidebar-active-bg); color: #fff;
}
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--sidebar-active-bar);
}
.nav-item.is-active svg { opacity: 1; }

.sidebar__foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.06); font-size: 11.5px; color: var(--sidebar-text-dim); }

/* 移动端遮罩 */
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  z-index: 35; opacity: 0; visibility: hidden; transition: opacity .25s ease;
  backdrop-filter: blur(1px);
}

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hamburger {
  display: none; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; place-items: center;
}
.hamburger svg { width: 20px; height: 20px; }
.topbar__title { font-size: 17px; font-weight: 650; }
.topbar__title small { display:block; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.topbar__right { display: flex; align-items: center; gap: 12px; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 999px; }
.user-chip__avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #2dd4bf);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-chip__meta { line-height: 1.2; }
.user-chip__meta b { font-size: 13px; display: block; }
.user-chip__meta span { font-size: 11px; color: var(--text-muted); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text-muted); cursor: pointer; display: grid; place-items: center;
  transition: all .15s ease;
}
.icon-btn:hover { color: var(--danger); border-color: var(--danger-bd); background: var(--danger-bg); }
.icon-btn svg { width: 18px; height: 18px; }

.content { padding: 26px 24px 48px; flex: 1; }
.container-x { max-width: 1180px; margin: 0 auto; }

/* ---------- 页面头 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
  margin-bottom: 20px;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.card__head h3 { font-size: 15px; }
.card__head .sub { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.card__body { padding: 18px; }
.card__body.is-flush { padding: 0; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm);
}
.stat__icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto; }
.stat__icon svg { width: 22px; height: 22px; }
.stat__num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat__label { font-size: 12.5px; color: var(--text-muted); }

.tint-teal   { background: var(--primary-50);  color: var(--primary-600); }
.tint-green  { background: var(--success-bg);  color: var(--success); }
.tint-amber  { background: var(--warning-bg);  color: var(--warning); }
.tint-red    { background: var(--danger-bg);   color: var(--danger); }
.tint-blue   { background: var(--info-bg);     color: var(--info); }
.tint-slate  { background: var(--neutral-bg);  color: var(--neutral); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--text-muted);
  background: var(--surface-2); padding: 12px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap; font-size: 12.5px; letter-spacing: .01em;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr { transition: background .12s ease; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent; line-height: 1.4; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--green { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.badge--amber { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bd); }
.badge--red   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-bd); }
.badge--blue  { background: var(--info-bg);    color: var(--info);    border-color: var(--info-bd); }
.badge--slate { background: var(--neutral-bg); color: var(--neutral); border-color: var(--neutral-bd); }
.badge--teal  { background: var(--primary-50); color: var(--primary-600); border-color: var(--primary-100); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font); font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: all .15s ease; white-space: nowrap; user-select: none;
}
.btn svg { width: 16px; height: 16px; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(13,148,136,.4); }
.btn--primary:hover { background: var(--primary-600); }
.btn--ghost { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn--soft { background: var(--primary-50); color: var(--primary-700); }
.btn--soft:hover { background: var(--primary-100); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #b91c1c; }
.btn--warn { background: #fff; border-color: var(--warning-bd); color: var(--warning); }
.btn--warn:hover { background: var(--warning-bg); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.col-3 { grid-column: span 3; } .field.col-4 { grid-column: span 4; }
.field.col-6 { grid-column: span 6; } .field.col-12 { grid-column: span 12; }
label.lbl { font-size: 12.5px; font-weight: 600; color: var(--text); }
label.lbl .opt { color: var(--text-faint); font-weight: 500; }
.input, .select, textarea.input {
  width: 100%; padding: 9px 12px; font-size: 13.5px; font-family: var(--font);
  border: 1px solid var(--border-strong); border-radius: var(--radius-xs); background: #fff;
  color: var(--text); transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-faint); }
.help { font-size: 12px; color: var(--text-muted); }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

.check-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- 提示 ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex: 0 0 auto; }
.alert--success { background: var(--success-bg); color: #146c31; border-color: var(--success-bd); }
.alert--warn { background: var(--warning-bg); color: #92590a; border-color: var(--warning-bd); }
.alert--danger { background: var(--danger-bg); color: #b91c1c; border-color: var(--danger-bd); }
.alert--info { background: var(--info-bg); color: #1d4ed8; border-color: var(--info-bd); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty svg { width: 42px; height: 42px; opacity: .5; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 13.5px; }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-aside {
  background: linear-gradient(150deg, #0f172a, #15324a 60%, #0d9488);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-aside::after {
  content: ""; position: absolute; width: 420px; height: 420px; right: -120px; top: -120px;
  background: radial-gradient(circle, rgba(45,212,191,.35), transparent 70%); border-radius: 50%;
}
.login-aside .brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.login-aside .brand .logo { width: 46px; height: 46px; border-radius: 13px; background: rgba(255,255,255,.14); display: grid; place-items: center; }
.login-aside h2 { font-size: 28px; margin-top: 48px; line-height: 1.3; position: relative; z-index: 1; }
.login-aside p { color: rgba(255,255,255,.72); max-width: 42ch; margin-top: 14px; position: relative; z-index: 1; }
.login-aside .foot { font-size: 12.5px; color: rgba(255,255,255,.6); position: relative; z-index: 1; }
.login-main { display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h3 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-muted); margin-bottom: 24px; font-size: 13.5px; }
.login-card .field { margin-bottom: 16px; }

/* ---------- 杂项 ---------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.split { display: flex; gap: 20px; flex-wrap: wrap; }
.split > * { flex: 1; min-width: 280px; }
.hidden { display: none !important; }
.kbd { font-family: var(--font); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; font-size: 12px; }

/* ---------- 响应式 ---------- */
@media (max-width: 991px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow-pop);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .sidebar-overlay { opacity: 1; visibility: visible; }
  .hamburger { display: grid; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .login-page { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .table-actions .btn { flex: 1 1 auto; }
  .user-chip__meta { display: none; }
  .page-head h2 { font-size: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.col-3, .field.col-4, .field.col-6, .field.col-12 { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
