/* ==========================================================================
   R20 Hosting · DR Control — layout and components
   RTL-first: only logical properties (inline/block), so English (LTR) mirrors
   automatically. Tokens live in tokens.css.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[dir="rtl"] { --dir: -1; }
html[dir="ltr"] { --dir: 1; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-1);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.3; font-weight: 600; letter-spacing: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.hidden { display: none !important; }
html[dir="ltr"] .flip-ltr { transform: scaleX(-1); }
.flip-rtl { transition: transform var(--t-fast) var(--ease); }
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---- Canvas ------------------------------------------------------------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: linear-gradient(165deg, var(--bg-0), var(--bg-1) 62%); pointer-events: none; }
.bg i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: var(--blob-opacity); will-change: transform; }
.bg i:nth-child(1) { width: 560px; height: 560px; background: var(--blob-1); inset-block-start: -180px; inset-inline-end: -120px; animation: drift-a 26s var(--ease-in-out) infinite alternate; }
.bg i:nth-child(2) { width: 480px; height: 480px; background: var(--blob-2); inset-block-end: -160px; inset-inline-start: -140px; animation: drift-b 32s var(--ease-in-out) infinite alternate; }
.bg i:nth-child(3) { width: 380px; height: 380px; background: var(--blob-3); inset-block-start: 38%; inset-inline-start: 42%; animation: drift-c 38s var(--ease-in-out) infinite alternate; opacity: calc(var(--blob-opacity) * .7); }
@keyframes drift-a { to { transform: translate3d(calc(var(--dir) * -90px), 70px, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(calc(var(--dir) * 110px), -60px, 0) scale(1.12); } }
@keyframes drift-c { to { transform: translate3d(calc(var(--dir) * -70px), -90px, 0) scale(.92); } }

/* ---- App shell ---------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; inset-block-start: 0; height: 100dvh; z-index: var(--z-sidebar);
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-4);
  background: var(--surface); border-inline-end: 1px solid var(--border);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%); backdrop-filter: blur(var(--blur)) saturate(150%);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-2) var(--sp-3); }
.brand__mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(140deg, #3b82f6, #1d4ed8 55%, #0891b2);
  box-shadow: 0 8px 20px -6px rgba(37, 99, 235, .6), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.brand__mark .icon { width: 22px; height: 22px; }
.brand__name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand__sub { font-size: 12px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding-block-end: var(--sp-2); }
.nav__label { font-size: 12px; font-weight: 600; color: var(--text-3); padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; padding: 0 var(--sp-3);
  border: 0; background: transparent; border-radius: var(--r-md); color: var(--text-2); font-weight: 500; text-align: start; width: 100%;
  position: relative; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-sunken); color: var(--text); text-decoration: none; }
.nav-item .icon { width: 20px; height: 20px; flex: none; }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav-item.is-active::before {
  content: ""; position: absolute; inset-inline-start: -4px; inset-block: 10px; width: 4px; border-radius: 4px; background: var(--primary);
}
.nav-item__badge { margin-inline-start: auto; }
.sidebar__foot { margin-top: auto; display: grid; gap: var(--sp-3); }
.sidebar__status { padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-sunken); border: 1px solid var(--border); display: grid; gap: 6px; font-size: 13px; }
.sidebar__status b { font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; inset-block-start: 0; z-index: var(--z-topbar); min-height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-6);
  background: var(--surface-2); border-block-end: 1px solid var(--border);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%); backdrop-filter: blur(var(--blur)) saturate(150%);
}
.topbar__title { min-width: 0; flex: 1; }
.topbar__title h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title p { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { display: flex; align-items: center; gap: var(--sp-2); }
.menu-btn { display: none; }
.page { padding: var(--sp-6); display: grid; gap: var(--sp-5); width: 100%; max-width: 1480px; margin-inline: auto; align-content: start; }
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: calc(var(--z-sidebar) - 1); opacity: 0; pointer-events: none; transition: opacity var(--t-med) var(--ease); }

/* ---- Surfaces ----------------------------------------------------------- */
.card {
  position: relative; padding: var(--sp-5); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%); backdrop-filter: blur(var(--blur)) saturate(150%);
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}
.card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 1px 0 var(--glass-edge); }
.card--hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-block-end: var(--sp-4); }
.card__title { font-size: 16px; display: flex; align-items: center; gap: var(--sp-2); }
.card__title .icon { width: 18px; height: 18px; color: var(--primary-text); }
.card__sub { font-size: 13px; color: var(--text-2); margin-block-start: 2px; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush .card__head { padding: var(--sp-5) var(--sp-5) 0; }

.grid { display: grid; gap: var(--sp-5); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.grid--hero { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.grid--topo { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
.stack { display: grid; gap: var(--sp-5); align-content: start; }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---- Icons -------------------------------------------------------------- */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  --btn-bg: var(--surface-solid); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 var(--sp-5); border-radius: var(--r-md); font-weight: 600; font-size: 14px; white-space: nowrap;
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); text-decoration: none; }
.btn:active { transform: translateY(0) scale(.98); box-shadow: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary { --btn-bg: var(--primary); --btn-fg: var(--text-on-primary); --btn-bd: transparent; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 70%, transparent); }
.btn--primary:hover { --btn-bg: var(--primary-hover); }
.btn--danger { --btn-bg: var(--crit-soft); --btn-fg: var(--crit); --btn-bd: color-mix(in srgb, var(--crit) 40%, transparent); }
.btn--danger-solid { --btn-bg: var(--solid-crit); --btn-fg: #fff; --btn-bd: transparent; }
:root[data-theme="dark"] .btn--danger-solid { --btn-fg: #2a0707; }
.btn--warn { --btn-bg: var(--warn-soft); --btn-fg: var(--warn); --btn-bd: color-mix(in srgb, var(--warn) 40%, transparent); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn--ghost:hover { --btn-bg: var(--surface-sunken); --btn-fg: var(--text); box-shadow: none; }
.btn--sm { min-height: 36px; padding: 0 var(--sp-3); font-size: 13px; border-radius: var(--r-sm); }
.btn--lg { min-height: 52px; padding: 0 var(--sp-6); font-size: 15px; }
.btn--block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: var(--r-md); border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  position: relative;
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .badge-dot { position: absolute; inset-block-start: 10px; inset-inline-end: 11px; width: 9px; height: 9px; border-radius: 50%; background: var(--crit-bright); border: 2px solid var(--surface-solid); }

/* ---- Badges, dots, chips ------------------------------------------------ */
.pill {
  --p-fg: var(--text-2); --p-bg: var(--surface-sunken); --p-bd: var(--border);
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; color: var(--p-fg); background: var(--p-bg); border: 1px solid var(--p-bd); white-space: nowrap;
}
.pill .icon { width: 14px; height: 14px; }
.pill--ok { --p-fg: var(--ok); --p-bg: var(--ok-soft); --p-bd: color-mix(in srgb, var(--ok) 28%, transparent); }
.pill--warn { --p-fg: var(--warn); --p-bg: var(--warn-soft); --p-bd: color-mix(in srgb, var(--warn) 30%, transparent); }
.pill--crit { --p-fg: var(--crit); --p-bg: var(--crit-soft); --p-bd: color-mix(in srgb, var(--crit) 30%, transparent); }
.pill--info { --p-fg: var(--info); --p-bg: var(--info-soft); --p-bd: color-mix(in srgb, var(--info) 28%, transparent); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; position: relative; background: var(--text-3); }
.dot--ok { background: var(--ok-bright); } .dot--warn { background: var(--warn-bright); } .dot--crit { background: var(--crit-bright); } .dot--info { background: var(--info-bright); }
.dot--pulse::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: ping 2.2s var(--ease) infinite; }
.dot--ok.dot--pulse { color: var(--ok-bright); } .dot--warn.dot--pulse { color: var(--warn-bright); } .dot--crit.dot--pulse { color: var(--crit-bright); } .dot--info.dot--pulse { color: var(--info-bright); }
@keyframes ping { 0% { transform: scale(.6); opacity: .8; } 80%, 100% { transform: scale(1.6); opacity: 0; } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-xs); background: var(--surface-sunken); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }

/* ---- Hero --------------------------------------------------------------- */
.hero { padding: var(--sp-6); overflow: hidden; isolation: isolate; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .9; transition: background var(--t-slow) var(--ease);
  background: radial-gradient(120% 140% at 100% 0%, var(--hero-tint, var(--ok-soft)), transparent 60%);
}
html[dir="ltr"] .hero::before { background: radial-gradient(120% 140% at 0% 0%, var(--hero-tint, var(--ok-soft)), transparent 60%); }
.hero[data-state="ok"] { --hero-tint: var(--ok-soft); --hero-c: var(--ok); }
.hero[data-state="warn"] { --hero-tint: var(--warn-soft); --hero-c: var(--warn); }
.hero[data-state="crit"] { --hero-tint: var(--crit-soft); --hero-c: var(--crit); }
.hero[data-state="info"] { --hero-tint: var(--info-soft); --hero-c: var(--info); }
.hero__top { display: flex; align-items: center; gap: var(--sp-4); }
.hero__orb {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; flex: none; color: var(--hero-c);
  background: color-mix(in srgb, var(--hero-c) 14%, var(--surface-solid)); border: 1px solid color-mix(in srgb, var(--hero-c) 35%, transparent);
  box-shadow: 0 10px 28px -10px color-mix(in srgb, var(--hero-c) 70%, transparent);
  position: relative;
}
.hero__orb .icon { width: 30px; height: 30px; }
.hero__orb::after { content: ""; position: absolute; inset: -7px; border-radius: 26px; border: 2px solid var(--hero-c); opacity: 0; animation: ping 2.6s var(--ease) infinite; }
.hero__title { font-size: 24px; line-height: 1.25; }
.hero__lead { color: var(--text-2); margin-block-start: 4px; max-width: 62ch; }
.hero__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); margin-block-start: var(--sp-5); }
.fact { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.fact__label { font-size: 12.5px; color: var(--text-2); }
.fact__value { font-size: 16px; font-weight: 600; margin-block-start: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hero__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-block-start: var(--sp-5); }

/* ---- Callouts ----------------------------------------------------------- */
.callout { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--co-bd); background: var(--co-bg); color: var(--text); font-size: 14px; }
.callout .icon { color: var(--co-fg); margin-block-start: 2px; }
.callout b { font-weight: 600; }
.callout--info { --co-bg: var(--info-soft); --co-bd: color-mix(in srgb, var(--info) 28%, transparent); --co-fg: var(--info); }
.callout--warn { --co-bg: var(--warn-soft); --co-bd: color-mix(in srgb, var(--warn) 32%, transparent); --co-fg: var(--warn); }
.callout--crit { --co-bg: var(--crit-soft); --co-bd: color-mix(in srgb, var(--crit) 32%, transparent); --co-fg: var(--crit); }
.callout--ok { --co-bg: var(--ok-soft); --co-bd: color-mix(in srgb, var(--ok) 30%, transparent); --co-fg: var(--ok); }

/* ---- KPI cards ---------------------------------------------------------- */
.kpi { display: grid; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.kpi__label { font-size: 13px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi__label .icon { width: 16px; height: 16px; color: var(--primary-text); }
.kpi__value { font-size: 28px; font-weight: 700; line-height: 1.1; display: flex; align-items: baseline; gap: 6px; }
.kpi__unit { font-size: 14px; font-weight: 500; color: var(--text-2); }
.kpi__hint { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi__spark { height: 34px; margin-block-start: 2px; }
.meter { height: 8px; border-radius: 8px; background: var(--surface-sunken); border: 1px solid var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 8px; width: var(--v, 0%); background: linear-gradient(90deg, var(--info-bright), var(--accent)); transition: width var(--t-slow) var(--ease); }
html[dir="rtl"] .meter > span { background: linear-gradient(270deg, var(--info-bright), var(--accent)); }
.meter--ok > span { background: var(--ok-bright); } .meter--warn > span { background: var(--warn-bright); } .meter--crit > span { background: var(--crit-bright); }
.progress { height: 10px; border-radius: 10px; background: var(--surface-sunken); border: 1px solid var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--v, 0%); border-radius: 10px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width var(--t-med) linear; position: relative; overflow: hidden; }
html[dir="rtl"] .progress > span { background: linear-gradient(270deg, var(--primary), var(--accent)); }
.progress > span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); transform: translateX(calc(var(--dir) * -100%)); animation: sheen 1.6s linear infinite; }
@keyframes sheen { to { transform: translateX(calc(var(--dir) * 100%)); } }

/* ---- Topology ----------------------------------------------------------- */
.topo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(86px, .46fr) minmax(0, 1fr); grid-template-areas: "dns dns dns" "da . db" "a link b" "chk chk chk"; gap: 0 var(--sp-2); align-items: center; }
.topo__dns { grid-area: dns; justify-self: center; }
.topo__drop-a { grid-area: da; } .topo__drop-b { grid-area: db; }
.topo__a { grid-area: a; } .topo__b { grid-area: b; } .topo__link { grid-area: link; }
.topo__chk { grid-area: chk; margin-block-start: var(--sp-4); }
.drop { height: 38px; justify-self: center; width: 2px; position: relative; background: repeating-linear-gradient(to bottom, var(--border-strong) 0 5px, transparent 5px 9px); }
.drop.is-live { background: linear-gradient(to bottom, var(--primary), var(--accent)); box-shadow: 0 0 12px var(--primary); }
.drop.is-live::after { content: ""; position: absolute; inset-inline-start: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: fall 1.6s linear infinite; }
@keyframes fall { from { inset-block-start: -4px; opacity: 0; } 15% { opacity: 1; } to { inset-block-start: 34px; opacity: 0; } }
.node { padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border-strong); display: grid; gap: var(--sp-3); transition: border-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), opacity var(--t-med) var(--ease); }
.node.is-live { border-color: color-mix(in srgb, var(--ok-bright) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ok-bright) 22%, transparent), 0 12px 32px -14px color-mix(in srgb, var(--ok-bright) 60%, transparent); }
.node.is-down { border-color: color-mix(in srgb, var(--crit-bright) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--crit-bright) 22%, transparent), 0 12px 32px -14px color-mix(in srgb, var(--crit-bright) 55%, transparent); }
.node.is-standby { border-style: dashed; }
.node__head { display: flex; align-items: center; gap: var(--sp-3); }
.node__ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.node__title { font-weight: 600; line-height: 1.25; }
.node__sub { font-size: 12.5px; color: var(--text-2); }
.vm { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-solid); border: 1px solid var(--border); }
.vm__name { font-weight: 600; font-size: 14px; }
.vm__meta { font-size: 12.5px; color: var(--text-2); }
.dns-node { display: inline-flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-1); }
.dns-node__ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(140deg, #f59e0b, #ea580c); }
.link { display: grid; gap: 6px; justify-items: center; padding-inline: var(--sp-1); min-width: 0; }
.link__label { font-size: 12.5px; color: var(--text-2); text-align: center; line-height: 1.35; }
.link__track { position: relative; width: 100%; height: 4px; border-radius: 4px; background: var(--surface-sunken); border: 1px solid var(--border); overflow: hidden; }
.link__track::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent); background-size: 200% 100%; opacity: .0; }
.link--flow .link__track::before { opacity: .9; animation: stream 1.8s linear infinite; }
html[dir="rtl"] .link--flow .link__track::before { background-image: linear-gradient(270deg, transparent, var(--primary), var(--accent), transparent); }
.link--rev.link--flow .link__track::before { animation-direction: reverse; }
.link--stalled .link__track { background: repeating-linear-gradient(90deg, var(--crit-bright) 0 6px, transparent 6px 12px); border-color: var(--crit-bright); }
.link--idle .link__track { background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 12px); }
@keyframes stream { from { background-position: calc(var(--dir) * 200%) 0; } to { background-position: calc(var(--dir) * -200%) 0; } }
.link__arrow { color: var(--text-3); }
.link--flow .link__arrow { color: var(--primary-text); }
.topo__chk-inner { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px dashed var(--border-strong); background: var(--surface-sunken); font-size: 13px; flex-wrap: wrap; }

/* ---- Lists, tables, key/value ------------------------------------------- */
.list { display: grid; }
.list__row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-block-end: 1px solid var(--border); min-width: 0; }
.list__row:last-child { border-block-end: 0; }
.list__ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary-text); }
.list__ico--ok { background: var(--ok-soft); color: var(--ok); } .list__ico--warn { background: var(--warn-soft); color: var(--warn); } .list__ico--crit { background: var(--crit-soft); color: var(--crit); }
.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.list__sub { font-size: 12.5px; color: var(--text-2); }
.list__end { text-align: end; flex: none; font-size: 13px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 10px var(--sp-5); font-size: 14px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { font-size: 14px; }
.table th { text-align: start; font-weight: 600; font-size: 12.5px; color: var(--text-2); padding: 10px var(--sp-4); background: var(--surface-sunken); white-space: nowrap; border-block-end: 1px solid var(--border); }
.table td { padding: 12px var(--sp-4); border-block-end: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-sunken); }
.table tbody tr:last-child td { border-block-end: 0; }
.table .cell-end { text-align: end; }

/* ---- Forms -------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field__label { font-size: 13.5px; font-weight: 600; }
.field__hint { font-size: 12.5px; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 0 var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface-solid); color: var(--text); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input:hover, .select:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border-strong)); }
.input:focus-visible, .select:focus-visible { outline: 0; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 28%, transparent); }
.input[readonly] { background: var(--surface-sunken); }
.select { appearance: none; -webkit-appearance: none; padding-inline-end: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2355668a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
html[dir="rtl"] .select { background-position: left 14px center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-5); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) 0; border-block-end: 1px solid var(--border); }
.switch-row:last-child { border-block-end: 0; }
.switch-row__t { font-weight: 600; font-size: 14px; } .switch-row__s { font-size: 12.5px; color: var(--text-2); }
.toggle { width: 48px; height: 28px; border-radius: 28px; border: 1px solid var(--border-strong); background: var(--surface-sunken); position: relative; flex: none; padding: 0; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.toggle::after { content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-solid); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--t-med) var(--ease); }
.toggle[aria-checked="true"] { background: var(--primary); border-color: var(--primary); }
.toggle[aria-checked="true"]::after { transform: translateX(calc(var(--dir) * 20px)); }
.seg { overflow-x: auto; display: inline-flex; padding: 3px; border-radius: var(--r-md); background: var(--surface-sunken); border: 1px solid var(--border); gap: 2px; max-width: 100%; }
.seg button { min-height: 38px; padding: 0 var(--sp-4); border: 0; background: transparent; border-radius: calc(var(--r-md) - 3px); color: var(--text-2); font-weight: 500; font-size: 13.5px; white-space: nowrap; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface-solid); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }
.choice { display: flex; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface-2); cursor: pointer; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.choice:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border-strong)); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
.choice input { margin-block-start: 4px; accent-color: var(--primary); width: 18px; height: 18px; flex: none; }
.choice__t { font-weight: 600; } .choice__s { font-size: 13px; color: var(--text-2); }
.check { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: 14px; }
.check input { accent-color: var(--primary); width: 20px; height: 20px; margin-block-start: 2px; flex: none; }

/* ---- Wizards ------------------------------------------------------------ */
.op-card { display: grid; gap: var(--sp-3); text-align: start; cursor: pointer; border: 1px solid var(--border); width: 100%; font: inherit; color: inherit; }
.op-card__ico { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.op-card--warn .op-card__ico { background: var(--warn-soft); color: var(--warn); }
.op-card--crit .op-card__ico { background: var(--crit-soft); color: var(--crit); }
.op-card--ok .op-card__ico { background: var(--ok-soft); color: var(--ok); }
.op-card h3 { font-size: 17px; } .op-card p { font-size: 13.5px; color: var(--text-2); }
.op-card[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.op-card[aria-disabled="true"]:hover { transform: none; box-shadow: var(--shadow-1); border-color: var(--border); }
.stepper { display: flex; align-items: flex-start; gap: 0; counter-reset: s; overflow-x: auto; padding-block: 2px; }
.step { flex: 1 1 0; min-width: 92px; display: grid; justify-items: center; gap: 6px; position: relative; text-align: center; font-size: 12.5px; color: var(--text-2); }
.step::before { content: ""; position: absolute; inset-block-start: 17px; inset-inline-start: calc(-50% + 20px); inset-inline-end: calc(50% + 20px); height: 2px; background: var(--border-strong); transition: background var(--t-med) var(--ease); }
.step:first-child::before { display: none; }
.step__n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--surface-solid); border: 2px solid var(--border-strong); color: var(--text-2); transition: all var(--t-med) var(--ease); position: relative; z-index: 1; }
.step.is-done .step__n { background: var(--ok-bright); border-color: var(--ok-bright); color: #052e16; }
.step.is-done::before, .step.is-current::before { background: var(--primary); }
.step.is-current .step__n { border-color: var(--primary); color: var(--primary-text); box-shadow: 0 0 0 5px var(--primary-soft); }
.step.is-current { color: var(--text); font-weight: 600; }
.wizard { display: grid; gap: var(--sp-5); }
.wizard__body { display: grid; gap: var(--sp-4); min-height: 260px; align-content: start; animation: rise var(--t-slow) var(--ease) both; }
.wizard__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding-block-start: var(--sp-4); border-block-start: 1px solid var(--border); }
.checks { display: grid; gap: var(--sp-2); }
.checks__row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.checks__row .icon { flex: none; }
.checks__main { flex: 1; min-width: 0; }
.checks__t { font-weight: 600; font-size: 14px; } .checks__s { font-size: 12.5px; color: var(--text-2); }
.ic-ok { color: var(--ok); } .ic-warn { color: var(--warn); } .ic-crit { color: var(--crit); } .ic-info { color: var(--info); } .ic-mute { color: var(--text-3); }
.run { display: grid; gap: 0; }
.run__row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; color: var(--text-3); transition: color var(--t-fast) var(--ease); }
.run__row.is-active, .run__row.is-done { color: var(--text); }
.run__ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); flex: none; }
.run__row.is-active .run__ic { border-color: var(--primary); color: var(--primary-text); }
.run__row.is-done .run__ic { border-color: var(--ok-bright); background: var(--ok-bright); color: #052e16; }
.run__ic .icon { width: 15px; height: 15px; }
.summary { padding: var(--sp-5); border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-2); display: grid; gap: var(--sp-3); justify-items: start; }
.code { font-family: var(--font-mono); font-size: 12.5px; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--surface-sunken); border: 1px solid var(--border); direction: ltr; text-align: left; overflow-x: auto; white-space: pre; unicode-bidi: isolate; color: var(--text); }

/* ---- Charts ------------------------------------------------------------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-sans); fill: var(--text-2); font-size: 11px; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .bar { fill: var(--chart-bar); transition: opacity var(--t-fast) var(--ease); }
.chart .bar--late { fill: var(--warn-bright); }
.chart .bar:hover { opacity: .75; }
.chart .thresh { stroke: var(--crit-bright); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#spark-grad); }
.chart-legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-block-start: var(--sp-3); }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring .trk { stroke: var(--surface-sunken); }
.ring .val { stroke: var(--ring-c, var(--primary)); transition: stroke-dashoffset var(--t-slow) var(--ease); }
.ring__c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.15; }
.ring__c b { font-size: 22px; } .ring__c span { font-size: 12px; color: var(--text-2); }
.timeline { position: relative; display: grid; gap: 0; }
.tl { position: relative; display: flex; gap: var(--sp-3); padding-block-end: var(--sp-4); }
.tl::before { content: ""; position: absolute; inset-block: 22px 0; inset-inline-start: 10px; width: 2px; background: var(--border); }
.tl:last-child::before { display: none; }
.tl__dot { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-solid); border: 2px solid var(--border-strong); z-index: 1; }
.tl__dot .icon { width: 12px; height: 12px; }
.tl__dot--ok { border-color: var(--ok-bright); color: var(--ok); } .tl__dot--warn { border-color: var(--warn-bright); color: var(--warn); } .tl__dot--crit { border-color: var(--crit-bright); color: var(--crit); } .tl__dot--info { border-color: var(--info-bright); color: var(--info); }
.tl__t { font-size: 14px; font-weight: 600; line-height: 1.4; } .tl__s { font-size: 12.5px; color: var(--text-2); }

/* ---- Dialog, toast, demo ------------------------------------------------ */
dialog.modal { padding: 0; border: 1px solid var(--border-strong); border-radius: var(--r-xl); background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-2); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; margin: auto; }
dialog.modal::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog.modal[open] { animation: pop var(--t-med) var(--ease) both; }
dialog.modal[open]::backdrop { animation: fade var(--t-med) var(--ease) both; }
.modal__head { padding: var(--sp-5) var(--sp-6) var(--sp-3); display: flex; gap: var(--sp-3); align-items: flex-start; }
.modal__body { padding: 0 var(--sp-6) var(--sp-4); display: grid; gap: var(--sp-4); }
.modal__foot { padding: var(--sp-4) var(--sp-6) var(--sp-5); display: flex; gap: var(--sp-3); justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; z-index: var(--z-toast); inset-block-start: calc(var(--topbar-h) + 12px); inset-inline-end: var(--sp-5); display: grid; gap: var(--sp-2); width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2); animation: toast-in var(--t-med) var(--ease) both; }
.toast.is-out { animation: toast-out var(--t-med) var(--ease) both; }
.toast .icon { margin-block-start: 2px; }
.toast__t { font-weight: 600; font-size: 14px; } .toast__s { font-size: 13px; color: var(--text-2); }
.demo {
  position: fixed; inset-block-end: var(--sp-4); inset-inline: 0; margin-inline: auto; width: max-content; max-width: calc(100vw - 24px); z-index: var(--z-demo);
  display: flex; align-items: center; gap: var(--sp-3); padding: 6px 8px 6px 14px; border-radius: var(--r-pill); flex-wrap: wrap; justify-content: center;
  background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
}
html[dir="rtl"] .demo { padding: 6px 14px 6px 8px; }
.demo__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.demo .seg { background: transparent; border: 0; padding: 0; flex-wrap: wrap; justify-content: center; }
.demo .seg button { min-height: 36px; border-radius: var(--r-pill); }
.demo .seg button[aria-pressed="true"] { background: var(--primary); color: var(--text-on-primary); box-shadow: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(calc(var(--dir) * 24px)); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(calc(var(--dir) * 24px)); } }
.reveal { animation: rise var(--t-slow) var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-sunken), var(--border), var(--surface-sunken)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--text-2); display: grid; justify-items: center; gap: var(--sp-2); }
.empty .icon { width: 36px; height: 36px; color: var(--text-3); }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid--main, .grid--hero, .grid--topo { grid-template-columns: minmax(0, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); transform: translateX(calc(var(--dir) * -105%)); transition: transform var(--t-med) var(--ease); background: var(--surface-solid); box-shadow: var(--shadow-2); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-grid; }
  .topbar { padding-inline: var(--sp-4); }
  .page { padding: var(--sp-4); padding-block-end: 120px; gap: var(--sp-4); }
  .grid--2, .grid--3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar__actions .hide-sm { display: none; }
}
@media (max-width: 560px) {
  .hero { padding: var(--sp-5) var(--sp-4); }
  .hero__top { align-items: flex-start; }
  .hero__title { font-size: 20px; }
  .hero__orb { width: 52px; height: 52px; border-radius: 16px; }
  .card { padding: var(--sp-4); }
  .topo { grid-template-columns: minmax(0, 1fr) minmax(54px, .3fr) minmax(0, 1fr); }
  .node { padding: var(--sp-3); }
  .node__sub { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-block-end: var(--sp-2); }
  .step { min-width: 74px; font-size: 11.5px; }
  .toasts { inset-inline: var(--sp-3); width: auto; }
  .demo { inset-block-end: var(--sp-2); border-radius: var(--r-lg); }
}

/* ---- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .bg i { animation: none !important; }
  .hero__orb::after, .dot--pulse::after { display: none; }
}
@media print { .sidebar, .topbar, .demo, .toasts, .bg { display: none !important; } .app { display: block; } }

/* ---- additions: avatar, quiet re-render, skip link ---- */
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--text-on-primary); background: linear-gradient(135deg, var(--primary), var(--accent)); flex: none; }
.quiet .reveal { animation: none; }
.skip { position: fixed; inset-block-start: 8px; inset-inline-start: 8px; z-index: 100; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong); transform: translateY(-200%); }
.skip:focus { transform: none; }
.live-clock { font-variant-numeric: tabular-nums; }

/* ---- overflow guards ---- */
.grid > *, .stack > *, .topo > *, .row > .seg, .card, .node { min-width: 0; }
.vm { flex-wrap: wrap; }
.vm > div { min-width: 0; }
.vm .pill { margin-inline-start: auto; }
.row--wrap > .seg { max-width: 100%; }
.page > * { min-width: 0; }
@media (max-width: 760px) { .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); } .form-grid { grid-template-columns: minmax(0, 1fr); } }

.page { padding-block-end: 110px; }
#wizard-host { scroll-margin-top: calc(var(--topbar-h) + 16px); }
@media (max-width: 560px) { .topbar__actions .avatar { display: none; } .topbar__title p { display: none; } .topbar__title h1 { font-size: 18px; } .topbar { gap: var(--sp-2); } }
