:root {
  --ink: #12141a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --side: #16181d;
  --accent: #d63a2f;
  --ok: #157a45;
  --warn: #9a6b12;
  --blue: #1d4ed8;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
.side { width: 248px; background: var(--side); color: #ececec; padding: 20px 16px; display: flex; flex-direction: column; flex-shrink: 0; }
.side-logo { font-size: 20px; font-weight: 700; margin-bottom: 24px; letter-spacing: -0.03em; }
.side-logo span { color: var(--accent); }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a { padding: 8px 10px; border-radius: 8px; color: #c5c8ce; font-size: 14px; }
.side nav a:hover { background: #2a2d34; color: #fff; }
.side nav a.on { background: #2a2d34; color: #fff; font-weight: 600; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-group .side-sub { display: none; flex-direction: column; gap: 1px; padding: 0 0 6px 10px; }
.side-group.open .side-sub { display: flex; }
.side-group .side-sub a { font-size: 13px; padding: 6px 10px; color: #9aa0a8; }
.side-group .side-sub a.on { color: #fff; }
.mod-nav {
  display: flex; flex-wrap: wrap; gap: 4px; margin: -6px 0 18px;
  padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.mod-nav a {
  padding: 7px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); font-weight: 500;
}
.mod-nav a:hover { background: #f3f4f6; color: var(--ink); }
.mod-nav a.on { background: var(--ink); color: #fff; }
.side-foot { margin-top: auto; font-size: 13px; color: #9aa0a8; display: flex; flex-direction: column; gap: 8px; }
.main { flex: 1; padding: 28px 32px 64px; min-width: 0; }
.main h1 { font-size: 22px; margin: 0 0 18px; }
.flash { background: #e7f4ec; color: var(--ok); padding: 10px 12px; border-radius: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; vertical-align: middle; }
.pill.warn { background: #f8e8c8; color: var(--warn); }
.pill.ok { background: #d9f0e3; color: var(--ok); }
.pill.l0, .pill.hub { background: #dbeafe; color: #1d4ed8; }
.pill.l1, .pill.grp { background: #ede9fe; color: #6d28d9; }
.pill.l2, .pill.leaf { background: #dcfce7; color: #166534; }
.pill.l3 { background: #ffedd5; color: #c2410c; }
.pill.soft { background: #fef3c7; color: #92400e; }
.pill.fb { background: #ffe4e6; color: #9f1239; }
.pill.off { background: #f3f4f6; color: #6b7280; }
.pill.nav { background: #e0f2fe; color: #0369a1; }
.pill.home { background: #fce7f3; color: #9d174d; }
.pill.feat { background: #ffedd5; color: #c2410c; }
table.data { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.data th { background: #fafafa; font-size: 12px; color: var(--muted); font-weight: 600; }
table.data.compact th, table.data.compact td { padding: 6px 8px; font-size: 13px; }
table.data.compact th { font-size: 11px; letter-spacing: .02em; text-transform: uppercase; }
table.data tr.off { opacity: .55; }
table.data tr.paused { opacity: .82; }
.toolbar.is-busy { pointer-events: none; opacity: .65; }
table.magfeed-table .col-check { width: 28px; text-align: center; padding-left: 6px; padding-right: 6px; }
table.magfeed-table .col-max { width: 64px; }
table.magfeed-table .col-cron { width: 168px; }
.feed-max { width: 52px !important; padding: 4px 6px !important; }
.cron-box { display: flex; flex-direction: column; gap: 4px; min-width: 148px; }
.feed-cron-pre { width: 100% !important; max-width: 168px; padding: 3px 4px !important; font-size: 12px !important; }
.cron-hm { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.cron-hm input { width: 48px !important; padding: 3px 4px !important; margin: 0 !important; }
table.magfeed-table .col-run { width: 88px; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.magfeed-table .col-acts { width: 96px; white-space: nowrap; text-align: right; }
.ico-act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; margin: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; vertical-align: middle;
}
a.ico-act { color: var(--muted); }
.ico-act:hover { background: #eef2f6; color: var(--ink); }
.ico-act.danger:hover { background: #fde8e8; color: #9a1f1f; }
table.magfeed-table .magfeed-url { max-width: 220px; word-break: break-all; }
.js-toggle-active, .js-toggle-pause { cursor: pointer; border: 0; font: inherit; }
table.data tbody tr:hover { background: #f8fafc; }
td.ico-cell { width: 40px; color: var(--blue); text-align: center; }
td.ico-cell .ico { display: block; margin: 0 auto; }
td.ico-cell img { max-height: 22px; display: block; margin: 0 auto; }
.num { font-variant-numeric: tabular-nums; font-weight: 650; }
.num.zero { color: var(--muted); font-weight: 400; }
.name-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 380px; }
.tree-name { display: inline-block; padding-left: calc(var(--lv, 0) * 18px); }
.chip { background: #f3f4f6; border-radius: 999px; padding: 1px 8px; font-size: 11px; color: #374151; }
td.view-col, th.view-col { width: 28px; text-align: center; padding-left: 4px; padding-right: 4px; }
table.data form { margin: 0; }
a.view-ext { color: #2563eb; display: inline-flex; align-items: center; justify-content: center; opacity: .7; }
a.view-ext:hover { opacity: 1; }
.form { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; max-width: 720px; }
.form.wide { max-width: 980px; }
.form h2 { font-size: 16px; margin: 22px 0 8px; }
.form label { display: block; font-size: 13px; margin: 12px 0 4px; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=url], .form input[type=number], .form input[type=file], .form textarea, .form select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.thumb-prev { max-height: 64px; margin: 6px 0; display: block; background: #f3f4f6; padding: 4px; border-radius: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 12px 18px; margin: 10px 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { display: inline-block; background: var(--ink); color: #fff; border: 0; padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; margin-top: 14px; }
.btn.sec { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.toolbar { display: flex; gap: 8px; align-items: center; margin: 0 0 16px; flex-wrap: wrap; }
.toolbar form { margin: 0; display: inline-flex; }
.toolbar .btn { margin-top: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.rd-dlg { border: 0; border-radius: 12px; padding: 0; width: min(920px, calc(100% - 24px)); max-height: 92vh; }
.rd-dlg::backdrop { background: rgba(18, 20, 26, .45); }
.rd-dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.rd-dlg-head .btn { margin-top: 0; }
.rd-dlg-body { padding: 12px 16px 20px; overflow: auto; max-height: calc(92vh - 56px); }
.rd-dlg .form { border: 0; padding: 0; max-width: none; background: transparent; }
.rd-dlg .form.wide { max-width: none; }
.pay-checks { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0; }
.pay-checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.pay-checks img { height: 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.login { min-height: 100vh; width: 100%; display: grid; place-items: center; background: var(--bg); }
.login .box { width: min(380px, calc(100% - 32px)); background: #fff; padding: 28px; border-radius: 14px; border: 1px solid var(--line); }
.login h1 { margin: 0 0 8px; font-size: 22px; }
.login label { display: block; font-size: 13px; margin: 12px 0 4px; }
.login input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.err { color: #9a1f1f; font-size: 13px; }
pre.ice-json { max-height: 480px; overflow: auto; background: #16181d; color: #e8e8e8; padding: 12px 14px; border-radius: 8px; font-size: 12px; line-height: 1.45; }
table.ice-fields th { width: 180px; color: var(--muted); font-weight: 600; vertical-align: top; white-space: nowrap; }

.live-bar {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 4px 12px; margin: 0 0 12px; max-width: 640px;
}
.live-bar-wide { max-width: none; flex-wrap: wrap; }
.live-tog { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); white-space: nowrap; cursor: pointer; margin: 0; }
.live-tog input { margin: 0; }
.live-per { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.live-per select { width: auto; padding: 4px 8px; margin: 0; font: inherit; }
.live-bar .live-ico { color: var(--muted); display: flex; }
.live-bar .live-q {
  flex: 1; border: 0; outline: 0; font: inherit; font-size: 14px; background: transparent; padding: 8px 0;
}
.live-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.live-pager { display: flex; gap: 4px; align-items: center; margin: 10px 0 0; flex-wrap: wrap; font-size: 13px; }
.live-pager button, .live-pager a {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit;
  color: inherit; text-decoration: none; display: inline-block;
}
.live-pager button.on, .live-pager a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.live-pager button:disabled { opacity: .4; cursor: default; }
.live-q-mini {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin: 0 0 8px;
}
.icon-select { display: flex; align-items: center; gap: 8px; }
.icon-select select { flex: 1; }
.icon-select-prev { width: 32px; height: 32px; display: grid; place-items: center; color: var(--blue); background: #eff6ff; border-radius: 8px; flex-shrink: 0; }
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px;
  max-height: 280px; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fafafa;
}
.icon-opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 10px; color: var(--muted);
  margin: 0; background: #fff; position: relative;
}
.icon-opt .ico { color: var(--blue); }
.icon-opt input { position: absolute; opacity: 0; pointer-events: none; }
.icon-opt:hover { border-color: #bfdbfe; }
.icon-opt:has(input:checked) { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }
.cat-checks {
  max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px;
}
.cat-checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; padding: 3px 0; }
.filter-row { align-items: end; }
.filters {
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 12px;
}
.filters > div { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.filters label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.filters input, .filters select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.filters-go { flex-direction: row !important; align-items: center; min-width: auto !important; }
.filters-go .btn { margin-top: 0; }
.col-thumb { width: 56px; }
.col-check { width: 28px; text-align: center; }
.bulk-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 0 10px; padding: 8px 10px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
}
.bulk-bar select, .bulk-bar input[type=date] {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.bulk-bar .btn { margin-top: 0; }
.bulk-bar .js-bulk-date, .bulk-bar .js-bulk-cat { display: flex; gap: 6px; align-items: center; }
.bulk-bar .js-bulk-date[hidden], .bulk-bar .js-bulk-cat[hidden] { display: none !important; }
.thumb-mini { width: 48px; height: 32px; object-fit: cover; border-radius: 4px; display: block; background: #f3f4f6; }
.col-dt { width: 128px; white-space: nowrap; }
.dt-btn {
  border: 0; background: none; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-align: left;
}
.dt-btn:hover { color: var(--ink); text-decoration: underline; }
.dt-pop {
  position: fixed; z-index: 40; display: flex; gap: 6px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.dt-pop[hidden] { display: none !important; }
.dt-pop input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.dt-pop .btn { margin-top: 0; }
.wid-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.wid-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fafafa; }
.wid-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.wid-head .check { margin-top: 0; }
.wid-head select { max-width: 220px; }
.wid-move { margin-left: auto; display: flex; gap: 4px; }
.wid-move .btn { margin-top: 0; padding: 4px 10px; }
.mag-job {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 14px;
}
.job-bar { height: 8px; background: #eef2f6; border-radius: 999px; overflow: hidden; }
.job-bar-fill { height: 100%; width: 0; background: #2563eb; transition: width .3s; }
.job-meta { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 8px 0 0; font-size: 13px; }
.job-meta .btn { margin-top: 0; }
.job-log {
  max-height: 220px; overflow: auto; margin: 10px 0 0; padding: 0; list-style: none; font-size: 12px;
}
.job-log li { padding: 3px 0; border-bottom: 1px solid #f3f4f6; }
.job-ok { color: #166534; }
.job-fail { color: #9a1f1f; }
.job-run { color: #1d4ed8; font-weight: 600; }
.job-skip { color: #6b7280; }
.job-pending { color: #6b7280; }
.pin-btn { cursor: pointer; border: 0; font: inherit; }
.pin-btn.on { background: #ffedd5; color: #c2410c; }

@media (max-width: 800px) {
  body { flex-direction: column; }
  .side { width: 100%; }
  .row2 { grid-template-columns: 1fr; }
  .cat-checks { grid-template-columns: 1fr; }
}
