:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e3e6ea; --line2: #eef0f3; --text: #1d232b; --muted: #6b7480; --faint: #9aa2ad;
  --accent: #d9480f; --accent-bg: #fff1ea; --blue: #2563eb; --hover: #f1f4f8; --sel: #fff6f1;
  --shadow: 0 8px 30px rgba(15, 23, 42, .14);
  --s-open: #64748b; --s-confirmed: #7c3aed; --s-doing: #2563eb; --s-testing: #c2410c; --s-done: #15803d; --s-rejected: #b91c1c; --s-cannot: #78716c;
  --p0: #dc2626; --p1: #ea580c; --p2: #ca8a04; --p3: #94a3b8;
  --res-bg: #f0fdf4; --res-line: #bbf7d0; --warn-bg: #fef2f2; --warn-line: #fecaca;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --panel: #181c21; --line: #2a3038; --line2: #222830; --text: #e6e9ed; --muted: #9aa3ae; --faint: #6b7480;
    --accent: #ff7a45; --accent-bg: #3a2119; --blue: #6ea0ff; --hover: #1f252c; --sel: #2a201b;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    --s-open: #94a3b8; --s-confirmed: #a78bfa; --s-doing: #6ea0ff; --s-testing: #fb923c; --s-done: #4ade80; --s-rejected: #f87171; --s-cannot: #a8a29e;
    --res-bg: #10241a; --res-line: #1e4d33; --warn-bg: #2b1616; --warn-line: #5b2525;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 12.5px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
svg.i { width: 14px; height: 14px; flex: none; vertical-align: -2px; }

/* 按钮 / 输入 */
.btn { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--s-rejected); }
.btn.sm { height: 22px; padding: 0 7px; font-size: 11.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.inp, select.inp, textarea.inp { height: 26px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); outline: none; min-width: 0; }
textarea.inp { height: auto; padding: 6px 8px; resize: vertical; line-height: 1.5; width: 100%; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
label.f > .inp { color: var(--text); font-size: 12.5px; }

/* 顶栏 */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.logbtn { font-weight: 600; }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; margin-right: 6px; }
.brand svg { color: var(--accent); width: 17px; height: 17px; }
.top .grow { flex: 1; }
.search { width: 220px; }
.user-btn { display: flex; align-items: center; gap: 6px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 11px; flex: none; }
.role-tag { font-size: 10px; padding: 0 5px; border-radius: 8px; background: var(--accent); color: #fff; }

/* 筛选栏 */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chips { display: flex; gap: 3px; flex-wrap: wrap; }
.chip { height: 22px; padding: 0 8px; border-radius: 11px; border: 1px solid var(--line); background: transparent; font-size: 11.5px; display: inline-flex; align-items: center; gap: 4px; }
.chip b { font-weight: 600; color: var(--muted); }
.chip.on { background: var(--text); color: var(--panel); border-color: var(--text); }
.chip.on b { color: inherit; opacity: .75; }
.bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
.bar select.inp { height: 24px; font-size: 11.5px; }

/* 主体 */
.main { display: flex; height: calc(100vh - 42px - var(--barh, 40px)); }
.list { flex: 1; min-width: 0; overflow: auto; }
.detail { width: 48%; max-width: 760px; min-width: 420px; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; }
.detail:empty { display: none; }
@media (min-width: 861px) and (max-width: 1280px) {
  .detail { position: fixed; right: 0; top: calc(42px + var(--barh, 40px)); bottom: 0; z-index: 15; width: min(560px, 70vw); min-width: 0; box-shadow: var(--shadow); }
}
.empty { padding: 40px; text-align: center; color: var(--faint); }

table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
.t th { position: sticky; top: 0; z-index: 2; background: var(--panel); text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.t th.s { cursor: pointer; } .t th.s:hover { color: var(--text); }
.t th .arr { color: var(--accent); }
.t td { padding: 5px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; white-space: nowrap; }
.t tr.row { cursor: pointer; }
.t tr.row:hover td { background: var(--hover); }
.t tr.row.sel td { background: var(--sel); }
.t td.ttl { white-space: normal; min-width: 220px; }
.ttl .tt { font-weight: 500; }
.ttl .pv { color: var(--faint); font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.mod { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 4px; background: var(--hover); color: var(--muted); margin-right: 4px; vertical-align: 1px; }
.cc { color: var(--faint); font-size: 11px; margin-left: 4px; }
.date { color: var(--muted); font-size: 11.5px; }

.st { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; color: var(--c); }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.st.open { --c: var(--s-open); } .st.confirmed { --c: var(--s-confirmed); } .st.doing { --c: var(--s-doing); } .st.testing { --c: var(--s-testing); }
.st.done { --c: var(--s-done); } .st.rejected { --c: var(--s-rejected); } .st.cannot { --c: var(--s-cannot); }
.pr { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 5px; border-radius: 4px; color: #fff; background: var(--c); }
.pr.p0 { --c: var(--p0); } .pr.p1 { --c: var(--p1); } .pr.p2 { --c: var(--p2); } .pr.p3 { --c: var(--p3); }
.kind { font-size: 11px; color: var(--muted); }
.kind.feature { color: var(--blue); }

/* 手机卡片 */
.cards { display: none; }
.card { background: var(--panel); border-bottom: 1px solid var(--line2); padding: 8px 12px; cursor: pointer; }
.card:active { background: var(--hover); }
.card .l1 { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.card .l2 { font-weight: 500; margin: 2px 0; font-size: 13px; }
.card .l3 { display: flex; gap: 8px; font-size: 11px; color: var(--faint); flex-wrap: wrap; }

/* 详情 */
.d-head { position: sticky; top: 0; z-index: 3; background: var(--panel); padding: 9px 14px 8px; border-bottom: 1px solid var(--line); }
.d-head .l1 { display: flex; align-items: center; gap: 8px; }
.d-head .code { font-weight: 700; color: var(--accent); }
.d-head h2 { margin: 4px 0 0; font-size: 15px; line-height: 1.35; font-weight: 650; word-break: break-word; }
.d-body { padding: 10px 14px 30px; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line2); }
.meta .k { font-size: 11px; color: var(--faint); }
.meta .v { display: flex; align-items: center; min-height: 24px; }
.meta select.inp { height: 24px; width: 100%; font-size: 12px; }
.sec { margin-top: 14px; }
.sec h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: none; }
.sec h3 .grow { flex: 1; }
.desc { white-space: pre-wrap; word-break: break-word; line-height: 1.6; font-size: 13px; }
.res { border: 1px solid var(--res-line); background: var(--res-bg); border-radius: 8px; padding: 8px 10px; }
.res.need { border-color: var(--warn-line); background: var(--warn-bg); }
.res .txt { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.6; }
.res .by { font-size: 11px; color: var(--muted); margin-top: 4px; }
.hint { font-size: 11.5px; color: var(--s-rejected); margin: 4px 0; }

.tl { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl li { position: relative; padding: 0 0 8px 16px; border-left: 1px solid var(--line); margin-left: 4px; }
.tl li:last-child { border-left-color: transparent; }
.tl li::before { content: ""; position: absolute; left: -4.5px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--panel); border: 2px solid var(--c, var(--faint)); }
.tl .when { font-size: 11px; color: var(--faint); }
.tl .what { font-size: 12px; }
.tl .what b { font-weight: 600; }
.tl .q { font-size: 11.5px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 6px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }

.cm { padding: 7px 0; border-bottom: 1px solid var(--line2); }
.cm .h { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.cm .h b { font-weight: 600; }
.cm .h .x { margin-left: auto; opacity: 0; }
.cm:hover .h .x { opacity: 1; }
.cm .b { white-space: pre-wrap; word-break: break-word; margin: 3px 0 0 28px; font-size: 13px; line-height: 1.55; }
.cm-new { display: flex; gap: 6px; align-items: flex-end; margin-top: 8px; }

/* 弹层 */
.mask { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .35); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; overflow: auto; }
.modal { background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); width: 100%; max-width: 560px; }
.modal.wide { max-width: 980px; }
.modal .mh { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 13.5px; }
.modal .mh .grow { flex: 1; }
.modal .mb { padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line); }
.row2 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.err { color: var(--s-rejected); font-size: 12px; min-height: 0; }

/* 操作记录抽屉（左上角） */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: min(520px, 100vw); background: var(--panel); box-shadow: var(--shadow); display: flex; flex-direction: column; transform: translateX(-102%); transition: transform .18s ease; }
.drawer.on { transform: none; }
.drawer .dh { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.drawer .dh .ttl { font-weight: 650; font-size: 13.5px; margin-right: auto; }
.drawer .dl { flex: 1; overflow: auto; padding: 0 10px 20px; }
.ev-day { position: sticky; top: 0; background: var(--panel); font-size: 11px; font-weight: 650; color: var(--muted); padding: 8px 0 4px; border-bottom: 1px solid var(--line2); }
.ev { display: grid; grid-template-columns: 58px 1fr; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--line2); }
.ev .tm { color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ev .tx b { font-weight: 600; }
.ev .tx .code { color: var(--accent); cursor: pointer; font-weight: 600; }
.ev .q { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: pre-wrap; word-break: break-word; }
.ev .dt { font-size: 11px; color: var(--muted); }
.drawer-mask { position: fixed; inset: 0; z-index: 39; background: rgba(15, 23, 42, .2); display: none; }
.drawer-mask.on { display: block; }

/* 菜单 */
.menu { position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; min-width: 170px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 7px; padding: 6px 8px; border: 0; background: none; border-radius: 5px; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu .mi { padding: 6px 8px 8px; border-bottom: 1px solid var(--line2); margin-bottom: 4px; font-size: 11.5px; color: var(--muted); }

/* 管理员用户表 */
.ut td, .ut th { white-space: nowrap; }
.pw { display: inline-flex; align-items: center; gap: 4px; }
.pw code { font-size: 12px; background: var(--hover); padding: 0 5px; border-radius: 4px; }

/* 登录 */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .box { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.auth h1 { margin: 0 0 4px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.auth h1 svg { color: var(--accent); width: 22px; height: 22px; }
.auth .tabs { display: flex; gap: 4px; background: var(--hover); padding: 3px; border-radius: 7px; }
.auth .tabs button { flex: 1; border: 0; background: none; height: 26px; border-radius: 5px; }
.auth .tabs button.on { background: var(--panel); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.auth .inp { height: 32px; font-size: 13px; }
.auth .btn.primary { height: 32px; justify-content: center; font-size: 13px; }
.note { font-size: 11.5px; color: var(--muted); background: var(--accent-bg); padding: 6px 8px; border-radius: 6px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: var(--text); color: var(--panel); padding: 7px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 12.5px; }
#toast div.bad { background: var(--s-rejected); color: #fff; }

.only-m { display: none; }

/* Junma logo */
.logo { height: 18px; width: auto; display: block; }
.brand { gap: 8px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 4px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.auth-brand .logo { height: 34px; }

/* two-column form row */
.row2.two { grid-template-columns: 1fr 1.6fr; }

/* module picker */
.combo { position: relative; display: flex; }
.combo > .inp { flex: 1; padding-right: 26px; width: 100%; }
.combo-btn { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 24px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 0 6px 6px 0; }
.combo-btn:hover { background: var(--hover); }
.combo-list { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 70; max-height: 220px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); padding: 3px; }
.combo-list.on { display: block; }
.combo-list .opt { padding: 5px 8px; border-radius: 5px; cursor: pointer; color: var(--text); font-size: 12.5px; }
.combo-list .opt:hover, .combo-list .opt.hi { background: var(--hover); }

/* module preset chips (admin) */
.mod-edit { display: flex; flex-wrap: wrap; gap: 5px; min-height: 26px; align-items: center; }
.mchip { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 3px 0 9px; border-radius: 12px; background: var(--hover); border: 1px solid var(--line); font-size: 12px; }
.mchip button { border: 0; background: none; color: var(--muted); width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; padding: 0; }
.mchip button:hover { background: var(--line); color: var(--text); }
.mchip svg.i { width: 11px; height: 11px; }

/* main admin: floating eye (bottom-left) + "User view" pill */
.eye-fab { position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 26; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: grid; place-items: center; box-shadow: var(--shadow); padding: 0; }
.eye-fab:hover { color: var(--text); }
.eye-fab svg.i { width: 19px; height: 19px; }
.eye-fab.is-user { background: var(--blue); border-color: var(--blue); color: #fff; }
.view-pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 12px; border: 0; background: var(--blue); color: #fff; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.menu button svg.i { color: var(--muted); }

/* 手机 */
@media (max-width: 860px) {
  .only-d { display: none !important; }
  .only-m { display: inline-flex; }
  .top { padding: 0 8px; gap: 6px; }
  .search { width: auto; flex: 1; }
  .top .grow { display: none; }
  .bar { flex-wrap: nowrap; overflow-x: auto; padding: 6px 8px; scrollbar-width: none; }
  .bar::-webkit-scrollbar { display: none; }
  .chips { flex-wrap: nowrap; }
  .chip, .bar select.inp, .bar .btn { flex: none; }
  .main { display: block; height: auto; }
  .list { overflow: visible; }
  table.t { display: none; }
  .cards { display: block; padding-bottom: 70px; }
  .detail { position: fixed; inset: 0; z-index: 30; width: auto; max-width: none; min-width: 0; border: 0; }
  .detail:empty { display: none; }
  .row2 { grid-template-columns: 1fr 1fr; }
  .meta { grid-template-columns: 1fr 1fr; }
  .fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 25; width: 48px; height: 48px; border-radius: 50%; padding: 0; justify-content: center; box-shadow: var(--shadow); }
  .fab svg { width: 22px; height: 22px; }
  .mask { padding: 0; align-items: stretch; }
  .modal { border-radius: 0; max-width: none; min-height: 100%; display: flex; flex-direction: column; }
  .modal .mb { flex: 1; }
  .cm .h .x { opacity: 1; }
  .inp, select.inp, textarea.inp { font-size: 16px; }   /* iOS 不自动放大 */
  .bar select.inp { font-size: 12px; }
}
