:root {
  --ink: #182029;
  --muted: #68727d;
  --line: #dfe3e7;
  --surface: #ffffff;
  --canvas: #f4f6f7;
  --sidebar: #15191e;
  --sidebar-muted: #929ba5;
  --accent: #176b87;
  --accent-soft: #e5f3f7;
  --success: #16734a;
  --success-soft: #e5f5ed;
  --danger: #b53c35;
  --danger-soft: #fbeae8;
  --warning: #925d0a;
  --warning-soft: #fff3d6;
  --shadow: 0 8px 28px rgba(24, 32, 41, 0.07);
}

* { box-sizing: border-box; }
html { min-height: 100%; font-size: 14px; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--canvas); font-family: "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #0e536c; }
svg { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.8; }

.admin-shell { display: flex; overflow-x: hidden; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: 232px; overflow-y: auto; flex-direction: column; color: #fff; background: var(--sidebar); }
.brand { display: flex; height: 76px; align-items: center; gap: 12px; padding: 0 22px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand:hover { color: #fff; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; color: #72d6be; background: #26313a; border: 1px solid rgba(255,255,255,.22); border-radius: 6px; }
.brand-mark svg { width: 21px; height: 21px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; font-weight: 650; }
.brand small { margin-top: 2px; color: var(--sidebar-muted); font-size: 9px; }
.side-nav { display: grid; gap: 5px; padding: 18px 12px; }
.side-nav a, .sidebar-foot a { display: flex; min-height: 42px; align-items: center; gap: 12px; padding: 0 12px; color: var(--sidebar-muted); border-radius: 6px; }
.side-nav a:hover, .sidebar-foot a:hover { color: #fff; background: rgba(255,255,255,.06); }
.side-nav a.active { color: #fff; background: #26363e; box-shadow: inset 3px 0 #53b9ac; }
.sidebar-foot { margin-top: auto; padding: 14px 12px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.shell-main { width: calc(100% - 232px); min-width: 0; margin-left: 232px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; height: 76px; align-items: center; gap: 12px; padding: 0 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.topbar-title { min-width: 0; overflow: hidden; font-size: 18px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.admin-menu { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.admin-menu form { display: flex; margin: 0; }
.admin-avatar { display: grid; width: 32px; height: 32px; place-items: center; color: #fff; background: #253541; border-radius: 50%; font-size: 13px; font-weight: 700; }
.admin-name { color: var(--muted); }
.icon-button { display: inline-grid; width: 36px; height: 36px; padding: 0; place-items: center; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 5px; cursor: pointer; }
.icon-button:hover { color: var(--ink); background: #f7f8f9; border-color: var(--line); }
.mobile-menu, .sidebar-scrim { display: none; }
.page-content { max-width: 1520px; margin: 0 auto; padding: 26px 28px 50px; }

.page-heading { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 0; font-size: 22px; font-weight: 680; }
.page-heading p { margin: 5px 0 0; color: var(--muted); }
.page-heading .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.section-heading h2 { margin: 0; font-size: 16px; font-weight: 680; }
.section-heading .count { color: var(--muted); font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; }
.stat-card { min-height: 112px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.stat-label svg { color: var(--accent); }
.stat-value { margin-top: 15px; font-size: 28px; font-weight: 700; line-height: 1; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr); gap: 18px; }

.panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.panel-head { display: flex; min-height: 54px; align-items: center; gap: 12px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 15px; font-weight: 680; }
.panel-head .panel-actions { display: flex; gap: 8px; margin-left: auto; }
.panel-body { padding: 18px; }
.empty-state { display: grid; min-height: 150px; place-items: center; padding: 28px; color: var(--muted); text-align: center; }
.empty-state svg { width: 30px; height: 30px; margin-bottom: 8px; color: #aab1b8; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.data-table th { height: 42px; padding: 0 14px; color: #59636d; background: #f8f9fa; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650; text-align: left; white-space: nowrap; }
.data-table td { height: 58px; padding: 9px 14px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfc; }
.primary-cell { min-width: 0; overflow-wrap: anywhere; color: var(--ink); font-weight: 650; }
.subtext { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 400; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.truncate { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status { display: inline-flex; min-height: 24px; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.status::before { width: 6px; height: 6px; background: currentColor; border-radius: 50%; content: ""; }
.status-online, .status-active { color: var(--success); background: var(--success-soft); }
.status-offline { color: #68727d; background: #edf0f2; }
.status-disabled, .status-revoked { color: var(--danger); background: var(--danger-soft); }
.status-expired, .status-pending { color: var(--warning); background: var(--warning-soft); }
.status-info { color: var(--accent); background: var(--accent-soft); }

.btn { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border: 1px solid transparent; border-radius: 5px; font-weight: 620; line-height: 1.2; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { color: #fff; background: #105b75; border-color: #105b75; }
.btn-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.btn-secondary:hover { color: var(--ink); background: #f8f9fa; border-color: #b9c0c6; }
.btn-danger { color: var(--danger); background: #fff; border-color: #d68b86; }
.btn-danger:hover { color: #962e29; background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.compact-actions { flex-wrap: nowrap; }
.inline-form { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.inline-form .form-select { width: auto; min-width: 150px; }
.operation-row form { margin: 0; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.search-box { position: relative; flex: 1 1 260px; max-width: 460px; }
.search-box svg { position: absolute; top: 10px; left: 11px; width: 16px; height: 16px; color: #85909b; pointer-events: none; }
.search-box .form-control { padding-left: 36px; }
.filter-select { width: auto; min-width: 150px; }
.segmented { display: inline-flex; min-height: 36px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 5px; }
.segmented a { display: inline-flex; align-items: center; padding: 0 11px; color: var(--muted); border-right: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.segmented a:last-child { border-right: 0; }
.segmented a.active { color: #155d76; background: #eaf2f4; font-weight: 650; }
.form-control, .form-select { min-height: 38px; color: var(--ink); border-color: #cfd5da; border-radius: 5px; }
.form-control:focus, .form-select:focus { border-color: #4b91a8; box-shadow: 0 0 0 3px rgba(23, 107, 135, .12); }
textarea.form-control { min-height: 94px; resize: vertical; }
.form-label { margin-bottom: 6px; font-size: 13px; font-weight: 650; }
.form-hint { margin-top: 5px; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 9px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.validation-summary-errors, .field-validation-error { color: var(--danger); font-size: 12px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.switch-row { display: flex; min-height: 48px; align-items: center; gap: 11px; }
.switch-row input[role="switch"] { width: 38px; height: 20px; }
.switch-row label { cursor: pointer; }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 3px; color: var(--muted); }

.detail-band { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.detail-band-main { min-width: 0; flex: 1 1 220px; }
.detail-band h1 { margin: 0; overflow-wrap: anywhere; font-size: 20px; font-weight: 700; }
.detail-band-meta { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.info-item { min-height: 86px; padding: 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.info-item:nth-child(4n) { border-right: 0; }
.info-label { color: var(--muted); font-size: 12px; }
.info-value { margin-top: 8px; overflow-wrap: anywhere; font-weight: 650; }
.key-reveal { display: flex; align-items: center; gap: 12px; margin: 16px 0; padding: 15px 17px; background: #eef8f4; border: 1px solid #b7d9cf; border-radius: 6px; }
.key-reveal > div { min-width: 0; flex: 1; }
.key-reveal strong, .key-reveal code { display: block; }
.key-reveal code { margin-top: 5px; overflow-wrap: anywhere; color: #11583d; font-size: 14px; }
.remark-box { min-width: 0; padding: 14px 16px; overflow-wrap: anywhere; color: #4f5963; background: #f7f8f9; border-left: 3px solid #9aa8b1; white-space: pre-wrap; }
.avatar { width: 34px; height: 34px; object-fit: cover; background: #e8ecef; border-radius: 50%; }
.profile-cell { display: flex; align-items: center; gap: 9px; }
.profile-cell > span { min-width: 0; }
.entitlement-summary { display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)) auto; align-items: center; gap: 12px; margin-bottom: 20px; padding: 13px 14px; background: #f6f8f9; border: 1px solid var(--line); border-radius: 6px; }
.entitlement-summary > div { min-width: 0; }
.entitlement-summary span, .entitlement-summary strong { display: block; }
.entitlement-summary span { color: var(--muted); font-size: 12px; }
.entitlement-summary strong { margin-top: 4px; overflow-wrap: anywhere; }

.event-list { margin: 0; padding: 0; list-style: none; }
.event-item { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; padding: 13px 0; border-bottom: 1px solid #edf0f2; }
.event-item:last-child { border-bottom: 0; }
.event-icon { display: grid; width: 24px; height: 24px; place-items: center; color: var(--accent); background: #edf2f4; border-radius: 50%; }
.event-icon svg { width: 13px; height: 13px; }
.event-title { font-size: 13px; font-weight: 650; }
.event-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.event-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.flash { display: flex; min-height: 44px; align-items: center; gap: 9px; margin-bottom: 18px; padding: 9px 13px; border: 1px solid; border-radius: 5px; }
.flash-success { color: var(--success); background: var(--success-soft); border-color: #a9d7c2; }
.flash-error { color: var(--danger); background: var(--danger-soft); border-color: #e5b4b0; }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.pagination-links { display: flex; gap: 6px; }
.pagination-links a, .pagination-links span { display: grid; min-width: 32px; height: 32px; padding: 0 8px; place-items: center; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.pagination-links span { color: var(--accent); background: #edf3f5; font-weight: 700; }

.auth-shell { display: grid; min-height: 100vh; place-items: center; overflow-x: hidden; padding: 24px; background: #edf1f2; }
.auth-main { width: 100%; max-width: 420px; }
.auth-card { width: 100%; padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 18px 48px rgba(24, 32, 41, .11); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand .brand-mark { background: #1d2a32; }
.auth-brand strong { display: block; font-size: 18px; }
.auth-brand span:last-child small { display: block; margin-top: 3px; color: var(--muted); }
.auth-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.auth-card > p { margin: 0 0 22px; color: var(--muted); }
.auth-card .mb-field { margin-bottom: 16px; }
.auth-card .btn { width: 100%; min-height: 42px; }
.oauth-result { text-align: center; }
.result-icon { display: grid; width: 58px; height: 58px; margin: 0 auto 18px; place-items: center; border-radius: 50%; }
.result-icon.success { color: var(--success); background: var(--success-soft); }
.result-icon.failure { color: var(--danger); background: var(--danger-soft); }
.result-icon svg { width: 28px; height: 28px; }
.oauth-profile { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.oauth-profile .avatar { width: 42px; height: 42px; }
.verify-card { width: min(460px, calc(100vw - 32px)); }
.verify-card .auth-brand { justify-content: center; margin-bottom: 20px; }
.verify-code { margin: 18px 0; color: var(--ink); font-family: Consolas, monospace; font-size: 30px; font-weight: 750; letter-spacing: 2px; text-align: center; }
.verify-code-input { margin-bottom: 14px; font-family: Consolas, monospace; font-size: 20px; letter-spacing: 2px; text-align: center; text-transform: uppercase; }
.verify-summary { display: grid; grid-template-columns: minmax(90px, auto) minmax(0, 1fr); gap: 10px 14px; margin: 18px 0; padding: 14px; color: var(--muted); background: #f6f8f9; border: 1px solid var(--line); border-radius: 6px; text-align: left; }
.verify-summary strong { overflow-wrap: anywhere; color: var(--ink); }
.btn-block { width: 100%; justify-content: center; }
.status-stats { grid-template-columns: repeat(3, minmax(150px, 1fr)); }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .info-item:nth-child(4n) { border-right: 1px solid var(--line); }
  .info-item:nth-child(2n) { border-right: 0; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.4); border: 0; }
  body.nav-open .sidebar-scrim { display: block; }
  body.nav-open { overflow: hidden; }
  .shell-main { width: 100%; margin-left: 0; }
  .topbar { height: 62px; padding: 0 14px; }
  .mobile-menu { display: inline-grid; }
  .admin-name { display: none; }
  .page-content { padding: 18px 14px 40px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .actions { margin-left: 0; }
  .page-heading .actions .btn { flex: 1; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { min-height: 100px; padding: 14px; }
  .stat-value { font-size: 24px; }
  .form-grid, .info-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .info-item, .info-item:nth-child(4n), .info-item:nth-child(2n) { border-right: 0; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented a { flex: 0 0 auto; }
  .filter-bar .btn { flex: 1; }
  .filter-select { width: 100%; }
  .detail-band { align-items: flex-start; flex-direction: column; }
  .detail-band-main { width: 100%; flex: 0 1 auto; }
  .detail-actions { width: 100%; }
  .detail-actions .btn { flex: 1; }
  .operation-row, .operation-row form, .inline-form { width: 100%; }
  .operation-row .btn, .inline-form .form-select { flex: 1; }
  .key-reveal { align-items: stretch; flex-direction: column; }
  .key-reveal .btn { width: 100%; }
  .entitlement-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entitlement-summary .btn { grid-column: 1 / -1; }
  .pagination-bar { align-items: flex-start; flex-direction: column; }
  .event-item { grid-template-columns: 24px minmax(0, 1fr); }
  .event-time { grid-column: 2; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .status-stats { grid-template-columns: 1fr; }
  .auth-shell { padding: 14px; }
  .auth-card { padding: 22px 18px; }
}
