:root {
  --bg: #0f1419;
  --surface: #171d26;
  --surface-2: #1e2530;
  --border: #2a323d;
  --text: #e6eaf0;
  --muted: #8993a4;
  --brand: #4fd1c5;
  --risk-high: #ef5b5b;
  --risk-high-bg: rgba(239, 91, 91, 0.12);
  --risk-medium: #f0a857;
  --risk-medium-bg: rgba(240, 168, 87, 0.12);
  --risk-low: #4fd17a;
  --risk-low-bg: rgba(79, 209, 122, 0.12);
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
}

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 2.25rem 1.5rem 1.75rem;
  text-align: center;
}

.brand {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tagline {
  color: var(--muted);
  max-width: 540px;
  margin: 0.5rem auto 0;
  font-size: 0.95rem;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.search-panel { margin-bottom: 1.5rem; }

.search-row {
  display: flex;
  gap: 0.6rem;
}

#searchInput {
  flex: 1;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

#searchInput:focus {
  outline: none;
  border-color: var(--brand);
}

#searchBtn, #printBtn {
  padding: 0.8rem 1.4rem;
  border-radius: 6px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #08211e;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

#searchBtn:hover, #printBtn:hover { filter: brightness(1.08); }

.help-link {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 0.85rem;
  padding: 0.5rem 0 0;
  cursor: pointer;
  font-family: var(--sans);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.help-link:hover { color: var(--text); }

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 13, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.help-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 960px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.75rem 2rem 2rem;
}

.help-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.help-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.help-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.help-close:hover { color: var(--text); border-color: var(--brand); }

.help-intro { margin: 0.35rem 0 1.5rem; }

.help-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.help-step {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 0.9rem 1.1rem;
  text-align: center;
}

.step-illustration {
  width: 100%;
  max-width: 130px;
  height: auto;
  margin: 0 auto 0.6rem;
  display: block;
}

.help-step-num {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #08211e;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-step h3 {
  font-size: 0.92rem;
  margin: 0.2rem 0 0.4rem;
}

.help-step p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.help-gotit {
  display: block;
  margin: 1.75rem auto 0;
  padding: 0.7rem 2rem;
  border-radius: 6px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #08211e;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.help-gotit:hover { filter: brightness(1.08); }

@media (max-width: 860px) {
  .help-steps { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .help-steps { grid-template-columns: 1fr; }
  .help-modal { padding: 1.5rem 1.25rem 1.75rem; }
}

.search-results {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.result-item:hover { border-color: var(--brand); }

.result-item img { width: 36px; height: 36px; border-radius: 8px; }

.result-item .r-title { font-weight: 600; font-size: 0.92rem; }
.result-item .r-dev { color: var(--muted); font-size: 0.8rem; }
.result-item .r-id { margin-left: auto; font-family: var(--mono); color: var(--muted); font-size: 0.75rem; }

.hidden { display: none !important; }

.loading {
  text-align: center;
  padding: 3rem 0;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

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

.error-box {
  background: var(--risk-high-bg);
  border: 1px solid var(--risk-high);
  color: var(--risk-high);
  padding: 1rem 1.2rem;
  border-radius: 6px;
  margin: 1rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card h3 {
  margin-top: 0;
  font-size: 1.1rem;
}

.muted { color: var(--muted); font-size: 0.88rem; }

.app-header {
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
}

.app-header img { width: 72px; height: 72px; border-radius: 16px; flex-shrink: 0; }

.app-header h2 { margin: 0 0 0.2rem; font-size: 1.3rem; }

.app-header a {
  color: var(--brand);
  font-size: 0.85rem;
  text-decoration: none;
}
.app-header a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 0.35rem;
  font-family: var(--mono);
}

.verdict-box {
  margin-left: auto;
  text-align: center;
  min-width: 100px;
}

.verdict-score {
  font-family: var(--mono);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
}

.verdict-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.risk-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.2rem;
}

.risk-pill {
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.risk-pill.high { background: var(--risk-high-bg); color: var(--risk-high); border-color: var(--risk-high); }
.risk-pill.medium { background: var(--risk-medium-bg); color: var(--risk-medium); border-color: var(--risk-medium); }
.risk-pill.low { background: var(--risk-low-bg); color: var(--risk-low); border-color: var(--risk-low); }
.risk-pill.score { background: var(--surface-2); color: var(--text); }

.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.perm-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.perm-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.perm-table .risk-tag {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
}

.risk-tag.High { background: var(--risk-high-bg); color: var(--risk-high); }
.risk-tag.Medium { background: var(--risk-medium-bg); color: var(--risk-medium); }
.risk-tag.Low { background: var(--risk-low-bg); color: var(--risk-low); }

.data-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.data-row:last-child { border-bottom: none; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }

.tag {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
}

.tag.sensitive { border-color: var(--risk-high); color: var(--risk-high); }

.rating-bars { margin-top: 0.8rem; }

.rating-bar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
}

.rating-bar-row .stars { width: 40px; color: var(--muted); font-family: var(--mono); }

.rating-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.rating-bar-fill {
  height: 100%;
  background: var(--brand);
}

.sentiment-row {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.sentiment-chip {
  flex: 1;
  text-align: center;
  padding: 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: var(--mono);
}

.sentiment-chip .val { font-size: 1.3rem; font-weight: 700; }
.sentiment-chip.pos { color: var(--risk-low); }
.sentiment-chip.neg { color: var(--risk-high); }
.sentiment-chip.neu { color: var(--muted); }

.review-list { margin-top: 0.6rem; }

.review-item {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.review-item:last-child { border-bottom: none; }

.review-item .r-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.review-heading {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 1rem 0 0.2rem;
}

.review-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 1rem 0 0.7rem;
  border-bottom: 1px solid var(--border);
}

.review-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem 0.6rem;
  cursor: pointer;
  margin-bottom: -1px;
}

.review-tab.active {
  color: var(--text);
}

.review-tab.good.active { border-bottom-color: var(--risk-low); color: var(--risk-low); }
.review-tab.bad.active { border-bottom-color: var(--risk-high); color: var(--risk-high); }

.review-tab-panel { display: none; }
.review-tab-panel.active { display: block; }

.sec-block { margin-bottom: 1.1rem; }

.sec-block:last-child { margin-bottom: 0; }

.sec-block-title {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.5rem;
}

.sec-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--risk-high);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.86rem;
}

.sec-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
}

.sec-item-head .sec-id { color: var(--text); font-weight: 600; }
.sec-item-head .sec-date { color: var(--muted); }

.sec-severity {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.08rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}
.sec-severity.critical, .sec-severity.high { background: var(--risk-high-bg); color: var(--risk-high); }
.sec-severity.medium { background: var(--risk-medium-bg); color: var(--risk-medium); }
.sec-severity.low, .sec-severity.unknown { background: var(--surface-2); color: var(--muted); }

.sec-empty {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.sec-disclaimer {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.mention-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.86rem;
}

.mention-item a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.mention-item a:hover { color: var(--brand); text-decoration: underline; }

.mention-meta {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 0.35rem;
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.complaint-tag {
  display: inline-block;
  background: var(--risk-high-bg);
  color: var(--risk-high);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.08rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.35rem;
}

.actions { text-align: center; margin-top: 1.5rem; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
}

.footer code {
  font-family: var(--mono);
  background: var(--surface);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

@media print {
  .search-panel, .footer, .actions, #searchBtn { display: none !important; }
  body { background: white; color: black; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}

@media (max-width: 600px) {
  .app-header { flex-direction: column; }
  .verdict-box { margin-left: 0; align-self: flex-start; }
}
