:root {
  --pico-font-size: 15px;
  --pico-spacing: .85rem;
  --pico-form-element-spacing-vertical: .5rem;
  --pico-form-element-spacing-horizontal: .7rem;
  --ok: #15803d;
  --err: #b91c1c;
  --warn: #b45309;
  --info: #1d4ed8;
  --line: #e5e7eb;
  --soft: #f8fafc;
}
body { background: #f4f6f9; }
main { padding-top: 1rem; padding-bottom: 2rem; }
h1 { font-size: 1.6rem; margin-bottom: .25rem; }
h3 { font-size: 1.1rem; margin-bottom: .75rem; }
h4 { font-size: 1rem; margin: 0; }
h6 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; margin-bottom: .35rem; }
.mono, code, .code-block { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.small { font-size: .82rem; }
.muted { color: #64748b; }
.nowrap { white-space: nowrap; }
.text-error { color: var(--err); }
.text-success { color: var(--ok); }
.inline { display: inline; margin: 0; }
footer { padding-bottom: 1.5rem; }

/* top bar */
.topbar { background: #0f172a; margin-bottom: .5rem; }
.topbar nav { padding: 0 1rem; }
.topbar a { color: #cbd5e1; }
.topbar a[aria-current="page"], .topbar a:hover { color: #fff; }
.topbar .brand { color: #fff; font-weight: 700; }
/* "Log out" is a POST form button, styled exactly like the nav links next to it. */
.topbar form.inline { display: block; }
.topbar button.nav-link {
  all: unset; box-sizing: border-box; cursor: pointer;
  margin: calc(var(--pico-nav-link-spacing-vertical) * -1) calc(var(--pico-nav-link-spacing-horizontal) * -1);
  padding: var(--pico-nav-link-spacing-vertical) var(--pico-nav-link-spacing-horizontal);
  display: inline-block; font: inherit; line-height: var(--pico-line-height); color: #cbd5e1; border-radius: var(--pico-border-radius);
}
.topbar button.nav-link:hover { color: #fff; }
.topbar button.nav-link:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }

button.small, [role="button"].small, .small[role="button"] { padding: .25rem .65rem; font-size: .82rem; }
button.icon { padding: .15rem .45rem; font-size: .85rem; background: transparent; color: #64748b; border: 1px solid var(--line); margin: 0; }
button.icon:hover { color: #0f172a; border-color: #94a3b8; }
button.link { background: none; border: 0; padding: 0; color: var(--pico-primary); width: auto; margin: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { display: flex; align-items: center; gap: .6rem; }
.head-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.head-actions > *, .head-actions form button { margin: 0; }
.head-actions details.dropdown { margin: 0; }
.head-actions details.dropdown summary { padding: .5rem 1rem; }
.sticky-head { position: sticky; top: 0; z-index: 10; background: #f4f6f9; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
article.mini { margin: 0; padding: .9rem 1rem; box-shadow: none; border: 1px solid var(--line); }
.cards-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 1rem; }
.two-col { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid.basics { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* flashes */
.flash { padding: .65rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.flash ul { margin: .25rem 0 0; }
.flash-success { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.flash-warning { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.field-error { color: var(--err); display: block; margin-top: -.4rem; margin-bottom: .5rem; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px;
  background: #e2e8f0; color: #334155; white-space: nowrap; vertical-align: middle; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-success-outline { background: transparent; color: #166534; border: 1px solid #86efac; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-rss { background: #ffedd5; color: #9a3412; }
.badge-json { background: #e0e7ff; color: #3730a3; }
.badge-off { background: transparent; color: #cbd5e1; border: 1px dashed #cbd5e1; }
.spinner { width: .75em; height: .75em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stats > div { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .7rem 1rem; }
.stats strong { display: block; font-size: 1.5rem; line-height: 1.2; }
.stats span { font-size: .8rem; color: #64748b; }
.stats .stat-error strong { color: var(--err); }

/* tables */
.table-wrap { overflow-x: auto; }
table { font-size: .88rem; margin-bottom: .5rem; }
th, td { padding: .45rem .6rem; vertical-align: top; }
.jobs-table td { vertical-align: middle; }
.row-failing td:first-child { box-shadow: inset 3px 0 0 var(--err); }
.row-disabled { opacity: .65; }
.actions { white-space: nowrap; text-align: right; }
.actions form, .actions a { margin: 0 0 0 .25rem; }
.result-cell { max-width: 280px; }
.data-table td { max-width: 360px; overflow-wrap: anywhere; }
.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: .5rem; }
.empty { text-align: center; padding: 3rem 1rem; }

/* copy field */
.copy-field { display: flex; gap: .4rem; }
.copy-field input { margin: 0; font-family: ui-monospace, monospace; font-size: .82rem; }
.copy-field button { margin: 0; width: auto; }
.url-row, .selector-row { display: flex; gap: .5rem; align-items: center; }
.url-row input, .url-row button, .selector-row input { margin: 0; }
.url-row button { width: auto; white-space: nowrap; }
.unit { white-space: nowrap; font-size: .85rem; color: #64748b; }
.button-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.button-row button { margin: 0; width: auto; }
.form-foot { display: flex; justify-content: flex-end; }
.form-foot button { width: auto; }
.toggle-target[hidden] { display: none; }
.check-list { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.check-list label { font-size: .85rem; }

/* ------------------------------------------------------------- picker */
.picker { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 1rem; padding: .75rem; }
@media (max-width: 1100px) { .picker { grid-template-columns: 1fr; } }
.picker-main { display: flex; flex-direction: column; min-width: 0; }
.picker-toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.tool-group { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tool { margin: 0; width: auto; padding: .3rem .65rem; font-size: .82rem; background: #fff; color: #334155; border: 0; border-right: 1px solid var(--line); border-radius: 0; }
.tool-group .tool:last-child { border-right: 0; }
.picker-toolbar > .tool { border: 1px solid var(--line); border-radius: 6px; }
.tool:hover:not(:disabled) { background: #f1f5f9; }
.tool.pressed { background: #1d4ed8; color: #fff; }
.tool:disabled { color: #cbd5e1; cursor: not-allowed; }
.inline-check { display: inline-flex; align-items: center; gap: .3rem; margin: 0; }
.inline-check input { margin: 0; }
.picker-hint { font-size: .85rem; padding: .45rem .7rem; border-radius: 6px; background: #eff6ff; color: #1e3a8a; margin-bottom: .5rem; }
.picker-hint.hint-warning { background: #fffbeb; color: #78350f; }
.picker-hint.hint-success { background: #f0fdf4; color: #14532d; }
.picker-hint code { font-size: .8rem; }
.frame-wrap { position: relative; flex: 1; min-height: 640px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.frame-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; background: var(--soft); }
.frame-empty[hidden] { display: none; }

.picker-side { display: flex; flex-direction: column; gap: .6rem; max-height: 820px; overflow-y: auto; padding-right: .25rem; }
.picker-side label { margin-bottom: .2rem; }
.picker-side input, .picker-side select { margin-bottom: .3rem; font-size: .85rem; }
.picker-side details { margin: 0; border-top: 1px solid var(--line); padding-top: .5rem; }
.picker-side summary { font-weight: 600; font-size: .9rem; }
.selection-info { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .65rem; }
.sel-text { font-size: .82rem; max-height: 4.5em; overflow: hidden; }
.match-count { font-size: .75rem; white-space: nowrap; font-weight: 600; }
.match-count.good, .f-preview .good { color: var(--ok); }
.match-count.bad, .f-preview .bad { color: var(--err); }
.fields-head, .preview-head { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: .5rem; }
.fields-head button, .preview-head button { margin: 0; width: auto; }
.fields { display: flex; flex-direction: column; gap: .4rem; }
.field-row { border: 1px solid var(--line); border-radius: 6px; padding: .45rem .5rem .3rem; background: #fff; }
.field-row.active { border-color: #60a5fa; box-shadow: 0 0 0 2px #dbeafe; }
.field-row-top { display: flex; gap: .3rem; align-items: center; }
.field-row-top input, .field-row-top select, .field-row-top button { margin: 0 !important; }
.field-row .f-name { flex: 1 1 30%; min-width: 0; font-weight: 600; }
.field-row .f-type { flex: 0 0 auto; width: auto; }
.field-row .f-attr { flex: 0 1 26%; min-width: 0; }
.field-row .f-selector { margin: .3rem 0 0 !important; font-size: .8rem !important; }
.field-row input, .field-row select { padding: .25rem .45rem !important; height: auto !important; font-size: .82rem; }
.field-color { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.f-preview { color: #475569; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding-top: .15rem; }
.f-preview:empty { display: none; }
.f-preview .value { color: #0f172a; }
.preview.loading { opacity: .5; }
.preview-table { font-size: .78rem; }
.preview-table td, .preview-table th { padding: .25rem .4rem; max-width: 220px; overflow-wrap: anywhere; }
body.mode-single .list-only { display: none !important; }
.cron-preview ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.cron-preview li { list-style: disc; margin: 0; }

/* logs */
.timeline { list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.timeline li { list-style: none; padding: .35rem .5rem; border-left: 3px solid #cbd5e1; margin-bottom: .2rem; background: var(--soft); border-radius: 0 4px 4px 0; }
.timeline .log-time { color: #64748b; margin-right: .5rem; font-size: .8rem; }
.timeline .log-level { font-size: .7rem; font-weight: 700; margin-right: .5rem; color: #64748b; display: inline-block; width: 4.8em; }
.timeline .log-debug { border-left-color: #cbd5e1; color: #64748b; }
.timeline .log-info { border-left-color: #60a5fa; }
.timeline .log-warning { border-left-color: #f59e0b; background: #fffbeb; }
.timeline .log-warning .log-level { color: var(--warn); }
.timeline .log-error { border-left-color: #ef4444; background: #fef2f2; }
.timeline .log-error .log-level { color: var(--err); }
.timeline details { margin: .25rem 0 0; }
.code-block { background: #0f172a; color: #e2e8f0; padding: .6rem .8rem; border-radius: 6px; overflow: auto; max-height: 420px; font-size: .78rem; white-space: pre-wrap; word-break: break-word; }
.level { font-size: .7rem; font-weight: 700; }
.level-warning { color: var(--warn); }
.level-error { color: var(--err); }
.level-debug { color: #94a3b8; }
.log-table tr.log-error td { background: #fef2f2; }
.log-table tr.log-warning td { background: #fffbeb; }
.log-table details { margin: .2rem 0 0; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.filters label { margin: 0; }
.filters select, .filters input { margin: 0; }
.filter-actions { display: flex; gap: .5rem; }
.filter-actions > * { margin: 0; width: auto; }

/* login / error */
body.bare { display: grid; min-height: 100vh; place-items: center; }
.narrow { max-width: 420px; }
.login-card header h2 { margin: 0; }
.error-page { text-align: center; padding: 3rem; }
dialog article { max-width: 900px; width: 90vw; }

/* Pico makes submit buttons full width; keep inline forms compact. */
form.inline button, .actions button, .head-actions button, .button-row button { width: auto; }
.actions { display: flex; gap: .35rem; justify-content: flex-end; align-items: center; }
.actions form, .actions a { margin: 0; }
td.actions { display: table-cell; }
td.actions > * { display: inline-block; vertical-align: middle; }
.timeline .log-level { width: 6em; }
.tool.pressed, .tool.pressed:hover { background: #1d4ed8 !important; color: #fff !important; }

/* section tools (per-page selector) and page numbers */
.section-head { gap: 1rem; flex-wrap: wrap; }
.section-tools { display: flex; align-items: center; gap: 1rem; }
.per-page { margin: 0; }
.per-page label { display: flex; align-items: center; gap: .4rem; margin: 0; white-space: nowrap; }
.per-page select { margin: 0; width: auto; padding: .2rem 2rem .2rem .5rem; font-size: .82rem; height: auto; }
.pagination { flex-wrap: wrap; }
.page-numbers { display: inline-flex; gap: .5rem; align-items: center; }
.page-numbers strong { padding: 0 .35rem; border-radius: 4px; background: #1d4ed8; color: #fff; }

/* dashboard row action menu */
details.row-actions { margin: 0; display: inline-block; }
details.row-actions summary { padding: .25rem .7rem; font-size: .82rem; }
details.row-actions summary::after { height: .8rem; margin-left: .35rem; }
details.row-actions > ul { z-index: 50; width: max-content !important; min-width: 12rem; max-width: 20rem; text-align: left; direction: ltr; }
details.row-actions > ul li { padding: 0; }
details.row-actions > ul li > a,
details.row-actions > ul li button.link,
details.row-actions > ul li .disabled-action {
  display: block; width: 100%; text-align: left; padding: .4rem .9rem; font-size: .88rem; color: var(--pico-dropdown-color);
  border-radius: 0; margin: 0; text-decoration: none; background: none;
}
details.row-actions > ul li form { margin: 0; }
details.row-actions > ul li > a:hover,
details.row-actions > ul li button.link:hover:not(:disabled) { background: var(--pico-dropdown-hover-background-color); }
details.row-actions > ul li button.link.text-error { color: var(--err); }
details.row-actions > ul li button:disabled,
details.row-actions > ul li .disabled-action { color: #94a3b8; cursor: not-allowed; }
details.row-actions > ul li.divider { border-top: 1px solid var(--line); margin: .25rem 0; height: 0; }
details.row-actions > ul li > a { margin: 0 !important; }
details.row-actions > ul li button.link { line-height: inherit; border: 0; }

/* alert rules */
.alert-rules { display: flex; flex-direction: column; gap: .75rem; margin-bottom: .25rem; }
.alert-rule { border: 1px solid var(--line); border-left: 4px solid #f59e0b; border-radius: 6px; padding: .65rem .8rem; background: #fffdf7; }
.alert-rule.inactive { opacity: .6; border-left-color: #cbd5e1; background: var(--soft); }
.alert-rule input, .alert-rule select { margin: 0; padding: .3rem .5rem; height: auto; font-size: .85rem; }
.alert-rule .rule-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .45rem; }
.alert-rule .rule-head .r-name { flex: 1; font-weight: 600; }
.alert-rule .rule-head .inline-check { white-space: nowrap; }
.alert-rule .rule-match { display: flex; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.alert-rule .rule-match select { width: auto; }
.alert-rule .conditions { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .45rem; }
.alert-rule .condition { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(150px, 1fr) minmax(140px, 2fr) auto; gap: .4rem; align-items: center; }
.alert-rule .condition .c-value[hidden] { display: block; visibility: hidden; }
.alert-rule .r-add-condition { width: auto; margin: 0 0 .45rem; }
.alert-rule .rule-foot { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; border-top: 1px dashed var(--line); padding-top: .45rem; }
.alert-rule .rule-foot label { display: flex; gap: .4rem; align-items: center; margin: 0; }
.alert-rule .rule-foot select { width: auto; }
.alert-rule .r-test:empty { display: none; }
.alert-rule .r-test { margin-top: .45rem; padding: .4rem .6rem; border-radius: 4px; background: #fff; border: 1px solid var(--line); }
.alert-rule .r-test.good strong { color: var(--ok); }
.alert-rule .r-test ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.alert-rule .r-test li { list-style: disc; margin: 0; }
.badge-alert { background: #fef3c7; color: #92400e; }
.rule-list { margin: 0 0 .75rem; padding-left: 1.1rem; }
.rule-list li { list-style: disc; margin: 0 0 .15rem; }
a.badge { text-decoration: none; }

/* field transforms (ƒx) */
.field-row .f-fx { font-style: italic; font-family: Georgia, serif; white-space: nowrap; }
.field-row .f-fx.has-steps { color: #7c3aed; border-color: #c4b5fd; background: #f5f3ff; }
.field-row .f-fx[aria-expanded="true"] { background: #ede9fe; }
.f-transforms { margin-top: .35rem; padding: .4rem .45rem; background: #faf5ff; border: 1px dashed #c4b5fd; border-radius: 4px; }
.f-transforms[hidden] { display: none; }
.fx-steps { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .3rem; }
.fx-step { display: flex; gap: .3rem; align-items: center; font-size: .8rem; }
.fx-step .fx-order { color: #7c3aed; font-weight: 600; width: 1.2rem; }
.fx-step .fx-label { flex: 0 0 6.5rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-step input { flex: 1; min-width: 0; margin: 0 !important; padding: .2rem .4rem !important; font-size: .78rem !important; height: auto !important; }
.fx-step input[hidden] { display: none; }
.fx-step button { margin: 0 !important; padding: .05rem .35rem; font-size: .75rem; }
.fx-step button:disabled { opacity: .3; }
.f-transforms .fx-add { margin: 0 !important; width: auto; font-size: .78rem !important; padding: .2rem 1.8rem .2rem .45rem !important; height: auto !important; }
.f-transforms .fx-empty { margin: 0 0 .25rem; }
.f-preview .raw { color: #94a3b8; text-decoration: line-through; text-decoration-color: #cbd5e1; }
.f-preview .fx-type { color: #7c3aed; font-size: .7rem; }
.text-warning { color: var(--warn); }
