/* muse-api admin console — no framework, no build step */
:root {
  --bg: #0f1115;
  --bg-2: #161a21;
  --bg-3: #1d222b;
  --line: #2a303b;
  --fg: #e6e9ef;
  --fg-dim: #9aa4b2;
  --fg-mute: #6b7280;
  --accent: #4c8dff;
  --ok: #2fbf71;
  --warn: #e0a33a;
  --err: #ef5350;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9; --bg-2: #fff; --bg-3: #f0f2f5; --line: #dfe3e9;
    --fg: #1b1f26; --fg-dim: #5b6672; --fg-mute: #8b95a1;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
.small { font-size: 12px; }
.muted { color: var(--fg-dim); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

#app { display: flex; height: 100%; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--bg-2);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.brand-name { font-weight: 650; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--fg-mute); }
#nav { padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 8px; color: var(--fg-dim); font-weight: 500;
}
#nav a:hover { background: var(--bg-3); color: var(--fg); }
#nav a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--fg); }
#nav a .ico { width: 16px; text-align: center; opacity: .85; }
.side-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--line); }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 620; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.view { padding: 22px; overflow: auto; }

/* ---------- bits ---------- */
.pill {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--fg-dim); background: var(--bg-3);
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

.btn {
  font: inherit; padding: 7px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--fg);
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px;
}
.card .k { font-size: 12px; color: var(--fg-mute); }
.card .v { font-size: 24px; font-weight: 640; margin-top: 4px; }
.card .s { font-size: 11px; color: var(--fg-mute); margin-top: 2px; }

.panel {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 15px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 14px; margin: 0; font-weight: 600; }
.panel-body { padding: 15px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 7px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--fg-mute); font-weight: 550; white-space: nowrap; }
/* Short status/kind cells must not wrap: a 52px 状态 column otherwise breaks "已完成"
   between every character and inflates each row to ~93px. */
td.nowrap { white-space: nowrap; }
td.mono.id { white-space: nowrap; }
/* Long free text (prompt, ref filename) is clamped to one line with an ellipsis. Without a
   bound it either wraps to many lines and inflates the row, or -- once the short columns are
   pinned with nowrap -- gets squeezed so narrow that every row becomes ~190px tall. The full
   value stays reachable through the cell's title tooltip. */
.clip { display: inline-block; max-width: 140px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }
td.actions { white-space: nowrap; text-align: right; }
/* Tighter than .btn.sm: the 任务列表 action cell now holds four buttons (详情/预览/下载/删除),
   and at the default padding the 11-column table overflowed its container by ~31px. */
td.actions .btn { margin-left: 3px; padding: 4px 5px; }
.table-wrap { overflow-x: auto; }

.empty { padding: 32px 16px; text-align: center; color: var(--fg-mute); }

.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-row label { font-size: 12px; color: var(--fg-dim); }
.hint { font-size: 11px; color: var(--fg-mute); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], textarea, select {
  font: inherit; color: var(--fg); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-dim); }
label.check input { width: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 130px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--bg-3); border: 1px solid var(--line);
  white-space: nowrap; display: inline-block; vertical-align: middle; }
.badge.ok { color: var(--ok); }
.badge.err { color: var(--err); }
.badge.warn { color: var(--warn); }
.badge.info { color: var(--accent); }

pre.out {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px; font-size: 12px; overflow: auto; max-height: 340px; margin: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  width: min(680px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 15px; }
.modal .x { background: none; border: none; color: var(--fg-dim); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; min-width: 220px; max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); font-size: 13px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }

.progress { height: 6px; background: var(--bg-3); border-radius: 999px; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.progress.done > i { background: var(--ok); }
.progress.fail > i { background: var(--err); }
