/* ============================================================
   坤舆自然资源行政执法智能研判系统 — 设计系统
   风格：精致克制（对标 Eagle/Raycast），无渐变、无重投影
   ============================================================ */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --ink: #1a1d21;
  --ink-2: #4b5563;
  --ink-3: #9aa1ab;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #eef3ff;
  --danger: #c0392b;
  --danger-soft: #fdf1ef;
  --danger-line: #e9c7c2;
  --warn: #b45309;
  --warn-soft: #fdf6ec;
  --ok: #15803d;
  --ok-soft: #eef7f0;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 8px 28px rgba(16, 24, 40, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Microsoft YaHei", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 54px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: 0.2px; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.brand .sub { color: var(--ink-3); font-weight: 500; font-size: 12px; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.userchip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px 5px 10px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel); font-size: 12.5px;
}
.userchip .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.navlink { font-size: 13px; color: var(--ink-2); padding: 6px 10px; border-radius: 7px; }
.navlink:hover { background: var(--bg); text-decoration: none; color: var(--ink); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 15px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  user-select: none;
}
.btn:hover { border-color: var(--ink-3); background: #fafafa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #1a45c0; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 28px; padding: 0 11px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; }

/* ---------- 输入 ---------- */
.input, .textarea, select.input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 11px; font-size: 13.5px; color: var(--ink);
  background: var(--panel); font-family: var(--font); outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--ink-3); }

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

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-pop); padding: 34px 32px 28px;
}
.login-logo { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.login-logo .mark { width: 40px; height: 40px; border-radius: 11px; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; }
.login-title { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.login-sub { color: var(--ink-3); font-size: 12.5px; margin: 2px 0 24px; }
.login-error {
  display: none; background: var(--danger-soft); border: 1px solid var(--danger-line);
  color: var(--danger); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}
.login-error.show { display: block; }
.login-foot { margin-top: 18px; text-align: center; color: var(--ink-3); font-size: 12px; }

/* ---------- 研判主页 ---------- */
.app-wrap { max-width: 1360px; margin: 0 auto; padding: 22px; display: grid; grid-template-columns: 420px 1fr; gap: 20px; align-items: start; }
.pane-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; margin-bottom: 10px; }
.pane-title .count { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.license-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid #d6e2ff;
}
.tag.all { background: var(--ok-soft); color: var(--ok); border-color: #cfe8d6; }
.tag.muted { background: var(--bg); color: var(--ink-2); border-color: var(--line); }

/* 结果区 */
.result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.result-head .spacer { flex: 1; }
.result-empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  padding: 70px 30px; text-align: center; color: var(--ink-3);
}
.result-empty .big { font-size: 30px; margin-bottom: 8px; opacity: .6; }
.section { margin-bottom: 16px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 8px;
}
.section-title .idx {
  width: 20px; height: 20px; border-radius: 6px; background: var(--bg);
  border: 1px solid var(--line); color: var(--ink-2); font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}
.risk-box {
  background: var(--danger-soft); border: 1px solid var(--danger-line);
  border-left: 4px solid var(--danger); border-radius: 8px;
  padding: 12px 14px; color: #7a1d14; font-size: 13px; white-space: pre-wrap; line-height: 1.75;
}
.body-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; color: var(--ink); font-size: 13.5px; white-space: pre-wrap; line-height: 1.8;
}
.meta-line { color: var(--ink-3); font-size: 12px; margin-top: 10px; }
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(10px);
  background: #1c2329; color: #fff; padding: 9px 18px; border-radius: 9px; font-size: 13px;
  box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none; transition: all .18s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.blocked-banner {
  background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: var(--radius);
  padding: 14px 16px; color: #7a1d14; font-size: 13.5px; margin-bottom: 16px;
}
.loading { display: none; align-items: center; gap: 9px; color: var(--ink-2); font-size: 13px; padding: 10px 2px; }
.loading.show { display: flex; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: #fafbfc; }
.mono { font-family: var(--mono); font-size: 12px; }
.pill { display: inline-block; font-size: 11.5px; padding: 1px 9px; border-radius: 999px; }
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.off { background: #f2f2f3; color: var(--ink-3); }
.pill.admin { background: #eef2ff; color: #4338ca; }
.pill.county { background: #ecfdf5; color: #047857; }
.pill.land { background: #fff7ed; color: #c2410c; }
.pill.plan { background: #f0f9ff; color: #0369a1; }
.pill.user { background: var(--bg); color: var(--ink-2); }

/* ---------- 管理后台 ---------- */
.admin-wrap { max-width: 1360px; margin: 0 auto; padding: 22px; }
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px 16px; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: .2px; }
.stat .k { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 9px 16px; font-size: 13.5px; font-weight: 550; color: var(--ink-2);
  border-bottom: 2px solid transparent; cursor: pointer; user-select: none;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabpage { display: none; }
.tabpage.active { display: block; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input { width: 220px; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; color: var(--ink-2); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .42); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px;
}
.modal-mask.show { display: flex; }
.modal {
  width: 560px; max-width: 96vw; background: var(--panel); border-radius: 14px;
  box-shadow: var(--shadow-pop); padding: 22px 24px 20px;
}
.modal-title { font-size: 15.5px; font-weight: 700; margin-bottom: 16px; }
.form-row { margin-bottom: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.county-pick { display: flex; flex-wrap: wrap; gap: 7px; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.county-pick .tag { cursor: pointer; }
.county-pick .tag.sel { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- 文书生成 ---------- */
.doc-btn {
  background: var(--accent-soft);
  border: 1px solid #d6e2ff;
  color: var(--accent);
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s ease;
}
.doc-btn:hover { background: var(--accent); color: #fff; }
.doc-modal {
  width: 760px; max-width: 94vw; max-height: 82vh;
  display: flex; flex-direction: column; padding: 0;
}
.doc-modal-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.doc-modal-title { font-size: 15px; font-weight: 700; }
.doc-modal-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}
.doc-content {
  font-size: 13.5px; line-height: 1.9; color: var(--ink);
  white-space: pre-wrap;
}
.doc-content .doc-section-title {
  font-weight: 700; margin-top: 10px;
}

@media (max-width: 1100px) {
  .app-wrap { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== 结构化渲染：案件事实八要素 ===== */
.facts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.fact-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel);
}
.fact-item.fact-missing {
  border-color: #f0c8a0;
  background: #fffaf3;
}
.fact-label {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 4px;
  font-weight: 500;
}
.fact-value {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.5;
  word-break: break-all;
}
.fact-placeholder {
  color: #e67e22;
  font-style: italic;
  font-size: 12.5px;
}
.facts-missing-note {
  font-size: 12.5px;
  color: #e67e22;
  padding: 8px 12px;
  background: #fffaf3;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

/* ===== 结构化渲染：处置方案分栏 ===== */
.plan-block {
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.plan-block-title {
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 14px;
  color: #fff;
}
.plan-compliant .plan-block-title {
  background: #15803d;
}
.plan-noncompliant .plan-block-title {
  background: #c0392b;
}
.plan-other .plan-block-title {
  background: var(--ink-2);
}
.plan-penalty .plan-block-title {
  background: #b45309;
}
.plan-penalty .penalty-content {
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-top: none;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--ink);
  white-space: pre-wrap;
}
.plan-block ul {
  margin: 0;
  padding: 10px 14px 10px 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: none;
}
.plan-block li {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink);
}

/* ===== 原文折叠 ===== */
.raw-toggle {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-3);
}
.raw-toggle summary {
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.raw-toggle summary:hover {
  color: var(--accent);
}
.raw-content {
  margin-top: 8px;
  padding: 10px 14px;
  background: #f9fafb;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-2);
  white-space: pre-wrap;
}

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