:root {
  --bg: #f5f6f8; --card: #fff; --line: #dfe3e8; --text: #1f2933; --muted: #6b7785;
  --accent: #1f5fbf; --ok: #1a7f4b; --warn: #a15c00; --bad: #b42318; --learn: #5b6b7c;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line); min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 600; white-space: nowrap; }
.domains { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.domains button { border: 0; background: none; padding: 14px 12px; cursor: pointer; border-bottom: 2px solid transparent; }
.domains button[aria-current="true"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.who select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.level { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef2f7; color: var(--muted); }
.level.read { background: #fff4e0; color: var(--warn); }
.signed-out .who, .signed-out .domains { visibility: hidden; }

main { max-width: 1120px; margin: 0 auto; padding: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; margin-bottom: 16px; }
.login { max-width: 420px; margin: 64px auto; }
.login h1 { font-size: 18px; margin: 0 0 4px; }
.login label, dialog label { display: block; margin: 12px 0 0; }
.login input, dialog input[type=text], dialog input[type=number], dialog select, dialog textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
dialog textarea { min-height: 64px; resize: vertical; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-current="true"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }

h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); margin: 8px 0 0; min-height: 0; }
.error:empty { display: none; }
.notice { padding: 8px 12px; border-radius: 6px; background: #e8f3ec; color: var(--ok); }
.notice.bad { background: #fdecea; color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { white-space: nowrap; }
.wrap { overflow-x: auto; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.stage { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.stage.enforce { background: #e8f3ec; color: var(--ok); }
.stage.learn { background: #eef2f7; color: var(--learn); }
.outcome.blocked { color: var(--bad); font-weight: 600; }
.outcome.would { color: var(--warn); }
.hint { display: block; color: var(--muted); font-size: 12px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch.on { border-color: #f0c36d; background: #fffaf0; }
.switch.off { border-color: #9fd3b5; background: #f3faf6; }

button { cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 6px; padding: 6px 14px; }
button.plain, dialog .actions button { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; }
dialog .actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
button.danger { color: var(--bad); }
button.below { display: block; margin-top: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.row-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label { display: block; font-size: 12px; color: var(--muted); }
.filters input, .filters select { display: block; margin-top: 2px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.suggestion { border-top: 1px solid var(--line); padding: 12px 0; }
.suggestion:first-child { border-top: 0; padding-top: 0; }
.suggestion .kind { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #eef2f7; margin-right: 8px; }
.facts { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin: 4px 0 8px; }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(15, 23, 42, .35); }
dialog h2 { margin-bottom: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.warn { margin: 12px 0 0; padding: 8px 12px; border-radius: 6px; background: #fff4e0; color: var(--warn); }
.kv { display: grid; grid-template-columns: 5em 1fr; gap: 4px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
footer.note { color: var(--muted); font-size: 12px; margin-top: 8px; }
/* 分组的页面（Story 8.4）：组的标题、动作的故障策略；「待开放」的行灰着。 */
tr.group th { padding-top: 18px; font-size: 14px; font-weight: 600; color: var(--text); white-space: normal; background: #fafbfc; }
tr.group .policy { margin-left: 12px; font-size: 12px; font-weight: 400; color: var(--muted); }
tr.pending td { color: var(--muted); }
.tag { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 8px; font-size: 11px; background: #eef2f7; color: var(--muted); vertical-align: 1px; }
.row-actions input[type=search] { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; min-width: 12em; }
