:root {
  --navy: #14213d;
  --text: #24324a;
  --muted: #68778f;
  --blue: #4267f5;
  --blue-dark: #3154dc;
  --blue-soft: #edf2ff;
  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --line: #dfe6f0;
  --line-strong: #cbd6e5;
  --green: #16855d;
  --red: #d64d55;
  --orange: #c77718;
  --shadow: 0 10px 30px rgba(31, 48, 78, .07);
  --shadow-hover: 0 14px 34px rgba(31, 48, 78, .11);
  --radius: 16px;
  --control-height: 44px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  font-size: 16px;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
small { color: var(--muted); font-size: 13px; line-height: 1.55; }

:focus-visible {
  outline: 3px solid rgba(66, 103, 245, .22);
  outline-offset: 2px;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 260px;
  flex-direction: column;
  padding: 22px 16px;
  overflow-y: auto;
  background: rgba(255, 255, 255, .98);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 30px rgba(31, 48, 78, .025);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 2px 8px 22px;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #4267f5, #708bff);
  border-radius: 13px;
  box-shadow: 0 9px 20px rgba(66, 103, 245, .26);
  font-size: 15px;
  font-weight: 800;
}

.brand > div:last-child { min-width: 0; }
.brand strong { display: block; overflow: hidden; color: var(--navy); font-size: 17px; line-height: 1.35; text-overflow: ellipsis; }
.brand small, .user-box small { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }

.nav-item,
.nav-group summary {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  margin: 3px 0;
  padding: 9px 12px;
  color: #53627a;
  border-radius: 11px;
  font-size: 15px;
  line-height: 1.35;
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}

.nav-item:hover,
.nav-group summary:hover { color: var(--blue); background: #f3f6ff; transform: translateX(2px); }
.nav-item.active { color: var(--blue); background: var(--blue-soft); font-weight: 700; }

.nav-icon {
  display: grid;
  flex: 0 0 29px;
  width: 29px;
  height: 29px;
  place-items: center;
  color: #65738a;
  background: #f0f3f8;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  transition: color .18s ease, background-color .18s ease;
}

.nav-item.active .nav-icon { color: #fff; background: var(--blue); }
.nav-group { margin-top: 5px; }
.nav-group summary { list-style: none; font-weight: 700; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group[open] summary { color: var(--blue); background: #f5f7fc; }
.nav-chevron { margin-left: auto; transition: transform .22s ease; }
.nav-group[open] .nav-chevron { transform: rotate(180deg); }
.nav-children { margin: 4px 0 4px 14px; padding: 2px 0 2px 12px; border-left: 2px solid #e8edf5; }
.nav-child { min-height: 42px; margin: 2px 0; padding: 7px 10px; font-size: 14px; }
.nav-child .nav-icon { flex-basis: 25px; width: 25px; height: 25px; font-size: 12px; }
.sidebar-foot { margin-top: auto; padding: 18px 12px 5px; color: #96a1b3; font-size: 12px; }

.main { width: calc(100% - 260px); min-width: 0; margin-left: 260px; }
.topbar { display: flex; min-height: 94px; align-items: center; gap: 20px; padding: 20px 32px; }
.topbar h1 { margin: 0; color: var(--navy); font-size: clamp(25px, 2vw, 30px); line-height: 1.25; letter-spacing: -.5px; }
.topbar p { margin: 7px 0 0; color: var(--muted); font-size: 15px; }
.user-box { display: flex; align-items: center; gap: 16px; margin-left: auto; text-align: right; }
.user-box strong { color: var(--navy); font-size: 15px; }
.content { width: 100%; min-width: 0; padding: 0 32px 42px; }

.card {
  min-width: 0;
  margin-bottom: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.card-head > div { min-width: 0; }
.card-head h2, .card-head h3 { margin: 0; color: var(--navy); line-height: 1.35; }
.card-head h2 { font-size: 22px; }
.card-head h3 { font-size: 18px; }
.card-head p { max-width: 780px; margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.75; }
.eyebrow { margin-bottom: 6px; color: #8a99b2; font-size: 12px; font-weight: 800; letter-spacing: 1.8px; line-height: 1.4; text-transform: uppercase; }

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { min-width: 0; padding: 19px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.stat:hover { border-color: #cfdaee; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat span { color: var(--muted); font-size: 14px; font-weight: 600; }
.stat strong { display: block; margin-top: 8px; overflow-wrap: anywhere; color: var(--navy); font-size: 28px; line-height: 1.25; }
.stat small { display: block; margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; color: #52627a; font-size: 14px; font-weight: 650; line-height: 1.5; }

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  font-size: 15px;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.input, .select { min-height: var(--control-height); padding: 9px 12px; }
.select { padding-right: 34px; }
.textarea { min-height: 112px; padding: 11px 12px; line-height: 1.7; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: #aebcd0; }
.input:focus, .select:focus, .textarea:focus { background: #fff; border-color: #6f8bf7; box-shadow: 0 0 0 4px rgba(66, 103, 245, .11); }
.input::placeholder, .textarea::placeholder { color: #9aa6b8; }
input[type="file"].input { padding: 7px 10px; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; margin: 0; accent-color: var(--blue); }
.help { margin-top: 6px; color: #8794a8; font-size: 13px; line-height: 1.7; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; margin-bottom: 18px; }
.toolbar .grow { flex: 1 1 300px; }
.toolbar > .input, .toolbar > .select { width: auto; flex: 1 1 180px; }
.toolbar > .grow { flex-basis: 300px; }
.toolbar > .btn { flex: 0 0 auto; }
.field > .toolbar { margin-bottom: 0; }

/* 表单内容与操作区保持一致间距，避免按钮紧贴文本框 */
.card form:not(.toolbar):not(.form-grid) > .field + .field { margin-top: 18px; }
.card form > .form-grid + .btn,
.card form > .field + .btn,
.card form > .form-grid + .toolbar,
.card form > .field + .toolbar,
.card form > .form-grid + .actions,
.card form > .field + .actions { margin-top: 22px !important; }
.card form > .form-grid + .toolbar,
.card form > .field + .toolbar { margin-bottom: 0; }
.card form > .field + .badge { margin-top: 18px !important; }
.card form > .badge + .actions { margin-top: 18px; }

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  color: #4b5c74;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 7px 16px rgba(66, 103, 245, .2); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); box-shadow: 0 9px 20px rgba(66, 103, 245, .25); }
.btn-light { color: #4e5f77; background: #fff; border-color: var(--line-strong); }
.btn-light:hover { color: var(--blue); background: #f8faff; border-color: #aebff5; }
.btn-danger { color: var(--red); background: #fff5f5; border-color: #f4cfd2; }
.btn-danger:hover { background: #ffeded; border-color: #eeb7bc; }
.btn-success { color: var(--green); background: #eaf8f2; border-color: #c7eadc; }
.btn-sm { min-height: 34px; padding: 6px 11px; border-radius: 8px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions form { margin: 0; }

.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; scrollbar-width: thin; scrollbar-color: #c5cfde transparent; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 12px 13px; color: #68778d; background: #f7f9fc; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; text-align: left; }
td { padding: 14px 13px; color: #33425a; border-bottom: 1px solid #e9edf3; font-size: 14px; line-height: 1.6; vertical-align: middle; }
tbody tr { transition: background-color .16s ease; }
tbody tr:hover { background: #fafbfe; }
tr:last-child td { border-bottom: 0; }
td strong { color: var(--navy); }

.badge {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  color: #5b6a80;
  background: #eef2f7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}

.badge.green { color: var(--green); background: #e7f7f1; }
.badge.blue { color: var(--blue-dark); background: var(--blue-soft); }
.badge.orange { color: var(--orange); background: #fff4e5; }
.badge.red { color: var(--red); background: #fff0f1; }

.alert { margin-bottom: 16px; padding: 13px 16px; border: 1px solid transparent; border-radius: 11px; font-size: 14px; line-height: 1.7; }
.alert-success { color: #116c4d; background: #eaf8f2; border-color: #ccebdd; }
.alert-error { color: #ae3f47; background: #fff1f2; border-color: #f5d4d7; }
.alert-warning { color: #8e6117; background: #fff7e8; border-color: #f4dfb5; }
.empty { padding: 46px 16px; color: #8491a5; font-size: 14px; text-align: center; }

.metric-list { display: grid; gap: 0; }
.metric-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid #e9edf3; }
.metric-row:first-child { padding-top: 0; }
.metric-row:last-child { padding-bottom: 0; border-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.detail-item { min-width: 0; padding: 15px; background: var(--surface-soft); border: 1px solid #edf0f5; border-radius: 11px; }
.detail-item span { display: block; color: var(--muted); font-size: 13px; }
.detail-item strong { display: block; margin-top: 6px; overflow-wrap: anywhere; color: var(--navy); font-size: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tab { padding: 8px 14px; color: #52627a; background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 14px; }
.tab.active { color: #fff; background: var(--blue); border-color: var(--blue); }

.notice-list { display: grid; gap: 15px; }
.notice-item { padding: 20px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; }
.notice-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notice-title h3 { margin: 0; color: var(--navy); font-size: 19px; }
.notice-meta { margin-top: 7px; color: var(--muted); font-size: 13px; }
.notice-content { margin-top: 15px; overflow-wrap: anywhere; color: #3d4c62; font-size: 15px; line-height: 1.9; }

/* 权限页 */
.scope-panel { margin-bottom: 22px; padding: 18px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 13px; }
.scope-panel > .field { max-width: 460px; }
.scope-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.scope-box { min-width: 0; padding: 15px; background: #fff; border: 1px solid var(--line); border-radius: 11px; }
.scope-box:not([hidden]) { grid-column: 1 / -1; }
.scope-box > strong { display: block; margin-bottom: 10px; color: var(--navy); font-size: 14px; }
.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; margin: 0; padding: 8px 11px; color: #4e5e75; background: #f6f8fb; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-size: 14px; line-height: 1.35; transition: color .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease; }
.choice-chip:hover { color: var(--blue-dark); background: #f2f5ff; border-color: #b9c7f5; }
.choice-chip:has(input:checked) { color: var(--blue-dark); background: var(--blue-soft); border-color: #b7c6fb; box-shadow: inset 0 0 0 1px rgba(66, 103, 245, .08); }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.permission-section { min-width: 0; padding: 17px; background: #fff; border: 1px solid var(--line); border-radius: 13px; }
.permission-section h3 { margin: 0 0 12px; color: var(--navy); font-size: 16px; line-height: 1.4; }
.permission-section .choice-grid { align-items: stretch; }
.permission-section .choice-chip { flex: 1 1 190px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #e6ecff 0, transparent 42%), radial-gradient(circle at bottom right, #e7f3ff 0, transparent 40%), #f5f7fb; }
.login-card { width: min(440px, 100%); padding: 38px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 60px rgba(26, 48, 82, .13); }
.login-logo { margin-bottom: 28px; text-align: center; }
.login-logo img { max-width: 230px; max-height: 100px; }
.login-logo .fallback { color: var(--blue); font-size: 30px; font-weight: 900; }
.login-card h1 { margin: 5px 0; color: var(--navy); font-size: 25px; }
.login-card .sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.login-card .field { margin-bottom: 15px; }
.login-card .btn { width: 100%; min-height: 46px; }
.login-foot { margin-top: 20px; color: #8491a5; font-size: 12px; text-align: center; }
.mobile-menu { display: none; min-width: 42px; min-height: 42px; padding: 8px; color: var(--navy); background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 20px; }

@media (max-width: 1280px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .sidebar { width: 242px; }
  .main { width: calc(100% - 242px); margin-left: 242px; }
  .topbar, .content { padding-left: 22px; padding-right: 22px; }
  .grid-3 { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open::before { content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(20, 33, 61, .34); backdrop-filter: blur(2px); }
  .app-shell, .main, .content, .card, .topbar { width: 100%; max-width: 100%; min-width: 0; }
  .sidebar { width: min(84vw, 310px); transform: translateX(-102%); box-shadow: 16px 0 42px rgba(20, 33, 61, .18); transition: transform .24s cubic-bezier(.22, .8, .32, 1); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-menu { display: inline-grid; flex: 0 0 42px; place-items: center; }
  .topbar { min-height: 76px; padding: 14px; }
  .topbar h1 { font-size: 23px; }
  .topbar p { font-size: 13px; }
  .content { padding: 0 12px 28px; }
  .card { margin-bottom: 14px; padding: 17px 14px; border-radius: 13px; }
  .card-head { flex-direction: column; gap: 13px; margin-bottom: 17px; }
  .card-head h2 { font-size: 20px; }
  .card-head > .actions { width: 100%; }
  .card-head > .actions .btn { flex: 1 1 auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .stat { padding: 14px; }
  .stat strong { font-size: 22px; }
  .grid-2, .grid-3, .form-grid, .form-grid.cols-3, .detail-grid, .scope-options { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .toolbar { align-items: stretch; }
  .toolbar > .input, .toolbar > .select, .toolbar > .btn, .toolbar .grow { width: 100%; flex-basis: 100%; }
  .metric-row { align-items: flex-start; flex-wrap: wrap; }
  .user-box { gap: 8px; }
  .user-box > div { display: none; }
  .notice-item { padding: 16px; }
  .notice-title { align-items: flex-start; }
  .scope-panel { padding: 14px; }
  .choice-grid { display: grid; grid-template-columns: 1fr; }
  .choice-chip, .permission-section .choice-chip { width: 100%; }

  .table-wrap { overflow: visible; border: 0; border-radius: 0; }
  table, tbody, tr, td { display: block; width: 100%; max-width: 100%; }
  table { white-space: normal; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tr { overflow: hidden; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 11px; }
  td { padding: 9px; white-space: normal; overflow-wrap: anywhere; word-break: break-word; border: 0; }
  td + td { border-top: 1px dashed #e3e8f0; }
  td .actions, td form.actions { width: 100%; }
  td .actions .btn, td form.actions .btn { flex: 1 1 auto; }
  .btn { white-space: normal; }
  .login-card { padding: 28px 21px; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
  .topbar { gap: 10px; }
  .topbar h1 { font-size: 21px; }
  .card { padding: 15px 12px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
