/* 经销商客诉页：与知客后台同一套令牌（靛蓝强调、石墨中性色）。主题：跟随系统 / 明亮 / 黑暗（html[data-theme]） */
:root {
  color-scheme: light;
  --bg: #f4f4f6; --surface: #ffffff; --surface-2: #f9f9fb; --sidebar: #ececf0; --field: #f1f1f4; --line: #e3e3e8; --line-2: #ececf0;
  --text: #1c1c21; --text-2: #4b4b53; --text-3: #85858d;
  --accent: #4f46e5; --accent-soft: #eeedfd; --accent-ring: rgba(79,70,229,.24); --on-accent: #ffffff; --sel: #ecebfb;
  --ok: #189a58; --ok-soft: #e4f6ec; --warn: #b45309; --warn-soft: #fbf0df; --err: #d64545; --err-soft: #fbe9e9;
  --edge: 0 0 0 1px rgba(20,22,30,.06), 0 1px 2px rgba(20,22,30,.04);
  --seg-edge: 0 1px 2px rgba(0,0,0,.14), 0 0 0 .5px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", "Microsoft YaHei", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a1e; --surface: #232327; --surface-2: #1f1f23; --sidebar: #1f1f23; --field: #2d2d33; --line: #333339; --line-2: #2c2c32;
  --text: #ededf1; --text-2: #b9b9c1; --text-3: #8b8b94;
  --accent: #a5b4fc; --accent-soft: #2b2c47; --accent-ring: rgba(165,180,252,.3); --on-accent: #14142a; --sel: #2b2c47;
  --ok: #6fd99b; --ok-soft: #1d3a2a; --warn: #f2b544; --warn-soft: #3a2f1a; --err: #f28b82; --err-soft: #3e2323;
  --edge: 0 0 0 1px rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.3);
  --seg-edge: 0 1px 2px rgba(0,0,0,.4), 0 0 0 .5px rgba(255,255,255,.1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1a1e; --surface: #232327; --surface-2: #1f1f23; --sidebar: #1f1f23; --field: #2d2d33; --line: #333339; --line-2: #2c2c32;
    --text: #ededf1; --text-2: #b9b9c1; --text-3: #8b8b94;
    --accent: #a5b4fc; --accent-soft: #2b2c47; --accent-ring: rgba(165,180,252,.3); --on-accent: #14142a; --sel: #2b2c47;
    --ok: #6fd99b; --ok-soft: #1d3a2a; --warn: #f2b544; --warn-soft: #3a2f1a; --err: #f28b82; --err-soft: #3e2323;
    --edge: 0 0 0 1px rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.3);
    --seg-edge: 0 1px 2px rgba(0,0,0,.4), 0 0 0 .5px rgba(255,255,255,.1);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }
svg.i { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* 顶栏 */
.top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--surface); box-shadow: var(--edge); z-index: 3; flex: none; }
.brand { display: flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text); }
.brand svg { width: 20px; height: 20px; }
.spacer { flex: 1; }
.who-name { color: var(--text-2); font-size: 13px; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: inline-flex; background: var(--field); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-3); padding: 4px 9px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--seg-edge); }
.btn { font-size: 13px; padding: 6px 13px; border-radius: 8px; border: 0; cursor: pointer; background: var(--surface); color: var(--text); box-shadow: var(--edge);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.quiet { box-shadow: none; background: transparent; color: var(--text-2); }
.btn.quiet:hover { background: var(--field); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.empty { color: var(--text-3); text-align: center; padding: 56px 16px; margin: 0; }

/* 工作台：列表 | 主区（总览表格 / 对话 + 表单 / 新建） */
.shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.shell > .empty { grid-column: 1 / -1; }
.side { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.side-head .btn.primary { justify-content: center; }
.side-head .seg { width: 100%; }
.side-head .seg button { flex: 1; justify-content: center; }
.search { width: 100%; font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; box-shadow: var(--edge); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.all-link { font-size: 12.5px; color: var(--text-2); padding: 6px 10px; border-radius: 8px; display: flex; align-items: center; gap: 6px; }
.all-link[aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: var(--edge); }
.items { overflow-y: auto; flex: 1; padding: 0 8px 12px; }
.it { display: block; color: inherit; padding: 9px 10px 9px 14px; border-radius: 9px; margin-bottom: 2px; position: relative; }
.it:hover { background: var(--surface-2); }
.it[aria-current="true"] { background: var(--surface); box-shadow: var(--edge); }
.it .r1 { display: flex; gap: 6px; align-items: baseline; }
.it .no { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.it .t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it .w { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.it .s { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 2px 0 4px; }
.it .u { position: absolute; left: 4px; top: 16px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.pill { font-size: 11.5px; padding: 0 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; display: inline-block; line-height: 19px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.dim { color: var(--text-3); font-size: 12px; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.main-scroll { overflow: auto; flex: 1; padding: 20px; }
.back { display: none; }

/* 详情：头 + 对话 + 表单侧栏 */
.dhead { flex: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dhead h1 { font-size: 15px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbody { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.convo { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.bub { max-width: min(78%, 640px); background: var(--surface); box-shadow: var(--edge); border-radius: 12px; padding: 9px 12px; align-self: flex-start; }
.bub.me { align-self: flex-end; background: var(--sel); box-shadow: none; }
.bub .h { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.bub .h b { color: var(--text-2); font-weight: 600; }
.bub.tech .h b { color: var(--accent); }
.txt { white-space: pre-wrap; word-break: break-word; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.atts img { max-width: 220px; max-height: 180px; min-width: 60px; min-height: 40px; object-fit: cover; border-radius: 7px; cursor: zoom-in; background: var(--field); }
.atts video { max-width: 100%; max-height: 360px; border-radius: 7px; background: #000; }
.file { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 7px; background: var(--surface-2); box-shadow: var(--edge); font-size: 12.5px; color: var(--text); }
.file.err { color: var(--err); }
.file button { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 15px; padding: 0 2px; }
.compose { flex: none; border-top: 1px solid var(--line); background: var(--surface); padding: 10px 14px; }
.compose textarea { width: 100%; min-height: 64px; max-height: 40vh; resize: vertical; font: inherit; color: var(--text); background: var(--field); border: 1px solid transparent; border-radius: 9px; padding: 8px 10px; display: block; }
.compose textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compose .row { margin-top: 8px; }
.closed-tip { font-size: 12.5px; color: var(--ok); background: var(--ok-soft); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.formside { overflow-y: auto; padding: 16px; background: var(--surface-2); }
.formside h3 { font-size: 11.5px; letter-spacing: .04em; color: var(--text-3); font-weight: 600; margin: 0 0 10px; }
.kv { margin-bottom: 12px; }
.kv .k { font-size: 12px; color: var(--text-3); }
.kv .v { white-space: pre-wrap; word-break: break-word; }
.form-toggle { display: none; }

/* 总览表格（对应后台「工单记录」那种一行一单） */
.overview h1 { font-size: 17px; margin: 0 0 4px; }
.overview .sub { color: var(--text-3); font-size: 12.5px; margin: 0 0 14px; }
.tbl-wrap { background: var(--surface); border-radius: 10px; box-shadow: var(--edge); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 1080px; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.nw { white-space: nowrap; font-variant-numeric: tabular-nums; }
td .clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 280px; }
td.wide .clip { min-width: 140px; }

/* 新建表单 */
.form-card { max-width: 760px; background: var(--surface); border-radius: 12px; box-shadow: var(--edge); padding: 18px 20px; }
.form-card h1 { font-size: 17px; margin: 0 0 14px; }
label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
label .req { color: var(--err); }
.form-card input, .form-card textarea { display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--text); background: var(--field); border: 1px solid transparent; border-radius: 8px; padding: 8px 10px; }
.form-card textarea { min-height: 130px; resize: vertical; }
.form-card input:focus, .form-card textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; cursor: zoom-out; z-index: 10; }
.lightbox img { max-width: 94vw; max-height: 94vh; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 13px; z-index: 20; max-width: calc(100vw - 32px); }
#toast.err { background: var(--err); color: #fff; }

/* 窄屏：表单侧栏收进对话上方的折叠块 */
@media (max-width: 1100px) {
  .dbody { grid-template-columns: minmax(0, 1fr); }
  .dbody > .formside { display: none; }
  .form-toggle { display: block; flex: none; border-bottom: 1px solid var(--line); background: var(--surface-2); }
  .form-toggle summary { cursor: pointer; padding: 8px 18px; font-size: 12.5px; color: var(--text-2); }
  .form-toggle .formside { padding-top: 0; max-height: 40vh; }
}
/* 手机：列表和详情二选一，详情页顶部有返回 */
@media (max-width: 760px) {
  .top { padding: 8px 12px; gap: 6px; }
  .who-name, .seg button span { display: none; }
  .shell { grid-template-columns: 1fr; }
  .shell.detail .side { display: none; }
  .shell:not(.detail) .main { display: none; }
  .side { border-right: 0; }
  .back { display: inline-flex; }
  .msgs { padding: 12px; }
  .bub { max-width: 88%; }
  .main-scroll { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
}
