/* 批作阅稿 · 管理控制台样式（独立服务，无框架无构建） */
:root {
  --blue: #2563eb;
  --blue-700: #1d4ed8;
  --blue-50: #eff4ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5eaf2;
  --bg: #f5f7fb;
  --card: #ffffff;
  --green: #16a34a;
  --green-bg: #e9f9ef;
  --red: #dc2626;
  --red-bg: #fdecec;
  --amber: #b45309;
  --amber-bg: #fef4e6;
  --gray-bg: #f1f4f9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
h1 { font-size: 20px; letter-spacing: .2px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
small { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(900px 420px at 15% -10%, #e3ecff 0%, transparent 60%),
    radial-gradient(700px 360px at 100% 0%, #eef3ff 0%, transparent 55%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 30px 28px 26px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand b { font-size: 17px; }
.login-brand small { display: block; line-height: 1.2; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card .hint { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.form-error {
  margin: 12px 0 0; padding: 9px 12px; border-radius: 8px; background: var(--red-bg);
  color: var(--red); font-size: 13px; display: none;
}
.form-error.show { display: block; }

/* ---------- 品牌标记 ---------- */
.mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; position: relative; flex: none;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .28);
}
.mark::after {
  content: "✓"; position: absolute; right: -3px; bottom: -4px; font-size: 12px;
  color: var(--red); background: #fff; border-radius: 50%; width: 15px; height: 15px;
  line-height: 15px; text-align: center; font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

/* ---------- 主框架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: none; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px;
}
.sidebar .brand b { font-size: 15px; display: block; line-height: 1.25; }
.sidebar .brand small { font-size: 11px; letter-spacing: .4px; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px; margin-bottom: 2px;
  border-radius: 9px; color: #334155; font-size: 13.5px;
}
.nav a:hover { background: #f4f7fd; color: var(--ink); }
.nav a.active { background: var(--blue-50); color: var(--blue-700); font-weight: 600; }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .45; }
.side-foot { padding: 12px 18px 16px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; background: rgba(255,255,255,.86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.crumb { font-size: 13px; color: var(--muted); }
.crumb b { color: var(--ink); font-size: 15px; margin-right: 8px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who .avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue-50); color: var(--blue-700);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.view { padding: 20px 22px 48px; max-width: 1280px; width: 100%; }

/* ---------- 页头 / 卡片 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15,23,42,.03); padding: 16px;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .tip { color: var(--muted); font-size: 12px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.4px; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .foot { color: var(--muted); font-size: 12px; }
.kpi .foot b { color: var(--ink); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; }
.grid-2 > .card + .card { margin-top: 0; }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; outline: none; min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #9db8f7; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.toolbar input[type="text"] { width: 220px; }
.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f7f9fd; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-700); }
.btn.danger { background: #fff; border-color: #f3c1c1; color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 0 2px; font-size: 13px; }
.link-btn.danger { color: var(--red); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8fafd; color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f8fbff; }
td .sub { color: var(--muted); font-size: 12px; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; line-height: 20px; background: var(--gray-bg); color: #475569; white-space: nowrap;
}
.badge.ok { background: var(--green-bg); color: #15803d; }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.info { background: var(--blue-50); color: var(--blue-700); }

/* ---------- 分页 / 空态 / 加载 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.empty { padding: 40px 12px; text-align: center; color: var(--muted); }
.loading { padding: 36px; text-align: center; color: var(--muted); }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg,#eef2f8 25%,#f7f9fc 37%,#eef2f8 63%); background-size: 400% 100%; animation: skel 1.2s ease infinite; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 图表 ---------- */
.chart-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chart-row .name { width: 64px; color: var(--muted); font-size: 12px; flex: none; }
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 54px; flex: 1; }
.chart-bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; height: 100%; }
.chart-bars .bar .track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.chart-bars .bar i { display: block; width: 100%; max-width: 26px; background: var(--blue-50); border-radius: 4px 4px 2px 2px; min-height: 2px; }
.chart-bars .bar.on i { background: var(--blue); }
.chart-bars .bar span { font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart-legend { display: flex; gap: 12px; color: var(--muted); font-size: 12px; margin-top: 6px; flex-wrap: wrap; }

/* ---------- 批改成本 ---------- */
.cost-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.cost-trend .chart-bars { height: 76px; }
.cost-trend .bar span { font-size: 11px; }
.cost-head p { margin: 1px 0 0; font-size: 13px; line-height: 1.6; color: #334155; }
.cost-pill {
  flex: none; display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 18px;
}
.cost-pill.ok { background: var(--green-bg); color: #15803d; }
.cost-pill.warn { background: var(--amber-bg); color: var(--amber); }
.cost-pill.critical { background: var(--red-bg); color: var(--red); }
.cost-alerts { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
.cost-alerts summary {
  cursor: pointer; font-size: 13px; color: var(--blue-700);
  list-style: none; user-select: none;
}
.cost-alerts summary::-webkit-details-marker { display: none; }
.cost-alerts summary::before { content: "▸ "; }
.cost-alerts[open] summary::before { content: "▾ "; }
.cost-alert-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.cost-alert-row:last-child { border-bottom: none; }
.cost-alert-row time { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; padding-top: 1px; }
.cost-alert-row p { margin: 0; font-size: 13px; line-height: 1.55; color: #334155; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 620px; background: #fff; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15,23,42,.22); animation: pop .16s ease-out;
}
.modal.wide { max-width: 860px; }
@keyframes pop { from { transform: translateY(6px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal-head h2 { font-size: 16px; }
.icon-btn { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 4px 18px 16px; }
.modal-foot { padding: 12px 18px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.modal-foot:empty { display: none; }
.danger-box { border: 1px solid #f3d2d2; background: #fffafa; border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.danger-box h4 { color: var(--red); font-size: 13px; margin-bottom: 6px; }
.danger-box p { margin: 0 0 10px; color: #7f1d1d; font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: #334155; }
.form-grid label.check input { width: 15px; height: 15px; accent-color: var(--blue); }
.kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
pre.code {
  margin: 0; padding: 10px 12px; background: #0f172a; color: #dbe4f5; border-radius: 8px;
  font-size: 11.5px; line-height: 1.55; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.section-split { border-top: 1px dashed var(--line); margin: 16px 0 12px; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- Toast ---------- */
#toastRoot { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  padding: 10px 14px; border-radius: 9px; background: #0f172a; color: #fff; font-size: 13px;
  box-shadow: 0 10px 30px rgba(15,23,42,.22); animation: pop .16s ease-out; max-width: 380px;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

/* ---------- 系统状态 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfcfe; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }

@media (max-width: 1024px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 12px 14px 6px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; padding: 6px 10px 10px; }
  .nav a { white-space: nowrap; margin: 0; }
  .side-foot { display: none; }
  .view { padding: 14px 12px 40px; }
  .toolbar input[type="text"] { width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
