:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #175cd3;
  --primary-dark: #0b4db8;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .03);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 28px; letter-spacing: -.03em; }
h2 { margin: 0; font-size: 16px; }

.topbar {
  height: 60px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 34px;
  background: #101828;
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; }
.brand:hover { color: #fff; }
.brand-mark {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #2e90fa;
  color: #fff;
  font-weight: 800;
}
.nav { display: flex; gap: 6px; height: 100%; }
.nav a { padding: 0 12px; display: flex; align-items: center; color: #d0d5dd; font-weight: 500; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(255,255,255,.08); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 12px; color: #d0d5dd; }
.user-menu form { margin: 0; }
.link-button { border: 0; padding: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.link-button:hover { color: #fff; }

.page-shell { max-width: 1440px; margin: 0 auto; padding: 30px 28px 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading p:last-child { margin-bottom: 0; }
.eyebrow { margin-bottom: 5px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.heading-actions { display: flex; align-items: center; gap: 7px; padding-bottom: 4px; }
.muted { color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; }
.status-dot.status-ok { background: #12b76a; box-shadow: 0 0 0 3px rgba(18,183,106,.12); }

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.compact-filter { max-width: 900px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 132px; }
.field label { color: #344054; font-size: 12px; font-weight: 600; }
.field-wide { flex: 1; min-width: 220px; }
input, select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
}
input:focus, select:focus { border-color: #84adff; box-shadow: 0 0 0 3px rgba(46,144,250,.12); }
.button {
  display: inline-flex;
  height: 38px;
  padding: 0 14px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); color: #fff; }
.button-ghost { border-color: #d0d5dd; background: #fff; color: #344054; }
.button-ghost:hover { background: #f9fafb; color: var(--text); }
.button-full { width: 100%; margin-top: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric-card { min-height: 136px; padding: 20px; display: flex; flex-direction: column; }
.metric-label { color: #475467; font-size: 13px; font-weight: 600; }
.metric-card strong { margin: 12px 0 7px; font-size: 31px; line-height: 1.1; letter-spacing: -.04em; }
.metric-card small { margin-left: 3px; color: #667085; font-size: 14px; font-weight: 500; }
.metric-hint { margin-top: auto; color: var(--muted); font-size: 12px; }
.empty-value { color: #98a2b3; }

.panel { padding: 20px; margin-bottom: 18px; min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading p { margin: 3px 0 0; font-size: 12px; }
.chart-panel { padding-bottom: 14px; }
.bar-chart {
  height: 245px;
  padding: 8px 0 0;
  display: flex;
  align-items: stretch;
  gap: 3px;
  border-bottom: 1px solid var(--line);
}
.bar-column { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar-track { width: 70%; max-width: 30px; height: 205px; display: flex; align-items: flex-end; position: relative; border-radius: 4px 4px 0 0; background: #f2f4f7; }
.bar-total { position: absolute; inset: auto 0 0; border-radius: 4px 4px 0 0; background: #d1e0ff; }
.bar-errors { position: absolute; inset: auto 0 0; min-height: 2px; border-radius: 4px 4px 0 0; background: #f97066; }
.bar-label { max-width: 84px; height: 20px; margin-top: 7px; overflow: hidden; color: #98a2b3; font-size: 10px; white-space: nowrap; transform: translateX(0); }

.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.two-column > .panel { margin-bottom: 18px; }
.status-row { display: grid; grid-template-columns: 54px 1fr 70px 48px; align-items: center; gap: 10px; min-height: 38px; }
.status-badge, .level {
  width: fit-content;
  min-width: 40px;
  padding: 2px 7px;
  display: inline-block;
  border-radius: 5px;
  background: #f2f4f7;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.status-2xx { background: #ecfdf3; color: var(--success); }
.status-3xx { background: #eff8ff; color: #175cd3; }
.status-4xx { background: #fffaeb; color: var(--warning); }
.status-5xx { background: #fef3f2; color: var(--danger); }
.progress-track { height: 7px; overflow: hidden; border-radius: 99px; background: #f2f4f7; }
.progress-value { height: 100%; border-radius: inherit; background: #84adff; }
.status-fill-2xx { background: #32d583; }
.status-fill-3xx { background: #53b1fd; }
.status-fill-4xx { background: #fdb022; }
.status-fill-5xx { background: #f97066; }
.level-error { background: #fef3f2; color: var(--danger); }
.level-warn { background: #fffaeb; color: var(--warning); }
.level-notice { background: #eff8ff; color: #175cd3; }
.ranking { margin: 0; padding: 0; list-style: none; }
.ranking li { min-height: 34px; padding: 6px 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid #f2f4f7; }
.ranking li:last-child { border: 0; }
.rank-name { min-width: 0; overflow: hidden; color: #344054; text-overflow: ellipsis; white-space: nowrap; }
.ranking strong { color: #475467; font-size: 12px; white-space: nowrap; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f9fafb; color: #475467; font-size: 11px; font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .04em; }
td { max-width: 330px; padding: 11px 12px; border-bottom: 1px solid #f2f4f7; color: #344054; font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.nowrap { white-space: nowrap; }
.truncate-cell { overflow: hidden; text-overflow: ellipsis; }
.message-cell { min-width: 300px; white-space: normal; }
details summary { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
pre { max-width: 680px; padding: 10px; overflow: auto; border-radius: 6px; background: #101828; color: #f2f4f7; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.empty-state { padding: 28px !important; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; color: var(--muted); font-size: 12px; }
.pagination-links { display: flex; gap: 7px; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(46,144,250,.17), transparent 35%),
    radial-gradient(circle at 80% 85%, rgba(50,213,131,.11), transparent 32%),
    #101828;
}
.login-card { width: min(100%, 390px); padding: 34px; border: 1px solid rgba(255,255,255,.1); border-radius: 18px; background: #fff; box-shadow: 0 20px 50px rgba(0,0,0,.24); }
.login-brand { margin-bottom: 20px; }
.login-card h1 { margin-bottom: 7px; font-size: 24px; }
.login-card > p { margin-bottom: 25px; }
.login-form { display: flex; flex-direction: column; gap: 7px; }
.login-form label { margin-top: 8px; color: #344054; font-size: 12px; font-weight: 600; }
.alert { padding: 10px 12px; border-radius: 7px; }
.alert-error { border: 1px solid #fecdca; background: #fef3f2; color: var(--danger); }
.alert-success { border: 1px solid #abefc6; background: #ecfdf3; color: var(--success); }

.security-warning { padding: 6px 10px; border: 1px solid #fedf89; border-radius: 99px; background: #fffaeb; color: var(--warning); font-size: 11px; font-weight: 600; }
.metric-danger { border-color: #fecdca; background: linear-gradient(150deg, #fff 25%, #fef3f2); }
.security-metrics { margin-top: 0; }
.security-category-row { display: grid; grid-template-columns: 115px 1fr 52px; align-items: center; gap: 12px; min-height: 39px; }
.security-category-row a { color: #344054; font-size: 13px; }
.security-category-row a:hover { color: var(--danger); }
.security-fill { background: linear-gradient(90deg, #fda29b, #f04438) !important; }
.severity, .triage {
  padding: 3px 7px;
  display: inline-block;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.severity-critical { background: #7a271a; color: #fff; }
.severity-high { background: #fef3f2; color: var(--danger); }
.severity-medium { background: #fffaeb; color: var(--warning); }
.severity-low { background: #f2f4f7; color: #475467; }
.triage-open { background: #fffaeb; color: var(--warning); }
.triage-confirmed { background: #fef3f2; color: var(--danger); }
.triage-false_positive { background: #f2f4f7; color: #475467; }
.triage-resolved { background: #ecfdf3; color: var(--success); }
.request-method { color: #6941c6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 700; }
.event-summary { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 18px; }
.event-summary .panel { margin: 0 0 18px; }
.event-summary .metric-label { display: block; margin-bottom: 10px; }
.event-score > .severity { margin-bottom: 14px; }
.event-score-number { display: block; font-size: 29px; font-weight: 700; letter-spacing: -.04em; }
.event-score-number small { color: var(--muted); font-size: 12px; font-weight: 500; }
.event-request { margin: 7px 0 9px; color: #344054; overflow-wrap: anywhere; }
.rule-list { display: flex; flex-direction: column; gap: 8px; }
.rule-item { padding: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: 7px; background: #f9fafb; }
.rule-item strong { display: block; margin-bottom: 2px; font-size: 13px; }
.rule-item code { color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.triage-form { display: flex; flex-direction: column; gap: 7px; }
.triage-form label { margin-top: 4px; color: #344054; font-size: 12px; font-weight: 600; }
.triage-form textarea { padding: 10px; border: 1px solid #d0d5dd; border-radius: 8px; color: var(--text); font: inherit; resize: vertical; }
.triage-form .button { align-self: flex-start; margin-top: 7px; }
.break-text { overflow-wrap: anywhere; }
.context-list { display: grid; grid-template-columns: 120px 1fr; gap: 9px 18px; }
.context-list dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.context-list dd { margin: 0; color: #344054; font-size: 13px; }
.allowlist-form { align-items: center; }
.check-field { display: inline-flex; align-items: center; gap: 7px; color: #344054; font-size: 12px; white-space: nowrap; }
.check-field input { width: 16px; height: 16px; }
.allowlist-preview { padding-top: 14px; color: var(--muted); font-size: 12px; }
.allowlist-preview code { margin-left: 5px; padding: 2px 5px; border-radius: 4px; background: #f2f4f7; color: #475467; }

@media (max-width: 1000px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
  .event-summary { grid-template-columns: 1fr; gap: 0; }
  .nav { gap: 0; }
  .brand span:last-child { display: none; }
}
@media (max-width: 680px) {
  .topbar { padding: 0 15px; gap: 8px; }
  .user-menu > span { display: none; }
  .page-shell { padding: 20px 14px 40px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 23px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 115px; }
  .filter-bar { align-items: stretch; }
  .field, .field-wide { flex: 1 1 140px; min-width: 0; }
  .pagination { align-items: flex-start; flex-direction: column; }
}
