:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #1b2430;
  --muted: #6b7785;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --green: #12864a;
  --green-soft: #e8f6ee;
  --red: #d13b3b;
  --red-soft: #fdecec;
  --amber: #b7791f;
  --amber-soft: #fdf5e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------------- 顶部导航 ---------------- */
.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  margin-right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff; font-size: 13px; display: grid; place-items: center; font-weight: 700;
}
.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav a {
  padding: 7px 13px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { background: #f2f4f7; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.userbox b { color: var(--text); font-weight: 600; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}

/* ---------------- 通用 ---------------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
}
.card-b { padding: 16px 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid { display: grid; gap: 14px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }

.btn {
  height: 36px; padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { background: #f7f9fc; border-color: #cfd8e3; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(.94); }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { filter: brightness(.94); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f2f4f7; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }

.input, .select, .textarea {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
  width: 100%;
  transition: .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }
label.field { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  background: #f1f3f7; color: var(--muted);
}
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }

table.tb { width: 100%; border-collapse: collapse; }
table.tb th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfd;
  position: sticky; top: 0;
}
table.tb td { padding: 9px 10px; border-bottom: 1px solid #f1f4f8; }
table.tb tr:hover td { background: #fafcff; }
.num { font-variant-numeric: tabular-nums; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------------- 登录页 ---------------- */
.login-page {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(900px 500px at 15% 0%, #e8efff 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, #e9f6f0 0%, transparent 55%),
    #f4f6f9;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 16px; padding: 34px 30px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .1);
  border: 1px solid #eef1f6;
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-foot { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--muted); line-height: 1.8; }
.err { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 8px;
  font-size: 13px; margin-bottom: 14px; }

/* ---------------- 工作台 ---------------- */
.work-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  gap: 14px;
  padding: 14px;
  height: calc(100vh - 56px);
}
.stage {
  background: #eef1f5;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.stage-tools {
  height: 40px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  background: #fff; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.stage-body {
  flex: 1; overflow: hidden; position: relative;
  display: grid; place-items: center;
  cursor: grab;
}
.stage-body:active { cursor: grabbing; }
.stage-body img {
  max-width: 100%; max-height: 100%;
  user-select: none; -webkit-user-drag: none;
  transform-origin: center center;
  transition: transform .06s linear;
  box-shadow: 0 2px 14px rgba(0,0,0,.12);
  background: #fff;
}
.stage-empty { color: #8b96a5; text-align: center; padding: 30px; }

.panel { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.panel-scroll { overflow-y: auto; }

.meta-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.lines { display: flex; flex-direction: column; gap: 8px; }
.line-item {
  display: flex; gap: 6px; align-items: flex-start;
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; padding: 6px;
}
.line-item .idx {
  width: 22px; height: 26px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.line-item textarea {
  flex: 1; border: none; background: transparent; outline: none;
  resize: none; min-height: 26px; line-height: 1.55; padding: 3px 2px;
  font-size: 14px;
}
.line-item .acts { display: flex; flex-direction: column; gap: 2px; }
.icon-btn {
  width: 24px; height: 20px; border: none; background: transparent;
  color: #9aa5b1; cursor: pointer; border-radius: 4px; font-size: 13px; line-height: 1;
}
.icon-btn:hover { background: #eef1f5; color: var(--red); }

.stat-strip {
  display: flex; gap: 0;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #fbfcfe;
}
.stat-strip > div { flex: 1; padding: 7px 10px; text-align: center; border-right: 1px solid var(--line); }
.stat-strip > div:last-child { border-right: none; }
.stat-strip .k { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.stat-strip .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.flag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.flag {
  height: 30px; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--muted);
}
.flag:hover { border-color: #cfd8e3; }
.flag.on { background: var(--red-soft); border-color: #f3b7b7; color: var(--red); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #1b2430; color: #fff; padding: 10px 18px; border-radius: 9px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

kbd {
  background: #f1f3f7; border: 1px solid #dfe5ec; border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; font-size: 11px; font-family: inherit; color: #4a5563;
}

/* ---------------- 看板 ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .k { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 3px; }

.bar { height: 8px; border-radius: 4px; background: #eef1f5; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar > i.g { background: var(--green); }
.bar > i.a { background: #e0a83a; }
.bar > i.r { background: var(--red); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.chart-bars .cb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.chart-bars .cb > i {
  width: 100%; max-width: 34px; background: linear-gradient(180deg, #60a5fa, #2563eb);
  border-radius: 5px 5px 0 0; min-height: 2px;
}
.chart-bars .cb span { font-size: 10px; color: var(--muted); white-space: nowrap; transform: scale(.92); }
.chart-bars .cb b { font-size: 11px; font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  padding: 9px 14px; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

.dropzone {
  border: 2px dashed #cbd5e1; border-radius: 12px; padding: 26px;
  text-align: center; color: var(--muted); background: #fafbfd; cursor: pointer;
  transition: .15s;
}
.dropzone.hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.progress { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); transition: width .2s; }

pre.code {
  background: #0f172a; color: #cbd5e1; padding: 12px; border-radius: 8px;
  font-size: 12px; overflow: auto; line-height: 1.6; margin: 0;
}
.hide { display: none !important; }

@media (max-width: 1080px) {
  .work-shell { grid-template-columns: 1fr; height: auto; }
  .stage { height: 55vh; }
}

/* ---------------- 图片库 ---------------- */
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.img-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.img-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(37, 99, 235, .14);
  transform: translateY(-1px);
}
.img-card .ph {
  height: 118px;
  background: #f6f8fc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.img-card .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-card .meta { padding: 7px 9px 9px; }
.img-card .nm {
  font-size: 12px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-card .sub {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.img-empty { padding: 70px 0; text-align: center; color: var(--muted); line-height: 1.9; }
.img-viewer {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(10, 16, 26, .88);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px; padding: 24px; cursor: zoom-out;
}
.img-viewer img { max-width: 92vw; max-height: 82vh; object-fit: contain; border-radius: 6px; }
.img-viewer-cap { color: #dfe7f3; font-size: 13px; text-align: center; word-break: break-all; }
