:root {
  --ink: #26302d;
  --muted: #76807d;
  --line: #dfe8e3;
  --paper: #fbfdf9;
  --soft: #eef8f1;
  --green: #79bd22;
  --deep: #27815f;
  --teal: #43b8c8;
  --gray-logo: #858789;
  --red: #b93838;
  --amber: #a56a22;
  --blue: #2876a8;
  --white: #ffffff;
  font-family: "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(121, 189, 34, 0.16), transparent 34vw),
    linear-gradient(160deg, #fbfdf9 0%, #f0f8f2 48%, #f7fbf8 100%);
}
button, input, textarea, select { font: inherit; }
button, .link-button, .file-button {
  border: 0;
  background: linear-gradient(135deg, var(--deep), var(--green));
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:disabled { opacity: 0.62; cursor: wait; }
button.secondary, .secondary {
  background: #edf6ee;
  color: var(--deep);
  border: 1px solid #cfe4d5;
}
button.accent { background: linear-gradient(135deg, var(--blue), var(--teal)); }
.icon-button {
  background: white;
  color: var(--deep);
  border: 1px solid var(--line);
  padding: 8px 12px;
  min-height: 38px;
}
.mini-button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 6px;
}
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 420px;
}
.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8vw;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.86), rgba(240,249,243,0.74)),
    url("https://images.unsplash.com/photo-1570172619644-dfd03ed5d881?auto=format&fit=crop&w=1600&q=80") center/cover;
}
.login-brand img {
  width: min(176px, 38vw);
  margin-bottom: 28px;
  filter: drop-shadow(0 14px 24px rgba(39, 129, 95, 0.16));
}
.login-brand h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1.08;
  margin: 0 0 16px;
  letter-spacing: 0;
}
.login-brand p { max-width: 520px; font-size: 20px; line-height: 1.7; color: #52605b; }
.login-box {
  background: rgba(255,255,255,0.96);
  padding: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  border-left: 1px solid var(--line);
}
.form-logo { width: 188px; margin-bottom: 10px; }
label { display: grid; gap: 8px; color: var(--muted); font-weight: 800; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 12px;
  min-height: 44px;
}
textarea { resize: vertical; line-height: 1.7; min-height: 150px; }
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--red); min-height: 20px; }

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 18px 96px;
}
.mobile-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  background: rgba(251, 253, 249, 0.92);
  backdrop-filter: blur(12px);
}
.mobile-header img { width: 156px; height: auto; }
.identity-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, rgba(255,255,255,0.94), rgba(237,247,239,0.94));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 8px 0 14px;
  box-shadow: 0 12px 36px rgba(38, 48, 45, 0.06);
}
.identity-strip span { color: var(--muted); font-size: 13px; }
.identity-strip strong { display: block; margin-top: 2px; font-size: 18px; }
#auditStatus {
  color: var(--deep);
  font-weight: 800;
  text-align: right;
}
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.tabs button {
  background: white;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 78px;
}
.tabs button.active {
  color: white;
  background: linear-gradient(135deg, var(--deep), var(--green));
  border-color: transparent;
}

.audit-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
  gap: 14px;
  align-items: start;
}
.phone-card, .form-card, .table-card {
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 12px 34px rgba(38, 48, 45, 0.05);
}
.input-card { grid-row: span 2; }
#sourceText { min-height: 430px; font-size: 16px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
h2, h3 { margin: 0; font-size: 18px; }
.risk-dashboard {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  background: linear-gradient(135deg, #eaf8ed, #f7fcf8);
  border: 1px solid #d6eadb;
  border-radius: 10px;
  padding: 16px;
}
.risk-result span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
#riskLevel {
  font-size: 28px;
  color: var(--deep);
}
.risk-counts {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 8px;
  align-content: center;
}
.risk-counts span {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
}
.highlight-box {
  min-height: 150px;
  max-height: 280px;
  overflow: auto;
  line-height: 1.8;
  background: #fcfdfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
}
mark {
  border-radius: 5px;
  padding: 1px 4px;
  color: #111;
}
mark.high { background: #ffdada; }
mark.medium { background: #ffe9c2; }
mark.low { background: #d7eff4; }
.finding-list {
  display: grid;
  gap: 10px;
  max-height: 290px;
  overflow: auto;
  margin-top: 10px;
}
.finding-item {
  border-left: 4px solid var(--amber);
  background: #fffaf0;
  border-radius: 8px;
  padding: 10px;
}
.finding-item.high { border-color: var(--red); background: #fff3f3; }
.finding-item.low { border-color: var(--teal); background: #f2fbfc; }
.finding-item strong { display: block; }
.finding-item p { margin: 6px 0 0; color: var(--muted); }
.rewrite-card textarea { min-height: 180px; }
.bottom-actions {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  z-index: 30;
  background: rgba(255,255,255,0.86);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 18px 42px rgba(38, 48, 45, 0.18);
  backdrop-filter: blur(14px);
}

.admin-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.file-button input { display: none; }
.management-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}
.form-card { display: grid; gap: 14px; align-content: start; }
.table-card.full { width: 100%; }
.table-wrap { overflow: auto; max-height: 620px; border-radius: 8px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; background: white; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 12px 10px; vertical-align: top; }
th { color: var(--muted); background: #f4faf5; position: sticky; top: 0; }
.audit-console {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.log-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 12px 34px rgba(38, 48, 45, 0.05);
}
.filter-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  grid-column: 1 / -1;
}
.log-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.log-stats div {
  background: linear-gradient(135deg, #ffffff, #f0f8f2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.log-stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.log-stats strong {
  font-size: 26px;
  color: var(--deep);
}
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pager span {
  color: var(--muted);
  min-width: 110px;
  text-align: center;
}
.detail-dialog {
  width: min(860px, calc(100% - 24px));
  max-height: 86vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(38, 48, 45, 0.28);
}
.detail-dialog::backdrop { background: rgba(20, 32, 27, 0.42); }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid var(--line);
}
.detail-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}
.detail-body h3 { margin-top: 4px; }
.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
.detail-meta div {
  background: #f7fbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.detail-meta dt {
  color: var(--muted);
  font-size: 12px;
}
.detail-meta dd {
  margin: 4px 0 0;
  font-weight: 800;
}
.detail-findings {
  display: grid;
  gap: 8px;
}
.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 80;
  max-width: min(360px, calc(100% - 28px));
  padding: 13px 16px;
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 18px 46px rgba(38, 48, 45, 0.18);
  transform: translateY(-12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  font-weight: 800;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.success {
  border-color: #bfe2c7;
  background: #f1fbf3;
  color: var(--deep);
}
.toast.error {
  border-color: #f0c4c4;
  background: #fff5f5;
  color: var(--red);
}
pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: #fbfdfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.7;
}

@media (max-width: 860px) {
  body { background: #f7fbf8; }
  .login-view { grid-template-columns: 1fr; }
  .login-brand {
    min-height: 38vh;
    padding: 38px 24px 24px;
    align-items: center;
    text-align: center;
  }
  .login-brand img { width: 132px; margin-bottom: 18px; }
  .login-brand h1 { font-size: 32px; }
  .login-brand p { font-size: 15px; margin: 0; }
  .login-box {
    border-left: 0;
    padding: 24px;
    justify-content: flex-start;
  }
  .form-logo { display: none; }
  .workspace { padding: 10px 12px 104px; }
  .mobile-header img { width: 132px; }
  .identity-strip {
    align-items: flex-start;
    flex-direction: column;
  }
  #auditStatus { text-align: left; }
  .audit-panel, .management-grid { grid-template-columns: 1fr; }
  .input-card { grid-row: auto; }
  #sourceText { min-height: 260px; }
  .risk-dashboard { grid-template-columns: 1fr; }
  .risk-counts { grid-template-columns: repeat(3, 1fr); }
  .risk-counts span { text-align: center; }
  .section-head { align-items: flex-start; }
  .admin-tools { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-tools .file-button { grid-column: span 2; }
  .log-filters { grid-template-columns: 1fr; }
  .filter-actions { grid-template-columns: 1fr; }
  .log-stats { grid-template-columns: repeat(2, 1fr); }
  .pager {
    width: 100%;
    justify-content: space-between;
  }
  .detail-meta { grid-template-columns: 1fr; }
  .toast {
    top: auto;
    right: 14px;
    bottom: 92px;
    left: 14px;
    max-width: none;
  }
  th, td { min-width: 110px; }
}
