:root {
  --accent: #f05a28;
  --ink: #20262d;
  --muted: #737a80;
  --line: #e9e6e2;
  --bg: #fffdfa;
  --panel: #ffffff;
  --soft: #f6f3ef;
  --ok: #2f8f5b;
  --warn: #c98a12;
  --bad: #c8412b;
  --info: #3b6fb6;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

button, select, input {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 7px 12px;
  background: var(--panel);
  color: var(--ink);
}
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); border-color: #f0c8c0; }
button.small { padding: 4px 10px; font-size: 13px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid rgba(240, 90, 40, .35); outline-offset: 1px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 12px; }
.login-card .brand { margin-bottom: 8px; }
.login-card label { font-weight: 500; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.error { color: var(--bad); margin: 0; }

.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.nav { border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.nav .brand { padding: 0 10px 16px; }
.nav a { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.nav a:hover { background: var(--soft); }
.nav a.active { background: #fdebe4; color: var(--accent); font-weight: 600; }
.nav #change-password { margin-top: auto; }
main { padding: 20px 28px 40px; min-width: 0; }
.bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.bar h1 { font-size: 20px; margin: 0; }
.bar-actions { display: flex; align-items: center; gap: 10px; }
.flash { padding: 10px 14px; border-radius: 8px; background: #fdebe4; color: var(--ink); }
.flash.bad { background: #fbe3df; color: var(--bad); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-all; }

.bar-row { display: grid; grid-template-columns: 88px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-track { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--muted); }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }
.subhead { color: var(--muted); font-size: 12px; margin: 12px 0 8px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--soft); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-completed, .s-on { color: var(--ok); }
.s-running { color: var(--info); }
.s-queued, .s-paused, .s-recording { color: var(--warn); }
.s-failed, .s-off { color: var(--bad); }
.fill-completed { background: var(--ok); }
.fill-running { background: var(--info); }
.fill-queued { background: var(--warn); }
.fill-failed { background: var(--bad); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfaf7; }
td.wrap { white-space: normal; max-width: 320px; }
td.error-cell { color: var(--bad); font-size: 12px; white-space: normal; max-width: 260px; }
.empty { text-align: center; color: var(--muted); padding: 32px; }

.drawer { border: 0; padding: 0; margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(520px, 100vw); background: var(--panel); box-shadow: -8px 0 24px rgba(0, 0, 0, .08); }
.drawer::backdrop { background: rgba(32, 38, 45, .25); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 16px; }
#drawer-body { padding: 16px 20px; }
#drawer-error { margin: 16px 20px 0; }
#drawer-body form { display: grid; gap: 10px; margin-top: 16px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 20px; }
.note { background: var(--soft); border-radius: 8px; padding: 10px 12px; color: var(--muted); font-size: 12px; margin-top: 14px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .nav .brand { padding: 6px 10px; }
  .nav #change-password { margin: 0 0 0 auto; }
  main { padding: 16px; }
}
