:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #1c2430;
  --text-dim: #6b7785;
  --primary: #1a6fd4;
  --primary-dark: #14559f;
  --primary-soft: #eaf2fd;
  --danger: #cf2b32;
  --danger-soft: #fdecec;
  --warn: #c77700;
  --warn-soft: #fff6e5;
  --ok: #14804a;
  --ok-soft: #e8f6ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

/* hidden 属性必须真的隐藏：否则 .modal{display:grid} 之类的规则会盖掉 UA 默认的
   display:none，元素虽然带 hidden 仍然铺满屏幕并拦截点击。 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 500px at 15% -10%, #dfeafb 0%, transparent 55%),
    radial-gradient(900px 480px at 100% 110%, #e6f0fb 0%, transparent 50%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px 28px 22px;
}

.login-brand { text-align: center; margin-bottom: 24px; }

.logo {
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #2f8ee0);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.login-brand h1 { font-size: 17px; margin-bottom: 6px; }
.login-brand p { margin: 0; font-size: 12.5px; color: var(--text-dim); }

.login-step { display: flex; flex-direction: column; gap: 14px; }
.login-step label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; color: var(--text-dim); font-weight: 500;
}

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.verify-hint {
  margin: 0;
  padding: 10px 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 8px;
  font-size: 12.5px;
}

.verify-actions { display: flex; justify-content: space-between; }

.login-error {
  margin: 0; min-height: 18px;
  color: var(--danger); font-size: 12.5px; text-align: center;
}

.login-foot {
  margin: 18px 0 0; padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center; font-size: 11.5px; color: var(--text-dim);
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: #c9d2df; background: #fafbfd; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #f6cdcd; }
.btn-block { width: 100%; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }

.btn-link {
  background: none; border: none; padding: 0;
  color: var(--primary); font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px; flex: 0 0 208px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.side-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 18px 14px;
  font-weight: 600; font-size: 14px;
}

.logo-sm {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), #2f8ee0);
  color: #fff; font-size: 13px;
  display: grid; place-items: center;
}

.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; flex: 1; }

.nav-item {
  text-align: left;
  background: none; border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit; font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #f3f6fa; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

.side-foot {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.user-chip { display: flex; flex-direction: column; }
.user-chip span { font-size: 13px; font-weight: 600; }
.user-chip small { color: var(--text-dim); font-size: 11.5px; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

.page { max-width: 1240px; }
.page-head { margin-bottom: 18px; }
.page-head p { margin: 5px 0 0; color: var(--text-dim); font-size: 13px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; color: var(--text-dim); }
.stat .value { font-size: 22px; font-weight: 650; margin-top: 3px; letter-spacing: -.02em; }
.stat .value small { font-size: 12px; font-weight: 400; color: var(--text-dim); margin-left: 4px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-weight: 600; font-size: 12px; color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fbfcfe;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid #f0f3f7;
  vertical-align: middle;
}

tbody tr:hover { background: #fafbfd; }

td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { max-width: 460px; }
td.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; }

/* 原文片段限高，避免一行撑满半个屏幕 */
.clip {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 460px;
  line-height: 1.7;
}
.clip-5 { -webkit-line-clamp: 5; }
.clip-2 { -webkit-line-clamp: 2; }

.empty {
  padding: 28px; text-align: center;
  color: var(--text-dim); font-size: 13px;
}

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-gray { background: #f0f3f7; color: var(--text-dim); }
.tag-blue { background: var(--primary-soft); color: var(--primary-dark); }
.tag-red { background: var(--danger-soft); color: var(--danger); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------------- 上传 ---------------- */
.upload-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

.dropzone {
  border: 1.5px dashed #cfd8e5;
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  background: #fbfcfe;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dz-title { margin: 0 0 6px; font-size: 13.5px; }
.dz-sub { margin: 0; font-size: 12px; color: var(--text-dim); }
.dropzone .link { color: var(--primary); }

#file-chosen { margin-top: 10px; font-size: 12.5px; color: var(--text-dim); text-align: left; }
#file-chosen div { padding: 3px 0; border-bottom: 1px dashed #eef2f7; }

.upload-meta { display: flex; flex-direction: column; gap: 10px; }
.upload-meta label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--text-dim);
}

.upload-result { margin-top: 12px; font-size: 12.5px; }
.upload-result div { padding: 4px 0; }

/* ---------------- 检索条 ---------------- */
.search-bar { display: flex; gap: 10px; }
.search-bar input { flex: 1; }
.search-bar select { width: 150px; flex: 0 0 auto; }

.search-meta { margin: 10px 0 4px; font-size: 12.5px; color: var(--text-dim); }

.result {
  padding: 13px 0;
  border-bottom: 1px solid #f0f3f7;
}
.result:last-child { border-bottom: none; }
.result-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 5px;
}
.result-title {
  font-weight: 600; font-size: 13.5px;
  color: var(--primary-dark); cursor: pointer;
}
.result-title:hover { text-decoration: underline; }
.result-snippet { font-size: 13px; color: #3a4553; line-height: 1.75; }
.result-snippet mark { background: #fff2a8; padding: 0 1px; border-radius: 2px; }

/* ---------------- 企业画像 ---------------- */
.profile-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.profile-name { font-size: 17px; font-weight: 650; }
.risk-badge {
  padding: 3px 12px; border-radius: 20px;
  font-size: 12.5px; font-weight: 600;
}
.risk-high { background: var(--danger-soft); color: var(--danger); }
.risk-medium { background: var(--warn-soft); color: var(--warn); }
.risk-normal { background: var(--ok-soft); color: var(--ok); }

.finding {
  padding: 11px 0; border-bottom: 1px solid #f0f3f7;
}
.finding:last-child { border-bottom: none; }
.finding-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.finding-rule { font-weight: 600; font-size: 13px; }
.finding-snippet { font-size: 12.5px; color: #55606e; line-height: 1.7; }

/* ---------------- 弹层 ---------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, .42);
  display: grid; place-items: center;
  padding: 24px; z-index: 100;
}
.modal-box {
  background: var(--panel);
  border-radius: 12px;
  width: min(880px, 100%);
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .25);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.modal-close {
  background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--text-dim); cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; font-size: 13px; }

.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 20px; margin-bottom: 16px;
}
.meta-grid div { font-size: 12.5px; }
.meta-grid span { color: var(--text-dim); margin-right: 6px; }

.seg {
  padding: 9px 11px;
  background: #fafbfd;
  border: 1px solid #f0f3f7;
  border-radius: 7px;
  margin-bottom: 8px;
  font-size: 12.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.seg .seg-no { color: var(--text-dim); font-size: 11.5px; margin-bottom: 3px; display: block; }

/* ---------------- 其他 ---------------- */
.filters { display: flex; gap: 8px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 130px; height: 32px; padding: 5px 9px; font-size: 12.5px; }

.pager {
  display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  margin-top: 12px; font-size: 12.5px; color: var(--text-dim);
}

.watch-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px; align-items: end;
}
.watch-form input, .watch-form select { height: 36px; }

.toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%);
  background: #1c2430; color: #fff;
  padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 200;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .28);
  max-width: 80vw;
}
.toast.err { background: var(--danger); }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { padding: 18px 14px 50px; }
  .upload-grid { grid-template-columns: 1fr; }
  .search-bar { flex-wrap: wrap; }
  .search-bar select { width: 100%; }
}
