:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2327;
  --muted: #646970;
  --border: #dcdcde;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok-bg: #e7f6ec; --ok-text: #1a6b35;
  --warn-bg: #fdf3dc; --warn-text: #7a5300;
  --bad-bg: #fbe9e9; --bad-text: #a12020;
  --muted-bg: #eef0f2;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2025;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #33373e;
    --accent: #5b8cff;
    --accent-text: #0b0d10;
    --ok-bg: #173323; --ok-text: #7fd8a0;
    --warn-bg: #3a2e12; --warn-text: #f0c76a;
    --bad-bg: #3d1b1b; --bad-text: #f19b9b;
    --muted-bg: #2a2e34;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; background: var(--muted-bg); padding: .1em .35em; border-radius: 4px; }
code.code { font-size: 1.05em; letter-spacing: .04em; }
code.wrap { word-break: break-all; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

.brand { font-weight: 700; font-size: 1.05rem; }
.brand span { color: var(--accent); }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { margin-bottom: 1rem; }

/* app shell */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .agency { font-weight: 600; }
.topbar .who { margin-left: auto; color: var(--muted); font-size: .9em; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 5; }
.tab { padding: 10px 12px; color: var(--muted); text-decoration: none; border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.content { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }
.loading { padding: 32px 16px; color: var(--muted); }

/* blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.card.narrow, form.narrow { max-width: 480px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; }
.pair { border-color: var(--accent); }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.row-form label { flex: 1 1 200px; }
.inline { display: inline; }
.hint, .sub, .empty { color: var(--muted); font-size: .9em; margin: 0; }
.empty { padding: 16px 0; }

/* forms */
/* align-content: start — in a grid row taller than this label (e.g. a neighbour with a "remove" tick box), keep the input its normal height. */
label { display: grid; gap: 4px; align-content: start; font-weight: 500; font-size: .92em; }
label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; width: 100%; }
input[type=checkbox] { width: auto; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; margin: 0; }
legend { font-weight: 600; font-size: .85em; color: var(--muted); padding: 0 4px; }
.cap-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.cap-group { display: grid; gap: 2px; }

.btn { font: inherit; font-size: .92em; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 7px 14px; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-danger { color: var(--bad-text); }
.btn-small { padding: 3px 9px; font-size: .85em; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .82em; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.edit-row td { background: var(--bg); }

/* badges, pills, messages */
.badge { display: inline-block; font-size: .8em; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-bad { background: var(--bad-bg); color: var(--bad-text); }
.badge-muted { background: var(--muted-bg); color: var(--muted); }
.pills { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pills li { background: var(--muted-bg); border-radius: 999px; padding: 2px 10px; font-size: .85em; }
.msg { padding: 10px 14px; border-radius: 6px; margin: 0 0 16px; display: flex; gap: 12px; align-items: flex-start; }
.msg-ok { background: var(--ok-bg); color: var(--ok-text); }
.msg-error { background: var(--bad-bg); color: var(--bad-text); }
.text-bad { color: var(--bad-text); }
.msg .dismiss { margin-left: auto; text-decoration: none; color: inherit; font-size: 1.2em; line-height: 1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.block-gap { margin-bottom: 16px; }
.field { display: grid; gap: 2px; }
.field .hint { font-weight: 400; }
.actions.start { justify-content: flex-start; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88em; }
details.advanced { border: 1px dashed var(--border); border-radius: 6px; padding: 8px 12px; }
details.advanced summary { cursor: pointer; font-weight: 600; font-size: .9em; }
details.advanced textarea { margin-top: 8px; }
.top-gap { margin-top: 16px; }
.wrap-cell { word-break: break-all; }
.vuln-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tpl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.tpl-row:last-child { border-bottom: 0; }
.tpl-row > .actions { margin-left: auto; }
.tpl-row > form { flex-basis: 100%; }
.token-list { list-style: none; margin: 4px 0 0; padding: 0; font-size: .88em; color: var(--muted); display: grid; gap: 4px; }
/* overview screens: stat cards, filters, activity dots, bars, pager */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-l { font-size: .82em; color: var(--muted); margin-top: 4px; }
.tone-ok { color: var(--ok-text); }
.tone-warn { color: var(--warn-text); }
.tone-bad { color: var(--bad-text); }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.filter-bar select, .filter-bar .search { width: auto; min-width: 180px; }
.filter-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.filter-links .sep { color: var(--border); }
.push-right { margin-left: auto; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.link-btn.current { color: var(--text); font-weight: 600; }
.link-btn.tone-bad { color: var(--bad-text); }
.link-btn:hover { text-decoration: underline; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot-active { background: #00a32a; }
.dot-moderate { background: #dba617; }
.dot-inactive { background: #d63638; }
.dot-never { background: var(--border); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 8px; }
.bar-wrap { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.bar { display: inline-block; width: 100px; height: 8px; background: var(--muted-bg); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; }
.fill-ok { background: #00a32a; }
.fill-warn { background: #dba617; }
.fill-bad { background: #d63638; }
.pager { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .9em; }
.onboarding-row td { background: var(--bg); font-size: .88em; padding-top: 6px; }
.ob-label { font-weight: 600; margin-right: 12px; }
.ob-item { margin-right: 14px; white-space: nowrap; }
.pf-table td { vertical-align: middle; }
.comp-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: .9em; }
details > summary { cursor: pointer; }
.ob-label { white-space: nowrap; }
.filter-bar .search { min-width: 260px; }
/* grouped navigation: dropdown menus + sub-page strip */
.navgroup { position: relative; display: flex; }
.caret { font-size: .8em; }
.menu { position: absolute; top: 100%; left: 0; min-width: 210px; margin: 0; padding: 6px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); z-index: 20; }
.menu a { display: block; padding: 8px 14px; color: var(--text); text-decoration: none; white-space: nowrap; }
.menu a:hover, .menu a:focus-visible { background: var(--muted-bg); outline: none; }
.menu a.current { font-weight: 600; color: var(--accent); }
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.subtab { padding: 4px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .9em; border: 1px solid transparent; }
.subtab:hover { border-color: var(--border); }
.subtab.active { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; }
.navgroup:last-child .menu { left: auto; right: 0; }
/* operator console: Wordfence feed browser */
tr.row-hit td { background: var(--bad-bg); }
.wf-sw + .wf-sw { margin-top: 8px; }
/* operator "log in as" banner */
.operator-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 8px 16px; background: var(--warn-bg); color: var(--warn-text); font-size: .9em; }
/* operator console: wide tables, use the screen */
#admin .content { max-width: 1600px; }
/* Action buttons in a table cell: keep it a real table cell (a flex <td> breaks
   the row's bottom border) and keep the buttons on one line. */
td.actions { display: table-cell; text-align: right; white-space: nowrap; }
td.actions > * + * { margin-left: 6px; }
/* settings forms split into titled sections */
.form-card { max-width: 720px; }
.form-section + .form-section { border-top: 1px solid var(--border); padding-top: 16px; }
.form-section h4 { margin: 0; font-size: 1em; }
.form-section label:not(.check) { max-width: 420px; }
.form-section label .hint { font-weight: 400; }

/* AI templates: collapsible categories, file-picker button */
.tpl-group { border-top: 1px solid var(--border); padding: 6px 0; }
.tpl-group > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.tpl-row .sub { font-weight: normal; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tpl-row details textarea[readonly] { margin-top: 6px; background: var(--muted-bg); resize: vertical; }
.tpl-row > form { min-width: 0; }
/* policies grouped by module category */
.policy-group { margin-top: 24px; }
.policy-group > .group-head { margin: 0 0 8px; font-size: 1.05em; }
.policy-group > .group-head .sub { font-weight: normal; }
/* module list screens (Plugin Manager, UI Clean-up, Email Health groups) */
.msg-warn { background: var(--warn-bg); color: var(--warn-text); }
td.center, th.center { text-align: center; }
/* Number columns: right-aligned, equal-width digits so figures line up down the column. */
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.num .bar-wrap { margin-top: 4px; }
.pm-table td textarea { min-width: 220px; }
.pm-table th { white-space: nowrap; }
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit input { min-width: 0; }
label.btn.file-btn { display: inline-flex; width: auto; align-items: center; font-weight: inherit; }
/* tool panels: titled groups of related buttons side by side, stacked on narrow screens */
.tool-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 32px; }
.tool-group { display: grid; gap: 8px; align-content: start; }
.tool-group + .tool-group { border-left: 1px solid var(--border); padding-left: 32px; }
.tool-group h4 { margin: 0; font-size: .95em; }
.tool-group .sub { margin: 0; }
.tool-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tool-buttons label.check { flex: 0 0 auto; }
@media (max-width: 700px) { .tool-group + .tool-group { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 16px; } }
label.check.strong { font-weight: 600; }
.card-foot { margin: 0; padding-top: 10px; border-top: 1px solid var(--border); }
.suggest-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.field label > textarea, .field label > input, .field label > select { font-weight: 400; }
.field-note { display: block; margin-top: 4px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--muted-bg); color: var(--text); }
/* Feature Set pills: managed by the hub / reported as not switched on */
.pills li.pill-managed, .pill-key.pill-managed { background: var(--ok-bg); color: var(--ok-text); }
.pills li.pill-problem, .pill-key.pill-problem { background: var(--bad-bg); color: var(--bad-text); }
.pill-legend { margin: 4px 0 12px; }
.pill-key { display: inline-block; border-radius: 999px; padding: 0 8px; background: var(--muted-bg); font-size: .9em; }
/* Policies: module help text and filter matches */
.module-desc { margin: 4px 0 0; color: var(--muted); font-size: .92em; }
.field.field-hit { border-left: 3px solid var(--accent); padding-left: 10px; background: var(--muted-bg); border-radius: 4px; }
/* activity log change diff */
.diff-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.diff-table th, .diff-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: top; word-break: break-word; }

/* Policy profiles: which policies a policy screen is editing, and a Feature Set's choice. */
.msg-info { background: var(--muted-bg); color: var(--text); }
.profile-bar { border-left: 4px solid var(--border); }
.profile-bar-custom { border-left-color: var(--accent); }
.profile-bar { padding: 12px 16px; }
.profile-bar .card-head { align-items: center; gap: 8px 12px; }
.profile-bar .sub { margin: 8px 0 0; }
/* One row: "Editing [picker] [badge] … actions" (labels are a grid elsewhere). */
.profile-pick { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1em; }
.profile-pick select { width: auto; min-width: 200px; max-width: 100%; font-weight: 400; }
.set-policies { margin: 12px 0; padding: 12px; background: var(--bg); border-radius: 6px; }
.set-policies .hint { margin: 0; }

/* Author display rules (e.g. label { display: grid }) would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
