/* Website Monitor — clean, minimal, audit-oriented. No external fonts or frameworks. */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f1ed;
  --border: #e3e3dd;
  --border-strong: #cfcfc7;
  --text: #1b1b19;
  --muted: #6a6a63;
  --accent: #2b59c3;
  --accent-soft: #e8eefb;
  --ok: #1d7a45;       --ok-soft: #e5f4ea;
  --changed: #a35f00;  --changed-soft: #fcf1de;
  --error: #b42318;    --error-soft: #fdecea;
  --blocked: #b54708;  --blocked-soft: #fdf0e4;
  --revert: #2b59c3;   --revert-soft: #e8eefb;
  --neutral: #6a6a63;  --neutral-soft: #efefea;
  --add: #1d7a45;      --add-bg: #e7f5ec;
  --del: #b42318;      --del-bg: #fcebea;
  --code-bg: #fbfbf9;
  --tok-tag: #22863a; --tok-attr: #6f42c1; --tok-str: #032f62; --tok-com: #8a8a80; --tok-doc: #b35900;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1c1c1a; --surface-2: #232320; --border: #2e2e2a; --border-strong: #3d3d38;
    --text: #ececE6; --muted: #9a9a91; --accent: #7aa2ff; --accent-soft: #1f2940;
    --ok: #5cc98a; --ok-soft: #173424; --changed: #f0b45a; --changed-soft: #3a2c14;
    --error: #ff7b72; --error-soft: #3d1c1a; --blocked: #f5a05a; --blocked-soft: #3a2616;
    --revert: #7aa2ff; --revert-soft: #1f2940; --neutral: #a3a39a; --neutral-soft: #2a2a26;
    --add: #6fd79a; --add-bg: #15301f; --del: #ff8f87; --del-bg: #3a1a18; --code-bg: #181816;
    --tok-tag: #7ee787; --tok-attr: #d2a8ff; --tok-str: #a5d6ff; --tok-com: #8b8b82; --tok-doc: #ffa657;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1c1c1a; --surface-2: #232320; --border: #2e2e2a; --border-strong: #3d3d38;
  --text: #ececE6; --muted: #9a9a91; --accent: #7aa2ff; --accent-soft: #1f2940;
  --ok: #5cc98a; --ok-soft: #173424; --changed: #f0b45a; --changed-soft: #3a2c14;
  --error: #ff7b72; --error-soft: #3d1c1a; --blocked: #f5a05a; --blocked-soft: #3a2616;
  --revert: #7aa2ff; --revert-soft: #1f2940; --neutral: #a3a39a; --neutral-soft: #2a2a26;
  --add: #6fd79a; --add-bg: #15301f; --del: #ff8f87; --del-bg: #3a1a18; --code-bg: #181816;
  --tok-tag: #7ee787; --tok-attr: #d2a8ff; --tok-str: #a5d6ff; --tok-com: #8b8b82; --tok-doc: #ffa657;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 640; }
h3 { font-size: .95rem; font-weight: 640; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .85em; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.hidden, [hidden] { display: none !important; }
.stack > * + * { margin-top: 1rem; }

/* ---------- shell ---------- */
.topbar { display: none; }
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); padding: 4px 8px 14px; font-size: 1rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-grid; place-items: center; color: #fff; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: .92rem; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.nav-sites { flex: 1 1 auto; min-height: 120px; overflow-y: auto; margin-top: 4px; }
.nav-sites a { font-size: .88rem; overflow: hidden; }
.nav-other summary { cursor: pointer; padding: 7px 10px; border-radius: 8px; font-size: .92rem; list-style: none; }
.nav-other summary::-webkit-details-marker { display: none; }
.nav-other summary::before { content: "\25B8"; display: inline-block; width: 1em; color: var(--muted); }
.nav-other[open] summary::before { content: "\25BE"; }
.nav-other summary:hover { background: var(--surface-2); }
.nav-other .nav { padding-left: 10px; }
.nav-sites a span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { flex: none; margin-top: auto; padding-top: 12px; display: grid; gap: 8px; }
.main { padding: 28px 32px 64px; max-width: 1180px; width: 100%; }
.drawer-backdrop { display: none; }

@media (max-width: 900px) {
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .topbar .brand { padding: 0; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .18s ease; }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .main { padding: 18px 16px 48px; }
}
.menu-btn { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 36px; height: 34px; font-size: 18px; cursor: pointer; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--error); border-color: var(--error); background: transparent; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }
input[type=text], input[type=url], input[type=search], input[type=password], input[type=date], input[type=number], select, textarea {
  font: inherit; font-size: .92rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { font-family: var(--mono); font-size: .85rem; min-height: 110px; }
label { font-weight: 600; font-size: .88rem; display: block; margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check-row input { width: auto; }

/* ---------- cards / layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid-2 > .card + .card, .grid-3 > .card + .card, .tree-wrap > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: .9rem; border: 1px solid; }
.banner-warn { background: var(--changed-soft); border-color: var(--changed); color: var(--text); }
.banner-error { background: var(--error-soft); border-color: var(--error); }
.banner-info { background: var(--accent-soft); border-color: var(--accent); }
.flash { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: .9rem; }

/* ---------- status ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--neutral); }
.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: .88rem; white-space: nowrap; }
.status-ok { color: var(--ok); } .status-ok .dot, .dot-ok { background: var(--ok); }
.status-changed { color: var(--changed); } .status-changed .dot, .dot-changed { background: var(--changed); }
.status-error { color: var(--error); } .status-error .dot, .dot-error { background: var(--error); }
.status-blocked { color: var(--blocked); } .status-blocked .dot, .dot-blocked { background: var(--blocked); }
.status-pending, .status-baseline { color: var(--neutral); }
.status-revert { color: var(--revert); } .status-revert .dot, .dot-revert { background: var(--revert); }
.status-lg { font-size: 1.25rem; gap: 10px; }
.status-lg .dot { width: 12px; height: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; font-size: .78rem; color: var(--text); white-space: nowrap; }
.chip-changed { background: var(--changed-soft); border-color: transparent; color: var(--changed); }
.chip-add { background: var(--add-bg); color: var(--add); border-color: transparent; }
.chip-del { background: var(--del-bg); color: var(--del); border-color: transparent; }
.chip-state-ADDED { background: var(--add-bg); color: var(--add); border-color: transparent; }
.chip-state-REMOVED { background: var(--del-bg); color: var(--del); border-color: transparent; }
.chip-state-CHANGED { background: var(--changed-soft); color: var(--changed); border-color: transparent; }
.code-tag { font-family: var(--mono); font-size: .74rem; color: var(--muted); letter-spacing: .01em; }

/* ---------- dashboard ---------- */
.site-list { display: grid; gap: 10px; }
.site-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; color: var(--text); }
.site-card:hover { border-color: var(--border-strong); text-decoration: none; }
.site-name { font-weight: 650; font-size: 1rem; }
.site-url { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-status { text-align: right; display: grid; gap: 2px; justify-items: end; }
@media (max-width: 600px) { .site-card { grid-template-columns: minmax(0, 1fr); } .site-status { text-align: left; justify-items: start; } }
.empty { text-align: center; padding: 56px 24px; }
.empty h2 { font-size: 1.2rem; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 20px; }

/* ---------- website header / tabs ---------- */
.site-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.site-head h1 { margin-bottom: 2px; }
.site-head .url { color: var(--muted); font-size: .9rem; word-break: break-all; }
.tabs { position: relative; display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; font-size: .92rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.subtabs { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.subtabs a, .subtabs button { padding: 5px 12px; border-radius: 7px; color: var(--muted); font-size: .86rem; font-weight: 550; background: none; border: 0; cursor: pointer; font-family: inherit; }
.subtabs a.active, .subtabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.subtabs a:hover { text-decoration: none; color: var(--text); }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 600px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd { margin-bottom: 8px; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
.stat .l { color: var(--muted); font-size: .8rem; }
.comp-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.comp { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.comp .l { font-size: .78rem; color: var(--muted); }
.comp .v { font-weight: 600; font-size: .9rem; }
.comp.changed { border-color: var(--changed); background: var(--changed-soft); }
.comp.changed .v { color: var(--changed); }
.count-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.count-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.count-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.count-table tr:last-child td { border-bottom: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }

/* ---------- timeline ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-chips a { border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .84rem; color: var(--text); background: var(--surface); }
.filter-chips a.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter-chips a:hover { text-decoration: none; border-color: var(--border-strong); }
.tl-day { font-size: .8rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 22px 0 8px; }
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item > .dot { position: absolute; left: -24px; top: 6px; width: 12px; height: 12px; border: 2px solid var(--bg); box-sizing: content-box; }
.tl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
a.tl-card { display: block; color: var(--text); }
a.tl-card:hover { border-color: var(--border-strong); text-decoration: none; }
.tl-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tl-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; min-width: 44px; }
.tl-title { font-weight: 650; }
.tl-lines { margin: 6px 0 0; padding: 0; list-style: none; font-size: .88rem; color: var(--text); }
.tl-lines li { padding: 1px 0; }
.tl-lines li::before { content: "–"; color: var(--muted); margin-right: 8px; }
.tl-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: .85rem; }
.tl-item.compact .tl-card { padding: 7px 14px; }
.ev { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; }
.ev-ok { color: var(--ok); } .ev-ok .dot { background: var(--ok); }
.ev-changed { color: var(--changed); } .ev-changed .dot { background: var(--changed); }
.ev-error { color: var(--error); } .ev-error .dot { background: var(--error); }
.ev-blocked { color: var(--blocked); } .ev-blocked .dot { background: var(--blocked); }
.ev-revert { color: var(--revert); } .ev-revert .dot { background: var(--revert); }
.ev-baseline { color: var(--neutral); } .ev-baseline .dot { background: var(--neutral); }
.load-more { text-align: center; margin-top: 12px; }

/* ---------- before / after ---------- */
.change-block { border-top: 1px solid var(--border); padding: 14px 0; }
.change-block:first-of-type { border-top: 0; padding-top: 4px; }
.change-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.change-head .field { font-weight: 600; margin: 0; }
.ba { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ba-col { padding: 10px 12px; min-width: 0; }
.ba-col + .ba-col { border-left: 1px solid var(--border); }
.ba-before { background: var(--del-bg); }
.ba-after { background: var(--add-bg); }
.ba-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ba pre { font-family: var(--font); font-size: .92rem; }
.ba .absent { color: var(--muted); font-style: italic; }
@media (max-width: 700px) { .ba { grid-template-columns: minmax(0, 1fr); } .ba-col + .ba-col { border-left: 0; border-top: 1px solid var(--border); } }
.dlist { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: .82rem; border: 1px solid var(--border); border-radius: 8px; max-height: 420px; overflow: auto; }
.dlist li { padding: 3px 10px; word-break: break-all; white-space: pre-wrap; border-bottom: 1px solid var(--border); }
.dlist li:last-child { border-bottom: 0; }
.dlist .add { background: var(--add-bg); color: var(--add); }
.dlist .del { background: var(--del-bg); color: var(--del); }
.dlist .add::before { content: "+ "; } .dlist .del::before { content: "- "; }
.dlist .mod { background: var(--changed-soft); }
.dlist .muted-text { color: var(--muted); }
.counts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.counts-grid a { display: flex; justify-content: space-between; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: .9rem; }
.counts-grid a:hover { border-color: var(--accent); text-decoration: none; }
.counts-grid a b { font-variant-numeric: tabular-nums; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; scroll-margin-top: 70px; }
details summary { cursor: pointer; color: var(--accent); font-size: .88rem; margin: 6px 0; }

/* ---------- code viewer / diff ---------- */
.code-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.code-toolbar input[type=search] { max-width: 280px; }
.code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 72vh; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.code table { border-collapse: collapse; width: 100%; }
.code td { padding: 0 10px; vertical-align: top; white-space: pre-wrap; word-break: break-all; }
.code td.ln { color: var(--muted); text-align: right; user-select: none; width: 1%; white-space: nowrap; border-right: 1px solid var(--border); background: var(--surface-2); font-size: 11.5px; }
.code tr.hit td.src { background: var(--changed-soft); }
.code tr.hit-current td.src { outline: 2px solid var(--changed); outline-offset: -2px; }
.code tr.d-add td.src { background: var(--add-bg); }
.code tr.d-del td.src { background: var(--del-bg); }
.code tr.d-hunk td { background: var(--accent-soft); color: var(--accent); }
.code tr.d-meta td { color: var(--muted); }
.code .more { padding: 10px; text-align: center; }
.t-tag { color: var(--tok-tag); } .t-attr { color: var(--tok-attr); } .t-str { color: var(--tok-str); }
.t-com { color: var(--tok-com); font-style: italic; } .t-doc { color: var(--tok-doc); }
.diff-stats { display: inline-flex; gap: 8px; font-family: var(--mono); font-size: .85rem; }
.diff-stats .a { color: var(--add); } .diff-stats .r { color: var(--del); }

/* ---------- redirect tree ---------- */
.tree-toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.tree-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.tree-wrap.compare { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .tree-wrap, .tree-wrap.compare { grid-template-columns: minmax(0, 1fr); } }
.tree-canvas { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); height: 460px; overflow: hidden; touch-action: none; cursor: grab; }
.tree-canvas.dragging { cursor: grabbing; }
.tree-canvas svg { width: 100%; height: 100%; display: block; user-select: none; }
.tree-title { position: absolute; top: 10px; left: 12px; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); pointer-events: none; }
.tree-node rect { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.2; }
.tree-node.final rect { stroke: var(--ok); stroke-width: 2; }
.tree-node.manual rect { stroke: var(--accent); stroke-dasharray: 2 3; }
.tree-node.blocked rect { stroke: var(--error); stroke-dasharray: 5 3; }
.tree-node.state-ADDED rect { fill: var(--add-bg); stroke: var(--add); }
.tree-node.state-REMOVED rect { fill: var(--del-bg); stroke: var(--del); stroke-dasharray: 5 3; }
.tree-node.state-CHANGED rect { fill: var(--changed-soft); stroke: var(--changed); }
.tree-node .rank-pill { fill: var(--accent); stroke: none; }
.tree-node text.rank-text { fill: #fff; font-weight: 700; font-size: 10.5px; }
.tree-node.selected rect { stroke: var(--accent); stroke-width: 2.5; }
.tree-node { cursor: pointer; outline: none; }
.tree-node:focus-visible rect { stroke: var(--accent); stroke-width: 2.5; }
.tree-node text { fill: var(--text); font: 12px var(--font); }
.tree-node text.url { font-family: var(--mono); font-size: 11.5px; }
.tree-node text.meta { fill: var(--muted); font-size: 11px; }
.tree-node text.badge { font-weight: 700; font-size: 10.5px; letter-spacing: .05em; }
.tree-edge line, .tree-edge path { stroke: var(--border-strong); stroke-width: 1.6; fill: none; }
.tree-edge text { fill: var(--muted); font: 600 11px var(--font); }
.tree-edge rect { fill: var(--surface-2); stroke: var(--border); }
.node-panel h3 { margin-bottom: 10px; }
.node-panel .kv { grid-template-columns: 110px minmax(0, 1fr); font-size: .86rem; }
.headers-box { margin-top: 10px; max-height: 260px; overflow: auto; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: .78rem; }
.chain-text { font-family: var(--mono); font-size: .84rem; line-height: 1.7; }
.chain-text .hop { display: block; word-break: break-all; }
.chain-text .arrow { display: block; color: var(--muted); padding-left: 12px; }

/* ---------- progress ---------- */
.steps { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.steps li .ic { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); display: inline-grid; place-items: center; font-size: 12px; flex: none; }
.steps li.done { color: var(--text); }
.steps li.done .ic { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active .ic { border-color: var(--accent); border-top-color: transparent; animation: spin 1s linear infinite; }
.steps li.failed { color: var(--error); font-weight: 600; }
.steps li.failed .ic { background: var(--error); border-color: var(--error); color: #fff; }
.steps li.skipped { color: var(--muted); }
.steps li.skipped .ic { border-style: dashed; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .steps li.active .ic { animation: none; } }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 14px; align-items: center; }
.login-box { max-width: 380px; margin: 10vh auto; }

/* ---------- finalization additions ---------- */
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
@media (max-width: 1000px) { .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .summary-grid { gap: 8px; }
  .summary-grid .stat { padding: 9px 10px; }
  .summary-grid .stat .v { font-size: 1.15rem; }
  .summary-grid .stat .l { font-size: .74rem; line-height: 1.25; }
  .site-head h1 { font-size: 1.3rem; }
  .tree-canvas { height: 400px; }
}
.stat-changed { border-color: var(--changed); } .stat-changed .v { color: var(--changed); }
.stat-blocked { border-color: var(--blocked); } .stat-blocked .v { color: var(--blocked); }
.stat-error { border-color: var(--error); } .stat-error .v { color: var(--error); }
.comp.unavailable { border-style: dashed; } .comp.unavailable .v { color: var(--muted); }

/* ---------- redirect time machine ---------- */
.tm-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tm-when { text-align: center; flex: 1 1 200px; }
.btn.is-disabled { opacity: .4; pointer-events: none; }
.dot.tm-hollow { background: var(--bg) !important; border: 2px solid var(--border-strong) !important; width: 8px; height: 8px; }
.chain-inline { font-family: var(--mono); font-size: .84rem; margin-top: 4px; }
.chip-redirect { background: var(--revert-soft); color: var(--revert); border-color: transparent; }
a.chip-redirect:hover { text-decoration: none; filter: brightness(.97); }
.chip-blocked { background: var(--blocked-soft); color: var(--blocked); border-color: transparent; margin-left: auto; }
.paste-box { width: 100%; min-height: 140px; font-family: var(--mono); font-size: .8rem; }
.chain { margin: 0; padding-left: 1.3em; }
.chain li { margin: 2px 0; }

/* floating "add website" button */
.fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 32px; line-height: 54px; text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.28); }
.fab:hover { text-decoration: none; filter: brightness(1.08); }
.fab:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
@media (max-width: 720px) { .fab { right: 16px; bottom: 16px; } }

/* sidebar domain search */
.side-search { position: relative; margin: 8px 0 0; }
.side-search input { width: 100%; }
.side-results { margin-top: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); max-height: 60vh; overflow-y: auto; }
.side-results a { display: block; padding: 7px 10px; color: var(--text); border-top: 1px solid var(--border); }
.side-results a:hover { background: var(--surface-2); text-decoration: none; }
.sr-title { font-size: .86rem; font-weight: 600; word-break: break-all; }
.sr-sub { font-size: .74rem; color: var(--muted); word-break: break-all; }
.sr-head { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 7px 10px 3px; }
.side-results .sr-all { text-align: center; font-size: .8rem; color: var(--accent); }

/* Icon-only copy / open buttons next to a URL */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; margin-left: 6px; vertical-align: middle; border: 1px solid var(--border, #ddd); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.icon-btn:hover { color: inherit; background: rgba(127,127,127,.12); }
.icon-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.copied { color: #1f7a4d; border-color: #1f7a4d; }
.icon-btn.copy-failed { color: #b42318; border-color: #b42318; }

/* Read-only account: every form that changes something is hidden (the server refuses it as well) */
.role-viewer form[method="post"]:not(.keep), .role-viewer [data-inline-discover], .role-viewer .btn-danger { display: none !important; }

/* ---------- redirect tree: full screen ---------- */
.tree-wrap:fullscreen, .tree-wrap.is-full { background: var(--bg, var(--surface)); padding: 12px; overflow: auto; gap: 12px; }
.tree-wrap.is-full { position: fixed; inset: 0; z-index: 1000; }
.tree-wrap:fullscreen .tree-canvas, .tree-wrap.is-full .tree-canvas { height: calc(100vh - 24px); }
.tree-wrap:fullscreen.compare .tree-canvas, .tree-wrap.is-full.compare .tree-canvas { height: calc(100vh - 24px); }
/* full screen is for the tree only: no node detail panel, the tree takes the whole width */
.tree-wrap:fullscreen .node-panel, .tree-wrap.is-full .node-panel { display: none; }
.tree-wrap:fullscreen:not(.compare), .tree-wrap.is-full:not(.compare) { grid-template-columns: minmax(0, 1fr); }


/* Ranking page */
.rk-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.rk-timeline { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.rk-tick { flex: 1 0 110px; text-align: center; font: inherit; color: var(--text); cursor: pointer; border: 1px solid var(--border); border-radius: 8px; padding: 10px 8px; background: var(--surface-2, var(--surface)); }
.rk-tick:hover { border-color: var(--border-strong); }
.rk-tick-on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.rk-tick-time { font-weight: 600; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.rk-tick-mv { display: flex; gap: 6px; justify-content: center; margin-top: 4px; min-height: 1.2em; }
.rk-up, .rk-new { color: var(--ok); } .rk-down { color: var(--changed); } .rk-lost { color: var(--error); }
.rk-cards { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 12px; align-items: flex-start; scroll-snap-type: x proximity; }
.rk-card { flex: 0 0 340px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.rk-card .rk-kw { font-weight: 700; font-size: 1rem; margin-bottom: 8px; overflow-wrap: anywhere; }
.rk-tbl { font-size: .82rem; }
.rk-tbl th { font-size: .72rem; }
.rk-tbl td.rk-num { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rk-row { cursor: pointer; }
.rk-row:hover td { background: var(--surface-2, var(--bg)); }
.rk-row-on td { background: var(--accent-soft); }
.rk-info { white-space: nowrap; }
.rk-info.rk-t-up { color: var(--ok); } .rk-info.rk-t-down { color: var(--changed); } .rk-info.rk-t-lost { color: var(--error); }
.rk-info.rk-t-new, .rk-info.rk-t-returned { color: var(--accent); } .rk-info.rk-t-same { color: var(--muted); }
.rk-chart { width: 100%; overflow-x: auto; }
.rk-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.rk-chip { font: inherit; font-size: .78rem; cursor: pointer; }
.rk-chip:hover { border-color: var(--border-strong); }
.rk-chip-on { outline: 2px solid var(--accent); outline-offset: 1px; }
.rk-legend-items { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 10px; }
.rk-lg { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .8rem; color: var(--text); cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.rk-lg-on { outline: 2px solid var(--accent); outline-offset: 1px; }
.rk-sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Ranking movement matrix */
.rk-summary { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 10px; }
.rk-sum-i { color: var(--muted); }
.rk-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.rk-tools input[type=search] { flex: 1 1 220px; max-width: 320px; }
.rk-matrix { font-size: .85rem; }
.rk-matrix th.rk-c, .rk-matrix td.rk-c { text-align: center; white-space: nowrap; padding: 4px 6px; }
.rk-matrix td.rk-kwc { font-weight: 600; min-width: 140px; }
.rk-colh { cursor: pointer; }
.rk-colh:hover { color: var(--accent); }
.rk-colh-d { font-weight: 400; font-size: .7rem; color: var(--muted); }
.rk-matrix .rk-col-on { background: var(--accent-soft); }
.rk-cell { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 52px; padding: 3px 6px; border-radius: 6px; line-height: 1.15; font-variant-numeric: tabular-nums; background: var(--neutral-soft); color: var(--text); font-size: .8rem; }
.rk-cell b { font-size: .9rem; }
.rk-cell small { font-size: .68rem; font-weight: 600; }
.rk-cell.rk-top10 b { color: var(--accent); }
.rk-cell.rk-top3 { box-shadow: 0 0 0 1.5px var(--accent) inset; }
.rk-c-up { background: var(--ok-soft); } .rk-c-up small { color: var(--ok); }
.rk-c-down { background: var(--changed-soft); } .rk-c-down small { color: var(--changed); }
.rk-c-lost { background: var(--error-soft); color: var(--error); font-weight: 700; }
.rk-c-new, .rk-c-returned { background: var(--accent-soft); } .rk-c-new small, .rk-c-returned small { color: var(--accent); }
.rk-c-none { background: none; color: var(--muted); }
.rk-net { font-weight: 700; font-variant-numeric: tabular-nums; }
.rk-net.rk-t-up { color: var(--ok); } .rk-net.rk-t-down { color: var(--changed); } .rk-net.rk-t-lost { color: var(--error); } .rk-net.rk-t-same { color: var(--muted); }
.rk-legend .rk-cell { min-width: 0; flex-direction: row; gap: 4px; padding: 1px 6px; }

/* Redirect tree: horizontal change timeline */
.rt-track { display: flex; overflow-x: auto; padding: 4px 2px 10px; scroll-behavior: smooth; }
.rt-node { position: relative; flex: 0 0 auto; width: 128px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; color: var(--text); border-radius: 8px; text-align: center; }
.rt-node:hover { text-decoration: none; background: var(--surface-2, var(--bg)); }
.rt-node::before { content: ""; position: absolute; left: 0; right: 0; top: 33px; height: 2px; background: var(--border-strong); }
.rt-node:first-child::before { left: 50%; } .rt-node:last-child::before { right: 50%; }
.rt-d { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rt-dot { position: relative; z-index: 1; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); box-sizing: border-box; }
.rt-final .rt-dot { border-color: var(--error); }
.rt-on .rt-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rt-final.rt-on .rt-dot { background: var(--error); box-shadow: 0 0 0 4px var(--error-soft); }
.rt-t { font-weight: 600; font-size: .95rem; font-variant-numeric: tabular-nums; }
.rt-on .rt-t { color: var(--accent); }
.rt-f { font-size: .72rem; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-now { color: var(--ok); font-size: .68rem; font-weight: 600; display: block; }
#rt-main.rt-busy { opacity: .6; transition: opacity .15s; }
