/* ==========================================================
   授权平台后台样式 (v2)
   设计目标:现代化、清爽、大字号、统一节奏
   ========================================================== */

:root {
  --brand:       #206bc4;
  --brand-dark:  #185a9d;
  --brand-soft:  #e8f1fd;

  --ink:         #1a2433;
  --ink-2:       #3b4a64;
  --muted:       #6c7793;
  --muted-2:     #98a2b8;

  --line:        #dde3ed;
  --line-soft:   #edf0f6;

  --bg:          #f4f6fb;
  --surface:     #ffffff;

  --radius:      13px;
  --radius-sm:   9px;
  --radius-lg:   16px;

  --shadow:      0 6px 20px rgba(24, 36, 51, .06);
  --shadow-lg:   0 14px 40px rgba(24, 36, 51, .14);

  /* 字号规范 */
  --fs-base:     14.5px;
  --fs-sm:       13px;
  --fs-xs:       12px;
  --fs-lg:       16px;
  --fs-title:    24px;
  --fs-stat:     28px;
}

* { box-sizing: border-box; }

html { font-size: var(--fs-base); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* ============= 整体外壳 ============= */

.admin-shell { display: flex; min-height: 100vh; }

/* ============= 左侧栏 ============= */

.app-sidebar {
  width: 232px; flex: 0 0 232px;
  background: linear-gradient(180deg, #1c2939 0%, #11192a 100%);
  color: #a8b7c7;
  position: sticky; top: 0; height: 100vh;
  z-index: 20;
  display: flex; flex-direction: column;
}

.app-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 22px 22px 18px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .02em;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4c91e3 0%, #206bc4 100%);
  display: grid; place-items: center;
  font-size: 17px;
  box-shadow: 0 4px 10px rgba(32,107,196,.4);
}

.app-nav { padding: 10px 14px 22px; flex: 1; overflow-y: auto; }

.nav-title {
  display: block;
  font-size: 11px;
  letter-spacing: .14em;
  margin: 20px 12px 8px;
  color: #6f8093;
  font-weight: 600;
  text-transform: uppercase;
}

.app-nav .nav-link {
  color: #b9c5d3;
  padding: 10px 13px;
  margin-bottom: 4px;
  border-radius: 10px;
  display: flex; align-items: center; gap: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.app-nav .nav-link i { font-size: 17px; opacity: .85; }
.app-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.app-nav .nav-link.active {
  background: linear-gradient(135deg, #2670d0 0%, #1f5eb0 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(32,107,196,.4);
}
.app-nav .nav-link.active i { opacity: 1; }

/* ============= 主区 ============= */

.admin-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

.app-topbar {
  min-height: 64px;
  padding: 12px 28px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex; align-items: center; gap: 18px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  z-index: 10;
}
.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .02em;
}
.topbar-user {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}

/* 用户头像 */
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4c91e3 0%, #206bc4 100%);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 8px rgba(32,107,196,.32);
  flex-shrink: 0;
}

/* 用户下拉触发器(单一) */
.user-menu-toggle {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink);
  cursor: pointer;
  padding: 5px 10px 5px 5px;
  border-radius: 30px;
  transition: background .15s ease;
}
.user-menu-toggle:hover { background: rgba(0,0,0,.04); color: var(--ink); }
.user-menu-toggle::after { display: none !important; }

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.user-role {
  font-size: 11.5px;
  color: var(--muted-2);
  line-height: 1.2;
}
.user-menu-toggle .chev {
  font-size: 12px;
  color: var(--muted-2);
  transition: transform .2s;
}
.user-menu-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

.user-dropdown {
  border: 0;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 200px;
  margin-top: 8px !important;
}
.user-dropdown .dropdown-item {
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
}
.user-dropdown .dropdown-item i { color: var(--muted); font-size: 15px; }
.user-dropdown .dropdown-item:hover { background: var(--bg); color: var(--ink); }
.user-dropdown .dropdown-divider { margin: 6px 0; }

.topbar-user .badge.rounded-pill.status-danger {
  font-size: 11px;
  padding: 4px 10px;
}

/* ============= 内容区 ============= */

.admin-content { padding: 26px 28px 44px; }

.page-title {
  display: flex; align-items: end; justify-content: space-between;
  margin-bottom: 22px; gap: 14px; flex-wrap: wrap;
}
.page-title h2 {
  font-size: var(--fs-title);
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  letter-spacing: -.01em;
}
.page-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ============= 卡片 ============= */

.card {
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow .2s ease;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 20px;
  font-weight: 700;
  color: var(--ink);
  font-size: 14.5px;
  display: flex; align-items: center;
}
.card-body { padding: 20px; }
.card-footer {
  background: #fff;
  border-top: 1px solid var(--line-soft);
  padding: 14px 20px;
  font-size: var(--fs-sm);
}

.filter-card {
  border-left: 4px solid var(--brand);
  margin-bottom: 22px;
}
.filter-card .form-label {
  color: var(--muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

/* ============= 按钮 ============= */

.btn {
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  transition: all .2s ease;
}
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 10px 22px; font-size: 14.5px; }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}
.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: 0 4px 12px rgba(32,107,196,.3);
}
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-outline-secondary { color: var(--ink-2); }
.btn-link { color: var(--brand); }

/* ============= 表单 ============= */

.form-label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-weight: 500;
  margin-bottom: 6px;
}
.form-label.small { font-size: var(--fs-xs); }
.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: #dfe5ee;
  padding: 8px 12px;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control-sm,
.form-select-sm { padding: 6px 10px; font-size: 12.5px; }
.form-control:focus,
.form-select:focus {
  border-color: #82aede;
  box-shadow: 0 0 0 3px rgba(32,107,196,.12);
}
.form-text { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; }
.invalid-feedback { font-size: 12.5px; }

/* 密码框眼睛切换按钮 */
.pwd-toggle {
  border-left: 0 !important;
  background: #fff !important;
  color: var(--muted);
  padding: 0 12px;
  font-size: 16px;
  transition: color .15s ease;
}
.pwd-toggle:hover,
.pwd-toggle:focus { color: var(--brand); box-shadow: none; }
.input-group > .form-control.is-invalid + .pwd-toggle { border-color: #dc3545; }
.input-group > .form-control.is-valid + .pwd-toggle { border-color: #198754; }

/* ============= 表格 ============= */

.app-table { background: #fff; }
.table { margin: 0; color: #34435a; }
.table th,
.table td { text-align: center; vertical-align: middle; }
.table > :not(caption) > * > * { padding: 14px 16px; }
.table thead th {
  background: #f7f9fc;
  color: #657289;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  border-color: var(--line-soft);
  font-size: 13.5px;
}
.table tbody tr { transition: background .15s ease; }
.table-hover tbody tr:hover { background: #f8faff; }
.table .text-start { text-align: left !important; }

/* ============= 状态徽章 ============= */

.badge {
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  letter-spacing: .02em;
}
.status-success { background: #d5f1e1; color: #186a3b; }
.status-warning { background: #fff1c9; color: #8a5b00; }
.status-secondary { background: #e9eaf0; color: #484f66; }
.status-danger  { background: #ffe5e8; color: #c02631; }
.status-info    { background: #dff3fb; color: #0b6f96; }
.bg-success { background: #d5f1e1 !important; color: #186a3b !important; }
.bg-warning { background: #fff1c9 !important; color: #8a5b00 !important; }
.bg-secondary { background: #e9eaf0 !important; color: #484f66 !important; }
.bg-dark { background: var(--ink) !important; color: #fff !important; }
.bg-info { background: #dff3fb !important; color: #0b6f96 !important; }

/* ============= 统计卡 ============= */

.stat-card {
  display: flex; gap: 16px; align-items: center;
  padding: 22px;
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 22px;
  flex: 0 0 52px;
}
.stat-card .num {
  font-size: var(--fs-stat);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--ink);
}
.stat-card .text-muted.small {
  color: var(--muted) !important;
  font-size: var(--fs-xs);
}
.stat-green  { background: #e7f7ee; color: #15803d; }
.stat-red    { background: #ffe9ec; color: #d63939; }
.stat-blue   { background: #e8f1fd; color: var(--brand); }
.stat-purple { background: #f0ebfd; color: #6743d1; }
.stat-card > div:last-child { flex: 1; min-width: 0; text-align: left; }
.stat-card .small, .stat-card .num { line-height: 1.4; }

/* ============= 分页 ============= */

.pagination { gap: 4px; margin: 0; }
.pagination .page-link {
  border: 0;
  color: var(--ink-2);
  border-radius: 8px;
  margin: 0 2px;
  padding: 7px 12px;
  font-size: 13px;
  background: transparent;
  transition: background .15s, color .15s;
}
.pagination .page-link:hover {
  background: var(--bg);
  color: var(--brand);
}
.pagination .page-item.active .page-link {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 6px rgba(32,107,196,.3);
}
.pagination .page-item.disabled .page-link {
  color: var(--muted-2);
  background: transparent;
}

/* ============= 模态框 ============= */

.modal-content {
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  border-bottom: 1px solid var(--line-soft);
  padding: 18px 22px;
}
.modal-title {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink);
}
.modal-body { padding: 22px; font-size: 13.5px; }
.modal-footer {
  border-top: 1px solid var(--line-soft);
  padding: 14px 22px;
  gap: 10px;
}
.btn-close { opacity: .5; transition: opacity .15s; }
.btn-close:hover { opacity: 1; }

/* ============= Alert ============= */

.alert {
  border-radius: 10px;
  border: 0;
  font-size: 13px;
  padding: 12px 16px;
}

/* ============= 小工具 ============= */

.icon-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  opacity: 0; pointer-events: none;
  transition: .2s ease;
  z-index: 15;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* ============= Toast ============= */

.app-toast {
  position: fixed; top: 22px; right: 22px; z-index: 10900;
  padding: 12px 18px;
  border-radius: 10px;
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity .3s ease, transform .3s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  max-width: 360px;
}
.app-toast.show { opacity: 1; transform: translateY(0); }
.app-toast.success { background: #15803d; }
.app-toast.error { background: #c02631; }

/* ============= 滚动条 ============= */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d7e2; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b3bccd; }

/* ============= 响应式 ============= */

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed; left: -260px;
    transition: left .25s ease;
  }
  .app-sidebar.active { left: 0; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .admin-content { padding: 20px 16px 34px; }
  .app-topbar { padding: 12px 16px; }
  .topbar-title { display: none; }
  .user-menu-toggle .user-name,
  .user-menu-toggle .user-role { display: none; }
}

@media (max-width: 575.98px) {
  .page-title h2 { font-size: 20px; }
  .stat-card { padding: 18px; }
  .stat-card .num { font-size: 24px; }
}

/* ============= 列表项内嵌小工具 ============= */

.code-chip {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  background: var(--bg);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--ink-2);
}

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
