:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e1e6eb;
  --text: #1f2933;
  --muted: #7a8794;
  --primary: #2066b0;
  --primary-d: #19508c;
  --accent: #ff7a00;
  --green: #28a745;
  --red: #d9534f;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 18px; box-shadow: var(--shadow);
}
header.topbar h1 { font-size: 18px; margin: 0; display: flex; align-items: center; gap: 10px; }
.logo { width: 28px; height: 28px; background: var(--primary); border-radius: 7px; display: grid; place-items: center; color: #fff; font-weight: 700; }
.status-pills { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px; background: #eef2f6; font-size: 12px; color: var(--muted); }
.pill b { color: var(--text); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(40,167,69,.15); }
.dot.off { background: var(--red); }

nav.tabs { display: flex; gap: 4px; margin: 16px 0; border-bottom: 2px solid var(--border); }
nav.tabs button {
  background: none; border: none; padding: 10px 18px; cursor: pointer;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; font-weight: 500;
}
nav.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 18px; }
.panel + .panel { margin-top: 16px; }

.btn { border: none; border-radius: 7px; padding: 9px 16px; font-size: 14px; cursor: pointer; font-weight: 500; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: #eef2f6; color: var(--text); }
.btn.ghost:hover { background: #e2e8ee; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #f0c8c6; }
.btn.danger:hover { background: #fdf0ef; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar { margin-bottom: 14px; }
h2.section { font-size: 15px; margin: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; background: #eef2f6; color: var(--muted); }
.tag.on { background: rgba(40,167,69,.12); color: var(--green); }
.tag.off { background: rgba(217,83,79,.1); color: var(--red); }
.tag.prio { background: rgba(255,122,0,.13); color: var(--accent); }
.stage-chip { display: inline-flex; align-items: center; gap: 6px; }
.stage-chip .swatch { width: 10px; height: 10px; border-radius: 3px; background: #ccc; }
.arrow { color: var(--muted); margin: 0 4px; }

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

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20,30,40,.45); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 50; }
.modal-back.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600; }
.modal .body { padding: 22px; }
.modal footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field input[type=text], .field input[type=number], .field input[type=password], .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; background: #fff;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 16px; height: 16px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2933; color: #fff; padding: 11px 20px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 100; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.err { background: var(--red); }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.log-ok { color: var(--green); }
.log-err { color: var(--red); }
small.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
