/* =====================================================================
 * 警情要素识别与智慧处置系统 · 网页版样式
 *
 * 响应式策略：**纯 CSS 媒体查询为主，JS 只做行为差异**。
 *   桌面（≥900px）：左侧固定导航 + 右侧内容区（充分利用横向空间）
 *   手机（<900px）：顶部标题栏 + 底部导航（拇指可达，符合手机习惯）
 *
 * 断点取 900 而不是常见的 768：本应用有表格与双栏表单，
 * 768~899 这个区间用侧栏会把内容挤变形，用底部导航反而更舒服。
 * ===================================================================== */

:root {
  --primary: #1B3A5C;
  --primary-light: #2E5B8A;
  --primary-dark: #102639;
  --gold: #C9A227;
  --gold-light: #E3C55A;
  --gold-dark: #9A7B1A;

  --success: #1E7E45;
  --warning: #D98324;
  --danger: #C0392B;
  --info: #2874A6;

  --bg: #F4F6F9;
  --card: #FFFFFF;
  --border: #D8DEE7;
  --text: #1A2434;
  --text-sub: #64748B;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(16, 38, 57, .07);
  --shadow-lg: 0 8px 28px rgba(16, 38, 57, .13);

  --sidebar-w: 236px;
  --navbar-h: 60px;
  --appbar-h: 54px;

  /* 一次性提示条的实测高度（0 = 还没量出来）。
     ★不写死：手机上地址栏与字号会让它换行成一到两行，
       写死就会造成顶栏与内容错位。由 store.js 实测写入。 */
  --notice-h: 0px;
}

/* ===================== 一次性提示条 =====================
   本页不做任何持久化（见 js/store.js），必须让使用者在录入之前就知道。
   固定在页面最顶端：切到哪个页签、滚到哪里都看得见。 */
.once-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #B3261E, #8A1A15);
  color: #fff; font-size: 12.8px; line-height: 1.45;
  box-shadow: 0 2px 12px rgba(138, 26, 21, .38);
}
.once-bar .oc-ic { font-size: 15px; flex: 0 0 auto; }
.once-bar .oc-tx { flex: 1; min-width: 0; }
.once-bar .oc-tx b { color: #FFE9A8; }
.once-bar .oc-btn {
  flex: 0 0 auto; min-height: 28px; padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .55); border-radius: 7px;
  background: rgba(255, 255, 255, .12); color: #fff;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.once-bar .oc-btn:hover { background: rgba(255, 255, 255, .22); }

/* ★「立即清空」按自己的类名隐藏，不复用 .desk-only。
   复用的话有两个毛病：.desk-only 在窄屏下只在 .appbar 内部被隐藏，
   提示条里这个按钮会漏出来；而且自适应验证会取 .desk-only 的
   计算样式，取到的是这个按钮而不是顶栏那块，判据被带偏
   （实测就是这么报的「桌面专用元素隐藏」失败）。 */
@media (max-width: 899px) {
  .once-bar .oc-wipe { display: none; }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.62;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }

/* ===================== 应用骨架 ===================== */

#app { display: flex; min-height: 100vh; }

/* ---------- 侧栏（桌面） ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: var(--notice-h) auto 0 0;   /* 顶部让位给一次性提示条 */
  z-index: 30;
}

.brand {
  padding: 20px 18px 18px;
  background: linear-gradient(140deg, var(--primary), var(--primary-dark));
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 11px;
}
.brand .shield {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  box-shadow: 0 3px 12px rgba(201,162,39,.36);
}
.brand .t { color: #fff; font-size: 13.5px; font-weight: 700; line-height: 1.32; }
.brand .s { color: #8FA8C0; font-size: 10.5px; margin-top: 3px; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 13px; margin: 3px 0; border-radius: 9px;
  color: #B6C9DB; font-size: 13.8px; cursor: pointer;
  border: 0; background: transparent; width: 100%; text-align: left;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.on { background: rgba(255,255,255,.11); color: #fff; font-weight: 600; }
.nav-item.on::after {
  content: ''; margin-left: auto; width: 3.5px; height: 16px;
  border-radius: 2px; background: var(--gold);
}
.nav-item .i { font-size: 16px; width: 20px; text-align: center; }

.side-foot {
  margin: 10px 12px 14px; padding: 12px;
  background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px; font-size: 11.5px; color: #8FA8C0;
}
.side-foot .k { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.side-foot .v { color: #fff; font-weight: 600; font-size: 12.5px; word-break: break-all; }

/* ---------- 主区 ---------- */
.main {
  flex: 1; min-width: 0; margin-left: var(--sidebar-w);
  padding-top: var(--notice-h);   /* 顶部让位给一次性提示条 */
  display: flex; flex-direction: column;
}

.appbar {
  height: var(--appbar-h); flex: 0 0 var(--appbar-h);
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  position: sticky; top: var(--notice-h); z-index: 20;
}
.appbar h1 { font-size: 15.5px; font-weight: 700; }
.appbar .sub { font-size: 11.5px; color: var(--text-sub); }
.appbar .spacer { flex: 1; }

.content { flex: 1; padding: 20px; max-width: 1180px; width: 100%; }

/* ---------- 底部导航（手机） ---------- */
.tabbar { display: none; }

/* ===================== 通用组件 ===================== */

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card > h2 {
  font-size: 15px; font-weight: 700; color: var(--primary);
  margin-bottom: 13px; display: flex; align-items: center; gap: 8px;
}
.card > h2::before {
  content: ''; width: 3px; height: 15px; border-radius: 2px; background: var(--gold);
}
.card .hint { font-size: 12.5px; color: var(--text-sub); margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 20px; border-radius: var(--radius-sm);
  border: 0; cursor: pointer; font-size: 14.5px; font-weight: 600;
  background: var(--primary); color: #fff; transition: filter .14s, transform .1s;
}
.btn:hover { filter: brightness(1.09); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--primary); border: 1.2px solid var(--primary); }
.btn.gold { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.danger { background: var(--danger); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .tip { font-size: 11.5px; color: var(--text-sub); margin-top: 5px; line-height: 1.5; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 12px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,58,92,.1);
}
textarea { min-height: 150px; resize: vertical; line-height: 1.65; font-size: 14px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

.msg {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px;
  margin: 12px 0; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.msg.ok { background: rgba(30,126,69,.07); border: 1px solid rgba(30,126,69,.3); color: var(--success); }
.msg.err { background: rgba(192,57,43,.06); border: 1px solid rgba(192,57,43,.3); color: var(--danger); }
.msg.info { background: rgba(40,116,166,.06); border: 1px solid rgba(40,116,166,.28); color: var(--info); }
.msg.warn { background: #FFF8E6; border: 1px solid #F0DCA0; color: #7A5A10; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-size: 12px; padding: 5px 11px; border-radius: 16px;
  background: #EDF2F7; color: var(--primary);
}
.chip.gold { background: rgba(201,162,39,.13); color: var(--gold-dark); font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 700;
}
.badge.r1 { background: rgba(192,57,43,.1); color: var(--danger); border: 1px solid rgba(192,57,43,.32); }
.badge.r2 { background: rgba(217,131,36,.11); color: var(--warning); border: 1px solid rgba(217,131,36,.34); }
.badge.r3 { background: rgba(30,126,69,.09); color: var(--success); border: 1px solid rgba(30,126,69,.3); }

.kv { display: grid; grid-template-columns: 116px 1fr; gap: 9px 14px; font-size: 14px; }
.kv dt { color: var(--text-sub); font-size: 13px; }
.kv dd { word-break: break-word; }

.cite {
  border-left: 3px solid var(--gold); padding: 9px 0 9px 12px;
  margin: 9px 0; background: rgba(201,162,39,.045); border-radius: 0 8px 8px 0;
}
.cite .h { font-size: 12.5px; font-weight: 700; color: var(--gold-dark); }
.cite .b { font-size: 13px; margin-top: 5px; line-height: 1.62; }
.cite .f { font-size: 11.5px; color: var(--text-sub); margin-top: 4px; }

.point { margin-bottom: 16px; }
.point .t { font-size: 14.5px; }
.point .n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; margin-right: 8px;
  background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 700;
  vertical-align: 2px;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 15px; cursor: pointer; transition: border-color .14s, box-shadow .14s;
}
.item:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.item .top { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; flex-wrap: wrap; }
.item .no { font-weight: 700; font-size: 14px; }
.item .meta { font-size: 12px; color: var(--text-sub); }
.item .sum { font-size: 13px; color: #334155; line-height: 1.55; }

.loading { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-sub); }
.spin {
  width: 18px; height: 18px; border: 2.4px solid rgba(27,58,92,.18);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 34px 16px; color: var(--text-sub); font-size: 13.5px; }
.empty .ic { font-size: 34px; opacity: .35; display: block; margin-bottom: 9px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #F8FAFC; font-weight: 600; font-size: 12.5px; color: var(--text-sub); }

details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 10px; }
summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
details[open] summary { margin-bottom: 10px; }

.hidden { display: none !important; }

/* 下载区 */
.dl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dl-box {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  text-align: center; background: #fff; transition: box-shadow .15s;
}
.dl-box:hover { box-shadow: var(--shadow-lg); }
.dl-box .ic { font-size: 34px; margin-bottom: 8px; }
.dl-box .n { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.dl-box .d { font-size: 12.5px; color: var(--text-sub); margin-bottom: 13px; line-height: 1.55; }

/* 彩蛋徽章 */
.cheer {
  background: linear-gradient(135deg, #FFF9E6, #FDF0C8);
  border: 1.5px solid var(--gold); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 15px;
  animation: pop .42s cubic-bezier(.2,1.3,.5,1);
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cheer .medal {
  width: 54px; height: 54px; flex: 0 0 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; box-shadow: 0 4px 14px rgba(201,162,39,.42);
}
.cheer .medal .num { font-size: 17px; font-weight: 800; line-height: 1; }
.cheer .medal .lb { font-size: 8.5px; opacity: .9; margin-top: 1px; }
.cheer .tx .t { font-weight: 800; font-size: 15px; color: var(--gold-dark); }
.cheer .tx .m { font-size: 13px; color: #7A5A10; margin-top: 3px; }

/* ===================== 知识库管理 ===================== */

/* 统计条：库规模 + 我的改动。手机上自动换行成两排。 */
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  flex: 1 1 74px; min-width: 74px; text-align: center;
  padding: 10px 6px; border-radius: var(--radius-sm);
  background: rgba(27,58,92,.045); border: 1px solid rgba(27,58,92,.12);
}
.stat .v { font-size: 16px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat .k { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

/* 标签栏（法律清单 / 新增 / AI 建议 / 改动历史）。
   手机上一排挤不下，允许横向滚动 —— 与 Flutter 版的可滚动 TabBar 一致。 */
.tabs {
  display: flex; gap: 8px; margin-bottom: 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.tabs .chip {
  flex: 0 0 auto; cursor: pointer; border: 1px solid transparent;
  background: #EDF2F7; font-weight: 600;
}
.tabs .chip.on {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

.chip.green  { background: rgba(30,126,69,.1);  color: var(--success); font-weight: 600; }
.chip.red    { background: rgba(192,57,43,.09); color: var(--danger);  font-weight: 600; }
.chip.orange { background: rgba(217,131,36,.12); color: var(--warning); font-weight: 600; }

.spacer { flex: 1; }

/* 被弃用的文字：划掉 + 变灰，一眼可辨但仍可读 */
.dep { text-decoration: line-through; color: var(--text-sub); }

/* 已撤销的历史条目：整条淡化 */
.kb-art.off { opacity: .55; }

/* 法律清单条目 */
.kb-law {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 9px;
  cursor: pointer; transition: border-color .14s, box-shadow .14s;
}
.kb-law:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.kb-law .h {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 14px; font-weight: 700; color: var(--text);
}
.kb-law .m { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.kb-law .f { font-size: 11.5px; color: var(--text-sub); margin-top: 5px; word-break: break-all; }

/* 条文条目 */
.kb-art {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 9px;
}
.kb-art .h {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 13px; font-weight: 700; color: var(--primary);
}
.kb-art .b { font-size: 13px; line-height: 1.66; margin-top: 6px; color: var(--text); }
.kb-art .f { font-size: 11.5px; color: var(--text-sub); margin-top: 4px; word-break: break-all; }

/* 必填星号 */
.req { color: var(--danger); }

/* ===================== 更新日志 ===================== */

.log-head {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}
.log-head .row > div { flex: 0 0 auto; width: auto; }
.log-k { font-size: 12px; color: #9FB6CC; }
.log-v {
  font-size: 30px; font-weight: 800; color: #fff;
  letter-spacing: .5px; line-height: 1.15; margin-top: 2px;
}
.log-scheme {
  margin-top: 14px; padding: 12px;
  background: rgba(255,255,255,.08); border-radius: 10px;
  font-size: 12px; color: #C3D3E2; line-height: 1.7;
}
.log-scheme b { color: #fff; }
.log-d { margin-top: 4px; }

.log-item { margin-bottom: 12px; }
.log-top {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 9px;
}
.log-tag {
  padding: 3px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 800;
}
.log-kind { font-size: 11.5px; }
.log-date { font-size: 11.5px; color: var(--text-sub); }
.log-title {
  font-size: 14.5px; font-weight: 700; color: var(--primary);
  margin-bottom: 8px;
}
.log-list { margin: 0; padding-left: 20px; }
.log-list li {
  font-size: 13px; line-height: 1.68; margin-bottom: 5px; color: var(--text);
}


/* ===================== 手机端适配（<900px） ===================== */

@media (max-width: 899px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }

  /* 顶栏改为深色 AppBar（手机上更像原生应用） */
  .appbar {
    background: var(--primary); border-bottom: 0;
    height: var(--appbar-h); padding: 0 14px;
    position: fixed; top: var(--notice-h); left: 0; right: 0;
    box-shadow: 0 1px 8px rgba(16,38,57,.2);
  }
  .appbar h1 { color: #fff; font-size: 16px; text-align: center; flex: 1; }
  .appbar .sub { display: none; }
  .appbar .spacer { display: none; }
  .appbar .mob-only { display: inline-flex !important; }
  .appbar .desk-only { display: none !important; }

  .content {
    padding: 12px 12px calc(var(--navbar-h) + 18px);
    /* 手机端顶栏是 fixed，内容要靠 margin 让位：提示条 + 顶栏 */
    margin-top: calc(var(--notice-h) + var(--appbar-h));
  }

  /* 底部导航：拇指可达区 */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0;
    height: var(--navbar-h); background: #fff; z-index: 40;
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 10px rgba(16,38,57,.07);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tabbar button {
    flex: 1; border: 0; background: transparent; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--text-sub); font-size: 10.5px; padding: 6px 0;
  }
  .tabbar button .i { font-size: 20px; line-height: 1; }
  .tabbar button.on { color: var(--primary); font-weight: 700; }
  .tabbar button.on .i { transform: translateY(-1px); }

  .card { padding: 15px; border-radius: 13px; }
  .dl-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 84px 1fr; font-size: 13.5px; }
  .content { max-width: none; }

  /* 手机上表格容易溢出，允许横向滚动 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* 桌面端隐藏手机专用元素 */
@media (min-width: 900px) {
  .mob-only { display: none !important; }
}

/* 打印（分析结果可直接打印归档） */
@media print {
  .sidebar, .tabbar, .appbar, .btn, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; font-size: 12pt; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
}
