/* ===========================================================
   食品安全自查与整改闭环系统 · 前端样式
   风格对齐「添饭网络中台」：苹果毛玻璃 + 彩色 mesh 背景 + 圆角 app-icon
   =========================================================== */

:root {
  --blue: #0071E3;
  --blue-d: #0059b3;
  --green: #34C759;
  --orange: #FF9F0A;
  --red: #FF3B30;
  --purple: #AF52DE;
  --teal: #30B0C7;

  --ink: #1d1d1f;
  --ink2: #424245;
  --ink3: #6e6e73;
  --line: rgba(0, 0, 0, .08);
  --line2: rgba(0, 0, 0, .05);

  --card: rgba(255, 255, 255, .72);
  --card-solid: #fff;
  --glass: rgba(255, 255, 255, .55);
  --shadow: 0 2px 10px rgba(0, 0, 0, .05), 0 12px 32px rgba(0, 0, 0, .06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .09), 0 24px 60px rgba(0, 0, 0, .10);
  --r: 16px;
  --r-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #eef2f8;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.6;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- mesh 背景 ---------- */
.bg-mesh { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-mesh .blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55; }
.blob.b1 { width: 640px; height: 640px; background: #7FB2FF; top: -220px; left: -160px; }
.blob.b2 { width: 560px; height: 560px; background: #FFC8A8; top: -180px; right: -140px; }
.blob.b3 { width: 620px; height: 620px; background: #B9F0D0; bottom: -260px; left: 32%; }

/* ---------- 布局 ---------- */
.layout { position: relative; z-index: 1; display: flex; height: 100%; }
/* ⚠️ 必须显式补这条：.layout 的 display:flex 优先级高于 UA 的 [hidden]{display:none}，
 *    不补的话 showLogin() 设了 hidden=true 侧栏照样显示 —— 登录页左上角漏出半截界面。 */
.layout[hidden] { display: none; }

.sidebar {
  width: 244px; flex: 0 0 244px;
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px;
  background: linear-gradient(150deg, #34C759, #30D158);
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(52, 199, 89, .34);
}
.brand-logo svg { width: 22px; height: 22px; }
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--ink3); margin-top: 1px; }

.side-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  font-size: 11px; color: var(--ink3); font-weight: 600;
  padding: 14px 10px 6px; letter-spacing: .04em;
}
.side-nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px;
  border: 0; border-radius: 10px;
  background: transparent; cursor: pointer;
  color: var(--ink2); text-align: left;
  transition: background .14s, color .14s;
}
.side-nav button:hover { background: rgba(0, 0, 0, .045); }
.side-nav button.active { background: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 3px 10px rgba(0, 113, 227, .3); }
.app-ico {
  width: 22px; height: 22px; flex: 0 0 22px;
  border-radius: 6px; display: grid; place-items: center;
}
.app-ico svg { width: 14px; height: 14px; display: block; }

.side-foot { padding: 10px 8px 4px; border-top: 1px solid var(--line2); }
.side-stat { font-size: 11px; color: var(--ink3); margin-bottom: 8px; line-height: 1.5; }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 26px 14px;
  flex: 0 0 auto;
}
.topbar-t { flex: 1; min-width: 0; }
.topbar h1 { font-size: 22px; }
.topbar .muted { font-size: 12.5px; color: var(--ink3); margin-top: 3px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.view { flex: 1; overflow-y: auto; padding: 6px 26px 34px; }
.loading, .empty { padding: 46px 10px; text-align: center; color: var(--ink3); font-size: 13px; }
.muted { color: var(--ink3); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h3 { font-size: 14.5px; }
.card-h .sp { flex: 1; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* 指标卡 */
.kpi { display: flex; align-items: center; gap: 12px; }
.kpi-ico {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px;
  display: grid; place-items: center; color: #fff;
}
.kpi-ico svg { width: 21px; height: 21px; }
.kpi-n { font-size: 24px; font-weight: 680; line-height: 1.15; letter-spacing: -.02em; }
.kpi-l { font-size: 12px; color: var(--ink3); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--ink3); font-size: 11.5px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line2); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: rgba(0, 0, 0, .022); }
.td-actions { white-space: nowrap; text-align: right; }
.td-actions .btn { margin-left: 6px; }
.cell-main { font-weight: 550; }
.cell-sub { font-size: 11.5px; color: var(--ink3); margin-top: 2px; }

/* ---------- 徽标 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.7;
  white-space: nowrap;
}
.tag.lv-A { background: rgba(255, 59, 48, .12); color: #C8271D; }
.tag.lv-B { background: rgba(255, 159, 10, .15); color: #A86300; }
.tag.lv-C { background: rgba(0, 113, 227, .11); color: #0060C0; }
.tag.lv-D { background: rgba(110, 110, 115, .12); color: #5A5A5F; }
.tag.st-issued { background: rgba(0, 113, 227, .11); color: #0060C0; }
.tag.st-signed { background: rgba(48, 176, 199, .14); color: #1B7F90; }
.tag.st-rectifying { background: rgba(255, 159, 10, .16); color: #A86300; }
.tag.st-reviewing { background: rgba(175, 82, 222, .13); color: #7C2BA6; }
.tag.st-closed { background: rgba(52, 199, 89, .14); color: #1E8A3C; }
.tag.st-escalated { background: rgba(255, 59, 48, .13); color: #C8271D; }
.tag.gray { background: rgba(110, 110, 115, .12); color: #5A5A5F; }
.tag.red { background: rgba(255, 59, 48, .12); color: #C8271D; }
.tag.green { background: rgba(52, 199, 89, .14); color: #1E8A3C; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 13px; border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card-solid); color: var(--ink);
  cursor: pointer; font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: filter .14s, background .14s, transform .06s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(0, 113, 227, .28); }
.btn.primary:hover { background: var(--blue-d); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: rgba(255, 255, 255, .6); }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn.lg { padding: 9px 20px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card-solid); cursor: pointer; display: grid; place-items: center; font-size: 14px;
}
.only-mobile { display: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink2); margin-bottom: 5px; }
.field .hint { font-size: 11px; color: var(--ink3); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: rgba(255, 255, 255, .85);
  outline: none; transition: border-color .14s, box-shadow .14s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, .13); }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.6; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { width: auto; min-width: 130px; }
.filters select.input { min-width: 108px; }

/* ---------- 检查项填报 ---------- */
.grp { margin-bottom: 16px; }
.grp-h {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 650; color: var(--ink);
  padding: 8px 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.grp-h .muted { font-weight: 400; font-size: 11.5px; }
.ci { padding: 10px 0; border-bottom: 1px dashed var(--line2); }
.ci:last-child { border-bottom: 0; }
.ci-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ci-code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; font-weight: 700;
  color: var(--ink2); background: rgba(0, 0, 0, .05); padding: 1px 6px; border-radius: 5px;
}
.ci-name { font-weight: 550; font-size: 13px; }
.ci-std { font-size: 12px; color: var(--ink3); margin-top: 4px; line-height: 1.55; }
.ci-basis { font-size: 11px; color: var(--ink3); margin-top: 2px; }
.ci-acts { margin-left: auto; display: flex; gap: 5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: var(--card-solid); padding: 3px 11px; font-size: 12px; cursor: pointer; color: var(--ink2);
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on.pass { background: var(--green); color: #fff; font-weight: 600; }
.seg button.on.fail { background: var(--red); color: #fff; font-weight: 600; }
.seg button.on.na { background: var(--ink3); color: #fff; font-weight: 600; }
.ci-detail { margin-top: 9px; padding: 11px 12px; background: rgba(255, 59, 48, .045); border-radius: 10px; border: 1px solid rgba(255, 59, 48, .16); }
.ci-detail.na-box { background: rgba(110, 110, 115, .05); border-color: var(--line); }

/* ---------- 进度条 ---------- */
.bar { height: 6px; border-radius: 999px; background: rgba(0, 0, 0, .07); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width .4s; }
.bar > i.warn { background: var(--orange); }
.bar > i.bad { background: var(--red); }

/* ---------- 时间线 ---------- */
.tl { position: relative; padding-left: 20px; }
.tl::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-i { position: relative; padding: 0 0 14px; }
.tl-i::before {
  content: ''; position: absolute; left: -18px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, .16);
}
.tl-i.done::before { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 199, 89, .18); }
.tl-i.cur::before { background: var(--orange); box-shadow: 0 0 0 3px rgba(255, 159, 10, .22); }
.tl-t { font-size: 13px; font-weight: 600; }
.tl-m { font-size: 11.5px; color: var(--ink3); margin-top: 2px; }
.tl-d { font-size: 12.5px; color: var(--ink2); margin-top: 4px; line-height: 1.6; }

/* ---------- 步骤条 ---------- */
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.step {
  flex: 1; min-width: 74px; text-align: center;
  padding: 7px 6px; border-radius: 9px;
  background: rgba(0, 0, 0, .04); font-size: 11.5px; color: var(--ink3);
}
.step.on { background: var(--blue); color: #fff; font-weight: 600; }
.step.done { background: rgba(52, 199, 89, .16); color: #1E8A3C; font-weight: 600; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .34);
  backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
}
/* 同理：display:grid 也会盖掉 [hidden]，弹层关闭时会留下一层灰蒙版。 */
.mask[hidden] { display: none; }
.modal {
  width: min(680px, 100%); max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--card-solid); border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal.wide { width: min(940px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line2); }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 9px 14px; border-radius: 11px;
  background: rgba(29, 29, 31, .93); color: #fff;
  font-size: 13px; box-shadow: var(--shadow-lg);
  max-width: 380px; animation: tin .22s ease-out;
  backdrop-filter: blur(10px);
}
.toast.ok { background: rgba(31, 138, 60, .95); }
.toast.err { background: rgba(200, 39, 29, .95); }
.toast.warn { background: rgba(168, 99, 0, .95); }
@keyframes tin { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

/* ---------- 说明条 ---------- */
.notice-bar {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 13px; border-radius: 11px; margin-bottom: 12px;
  background: rgba(0, 113, 227, .07); border: 1px solid rgba(0, 113, 227, .18);
  font-size: 12.5px; color: #00508F; line-height: 1.6;
}
.notice-bar.warn { background: rgba(255, 159, 10, .09); border-color: rgba(255, 159, 10, .26); color: #8A5200; }
/* danger：硬边界提示（AI 不得直接触发整改单等），比 warn 更重一档 */
.notice-bar.danger {
  background: rgba(255, 45, 85, .08); border-color: rgba(255, 45, 85, .28); color: #A8001E;
  /* 标题较长，横排会和正文挤在一行读不下去 —— 竖排让边界声明独立成段 */
  flex-direction: column; gap: 3px;
}
.notice-bar b { font-weight: 650; }

.scrim { display: none; }

/* ---------- 登录页 ---------- */
.login-wrap {
  position: relative; z-index: 2;
  min-height: 100%;
  display: grid; place-items: center;
  padding: 28px 18px;
}
.login-wrap[hidden] { display: none; }
.login-card {
  width: min(400px, 100%);
  background: var(--card-solid);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 24px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-logo { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; }
.login-brand .brand-logo svg { width: 25px; height: 25px; }
.login-name { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.login-sub { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.login-err {
  padding: 9px 12px; border-radius: 10px; margin-bottom: 14px;
  background: rgba(255, 59, 48, .09); border: 1px solid rgba(255, 59, 48, .2);
  color: #C8271D; font-size: 12.5px; line-height: 1.55;
}
.login-err[hidden] { display: none; }
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 14px; color: var(--ink3); font-size: 11.5px;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.login-alt[hidden] { display: none; }
.login-foot {
  margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line2);
  font-size: 11.5px; color: var(--ink3); text-align: center;
}

/* 侧栏账号区 */
.who { display: flex; align-items: center; gap: 5px; margin-bottom: 8px; flex-wrap: wrap; }
.who-n {
  font-size: 12px; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform .24s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .3); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.on { opacity: 1; pointer-events: auto; }
  .only-mobile { display: grid; }
  .view, .topbar { padding-left: 16px; padding-right: 16px; }
  .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}


/* ============================================================
   [hidden] 全局兜底（放最后：优先级最高）
   ============================================================
   踩过的坑：.layout{display:flex} / .mask{display:grid} / .btn{display:inline-block}
   都比浏览器默认的 [hidden]{display:none} 优先级高，于是 el.hidden = true
   完全没效果 —— 表现为「登录页漏出侧栏」「弹层关了还有灰蒙版」「操作人藏不掉」。
   逐个 class 补 [hidden] 规则总会漏（已经漏过 3 次），这里一次性兜住。 */
[hidden] { display: none !important; }
