:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #172033;
  background: #f2f5fa;
  --blue: #1768e5;
  --blue-dark: #0d4fb8;
  --blue-soft: #eaf2ff;
  --green: #16844a;
  --green-soft: #e9f7ef;
  --amber: #a96900;
  --amber-soft: #fff3df;
  --red: #c33535;
  --red-soft: #ffeded;
  --gray: #69758a;
  --line: #dfe5ef;
  --shadow: 0 14px 40px rgba(24, 45, 80, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: #f2f5fa; }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(420px, .85fr); }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 28px; overflow: hidden; padding: 9vw; color: #fff; background: linear-gradient(145deg, #0d4eb6, #1c75f0 55%, #4c98f8); }
.login-brand::before, .login-brand::after { content: ""; position: absolute; width: 420px; height: 420px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; }
.login-brand::before { right: -130px; top: -120px; }
.login-brand::after { right: 15%; bottom: -290px; }
.brand-mark { position: relative; z-index: 1; display: grid; width: 58px; height: 58px; place-items: center; border-radius: 18px; color: var(--blue); background: #fff; box-shadow: 0 14px 30px rgba(7, 44, 102, .2); font-size: 28px; font-weight: 900; }
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 19px; box-shadow: none; }
.login-brand > div, .login-brand > h1, .login-brand > p { position: relative; z-index: 1; }
.login-brand h1 { max-width: 700px; margin: 12px 0 12px; font-size: clamp(34px, 4vw, 62px); line-height: 1.08; letter-spacing: -.04em; }
.login-brand p { max-width: 620px; margin: 0; color: #dbeaff; font-size: 16px; line-height: 1.8; }
.eyebrow, .section-tag { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.login-brand .eyebrow { color: #cfe2ff; }
.login-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 760px; }
.login-points div { padding: 16px; border: 1px solid rgba(255,255,255,.18); border-radius: 12px; background: rgba(255,255,255,.09); backdrop-filter: blur(8px); }
.login-points b, .login-points span { display: block; }
.login-points b { font-size: 13px; }
.login-points span { margin-top: 6px; color: #dceaff; font-size: 11px; line-height: 1.6; }
.login-card { align-self: center; width: min(460px, calc(100% - 56px)); margin: auto; padding: 38px; border: 1px solid #e2e7ef; border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
.login-heading h2 { margin: 8px 0 5px; font-size: 27px; }
.login-heading p { margin: 0 0 25px; color: var(--gray); font-size: 12px; }

.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field > span { color: #445069; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #ccd5e3; border-radius: 8px; color: #172033; background: #fff; outline: none; transition: .18s ease; }
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 96px; padding: 11px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,104,229,.12); }
input:disabled, select:disabled { color: #7e8795; background: #f2f4f7; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
.stack-form { display: grid; gap: 0; }
.form-note { margin: -5px 0 15px; color: var(--gray); font-size: 11px; line-height: 1.6; }
.form-error { margin-top: 14px; padding: 11px 12px; border-radius: 8px; color: var(--red); background: var(--red-soft); font-size: 12px; line-height: 1.5; }

.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 700; line-height: 36px; white-space: nowrap; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .58; transform: none; }
.button.primary { color: #fff; border-color: var(--blue); background: var(--blue); box-shadow: 0 6px 14px rgba(23,104,229,.18); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: #364258; border-color: #ccd6e3; background: #fff; }
.button.secondary:hover, .button.ghost:hover { border-color: #acc8f5; color: var(--blue); background: #f6f9ff; }
.button.ghost { color: var(--blue); border-color: transparent; background: transparent; }
.button.danger { color: var(--red); border-color: #efbcbc; background: #fff7f7; }
.button.warning { color: var(--amber); border-color: #edce96; background: #fffaf1; }
.button.wide { width: 100%; }
.button.small { min-height: 30px; padding: 0 10px; border-radius: 7px; font-size: 11px; line-height: 28px; }
.link-button { padding: 0; border: 0; color: #bcd5fa; background: transparent; cursor: pointer; font-size: 11px; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #d8dfe9; border-radius: 9px; color: #607087; background: #fff; cursor: pointer; font-size: 22px; line-height: 1; }
.head-actions, .top-actions, .row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions { flex-wrap: wrap; }

.mfa-panel { margin-top: 20px; }
.notice { display: grid; gap: 4px; padding: 12px; border: 1px solid; border-radius: 9px; font-size: 11px; line-height: 1.55; }
.notice.info { border-color: #c9daf5; color: #315985; background: #f2f7ff; }
.notice.warning { border-color: #ecd398; color: #795a18; background: #fff9ea; }
.notice.danger { border-color: #f0bcbc; color: #8f2929; background: #fff2f2; }
.notice span { opacity: .85; }
.mfa-setup { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 14px; margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.mfa-setup img { width: 150px; height: 150px; }
.mfa-setup span, .mfa-setup code, .mfa-setup small { display: block; }
.mfa-setup span { font-size: 11px; font-weight: 700; }
.mfa-setup code { margin: 8px 0; padding: 8px; border-radius: 6px; background: #f2f4f8; overflow-wrap: anywhere; user-select: all; }
.mfa-setup small { color: var(--red); font-size: 10px; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 14px 0; }
.recovery-grid code { padding: 8px; border-radius: 6px; background: #f4f6f9; text-align: center; user-select: all; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 244px; flex-direction: column; padding: 22px 15px; color: #fff; background: linear-gradient(180deg, #0c54c4, #0b62dc 55%, #0b54bd); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.16); }
.sidebar-brand b, .sidebar-brand span { display: block; }
.sidebar-brand b { font-size: 16px; }
.sidebar-brand span { margin-top: 4px; color: #bcd7ff; font-size: 9px; letter-spacing: .12em; }
.nav-list { display: grid; gap: 6px; margin-top: 20px; }
.nav-item { display: grid; min-height: 43px; grid-template-columns: 30px 1fr; align-items: center; border: 0; border-radius: 9px; color: #dceaff; background: transparent; cursor: pointer; text-align: left; transition: .16s ease; }
.nav-item:hover { background: rgba(255,255,255,.1); }
.nav-item.active { color: var(--blue-dark); background: #fff; box-shadow: 0 8px 20px rgba(0,42,107,.18); font-weight: 800; }
.nav-index { color: #9bc6ff; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-align: center; }
.nav-item.active .nav-index { color: var(--blue); }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.15); }
.sidebar-foot > span { overflow: hidden; color: #fff; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.workspace { min-width: 0; grid-column: 2; padding: 27px 31px 60px; }
.topbar { display: flex; min-height: 74px; align-items: flex-start; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 5px 0 5px; font-size: 26px; letter-spacing: -.02em; }
.topbar p { margin: 0; color: var(--gray); font-size: 12px; }
.top-actions { padding-top: 8px; }
.page { display: none; }
.page.active { display: block; }
.page-status { position: sticky; top: 10px; z-index: 15; margin: 10px 0 16px; padding: 11px 14px; border: 1px solid #c9daf5; border-radius: 9px; color: #315985; background: rgba(242,247,255,.96); box-shadow: 0 8px 20px rgba(30,63,109,.08); font-size: 12px; }
.page-status.error { border-color: #efbcbc; color: var(--red); background: rgba(255,242,242,.97); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin: 14px 0 18px; }
.metric { position: relative; min-height: 116px; overflow: hidden; padding: 19px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 7px 24px rgba(26,48,78,.045); }
.metric::after { content: ""; position: absolute; width: 48px; height: 48px; right: -18px; top: -18px; border: 14px solid var(--blue-soft); border-radius: 50%; }
.metric .label { color: var(--gray); font-size: 11px; }
.metric strong { display: block; margin-top: 11px; color: #142038; font-size: 25px; line-height: 1; }
.metric small { display: block; margin-top: 9px; color: #8a94a4; font-size: 10px; }
.metric.good strong { color: var(--green); }
.metric.warn strong { color: var(--amber); }
.metric.bad strong { color: var(--red); }
.card { margin-top: 15px; padding: 19px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 8px 26px rgba(26,48,78,.045); }
.branding-intro { padding-bottom: 22px; }
.branding-slot-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.logo-ad-editor { min-width: 0; padding: 15px; border: 1px solid #e1e7f0; border-radius: 10px; background: #fbfcfe; }
.logo-ad-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-height: 42px; }
.logo-ad-editor-head h3 { margin: 5px 0 0; font-size: 14px; }
.logo-ad-preview { height: 92px; margin: 12px 0 14px; display: grid; place-items: center; overflow: hidden; border: 1px dashed #cbd7e8; border-radius: 8px; color: #98a5b7; background: #f5f8fc; font: 11px/1.5 Consolas, monospace; }
.logo-ad-preview.has-image { border-style: solid; background: #fff; }
.logo-ad-preview img { display: block; max-width: calc(100% - 18px); max-height: 78px; object-fit: contain; }
.logo-ad-editor .field { margin-bottom: 11px; }
.logo-ad-editor input[type="file"] { height: auto; min-height: 38px; padding: 8px 9px; font-size: 11px; }
.logo-ad-editor .form-note { margin: 11px 0 0; }
.logo-ad-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 3px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.card-head h2, .policy-card h2 { margin: 5px 0 0; font-size: 17px; letter-spacing: -.01em; }
.card-head p, .policy-card p { margin: 6px 0 0; color: var(--gray); font-size: 11px; line-height: 1.6; }
.content-grid { display: grid; gap: 15px; }
.content-grid.two-thirds { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.content-grid.half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.policy-card { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 22px; border-color: #bcd2f4; background: linear-gradient(105deg, #f2f7ff, #fff); }
.policy-card.off { border-color: #d7dce4; background: #f7f8fa; }

.status-pill { display: inline-flex; width: max-content; min-height: 26px; align-items: center; justify-content: center; padding: 0 9px; border-radius: 7px; font-size: 10px; font-weight: 800; line-height: 26px; white-space: nowrap; }
.status-pill.good { color: var(--green); background: var(--green-soft); }
.status-pill.warning { color: var(--amber); background: var(--amber-soft); }
.status-pill.danger { color: var(--red); background: var(--red-soft); }
.status-pill.info { color: var(--blue); background: var(--blue-soft); }
.status-pill.neutral { color: #69758a; background: #eef1f5; }
.health-list, .summary-list { display: grid; gap: 10px; }
.health-row, .summary-row { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; border: 1px solid #e7ebf1; border-radius: 8px; background: #fafbfd; font-size: 11px; }
.health-row span:first-child, .summary-row span:first-child { color: var(--gray); }
.summary-block { margin-bottom: 17px; }
.summary-block h3 { margin: 0 0 9px; font-size: 13px; }
.token-box { margin-top: 12px; padding: 12px; border: 1px solid #e6c985; border-radius: 8px; color: #755815; background: #fff9e9; font: 11px/1.7 Consolas, monospace; overflow-wrap: anywhere; user-select: all; }

.data-wrap { min-width: 0; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.table-filters { display: flex; flex: 1; align-items: center; gap: 8px; }
.table-filters input, .table-filters select { width: auto; min-width: 150px; height: 34px; font-size: 11px; }
.table-filters .search { width: min(320px, 45%); }
.table-count { color: #8590a1; font-size: 10px; white-space: nowrap; }
.table-scroll { overflow-x: auto; border: 1px solid #e2e7ef; border-radius: 9px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 11px; }
th, td { min-width: 90px; padding: 12px 11px; border-bottom: 1px solid #e8ecf2; text-align: left; vertical-align: middle; }
th { color: #69758a; background: #f7f9fc; font-size: 10px; font-weight: 800; white-space: nowrap; }
th button { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; font-weight: inherit; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdff; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: #8a94a3; font-size: 9px; line-height: 1.45; }
.cell-main { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-code { font-family: Consolas, monospace; font-size: 10px; }
.empty-state { display: grid; min-height: 118px; place-items: center; color: #8a94a3; font-size: 11px; text-align: center; }
.table-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; color: #7c8798; font-size: 10px; }
.table-pagination button { min-width: 30px; min-height: 28px; padding: 0 9px; border: 1px solid #d4dce7; border-radius: 6px; color: #49566c; background: #fff; cursor: pointer; }
.table-pagination button:disabled { cursor: default; opacity: .45; }

.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(13, 25, 44, .46); backdrop-filter: blur(2px); }
.modal-panel { width: min(620px, 100%); max-height: calc(100vh - 48px); overflow: hidden; border-radius: 14px; background: #fff; box-shadow: 0 25px 70px rgba(10,24,47,.28); }
.modal-panel > header, .drawer-panel > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.modal-panel h2, .drawer-panel h2 { margin: 5px 0 0; font-size: 18px; }
.modal-body { max-height: calc(100vh - 190px); overflow-y: auto; padding: 20px; }
.modal-panel footer { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfd; }
.danger-summary { margin-bottom: 16px; padding: 14px; border: 1px solid #efc0c0; border-radius: 9px; color: #7d2c2c; background: #fff5f5; font-size: 11px; line-height: 1.65; }
.drawer-layer { position: fixed; inset: 0; z-index: 90; }
.drawer-scrim { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(14,27,46,.3); cursor: default; }
.drawer-panel { position: absolute; inset: 0 0 0 auto; width: min(640px, 94vw); overflow: hidden; background: #f5f7fb; box-shadow: -18px 0 50px rgba(17,33,57,.2); animation: drawer-in .2s ease-out; }
.drawer-body { height: calc(100vh - 76px); overflow-y: auto; padding: 6px 20px 28px; }
.drawer-body .card { box-shadow: none; }
@keyframes drawer-in { from { transform: translateX(30px); opacity: .4; } }
.toast-region { position: fixed; z-index: 130; right: 22px; bottom: 22px; display: grid; width: min(360px, calc(100vw - 44px)); gap: 9px; }
.toast { display: grid; gap: 3px; padding: 13px 14px; border: 1px solid #c8d8ef; border-radius: 10px; color: #2d4f7c; background: #f4f8ff; box-shadow: 0 12px 30px rgba(18,39,72,.15); font-size: 11px; animation: toast-in .18s ease-out; }
.toast.error { border-color: #efbcbc; color: #8c2f2f; background: #fff3f3; }
.toast.success { border-color: #bde0ca; color: #196c40; background: #effaf3; }
.toast b { font-size: 12px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid.two-thirds, .content-grid.half { grid-template-columns: 1fr; }
  .branding-slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-points { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 300px; padding: 50px; }
  .login-points { display: none; }
  .login-card { margin: 40px auto; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; }
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-foot { margin-top: 20px; }
  .workspace { grid-column: 1; padding: 22px; }
  .topbar { flex-direction: column; }
  .top-actions { width: 100%; justify-content: space-between; }
}
@media (max-width: 620px) {
  .login-brand { min-height: 230px; padding: 30px; }
  .login-brand h1 { font-size: 34px; }
  .login-card { width: calc(100% - 28px); padding: 26px 20px; }
  .workspace { padding: 16px; }
  .metric-grid { grid-template-columns: 1fr; }
  .branding-slot-grid { grid-template-columns: 1fr; }
  .card-head, .policy-card { align-items: stretch; flex-direction: column; }
  .head-actions { flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .table-filters { align-items: stretch; flex-direction: column; }
  .table-filters input, .table-filters select, .table-filters .search { width: 100%; }
  .mfa-setup { grid-template-columns: 1fr; }
  .mfa-setup img { justify-self: center; }
}
