:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f3f5f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-size: 14px;
}

.topbar {
  background: #16202d;
  color: #fff;
  border-bottom: 1px solid #253244;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.topbar p {
  margin: 2px 0 0;
  color: #cbd5e1;
  font-size: 13px;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #dbe5f1;
  font-size: 12px;
  font-weight: 700;
}

.topbar-user button {
  min-height: 28px;
  border-color: #425166;
  background: #223047;
  color: #e5edf7;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 24px;
}

.login-panel {
  width: min(100%, 380px);
  margin: 64px auto;
  padding: 18px;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: #fff;
}

.login-panel h2 {
  margin: 0;
  font-size: 18px;
}

.login-panel p {
  margin: 5px 0 16px;
  color: #64748b;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form button {
  width: 100%;
}

.login-error {
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff1f2;
  color: #9f1239;
  font-size: 13px;
  font-weight: 700;
}

.panel {
  background: #fff;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid #e4e9f1;
}

.panel-header h2 {
  margin: 0;
  font-size: 17px;
}

.panel-header p {
  margin: 3px 0 0;
  color: #64748b;
  font-size: 13px;
}

.refresh-state {
  border: 1px solid #d8dee8;
  border-radius: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  white-space: nowrap;
}

.refresh-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.refresh-actions form {
  margin: 0;
}

.refresh-button {
  min-height: 30px;
  padding: 5px 9px;
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.refresh-icon {
  color: #2563eb;
  font-size: 13px;
  line-height: 1;
}

.refresh-progress {
  display: none;
  align-items: center;
  gap: 6px;
  color: #28415f;
  font-size: 12px;
  font-weight: 700;
}

.refresh-progress.is-visible {
  display: inline-flex;
}

.notice {
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid #e4e9f1;
  font-size: 13px;
  font-weight: 700;
}

.notice-success {
  background: #ecfdf5;
  color: #166534;
}

.notice-error {
  background: #fff1f2;
  color: #9f1239;
}

.notice-info {
  background: #eff6ff;
  color: #1d4ed8;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 14px 34px rgb(15 23 42 / 18%);
  color: #1f2a3a;
  font-size: 13px;
  font-weight: 700;
}

.toast-success {
  border-color: #86efac;
  background: #ecfdf5;
  color: #166534;
}

.toast-error {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #9f1239;
}

.toast-info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 150px 140px minmax(150px, 0.7fr) minmax(150px, 0.7fr) 112px auto;
  gap: 10px;
  align-items: end;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e4e9f1;
}

.field {
  display: grid;
  gap: 4px;
}

.field span {
  color: #526174;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #172033;
  font: inherit;
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
  outline: none;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.finding-list {
  display: grid;
}

.results-region {
  position: relative;
  min-height: 64px;
}

.loading-indicator {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  width: 100%;
  padding: 8px 16px;
  border-bottom: 1px solid #e4e9f1;
  background: #f8fafc;
  color: #28415f;
  font-size: 12px;
  font-weight: 700;
}

.loading-dot {
  width: 12px;
  height: 12px;
  border: 2px solid #b6c7dd;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.results-region.is-loading .loading-indicator {
  display: flex;
}

.results-region.is-loading .finding-list,
.results-region.is-loading .empty,
.results-region.is-loading .pagination {
  opacity: 0.48;
}

.finding {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid #e8edf4;
  border-left: 4px solid transparent;
  background: #fff;
}

.finding:last-child {
  border-bottom: 0;
}

.finding-status-open {
  border-left-color: #64748b;
}

.finding-status-seen {
  border-left-color: #0284c7;
}

.finding-status-resolved {
  border-left-color: #16a34a;
}

.finding-status-ticket {
  border-left-color: #d97706;
}

.finding-status-pattern_resolved {
  border-left-color: #475569;
  background: #f8fafc;
}

.finding-severity-critical,
.finding-severity-incident {
  background: #fff7f7;
}

.finding-severity-important {
  background: #fffaf2;
}

.finding-severity-review {
  background: #f8fbff;
}

.finding-main {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.finding-badges {
  display: grid;
  gap: 6px;
  align-content: flex-start;
  width: 100%;
  max-width: 112px;
}

.finding-badges .severity,
.finding-badges .status {
  justify-content: center;
  width: 100%;
}

.finding-content {
  min-width: 0;
}

.finding-title {
  display: flex;
  align-items: center;
  min-width: 0;
}

.finding-title h3 {
  margin: 0;
  color: #172033;
  font-size: 14px;
  line-height: 1.3;
}

.finding p {
  margin: 5px 0 7px;
  color: #44546a;
  line-height: 1.35;
}

.finding-details {
  min-width: 0;
}

.cve-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 7px;
  min-width: 0;
}

.cve-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid #d5dde8;
  border-radius: 6px;
  background: #fff;
  color: #44546a;
  font-size: 12px;
  line-height: 1.25;
}

.cve-pill a,
.cve-detail-head a {
  color: #1d4ed8;
  font-weight: 800;
  text-decoration: none;
}

.cve-pill a:hover,
.cve-detail-head a:hover {
  text-decoration: underline;
}

.cve-pill b {
  color: #253044;
  font-weight: 800;
}

.cve-pill span {
  color: #64748b;
  white-space: nowrap;
}

.cve-more {
  background: #eef3fb;
  color: #28415f;
  font-weight: 800;
}

.tag-group,
.metric-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  min-width: 0;
  min-height: 28px;
}

.tag-chip,
.metric-chip {
  border: 1px solid #d8dee8;
  border-radius: 6px;
  padding: 3px 7px;
}

.tag-chip,
.metric-chip {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
}

.tag-chip {
  background: #f4f6f8;
  border-color: #d8dee8;
  color: #566274;
  white-space: nowrap;
}

.tag-key {
  color: #7a8796;
}

.tag-chip b {
  color: #253044;
  font-weight: 700;
}

.event-details {
  grid-column: 1 / -1;
  margin-top: -4px;
  margin-left: 124px;
  color: #475569;
  font-size: 12px;
  min-width: 0;
}

.event-details summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: #475569;
  font-weight: 700;
  list-style: none;
}

.event-details summary::-webkit-details-marker {
  display: none;
}

.event-details[open] summary {
  color: #253044;
}

.details-icon {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid currentColor;
  transform: translateY(1px);
}

.event-details[open] > summary .details-icon {
  transform: rotate(90deg) translateX(1px);
}

.event-details-body {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid #cfd7e2;
  border-radius: 0 6px 6px 6px;
  background: #f8fafc;
  overflow: hidden;
}

.event-details-section + .event-details-section {
  padding-top: 10px;
  border-top: 1px solid #d8dee8;
}

.event-details h4 {
  margin: 0 0 7px;
  color: #334155;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.event-details dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.event-details dl div {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.event-details dt {
  color: #64748b;
  font-weight: 700;
}

.event-details dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.related-entity-details,
.vulnerability-details {
  display: grid;
  gap: 10px;
}

.related-entity,
.vulnerability-package {
  padding: 8px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #fff;
}

.cve-detail-list {
  display: grid;
  gap: 7px;
}

.cve-detail {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #fff;
}

.cve-detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: baseline;
}

.cve-detail-head b {
  color: #253044;
  font-weight: 800;
}

.cve-detail-head span {
  padding: 2px 5px;
  border: 1px solid #fed7aa;
  border-radius: 5px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 11px;
  font-weight: 800;
}

.cve-detail p {
  margin: 0;
  color: #44546a;
  line-height: 1.35;
}

.cve-detail-group {
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #fff;
}

.cve-detail-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  cursor: pointer;
  color: #111827;
  font-size: 12px;
  font-weight: 800;
  list-style: none;
}

.cve-detail-group > summary::-webkit-details-marker {
  display: none;
}

.cve-detail-group[open] > summary .details-icon {
  transform: rotate(90deg) translateX(1px);
}

.cve-detail-count {
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.cve-detail-group .cve-detail-list {
  padding: 0 8px 8px;
}

.cve-condition {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: #475569;
}

.cve-condition b {
  color: #334155;
}

.condition-evaluation dd,
.cve-condition-evaluation strong {
  color: #9a3412;
  font-weight: 900;
}

.event-key {
  display: inline-block;
  max-width: 100%;
  padding: 2px 5px;
  border: 1px solid #d8dee8;
  border-radius: 5px;
  background: #fff;
  color: #334155;
  font-family: "ShureTechMono Nerd Font Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.inline-link {
  display: inline-flex;
  margin-left: 8px;
  color: #1d4ed8;
  font-weight: 700;
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.event-details pre {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.metric-chip b {
  color: inherit;
  font-size: 11px;
}

.metric-group {
  justify-content: flex-end;
  min-width: 0;
}

.metric-chip {
  background: #eef3fb;
  border-color: #c8d6ea;
  color: #28415f;
}

.severity,
.status {
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.severity-critical,
.severity-incident {
  background: #fee2e2;
  color: #991b1b;
}

.severity-important {
  background: #ffedd5;
  color: #9a3412;
}

.severity-review {
  background: #dbeafe;
  color: #1e40af;
}

.status {
  background: #eef2f7;
  color: #46566c;
}

.status-seen {
  background: #e0f2fe;
  color: #075985;
}

.status-resolved {
  background: #dcfce7;
  color: #166534;
}

.status-ticket {
  background: #fef3c7;
  color: #92400e;
}

.status-pattern_resolved {
  background: #e2e8f0;
  color: #334155;
}

.actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-content: flex-start;
  justify-content: flex-end;
  max-width: 100%;
}

.actions form {
  margin: 0;
}

.finding-side {
  display: grid;
  gap: 7px;
  align-content: start;
  justify-items: end;
  flex: 0 0 452px;
  min-width: 452px;
}

button,
.button-muted,
.page-link,
.button-discover {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #c8d2df;
  background: #fff;
  border-radius: 6px;
  color: #1f2a3a;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  min-height: 32px;
  padding: 6px 10px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-muted:hover,
.page-link:hover {
  background: #f1f5f9;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.action-seen {
  background: #eef4fb;
  border-color: #9db2ca;
  color: #1d3d5a;
}

.action-resolved {
  background: #edf7f1;
  border-color: #8fc2a2;
  color: #1f5135;
}

.action-ticket {
  background: #faf2de;
  border-color: #c9a84e;
  color: #5d430d;
}

.action-pattern-resolved,
.action-reopen {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #334155;
}

.event-details-actions {
  display: flex;
  justify-content: flex-end;
}

.event-details-actions form {
  margin: 0;
}

.button-discover {
  background: #e8f0ff;
  border-color: #8aaadc;
  color: #143d72;
}

.button-discover:hover {
  background: #dbeafe;
}

.button-discover .action-icon {
  background: #cfe0fb;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
}

.action-seen .action-icon {
  background: #d9e8f6;
}

.action-resolved .action-icon {
  background: #d9efdf;
}

.action-ticket .action-icon {
  background: #efdca3;
}

.action-pattern-resolved .action-icon,
.action-reopen .action-icon {
  background: #e2e8f0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #e4e9f1;
  color: #526174;
  font-size: 13px;
}

.page-link.disabled {
  color: #94a3b8;
  pointer-events: none;
}

.empty {
  padding: 34px 18px;
  color: #637083;
  text-align: center;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .field-search,
  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1180px) {
  .finding-side {
    flex-basis: 346px;
    min-width: 346px;
  }

  .actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 780px) {
  .topbar-inner,
  .layout {
    padding: 14px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .field-search,
  .filter-actions {
    grid-column: auto;
  }

  .finding {
    display: block;
  }

  .finding-main {
    grid-template-columns: 1fr;
  }

  .finding-badges {
    min-width: 0;
  }

  .finding-details {
    grid-template-columns: 1fr;
  }

  .metric-group {
    justify-content: flex-start;
    min-width: 0;
  }

  .finding-side {
    justify-items: start;
    min-width: 0;
    margin-top: 10px;
  }

  .event-details {
    margin-left: 0;
  }

  .actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    min-width: 0;
  }

  .tag-chip {
    padding: 2px 6px;
    font-size: 11px;
  }

  .event-details dl div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .pagination {
    justify-content: space-between;
  }
}
