/* Automation, More, every settings page, the bill history, the sorting log, label and eval pages, and the sign-in and
   security pages. Phone first; 900 px is the phone/desktop switch, as in nav.css. */

/* page frame: Automation and More use the full width; a settings page reads best narrower */
.tab-page { max-width: 1040px; }
.tab-page.more { max-width: 720px; }
.settings-page { max-width: 960px; min-width: 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -4px 0 2px; color: var(--primary); font: 500 16px var(--sans); text-decoration: none; }
.back-link:hover { color: var(--primary); text-decoration: underline; }
.settings-page .page-title { margin: 0; }
.accounts-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.accounts-head .btn { margin-left: auto; }

/* status line: what the page's state is, in one quiet line (no box, no label) */
.status-line { display: grid; gap: 8px; margin: 4px 0 14px; color: var(--muted); font-size: 15px; }
.status-line.all-good p::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: 1px; }
.status-line ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.status-line li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--weak); color: var(--text); }
.status-line .tag { min-width: 0; padding: 1px 6px; font-size: 11px; }

/* Automation: tiles and last handled on the left, Set up on the right from 900 px */
.automation-grid { display: grid; gap: 8px; }
.automation .tiles { margin-top: 2px; }
.automation .tile { cursor: default; }
.handled-list { list-style: none; margin: 0; padding: 0; }
.handled-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.handled-list a:hover .handled-who b { color: var(--primary); }
.handled-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.handled-who b { font-weight: 600; }
.handled-who .arrow { color: var(--muted); }
.handled-what { grid-column: 1 / -1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* More: who is signed in */
.more-who { display: flex; gap: 12px; align-items: center; padding: 4px 0 12px; }

/* auth pages */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.brand { font: 700 16px var(--sans); letter-spacing: -.01em; color: var(--text); text-decoration: none; white-space: nowrap; }
.auth-card {
  width: 100%; max-width: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg);
  display: grid;
}
.auth-card.wide { max-width: 560px; }
.auth-card > header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.auth-card > .body { padding: 22px 24px 24px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 22px; }
.auth-card .lead { color: var(--muted); }
.auth-card .foot { padding: 14px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* 2FA setup */
.steps { margin: 0; padding-left: 20px; display: grid; gap: 14px; color: var(--muted); }
.steps li::marker { color: var(--primary); font-weight: 600; }
.qr { background: #FFFFFF; /* fixed: a QR code needs a white quiet zone in every theme */ padding: 12px; width: 204px; height: 204px; border-radius: var(--radius); }
.qr img { width: 180px; height: 180px; display: block; image-rendering: pixelated; }
.secret { font: 500 14px var(--mono); letter-spacing: .08em; color: var(--text); background: var(--weak); border-radius: var(--radius); padding: 8px 10px; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.codes code { font-size: 14px; border-radius: var(--radius); background: var(--weak); padding: 8px 10px; text-align: center; }

/* Profile and security: the Identity pages, with their two tabs on top */
.manage { display: grid; gap: 16px; margin-top: 8px; max-width: 720px; }
.manage-nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.manage-nav a { flex: none; min-height: 40px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 99px; background: var(--weak); color: var(--text); font: 500 14px var(--sans); text-decoration: none; }
.manage-nav a.active { background: var(--text); color: var(--bg); }
.manage-body { display: grid; gap: 16px; align-content: start; }

/* accounts (F1). Each account carries --acc, its colour; statuses keep a shape besides their colour. */
.tally { display: flex; gap: 6px; flex-wrap: wrap; }
.tally span { font: 600 12px var(--sans); padding: 2px 9px; border-radius: 99px; }
.tally-ok { color: var(--ok); background: var(--ok-soft); }
.tally-err { color: var(--danger); background: var(--danger-soft); }
.tally-pause { color: var(--muted); background: var(--weak); }

.ledger-cols, .ledger-row { display: grid; grid-template-columns: 64px minmax(0, 1.6fr) 130px minmax(0, 1.3fr) 110px 110px; gap: 16px; align-items: center; padding: 0 12px; }
.ledger-cols { height: 34px; margin-top: 4px; font: 500 13px var(--sans); color: var(--muted); border-bottom: 1px solid var(--line); }
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger-row { min-height: 68px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.ledger-row:hover, .ledger-row.editing { background: color-mix(in srgb, var(--acc) 6%, var(--bg)); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); flex: none; }
.name { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; align-items: center; }
.alias { font-size: 12px; border: 1px dashed color-mix(in srgb, var(--acc) 55%, transparent); border-radius: 4px; color: color-mix(in srgb, var(--acc) 75%, var(--text)); padding: 0 6px; }
.prov { font-size: 13px; color: var(--muted); }

.status { display: flex; gap: 9px; align-items: flex-start; justify-self: start; padding: 5px 9px; border: 1px solid; border-radius: var(--radius); font: 500 13px var(--sans); }
.status .reason { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; margin-top: 2px; font: 13px var(--sans); color: var(--muted); }
.status .mark { width: 10px; height: 10px; flex: none; margin-top: 3px; }
.s-ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }
.s-ok .mark { background: var(--ok); border-radius: 50%; }
.s-err { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.s-err .mark { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid var(--danger); }
.s-pause { color: var(--muted); background: var(--weak); border-color: var(--line); }
.s-pause .mark { width: 9px; background: linear-gradient(90deg, var(--muted) 0 3px, transparent 3px 6px, var(--muted) 6px 9px); }
.s-wait { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.s-wait .mark { border: 1.5px solid var(--warn); border-radius: 50%; }

.confirm { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--danger-soft); }
.confirm p { flex: 1; min-width: 220px; }

/* signatures */
.signature-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 18px; }
.signature-list label { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.signature-list .tag { min-width: 0; padding: 1px 6px; font-size: 11px; }
.signature-list .addr { font-size: 14px; overflow-wrap: anywhere; }
.signature-list em { font: 13px var(--sans); color: var(--muted); font-style: normal; }
.signature-list .saved { font-size: 13px; color: var(--ok); }
.signature-list textarea { width: 100%; max-width: 560px; padding: 10px 12px; border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); resize: vertical; }
.signature-list textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* privacy */
.section-title { margin: 20px 0 6px; font: 600 15px/1.3 var(--sans); color: var(--text); }
.allow-list { list-style: none; margin: 0; padding: 0; }
.allow-list li { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.allow-list .addr { font-size: 14px; flex: 1; min-width: 200px; overflow-wrap: anywhere; }

/* notifications (F6.4): this device, the device list, the test */
.notify-this { display: grid; gap: 8px; justify-items: start; margin-bottom: 8px; }
.notify-hint { margin: 0; max-width: 64ch; color: var(--muted); }
.notify-on { margin: 0; display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.notify-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.notify-devices { list-style: none; margin: 0; padding: 0; }
.notify-devices li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.notify-device { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.notify-label { font-weight: 600; overflow-wrap: anywhere; }
.notify-chip { font: 600 12px var(--sans); color: var(--primary); background: var(--primary-soft); border-radius: 99px; padding: 2px 9px; }
.notify-meta { flex-basis: 100%; font-size: 13px; }
.notify-test { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; }

/* account editor drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(520px, 100%); background: var(--bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.drawer > header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer > header .display { font-size: 22px; }
/* focused by code when the drawer opens, never by Tab: no ring around a heading */
.drawer > header .display:focus { outline: none; }
.drawer > header .icon-btn { margin-left: auto; }
.drawer-body { flex: 1; overflow: auto; padding: 20px; display: grid; gap: 18px; align-content: start; }
.drawer-body .status-line { margin: 0; }
.drawer > footer { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.drawer > footer .grow { flex: 1; }
.field-label { font: 500 13px var(--sans); color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }
.input.upper { text-transform: uppercase; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 12px; }
.trio { display: grid; grid-template-columns: minmax(0, 1fr) 84px 120px; gap: 10px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--weak); }
.segmented button { min-height: 40px; padding: 0 12px; font: 500 14px var(--sans); color: var(--muted); background: none; border: 0; border-radius: 8px; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--acc, var(--primary)); }
.segmented.fit { display: inline-grid; grid-auto-columns: minmax(104px, auto); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 40px; height: 40px; border-radius: 50%; background: var(--acc); border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--bg); cursor: pointer; }
.swatches button[aria-checked="true"] { border-color: var(--text); }
.saved-secret { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 14px; color: var(--muted); }
.saved-secret button { margin-left: auto; min-height: 40px; background: none; border: 0; cursor: pointer; font: 600 14px var(--sans); color: var(--primary); }
.disclosure { border: 1px solid var(--line); border-radius: var(--radius); }
.disclosure-toggle { width: 100%; min-height: 44px; text-align: left; padding: 10px 12px; background: none; border: 0; cursor: pointer; font: 500 14px var(--sans); color: var(--text); }
.disclosure-toggle small { margin-left: 8px; color: var(--muted); }
.server { padding: 4px 12px 14px; display: grid; gap: 14px; }
.server h3 { margin-top: 6px; font: 600 13px var(--sans); color: var(--muted); }
.identities { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.identities li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--weak); font-size: 14px; overflow-wrap: anywhere; }
.identities em { margin-left: auto; font: normal 13px var(--sans); color: var(--muted); }
.note { font-size: 13px; color: var(--text); border-radius: var(--radius); background: var(--warn-soft); padding: 8px 10px; }
.test { border: 1px solid var(--line); border-radius: var(--radius); display: grid; }
.test-line { display: grid; grid-template-columns: 52px 20px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.test-line:last-child { border-bottom: 0; }
.test-line .proto { font: 600 12px var(--sans); color: var(--muted); padding-top: 1px; }
.test-line .res { color: var(--muted); }
.test-line .res b { font-weight: 500; color: var(--text); }
.test-line .res small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.glyph { font: 600 14px/1.2 var(--sans); }
.glyph.ok { color: var(--ok); }
.glyph.err { color: var(--danger); }
.glyph.idle { color: var(--muted); }
.glyph.wait { color: var(--muted); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* appearance, sync, profile: one row per setting */
.pref-group { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.pref-group h2 { font: 600 15px/1.3 var(--sans); margin-bottom: 4px; }
.pref-group .muted { font-size: 14px; }
.pref-control { display: grid; gap: 10px; align-content: start; justify-items: start; }
.saved { min-height: 18px; font-size: 13px; color: var(--ok); }
.input.narrow { width: min(360px, 100%); }
.sync-list { list-style: none; margin: 0; padding: 0; }
.sync-list li { display: grid; grid-template-columns: 60px minmax(0, 1.2fr) 150px minmax(0, 1.4fr) auto; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.sync-list .when { font-size: 13px; color: var(--muted); }

/* sorting settings */
.setting-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 8px 20px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-label { font: 500 14px var(--sans); color: var(--muted); }
.resort { display: grid; gap: 8px; justify-items: start; max-width: 70ch; }
.resort p { margin: 0; }
.confirm-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--radius); background: var(--danger-soft); }
.model-failing { border: 1px solid var(--danger); background: var(--danger-soft); padding: 10px 12px; max-width: 70ch; border-radius: var(--radius); }
.model-failing p { margin: 0 0 6px; }
.model-failing p:last-child { margin: 0; font-size: 13px; }
.built-in-rules { display: grid; gap: 10px; justify-items: start; max-width: 80ch; }
.built-in-rules p { margin: 0; }
.built-in-rules ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; width: 100%; }
.built-in-rules li { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.switch { display: flex; gap: 8px; align-items: center; min-height: 40px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch-name { font-weight: 600; }
.switch-what { color: var(--muted); font-size: 13px; }
.key-state { display: inline-flex; gap: 8px; align-items: center; }
.key-state .mark { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.key-state.ok .mark { background: var(--ok); }
.key-state.off .mark { background: var(--warn); }
.spend-bar { height: 6px; max-width: 320px; border-radius: 99px; background: var(--weak); margin-bottom: 6px; overflow: hidden; }
.spend-bar span { display: block; height: 6px; background: var(--ok); }
.small-mono { font-size: 13px; font-variant-numeric: tabular-nums; }
.input.tiny { width: 90px; display: inline-block; }
.money { font-size: 14px; color: var(--muted); margin-right: 4px; }

/* F6.1 learned rules: Settings, the reading pane line and the rule log. */
.learned-rules { display: grid; gap: 4px; max-width: 900px; }
.rules-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.rule-list { list-style: none; margin: 0 0 8px; padding: 0; }
.rule-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule-list.suggested li, .log-wrap .rule-list li { grid-template-columns: minmax(0, 1fr) auto; }
.rule-list li.off .rule-what { opacity: .55; }
.rule-switch input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.rule-what { display: grid; gap: 3px; min-width: 0; }
.rule-cond { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rule-cond .addr, .rule-edit .addr { font: 500 14px var(--sans); overflow-wrap: anywhere; }
.rule-cond .arrow { color: var(--muted); }
.rule-cond .pill { font: 500 12px var(--sans); color: var(--muted); background: var(--weak); border-radius: 99px; padding: 1px 8px; }
.rule-meta { font-size: 13px; color: var(--muted); }
.rule-meta .warn { color: var(--danger); }
.rule-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rule-edit .input { width: auto; }
.block-list.rule-list li, .notrel-list.rule-list li { grid-template-columns: minmax(0, 1fr) auto; }
.notrel-list .addr { overflow-wrap: anywhere; }
.notrel-subject { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--muted); }
.notrel-inuse { font: 600 12px var(--sans); padding: 2px 9px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.log-back { margin: 0 0 8px; font-size: 14px; }
.log-tabs { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.log-tabs a { flex: none; min-height: 40px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 99px; background: var(--weak); color: var(--text); text-decoration: none; white-space: nowrap; font: 500 14px var(--sans); }
.log-tabs a[aria-current="page"] { background: var(--text); color: var(--bg); }
.log-wrap { overflow-x: auto; margin-top: 12px; }
.rule-log { width: 100%; border-collapse: collapse; font-size: 14px; }
.rule-log th { text-align: left; font: 500 13px var(--sans); color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.rule-log td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--muted); }
.rule-log td a { color: inherit; text-decoration: none; }
.rule-log td a b { color: var(--text); font-weight: 600; }
.rule-log td .rule-of { display: block; font-size: 13px; color: var(--muted); }
.rule-log .when { font-size: 13px; color: var(--muted); white-space: nowrap; }
.rule-log .kind { font: 600 12px var(--sans); padding: 2px 9px; border-radius: 99px; background: var(--weak); color: var(--muted); white-space: nowrap; }
.rule-log .kind.ok { background: var(--ok-soft); color: var(--ok); }
.rule-log .kind.bad { background: var(--danger-soft); color: var(--danger); }
.rule-log .kind.acc { background: var(--primary-soft); color: var(--primary); }
.log-more { margin-top: 12px; }
.log-tabs .tab-n, .bill-tabs .tab-n { font-size: 13px; color: inherit; opacity: .7; margin-left: 6px; font-variant-numeric: tabular-nums; }

/* accounting settings */
.accounting-form { margin-top: 8px; }
.mono-input { max-width: 440px; }
.setting-hint { font-size: 13px; margin: 6px 0 0; max-width: 60ch; }
.saved-line { color: var(--ok); font-size: 14px; margin: 10px 0 0; }

/* Automation > Bills to ClearFacts: the history. The row markup is shared with the bill cards (mail.css); here it
   only gets the page's spacing. */
.bill-history .bill-tabs { margin: 8px 0 6px; }
.bill-history .bill-setup { margin: 8px 0 4px; }
.bill-history .bill { padding: 14px 0; }
.bill-history .to-line { margin-top: 14px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.bill-history .bill-who .addr, .bill-history .bill-who .when, .bill-history .file-chip, .bill-history .bill-state, .bill-history .mono { font-family: var(--sans); }
.bill-history .bill-who .when { font-size: 13px; }
.bill-history .file-chip, .bill-history .bill-state { font-size: 12px; border-radius: 99px; padding: 2px 9px; }

/* Labelling and eval (F6 item 5): Automation > Eval and its Label page. */
.label-none { margin-top: 18px; }
.label-card { max-width: 760px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); overflow: hidden; }
.label-progress { height: 4px; background: var(--weak); }
.label-progress span { display: block; height: 4px; background: var(--primary); }
.label-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font: 500 13px var(--sans); color: var(--muted); }
.label-mail { padding: 16px; min-width: 0; }
.label-mail .meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; overflow-wrap: anywhere; }
.label-mail h2 { margin: 0 0 10px; font-size: 18px; overflow-wrap: anywhere; }
.label-mail .snip { color: var(--muted); font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 18em; overflow-y: auto; }
.label-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 16px; border-top: 1px solid var(--line); }
.label-key { display: flex; gap: 8px; align-items: center; min-width: 0; min-height: 44px; padding: 10px; border: 1.5px solid transparent; border-radius: var(--radius); background: var(--weak); color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.label-key:hover { border-color: var(--line); }
.label-key[aria-pressed="true"] { border-color: var(--ok); background: var(--ok-soft); }
.label-key kbd, .label-foot kbd { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.label-foot { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 0 16px 16px; font-size: 13px; color: var(--muted); }
.label-toggle[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.label-hint { margin-left: auto; }
.eval-run { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 14px; font-size: 14px; }
.eval-pass { color: var(--ok); }
.eval-fail { color: var(--danger); }
.eval-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.eval-gates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.eval-gates > div { padding: 12px 10px; border-radius: var(--radius-card); background: var(--weak); min-width: 0; }
.eval-gates .n { font: 700 24px/1 var(--sans); font-variant-numeric: tabular-nums; }
.eval-gates .n.ok { color: var(--ok); }
.eval-gates .n.no { color: var(--danger); }
.eval-gates .n.unjudged { color: var(--muted); }
.eval-gates .l { display: block; margin-top: 6px; font: 500 13px var(--sans); color: var(--muted); }
.eval-gates .few { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.eval-table { overflow-x: auto; margin-top: 18px; }
.eval-table table { border-collapse: collapse; width: 100%; font-size: 14px; }
.eval-table th { font: 500 13px var(--sans); color: var(--muted); text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.eval-table th:first-child, .eval-table td:first-child { text-align: left; }
.eval-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.eval-table td.bad { color: var(--danger); }
.eval-table td.good { color: var(--ok); }
.eval-table td.few { color: var(--muted); text-align: center; }
.eval-scores { min-width: 560px; }
.eval-confusion { min-width: 640px; }
.eval-confusion tbody th { text-align: left; color: var(--muted); }
.eval-confusion td.hit { background: var(--ok-soft); color: var(--text); }
.eval-confusion td.miss { background: var(--danger-soft); padding: 0; }
.eval-confusion td.miss button { width: 100%; min-height: 36px; padding: 8px 10px; border: 0; background: none; color: var(--text); font: inherit; text-align: right; cursor: pointer; text-decoration: underline; }
.eval-confusion td.miss button[aria-pressed="true"] { outline: 2px solid var(--primary); outline-offset: -2px; }
.eval-note { font-size: 13px; color: var(--muted); margin-top: 8px; max-width: 80ch; }
.eval-cell ul, .eval-history { list-style: none; margin: 0; padding: 0; }
.eval-cell li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
.eval-cell a { color: var(--muted); text-decoration: none; }
.eval-cell a b { color: var(--text); }
.eval-history li a { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr); gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 14px; font-variant-numeric: tabular-nums; }
.eval-history li[aria-current] a { color: var(--text); }

/* Phone: one column everywhere, lists stack their parts. */
@media (max-width: 899px) {
  .accounts-head .btn { margin-left: 0; }
  .ledger-cols { display: none; }
  .ledger-row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "tag who" "status status" "prov when" "acts acts"; row-gap: 10px; align-items: start; padding: 14px 0; }
  .ledger-row > .tag { grid-area: tag; }
  .ledger-row > .who { grid-area: who; }
  .ledger-row > .status { grid-area: status; }
  .ledger-row > .prov { grid-area: prov; }
  .ledger-row > .when { grid-area: when; text-align: right; }
  .ledger-row > .acts { grid-area: acts; justify-content: flex-start; }
  .status-line li { grid-template-columns: auto minmax(0, 1fr); }
  .status-line li .btn { grid-column: 1 / -1; justify-self: start; }
  .pair, .trio { grid-template-columns: 1fr; }
  .segmented:not(.fit) { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .drawer > footer .grow { display: none; }
  .drawer > footer .btn { flex: 1; }
  .pref-group { grid-template-columns: 1fr; gap: 10px; }
  .sync-list li { grid-template-columns: auto minmax(0, 1fr); row-gap: 8px; }
  .sync-list li .status, .sync-list li .when, .sync-list li .acts { grid-column: 1 / -1; }
  .setting-row { grid-template-columns: 1fr; }
  .icon-btn, .identities .icon-btn { width: 44px; height: 44px; }
  .swatches button { width: 44px; height: 44px; }
  .rule-list li { grid-template-columns: 34px minmax(0, 1fr); }
  .rule-list li .row-acts { grid-column: 2; justify-content: flex-start; }
  .rule-list.suggested li, .log-wrap .rule-list li, .block-list.rule-list li, .notrel-list.rule-list li { grid-template-columns: minmax(0, 1fr); }
  .rule-list.suggested li .row-acts, .log-wrap .rule-list li .row-acts, .block-list.rule-list li .row-acts, .notrel-list.rule-list li .row-acts { grid-column: 1; }
  .rule-log { min-width: 560px; }
  .label-keys { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .label-hint { margin-left: 0; }
  .eval-gates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .eval-history li a { gap: 10px; }
}

@media (min-width: 900px) {
  .automation-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .automation-grid > section:last-child .section-head { margin-top: 0; }
}
