:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e3e8ef;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --navy: #10233f;
  --navy-soft: #1d375d;
  --blue: #246bce;
  --blue-soft: #eaf2ff;
  --green: #178a5b;
  --green-soft: #e8f7f0;
  --amber: #bc6b05;
  --amber-soft: #fff4df;
  --red: #c43d4f;
  --red-soft: #fff0f2;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(24, 39, 75, .08);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%, #234b80 0, transparent 32%), linear-gradient(135deg, #0b1d37, #16355d); }
.login-card { width: min(420px, 100%); padding: 38px; color: var(--ink); background: rgba(255,255,255,.98); border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; color: white; font-weight: 800; letter-spacing: .08em; background: linear-gradient(140deg, #246bce, #59a9ff); border-radius: 13px; }
.login-card h1 { margin: 20px 0 8px; font-size: 26px; }
.login-card p { margin: 0 0 28px; color: var(--muted); line-height: 1.7; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 14px; color: #dce8f8; background: var(--navy); display: flex; flex-direction: column; gap: 20px; }
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 12px; color: white; font-weight: 700; letter-spacing: .02em; }
.sidebar .brand .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 13px; }
.nav-label { padding: 0 12px; color: #87a0c2; font-size: 12px; letter-spacing: .08em; }
.nav-menu { display: grid; gap: 4px; }
.nav-button { width: 100%; border: 0; border-radius: 9px; padding: 11px 12px; display: flex; align-items: center; gap: 10px; color: #bed0e9; background: transparent; text-align: left; transition: .15s ease; }
.nav-button:hover { color: white; background: rgba(255,255,255,.08); }
.nav-button.active { color: white; background: #254b7e; box-shadow: inset 3px 0 0 #78b3ff; }
.nav-button .nav-icon { width: 18px; text-align: center; font-size: 15px; }
.sidebar-footer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.12); color: #91a7c4; font-size: 12px; line-height: 1.6; }

.main-shell { min-width: 0; }
.topbar { min-height: 70px; padding: 14px 30px; display: flex; justify-content: space-between; align-items: center; gap: 16px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); }
.topbar-title { font-size: 18px; font-weight: 750; }
.topbar-meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { padding: 8px 11px; border-radius: 999px; color: #31517c; background: #edf3fb; font-size: 13px; }
.content { padding: 28px 30px 46px; max-width: 1640px; }

.page-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.page-header h2 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.page-header p { max-width: 780px; margin: 7px 0 0; color: var(--muted); line-height: 1.65; }
.section-title { margin: 28px 0 12px; font-size: 15px; font-weight: 750; }

.grid { display: grid; gap: 16px; }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); align-items: start; }
.card { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 7px rgba(17, 35, 63, .025); }
.metric-card { min-height: 142px; position: relative; overflow: hidden; }
.metric-card::after { position: absolute; width: 74px; height: 74px; right: -22px; bottom: -31px; content: ""; border-radius: 50%; background: var(--blue-soft); }
.metric-card.green::after { background: var(--green-soft); }
.metric-card.amber::after { background: var(--amber-soft); }
.metric-card.red::after { background: var(--red-soft); }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin: 13px 0 8px; font-size: clamp(25px, 2vw, 34px); font-weight: 780; letter-spacing: -.04em; }
.metric-note { color: var(--muted); font-size: 12px; }
.stat-emphasis { color: var(--blue); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; color: white; background: var(--blue); font-weight: 650; white-space: nowrap; }
.button:hover { filter: brightness(.96); }
.button.secondary { color: #31517c; background: white; border-color: #cad8e8; }
.button.danger { background: var(--red); }
.button.small { padding: 6px 10px; font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.input, .select, .textarea { width: 100%; padding: 10px 11px; color: var(--ink); background: white; border: 1px solid #cfd8e5; border-radius: 8px; outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,107,206,.12); }
.textarea { min-height: 86px; resize: vertical; }
.field { display: grid; gap: 6px; }
.field label { color: #46546b; font-size: 13px; font-weight: 650; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 11px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #41516a; background: #f7f9fc; font-weight: 700; font-size: 12px; }
td.wrap, th.wrap { white-space: normal; min-width: 180px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcff; }
.number { font-variant-numeric: tabular-nums; text-align: right; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; color: #45617f; background: #edf3fb; font-size: 12px; font-weight: 650; }
.badge.ok { color: #12734a; background: var(--green-soft); }
.badge.warning { color: #9b5a04; background: var(--amber-soft); }
.badge.error { color: #a62f42; background: var(--red-soft); }
.badge.muted { color: #64748b; background: #eff2f6; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 8px; color: #46546b; font-size: 16px; }
.notice { padding: 13px 14px; border-radius: 10px; color: #7d4a07; background: var(--amber-soft); line-height: 1.55; font-size: 13px; }
.notice.info { color: #235486; background: var(--blue-soft); }
.notice.error { color: #9f2d40; background: var(--red-soft); }

.issue-list { display: grid; gap: 9px; }
.issue-item { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.issue-item:last-child { border-bottom: 0; }
.issue-item .count { color: var(--muted); font-variant-numeric: tabular-nums; }

.rule-map { display: grid; grid-template-columns: 155px minmax(0, 1fr); gap: 8px 14px; align-items: start; font-size: 13px; }
.rule-map .key { color: var(--muted); }
.checkbox-list { display: flex; flex-wrap: wrap; gap: 9px 14px; }
.checkbox-list label { display: flex; gap: 6px; align-items: center; font-size: 13px; }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15, 31, 55, .45); }
.modal { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; background: white; border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.26); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.modal-header h3 { margin: 0; font-size: 19px; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 8px; color: var(--muted); background: #f1f4f8; font-size: 20px; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast-region { position: fixed; z-index: 30; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(400px, calc(100vw - 40px)); }
.toast { padding: 13px 15px; color: white; background: #233b5f; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; line-height: 1.45; }
.toast.error { background: #a43144; }
.loading { padding: 64px 20px; text-align: center; color: var(--muted); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px; }
  .sidebar .brand { justify-content: center; padding: 0 0 10px; }
  .sidebar .brand span, .nav-label, .nav-button .nav-text, .sidebar-footer { display: none; }
  .nav-button { justify-content: center; padding: 12px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 10px; flex-direction: row; overflow-x: auto; align-items: center; }
  .sidebar .brand { padding: 0 5px; }
  .sidebar .brand span { display: none; }
  .nav-menu { display: flex; gap: 4px; }
  .nav-button { width: auto; padding: 9px 10px; }
  .sidebar-footer { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .topbar { align-items: flex-start; }
  .topbar-actions .user-chip { display: none; }
  .page-header, .topbar { flex-wrap: wrap; }
  .metric-grid, .two-col, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .content { padding-top: 20px; }
}
