:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171b1f;
  --panel-2: #20262b;
  --line: #303942;
  --text: #eef2f3;
  --muted: #9aa6ad;
  --accent: #d7b56d;
  --accent-2: #4db7a8;
  --danger: #ee6a5f;
  --warning: #e1a63d;
  --good: #66c78f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(215, 181, 109, 0.08), transparent 34%),
    linear-gradient(215deg, rgba(77, 183, 168, 0.08), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

a {
  color: var(--accent);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.command-panel,
.result-panel {
  border: 1px solid var(--line);
  background: rgba(23, 27, 31, 0.94);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(215, 181, 109, 0.65);
  color: var(--accent);
  background: #111416;
  border-radius: 8px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mode-tabs,
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-tab,
.result-tab {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.mode-tab.active,
.result-tab.active {
  border-color: rgba(215, 181, 109, 0.8);
  color: var(--text);
  background: rgba(215, 181, 109, 0.12);
}

.access-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.access-panel input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101315;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.access-panel input:focus {
  border-color: rgba(215, 181, 109, 0.8);
}

.access-panel span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.input-card {
  display: grid;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 14px;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed #56636b;
  border-radius: 8px;
  background: #121619;
  cursor: pointer;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: rgba(215, 181, 109, 0.08);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-copy {
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.drop-copy strong {
  color: var(--text);
  font-size: 17px;
}

.preview-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1214;
}

.preview-wrap img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}

textarea {
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #101315;
  padding: 12px;
  outline: none;
}

textarea:focus {
  border-color: rgba(215, 181, 109, 0.8);
}

.input-card input[type="text"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101315;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.input-card input[type="text"]:focus {
  border-color: rgba(215, 181, 109, 0.8);
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.primary-action {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #191815;
  min-height: 44px;
  font-weight: 800;
  cursor: pointer;
}

.ghost-action {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.primary-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

.library-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.library-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.library-privacy-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.library-stats span {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101315;
  color: var(--muted);
  padding: 8px;
  text-align: center;
  font-size: 12px;
}

.library-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  margin-bottom: 10px;
}

.library-filters input,
.library-filters select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101315;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.library-filters input:focus,
.library-filters select:focus {
  border-color: rgba(215, 181, 109, 0.8);
}

.library-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
}

.library-item {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101315;
  color: var(--text);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.library-item:hover {
  border-color: rgba(215, 181, 109, 0.7);
}

.library-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.library-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-meta {
  color: var(--muted);
  font-size: 12px;
}

.risk-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(238, 106, 95, 0.5);
  border-radius: 999px;
  color: var(--danger);
  padding: 3px 7px;
  font-size: 12px;
}

.risk-pill.medium-risk {
  border-color: rgba(225, 166, 61, 0.5);
  color: var(--warning);
}

.risk-pill.low-risk {
  border-color: rgba(102, 199, 143, 0.5);
  color: var(--good);
}

.hidden {
  display: none !important;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  color: var(--muted);
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 18px rgba(77, 183, 168, 0.8);
}

.pulse.busy {
  background: var(--warning);
  box-shadow: 0 0 18px rgba(225, 166, 61, 0.8);
}

.pulse.error {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(238, 106, 95, 0.8);
}

.score-grid {
  display: grid;
  grid-template-columns: 150px 150px minmax(220px, 1fr);
  gap: 12px;
  margin: 12px 0 16px;
}

.score-card,
.decision-card {
  display: grid;
  gap: 8px;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.score-card span,
.decision-card span {
  color: var(--muted);
  font-size: 13px;
}

.score-card strong {
  font-size: 31px;
  color: var(--accent);
}

.decision-card strong {
  font-size: 18px;
  line-height: 1.35;
}

.intel-map {
  position: relative;
  overflow: hidden;
  height: 180px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #101416;
  background-size: 28px 28px;
}

.radar-ring,
.scan-line,
.node {
  position: absolute;
}

.radar-ring {
  border: 1px solid rgba(77, 183, 168, 0.38);
  border-radius: 999px;
  inset: 50%;
  transform: translate(-50%, -50%);
}

.ring-1 {
  width: 72px;
  height: 72px;
}

.ring-2 {
  width: 136px;
  height: 136px;
}

.ring-3 {
  width: 220px;
  height: 220px;
}

.scan-line {
  left: 50%;
  top: 50%;
  width: 180px;
  height: 2px;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(77, 183, 168, 0.85), transparent);
  animation: sweep 5s linear infinite;
}

.node {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(215, 181, 109, 0.9);
}

.node-a {
  left: 22%;
  top: 38%;
}

.node-b {
  left: 58%;
  top: 24%;
}

.node-c {
  left: 75%;
  top: 66%;
  background: var(--danger);
}

.node-d {
  left: 35%;
  top: 72%;
  background: var(--accent-2);
}

@keyframes sweep {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.result-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111518;
  min-height: 300px;
  padding: 14px;
}

.finding {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.finding:first-child {
  padding-top: 0;
}

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

.finding-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.finding-title strong {
  font-size: 17px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.badge.high {
  color: var(--danger);
  border-color: rgba(238, 106, 95, 0.5);
}

.badge.medium {
  color: var(--warning);
  border-color: rgba(225, 166, 61, 0.5);
}

.finding p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.5;
}

.finding ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #c5cdd2;
}

.text-output {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d9e0e3;
  line-height: 1.55;
  font-size: 14px;
}

.report-paths {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.report-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}

.report-toolbar .ghost-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedback-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101315;
  padding: 10px;
}

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

.feedback-actions span {
  color: var(--muted);
  margin-right: auto;
  font-size: 13px;
}

.feedback-box textarea {
  min-height: 76px;
  resize: vertical;
  font-size: 13px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .report-toolbar {
    grid-template-columns: 1fr;
  }
}

.admin-shell {
  min-height: 100vh;
  padding: 18px;
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 12px;
}

.legal-page {
  width: min(820px, calc(100% - 32px));
  margin: 24px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 31, 0.96);
  padding: 24px;
}

.legal-page h1 {
  margin-bottom: 18px;
}

.legal-page h2 {
  margin: 22px 0 8px;
  font-size: 17px;
}

.legal-page p {
  color: #c5cdd2;
  line-height: 1.7;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.admin-login {
  display: flex;
  gap: 8px;
}

.admin-login input {
  min-width: 280px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101315;
  color: var(--text);
  padding: 0 10px;
}

.admin-login .primary-action {
  padding: 0 18px;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 31, 0.94);
  padding: 14px;
}

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

.admin-table {
  display: grid;
  gap: 1px;
  max-width: 100%;
  overflow-x: auto;
}

.admin-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  background: #111518;
  padding: 9px;
  font-size: 12px;
}

.admin-row-head {
  color: var(--accent);
  font-weight: 700;
}

.admin-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 800px) {
  .admin-header,
  .admin-login {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-login input {
    min-height: 40px;
    min-width: 0;
  }

  .admin-metrics,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

  .admin-row-head {
    display: none;
  }
}
