/* 电脑端后台 · 支付宝 / Ant Design 风格 */
:root {
  --ali: #1677ff;
  --ali-hover: #4096ff;
  --ali-bg: #e6f4ff;
  --text: rgba(0, 0, 0, 0.88);
  --text2: rgba(0, 0, 0, 0.65);
  --text3: rgba(0, 0, 0, 0.45);
  --border: #f0f0f0;
  --border2: #d9d9d9;
  --bg: #f5f5f5;
  --sidebar-w: 220px;
  --header-h: 56px;
  --danger: #ff4d4f;
  --warn: #faad14;
  --ok: #52c41a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ali); text-decoration: none; }
a:hover { color: var(--ali-hover); }
button, input, select, textarea { font: inherit; color: inherit; }

.desk-login {
  min-height: 100vh;
  display: flex;
  background: #f5f5f5;
}
.desk-login-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 80px;
  background: linear-gradient(160deg, #1677ff 0%, #69b1ff 100%);
  color: #fff;
}
.desk-login-brand h1 {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.desk-login-brand p { font-size: 16px; opacity: 0.9; line-height: 1.7; max-width: 380px; }
.desk-login-panel {
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: #fff;
}
.desk-login-box { width: 100%; max-width: 360px; }
.desk-login-box h2 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.desk-login-box .sub { color: var(--text3); margin-bottom: 28px; }

.desk-shell { min-height: 100vh; display: flex; }
.desk-side {
  width: var(--sidebar-w);
  background: #001529;
  color: rgba(255, 255, 255, 0.65);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.desk-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.desk-logo .mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--ali); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.desk-menu { padding: 12px 0; flex: 1; }
.desk-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 24px;
  color: rgba(255, 255, 255, 0.65);
  transition: all 0.2s;
}
.desk-menu a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.desk-menu a.active { color: #fff; background: var(--ali); }

.desk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.desk-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.desk-header .crumb { font-size: 16px; font-weight: 500; }
.desk-header .right { display: flex; align-items: center; gap: 16px; color: var(--text2); }
.header-valid {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12px; line-height: 1.3;
  background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d;
  white-space: nowrap; max-width: min(42vw, 360px);
}
.header-valid .hv-label {
  font-weight: 600; opacity: 0.85;
}
.header-valid .hv-date { color: inherit; }
.header-valid .hv-days {
  font-weight: 600;
  padding-left: 8px; margin-left: 2px;
  border-left: 1px solid rgba(0,0,0,.12);
}
.header-valid.warn {
  background: #fffbe6; border-color: #ffe58f; color: #ad6800;
}
.header-valid.danger {
  background: #fff2f0; border-color: #ffccc7; color: #cf1322;
}
.header-valid.ok .hv-days { color: #1677ff; }
.header-valid.warn .hv-days { color: #d48806; }
.header-valid.danger .hv-days { color: #cf1322; }
.desk-body { flex: 1; padding: 24px; overflow: auto; }
.desk-section { display: none; }
.desk-section.active { display: block; }

.desk-alert {
  padding: 10px 16px; border-radius: 6px; margin-bottom: 16px;
  background: #fffbe6; border: 1px solid #ffe58f; color: #ad6800;
}
.desk-alert.danger { background: #fff2f0; border-color: #ffccc7; color: #cf1322; }
.desk-alert.hide { display: none; }

.desk-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1200px) { .desk-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .desk-stats { grid-template-columns: repeat(2, 1fr); } }

.desk-stat {
  background: #fff; border-radius: 8px; padding: 20px 24px;
  border: 1px solid var(--border);
}
.desk-stat .label { color: var(--text3); margin-bottom: 8px; }
.desk-stat .num {
  font-size: 28px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.desk-stat .num.blue { color: var(--ali); }

.desk-card {
  background: #fff; border-radius: 8px;
  border: 1px solid var(--border); margin-bottom: 16px;
}
.desk-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.desk-card-head h3 { font-size: 16px; font-weight: 600; }
.desk-card-head .tools { display: flex; align-items: center; gap: 8px; }
.desk-card-body { padding: 24px; }
.desk-card-body.tight { padding: 0; }

.desk-dual { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .desk-dual { grid-template-columns: 1fr; } }

.desk-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.desk-form-grid .full { grid-column: 1 / -1; }
.desk-field label { display: block; margin-bottom: 8px; color: var(--text2); }
.desk-field input,
.desk-field select,
.desk-field textarea {
  width: 100%; height: 36px; padding: 4px 11px;
  border: 1px solid var(--border2); border-radius: 6px;
  background: #fff; outline: none; transition: all 0.2s;
}
.desk-field textarea { height: auto; min-height: 80px; padding: 8px 11px; }
.desk-field input:hover, .desk-field select:hover { border-color: var(--ali-hover); }
.desk-field input:focus, .desk-field select:focus, .desk-field textarea:focus {
  border-color: var(--ali);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.d-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 15px; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer;
  font-size: 14px; transition: all 0.2s; background: #fff; color: var(--text);
  white-space: nowrap;
}
.d-btn:hover { color: var(--ali-hover); border-color: var(--ali-hover); }
.d-btn.primary { background: var(--ali); border-color: var(--ali); color: #fff; }
.d-btn.primary:hover { background: var(--ali-hover); border-color: var(--ali-hover); color: #fff; }
.d-btn.ghost { border-color: var(--border2); }
.d-btn.ghost:hover { color: var(--ali); border-color: var(--ali); }
.d-btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.d-btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.d-btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.d-btn.link { border: 0; background: transparent; color: var(--ali); height: auto; padding: 0 4px; }
.d-btn.link.danger { color: var(--danger); }

.desk-table-wrap { overflow: auto; }
.desk-table { width: 100%; border-collapse: collapse; }
.desk-table th {
  background: #fafafa; color: var(--text2); font-weight: 500;
  text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.desk-table td {
  padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.desk-table tr:hover td { background: #fafafa; }
.desk-table .sub { color: var(--text3); font-size: 12px; margin-top: 2px; }
.desk-table .ops { display: flex; flex-wrap: wrap; gap: 4px 8px; }

.tag {
  display: inline-block; padding: 0 8px; height: 22px; line-height: 20px;
  font-size: 12px; border-radius: 4px; border: 1px solid transparent;
}
.tag.blue { color: var(--ali); background: var(--ali-bg); border-color: #91caff; }
.tag.green { color: #389e0d; background: #f6ffed; border-color: #b7eb8f; }
.tag.orange { color: #d46b08; background: #fff7e6; border-color: #ffd591; }
.tag.red { color: #cf1322; background: #fff1f0; border-color: #ffa39e; }
.tag.gray { color: var(--text3); background: #fafafa; border-color: #d9d9d9; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar-row .name { width: 48px; color: var(--text3); }
.bar-row .track { flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--ali); border-radius: 4px; }
.bar-row .val { width: 40px; text-align: right; color: var(--text3); }

.empty-tip { text-align: center; color: var(--text3); padding: 40px 16px; }
.hint { color: var(--text3); font-size: 13px; line-height: 1.7; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; top: 72px;
  transform: translateX(-50%) translateY(-6px);
  display: none; align-items: center; gap: 8px;
  min-width: 160px; max-width: min(90vw, 420px);
  padding: 12px 18px 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1.45;
  z-index: 999;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none;
}
.toast.show {
  display: flex;
  animation: deskToastIn .28s cubic-bezier(.22, 1, .36, 1) forwards;
}
.toast.toast-out {
  display: flex;
  animation: deskToastOut .2s ease forwards;
}
.toast-ico {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.toast-ico::before { content: "i"; }
.toast-msg { flex: 1; word-break: break-word; }
.toast-info .toast-ico { background: var(--ali); }
.toast-ok .toast-ico { background: var(--ok); }
.toast-ok .toast-ico::before { content: "✓"; font-size: 13px; }
.toast-warn .toast-ico { background: var(--warn); }
.toast-warn .toast-ico::before { content: "!"; }
.toast-error .toast-ico { background: var(--danger); }
.toast-error .toast-ico::before { content: "×"; font-size: 15px; line-height: 1; }
@keyframes deskToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes deskToastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

.confirm-mask {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.confirm-mask.show { display: flex; }
.confirm-box {
  width: 100%; max-width: 400px; background: #fff;
  border-radius: 12px; overflow: hidden; text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  animation: deskPopIn .24s cubic-bezier(.22, 1, .36, 1);
}
@keyframes deskPopIn {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.confirm-ico {
  width: 48px; height: 48px; margin: 28px auto 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
}
.confirm-ico::before { content: "?"; }
.confirm-ico.info { background: linear-gradient(145deg, #4096ff, var(--ali)); }
.confirm-ico.danger { background: linear-gradient(145deg, #ff7875, var(--danger)); }
.confirm-ico.danger::before { content: "!"; }
.confirm-box .ct { padding: 14px 28px 24px; }
.confirm-box .ct h4 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.confirm-box .ct p { font-size: 14px; color: var(--text2); line-height: 1.6; }
.confirm-box .ft { display: flex; gap: 12px; padding: 0 20px 20px; justify-content: flex-end; }
.confirm-box .ft button {
  min-width: 88px; height: 36px; padding: 0 16px; border: 0; border-radius: 8px;
  font-size: 14px; cursor: pointer;
}
.confirm-box .ft .cancel { background: #f5f5f5; color: var(--text2); }
.confirm-box .ft .cancel:hover { background: #ebebeb; }
.confirm-box .ft .ok { background: var(--ali); color: #fff; font-weight: 500; }
.confirm-box .ft .ok:hover { background: var(--ali-hover); }
.confirm-box .ft .ok.danger { background: var(--danger); }
.confirm-box .ft .ok.danger:hover { background: #d9363e; }

.desk-modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45); display: none;
  align-items: center; justify-content: center; padding: 24px;
}
.desk-modal-mask.show { display: flex; }
.desk-modal {
  width: 100%; max-width: 640px; max-height: 90vh;
  background: #fff; border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.desk-modal.wide { max-width: 760px; }
.desk-table tr.clickable { cursor: pointer; }
.desk-table tr.clickable:hover td { background: rgba(22, 119, 255, 0.04); }
.ai-detail-meta { color: rgba(0,0,0,.45); font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.ai-detail-block { margin-bottom: 16px; }
.ai-detail-block h4 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: rgba(0,0,0,.65); }
.ai-detail-block pre {
  margin: 0; padding: 12px 14px; background: #f7f8fa; border-radius: 8px;
  white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 14px; line-height: 1.65;
}
@media (max-width: 900px) {
  #aiCaseChatModal .desk-modal-body > div[style*="grid-template-columns"] {
    display: block !important;
  }
  #aiCasePreviewWrap { margin-top: 12px; max-height: 360px !important; }
}
.desk-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.desk-modal-head h3 { font-size: 16px; font-weight: 600; }
.desk-modal-body { padding: 16px 20px; overflow: auto; flex: 1; }
.desk-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border);
}
.desk-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.desk-toolbar .grow { flex: 1; min-width: 160px; }
.desk-toolbar input, .desk-toolbar select {
  height: 32px; border: 1px solid var(--border2); border-radius: 6px;
  padding: 0 10px; background: #fff;
}
.desk-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border); color: var(--text3); font-size: 13px;
}
.desk-pager .pager-actions { display: flex; gap: 8px; }
.desk-thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--border); background: #fafafa; display: block;
}
.desk-thumb.lg {
  width: 100%; max-width: 280px; height: auto; max-height: 180px;
  object-fit: contain; margin-top: 8px;
}
.desk-cell-title { font-weight: 500; color: var(--text); }
.company-name {
  cursor: text;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  display: inline-block;
  max-width: 100%;
}
.company-name:hover {
  background: #e6f4ff;
  outline: 1px dashed #91caff;
}
.company-name-input {
  width: 100%; max-width: 240px; height: 32px;
  padding: 0 10px; border: 1px solid var(--ali);
  border-radius: 6px; outline: none;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
  font-size: 14px; font-weight: 500;
}
.desk-ops-col { min-width: 140px; }
.desk-table td.ops-cell .ops { justify-content: flex-start; }
.desk-preview-box {
  margin-top: 8px; padding: 10px 12px; background: #f7f8fa;
  border: 1px dashed var(--border2); border-radius: 8px; font-size: 13px; color: var(--text3);
}

/* 公司后台 · 图片/资料全屏预览 */
.admin-viewer {
  position: fixed; inset: 0; z-index: 320;
  display: none; flex-direction: column;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: adminViewerIn 0.18s ease;
}
.admin-viewer.show { display: flex; }
@keyframes adminViewerIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.admin-viewer-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-shrink: 0;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(0,0,0,.35), transparent);
}
.admin-viewer-title {
  min-width: 0; flex: 1;
  color: #fff; font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.admin-viewer-close {
  flex-shrink: 0;
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.14);
  color: #fff; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.admin-viewer-close:hover {
  background: #fff; color: #1677ff;
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.admin-viewer-close:active { transform: scale(0.96); }
.admin-viewer-stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 28px 8px;
  cursor: zoom-out;
}
.admin-viewer-stage img {
  max-width: min(1100px, 100%);
  max-height: calc(100vh - 120px);
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
  background: #0b1220;
  user-select: none; -webkit-user-drag: none;
  cursor: default;
  animation: adminImgIn .22s ease;
}
@keyframes adminImgIn {
  from { opacity: 0; transform: scale(.97); }
  to { opacity: 1; transform: scale(1); }
}
.admin-viewer-hint {
  flex-shrink: 0;
  text-align: center;
  padding: 0 16px 18px;
  color: rgba(255,255,255,.55);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.media-picker { margin-top: 4px; }
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px; margin-bottom: 10px;
}
.media-item {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: #f7f8fa; cursor: grab;
  user-select: none;
}
.media-item.dragging { opacity: 0.45; }
.media-item img {
  width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in;
}
.media-item .file-tile {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; color: var(--text3); padding: 6px; text-align: center;
}
.media-item .ord {
  position: absolute; left: 4px; top: 4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 9px;
  font-size: 11px; line-height: 18px; text-align: center;
}
.media-item .rm {
  position: absolute; right: 2px; top: 2px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 14px; line-height: 20px;
}
.media-item .rm:hover { background: #cf1322; }
.media-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.media-add-btn { cursor: pointer; margin: 0; }
.upload-progress {
  position: fixed; right: 20px; bottom: 20px; z-index: 400;
  width: 280px; background: #fff; border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 12px 14px;
  border: 1px solid var(--border);
}
.upload-progress-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 13px; font-weight: 500;
}
.upload-progress-track {
  height: 6px; background: #f0f0f0; border-radius: 3px; overflow: hidden;
}
.upload-progress-fill {
  height: 100%; width: 0; background: var(--ali); transition: width .15s linear;
}
.upload-progress-meta { margin-top: 6px; font-size: 12px; color: var(--text3); }
.desk-ai-status {
  display: inline-flex; flex-direction: column; gap: 2px; align-items: flex-start;
}
.desk-header select.desk-select {
  height: 32px; padding: 0 8px; border: 1px solid var(--border2);
  border-radius: 6px; background: #fff;
}

@media (max-width: 768px) {
  .desk-login-brand { display: none; }
  .desk-login-panel { width: 100%; }
  .desk-form-grid { grid-template-columns: 1fr; }
}
