/* ==========================================================================
   授权系统后台样式
   自包含，不依赖任何 CDN 或前端框架——授权服务常部署在内网/隔离环境，
   引 CDN 会在那种环境直接白屏。
   ========================================================================== */

:root {
  --bg:          #f5f6f8;
  --surface:     #ffffff;
  --border:      #e3e6ea;
  --border-soft: #eef0f3;
  --text:        #1f2329;
  --text-dim:    #6b7280;
  --text-faint:  #9aa1ab;

  --primary:     #2563eb;
  --primary-dark:#1d4ed8;
  --primary-soft:#eff4ff;

  --ok:          #15803d;
  --ok-soft:     #eaf7ee;
  --warn:        #b45309;
  --warn-soft:   #fdf4e3;
  --danger:      #b91c1c;
  --danger-soft: #fdeceb;
  --info:        #0e7490;
  --info-soft:   #e6f6f9;

  --radius:      6px;
  --radius-sm:   4px;
  --shadow:      0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --sidebar-w:   216px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 布局 */

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #1c2430;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  padding: 18px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  letter-spacing: .2px;
}

.sidebar__brand small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 400;
  color: #8494a8;
  letter-spacing: .4px;
}

.sidebar__group {
  padding: 16px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #64748b;
}

.sidebar__link {
  display: block;
  padding: 9px 20px;
  color: #cbd5e1;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
  text-decoration: none;
}

.sidebar__link.is-active {
  background: rgba(37, 99, 235, .18);
  border-left-color: #3b82f6;
  color: #fff;
  font-weight: 500;
}

.sidebar__foot {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 12px;
  color: #8494a8;
}

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__title {
  font-size: 15px;
  font-weight: 600;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.content { padding: 24px; flex: 1; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
}

.page-head p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card__head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

/* ---------------------------------------------------------------- 栅格 */

.grid { display: flex; flex-wrap: wrap; gap: 16px; }
.grid--stats > * { flex: 1 1 180px; }
.grid--2 > * { flex: 1 1 320px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat__label {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.stat__value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat__hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ---------------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data th,
table.data td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

table.data th {
  background: #fafbfc;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

table.data tbody tr:hover { background: #fafbfc; }
table.data tbody tr:last-child td { border-bottom: 0; }

table.data td.nowrap { white-space: nowrap; }
table.data td.mono { font-family: var(--mono); font-size: 12.5px; }
table.data td.actions { white-space: nowrap; text-align: right; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

/* ---------------------------------------------------------------- 徽标 */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  background: var(--border-soft);
  color: var(--text-dim);
}

.badge--ok      { background: var(--ok-soft);     color: var(--ok); }
.badge--warn    { background: var(--warn-soft);   color: var(--warn); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); }
.badge--info    { background: var(--info-soft);   color: var(--info); }
.badge--primary { background: var(--primary-soft);color: var(--primary); }

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: #f7f8fa; text-decoration: none; }

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn--danger { color: var(--danger); border-color: #f0c9c6; background: var(--danger-soft); }
.btn--danger:hover { background: #fbdad7; }

.btn--sm { padding: 4px 10px; font-size: 12.5px; }

.btn--link {
  border: 0;
  background: none;
  padding: 2px 4px;
  color: var(--primary);
}

.btn--link:hover { background: none; text-decoration: underline; }

.btn--link.is-danger { color: var(--danger); }

.btn[disabled], .btn.is-disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

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

/* ---------------------------------------------------------------- 表单 */

.field { margin-bottom: 16px; }

.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
}

.field .hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

.field .required { color: var(--danger); margin-left: 2px; }

input[type=text], input[type=password], input[type=number],
input[type=email], input[type=datetime-local], input[type=date],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }

select { height: 34px; }

.field--inline { display: inline-block; margin: 0 12px 10px 0; }
.field--inline > label { display: inline-block; margin: 0 6px 0 0; font-weight: 400; color: var(--text-dim); }

.checkbox-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fcfcfd;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13.5px;
  cursor: pointer;
}

.checkbox-list label:hover { color: var(--primary); }
.checkbox-list input { margin: 0; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: #fcfcfd;
}

.filter-bar .field { margin: 0; min-width: 140px; }
.filter-bar .field > label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

/* ---------------------------------------------------------------- 提示 */

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  line-height: 1.6;
}

.alert--ok     { background: var(--ok-soft);     border-color: #c3e6cd; color: var(--ok); }
.alert--warn   { background: var(--warn-soft);   border-color: #f0dcb4; color: var(--warn); }
.alert--danger { background: var(--danger-soft); border-color: #f0c9c6; color: var(--danger); }
.alert--info   { background: var(--info-soft);   border-color: #b8e2ea; color: var(--info); }

.alert ul { margin: 6px 0 0; padding-left: 20px; }

.note {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ---------------------------------------------------------------- 分页 */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-dim);
}

.pager__links { display: flex; gap: 4px; flex-wrap: wrap; }

.pager__links a,
.pager__links span {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface);
}

.pager__links a:hover { background: #f7f8fa; text-decoration: none; }

.pager__links .is-current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pager__links .is-disabled { color: var(--text-faint); background: #fafbfc; }

/* ---------------------------------------------------------------- 登录页 */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #1c2430 0%, #2b3a4f 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 372px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
  padding: 32px 30px 26px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}

.login-card .sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--text-dim);
}

.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row input { flex: 1; }

.captcha-img {
  width: 108px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #f7f8fa;
  flex: 0 0 108px;
}

/* ---------------------------------------------------------------- 其他 */

.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv th {
  width: 172px;
  text-align: left;
  padding: 8px 14px 8px 0;
  color: var(--text-dim);
  font-weight: 400;
  vertical-align: top;
}
.kv td { padding: 8px 0; word-break: break-all; }

.code-block {
  background: #1c2430;
  color: #d6e2f0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-backdrop.is-open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.modal__head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__body { padding: 20px; }

.modal__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal__close {
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 4px;
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .content { padding: 16px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #12161c;
    --surface:     #1a2029;
    --border:      #2a323d;
    --border-soft: #232b35;
    --text:        #e4e8ee;
    --text-dim:    #98a3b3;
    --text-faint:  #6d7887;
    --primary-soft:#1b2a45;
    --ok-soft:     #14291c;
    --warn-soft:   #2c2213;
    --danger-soft: #2e1a19;
    --info-soft:   #10262c;
    --shadow:      none;
  }
  table.data th { background: #1e252f; }
  table.data tbody tr:hover { background: #1e252f; }
  .filter-bar { background: #1e252f; }
  .checkbox-list { background: #1e252f; }
  .btn:hover { background: #232b35; }
  .pager__links .is-disabled { background: #1e252f; }
  .sidebar { background: #0f141b; }
}
