/* Storage web UI design system: tokens first, then layout, then components. No build step. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f4; --border: #dde1e8;
  --fg: #161a22; --fg-muted: #535b6b; --accent: #2557d6; --accent-fg: #ffffff; --accent-soft: #e6edfc;
  --ok: #17703a; --ok-soft: #e2f4e8; --warn: #8a5a00; --warn-soft: #fcf1d8; --err: #b42318; --err-soft: #fde7e5;
  --focus: #2557d6;
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem; --sp-6: 2rem;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b23; --surface-2: #202633; --border: #2c3341;
    --fg: #e8ebf1; --fg-muted: #a3acbd; --accent: #7aa2ff; --accent-fg: #0b1020; --accent-soft: #1d2a4a;
    --ok: #5fd18b; --ok-soft: #12301f; --warn: #f2c35b; --warn-soft: #34290f; --err: #ff8a80; --err-soft: #3a1714;
    --focus: #9dbaff; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b23; --surface-2: #202633; --border: #2c3341;
  --fg: #e8ebf1; --fg-muted: #a3acbd; --accent: #7aa2ff; --accent-fg: #0b1020; --accent-soft: #1d2a4a;
  --ok: #5fd18b; --ok-soft: #12301f; --warn: #f2c35b; --warn-soft: #34290f; --err: #ff8a80; --err-soft: #3a1714;
  --focus: #9dbaff; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--fg); background: var(--bg); }
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
pre { background: var(--surface-2); padding: var(--sp-3); border-radius: var(--r-sm); overflow-x: auto; margin: 0; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 var(--sp-3); }
p { margin: 0 0 var(--sp-3); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--fg-muted); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: -999px; top: var(--sp-2); z-index: 50; background: var(--surface); padding: var(--sp-2) var(--sp-3); }
.skip:focus { left: var(--sp-2); }

/* ---- layout ---- */
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; padding: var(--sp-2) var(--sp-3) var(--sp-4); color: var(--fg); text-decoration: none; }
.brand .icon { color: var(--accent); width: 22px; height: 22px; }
.nav-link { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  color: var(--fg-muted); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--fg); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.content { min-width: 0; padding: var(--sp-6); max-width: 78rem; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.stack > * + * { margin-top: var(--sp-5); }


/* ---- components ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--sp-5); }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.metric { display: flex; flex-direction: column; gap: var(--sp-1); }
.metric .label { color: var(--fg-muted); font-size: .85rem; font-weight: 500; }
.metric .value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }

.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); font: inherit; font-weight: 600;
  padding: .5rem .9rem; min-height: 2.25rem; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: var(--accent-fg); text-decoration: none; white-space: nowrap; }
.btn:hover, button:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-danger, button.danger { background: var(--err); color: #fff; }
:root[data-theme="dark"] .btn-danger, :root[data-theme="dark"] button.danger { color: #1a0605; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger, :root:not([data-theme="light"]) button.danger { color: #1a0605; } }
.btn-sm { padding: .25rem .6rem; min-height: 1.9rem; font-size: .85rem; }
button[aria-busy="true"] { opacity: .7; cursor: progress; }
button[aria-busy="true"]::after { content: ""; width: .9em; height: .9em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-request { opacity: .7; transition: opacity .2s; }

.form { display: grid; gap: var(--sp-3) var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); align-items: end; }
.form .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: var(--sp-1); font-weight: 500; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: var(--sp-2); font-weight: 400; }
input, textarea, select { font: inherit; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--fg); min-height: 2.25rem; min-width: 0; }
input:hover, textarea:hover { border-color: var(--fg-muted); }
input[type="checkbox"] { min-height: 0; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.hint { font-weight: 400; color: var(--fg-muted); font-size: .8rem; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); margin: 2px; align-items: center; }
form.inline input { width: 8rem; padding: .25rem .5rem; min-height: 1.9rem; font-size: .85rem; }

.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--sp-5)); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); font-weight: 600; background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); }
td.actions { white-space: nowrap; }
.search { display: none; }
.js .search { display: flex; position: relative; }
.search input { padding-left: 2rem; width: min(18rem, 100%); }
.search .icon { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--fg-muted); width: 16px; }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--fg-muted); }
.badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.services { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.services li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.services li:last-child { border-bottom: 0; }

.bar { height: .55rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; width: 100%; border: 0; appearance: none; display: block; }
.bar::-webkit-progress-bar { background: var(--surface-2); }
.bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.bar.warn::-webkit-progress-value { background: var(--warn); } .bar.warn::-moz-progress-bar { background: var(--warn); }
.bar.err::-webkit-progress-value { background: var(--err); } .bar.err::-moz-progress-bar { background: var(--err); }
.quota-row { display: grid; grid-template-columns: 8rem 1fr auto; gap: var(--sp-3); align-items: center; padding: var(--sp-2) 0; }
.quota-row .muted { font-size: .85rem; white-space: nowrap; }

.empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--fg-muted); }
.empty .icon { width: 32px; height: 32px; margin-bottom: var(--sp-2); }
.callout { border-radius: var(--r); padding: var(--sp-3) var(--sp-4); background: var(--accent-soft); }
.callout.err { background: var(--err-soft); color: var(--err); }
.callout.secret { background: var(--warn-soft); border: 1px solid var(--warn); }
.chip { display: inline-flex; align-items: center; gap: var(--sp-1); padding: .15rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 500;
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--border); min-height: 0; }
.chip:hover { background: var(--err-soft); color: var(--err); filter: none; }

/* toasts: static list without JS, floating + auto-dismiss with JS */
.toasts { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.js .toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 60; width: min(24rem, calc(100vw - 2rem)); margin: 0; }
.toast { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--ok); box-shadow: var(--shadow-lg); }
.toast.err { border-left-color: var(--err); }
.toast .icon { color: var(--ok); margin-top: 2px; } .toast.err .icon { color: var(--err); }
.toast p { margin: 0; flex: 1; }
.toast .x { display: none; background: none; color: var(--fg-muted); padding: 0 .25rem; min-height: 0; }
.js .toast .x { display: inline-flex; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }

/* dialogs (JS wraps [data-dialog] sections; without JS they stay inline) */
.js [data-dialog]:not(dialog [data-dialog]) { display: none; }
.dialog-open { display: none; }
.js .dialog-open { display: inline-flex; }
dialog { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0; width: min(34rem, calc(100vw - 2rem)); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10,14,22,.55); }
dialog .card { border: 0; box-shadow: none; }
.dialog-close { position: absolute; top: var(--sp-3); right: var(--sp-3); background: none; color: var(--fg-muted); padding: .25rem; min-height: 0; }

/* login */
.auth { min-height: 100vh; height: 100dvh; min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-4); }
.auth .card { width: min(24rem, 100%); padding: var(--sp-6); }
.auth .brand { justify-content: center; padding: 0 0 var(--sp-2); font-size: 1.15rem; }
.auth h1 { text-align: center; font-size: 1.25rem; margin-bottom: var(--sp-5); }
.auth form { display: grid; gap: var(--sp-4); }
.auth .theme-toggle { position: fixed; top: var(--sp-3); right: var(--sp-3); }
.theme-toggle .when-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .when-dark { display: inline; } :root[data-theme="dark"] .theme-toggle .when-light { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .theme-toggle .when-dark { display: inline; } :root:not([data-theme]) .theme-toggle .when-light { display: none; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.theme-toggle { display: none; }
.js .theme-toggle { display: inline-flex; }
.more { display: inline-block; vertical-align: middle; }
.more summary { list-style: none; } .more summary::-webkit-details-marker { display: none; }
.more[open] summary { background: var(--surface-2); }
.more-body { display: grid; gap: var(--sp-1); margin-top: var(--sp-2); }
.grid.metrics { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }
.metric .value { font-size: clamp(1.25rem, 5.5vw, 1.75rem); white-space: nowrap; }

/* ===================== v2: gradient brand, glass, motion, wizards, palette ===================== */
:root {
  --accent: #4f46e5; --accent-soft: #eef0ff; --focus: #4f46e5;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #06b6d4 100%);
  --grad-btn: linear-gradient(135deg, #4f46e5, #7c3aed);
  --glass: rgba(255,255,255,.72); --glass-border: rgba(255,255,255,.6);
  --ease: cubic-bezier(.2,.8,.2,1);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --accent: #a5b4fc; --accent-soft: #23264a; --focus: #a5b4fc; --glass: rgba(23,27,35,.62); --glass-border: rgba(255,255,255,.08); } }
:root[data-theme="dark"] { --accent: #a5b4fc; --accent-soft: #23264a; --focus: #a5b4fc; --glass: rgba(23,27,35,.62); --glass-border: rgba(255,255,255,.08); }

/* aurora background */
body { position: relative; isolation: isolate; }
body::before { content: ""; position: fixed; inset: -20%; z-index: -1; pointer-events: none; opacity: .55;
  background: radial-gradient(40% 35% at 20% 20%, rgba(99,102,241,.35), transparent 70%),
              radial-gradient(35% 30% at 80% 25%, rgba(139,92,246,.30), transparent 70%),
              radial-gradient(40% 35% at 60% 85%, rgba(6,182,212,.25), transparent 70%);
  filter: blur(40px); animation: aurora 28s ease-in-out infinite alternate; }
@keyframes aurora { to { transform: translate3d(4%, -3%, 0) rotate(8deg) scale(1.08); } }

/* brand */
.logo { width: 28px; height: 28px; flex: none; }
.brand-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; letter-spacing: -.01em; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* glass surfaces */
.topbar, dialog { background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); border-color: var(--glass-border); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.kbd { margin-left: auto; font: 600 .72rem var(--mono); padding: .05rem .4rem; border: 1px solid var(--border); border-radius: 4px; color: var(--fg-muted); }

/* buttons: gradient, press, ripple */
.btn, button { position: relative; overflow: hidden; transition: transform .15s var(--ease), box-shadow .2s, background-color .2s; }
.btn:not(.btn-ghost):not(.btn-danger):not(.chip), button:not(.btn-ghost):not(.danger):not(.chip):not(.x):not(.dialog-close) { background: var(--grad-btn); color: #fff; box-shadow: 0 4px 14px -6px rgba(99,102,241,.7); }
.btn:active, button:active { transform: scale(.97); }
.btn-glow { box-shadow: 0 0 0 0 rgba(139,92,246,.6); animation: glow 2.4s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgba(139,92,246,0); } }
.ripple { position: absolute; left: var(--x); top: var(--y); width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: currentColor; opacity: .35; pointer-events: none; animation: ripple .6s var(--ease) forwards; }
@keyframes ripple { to { transform: scale(40); opacity: 0; } }

/* cards: glow, lift, stagger */
.card { transition: transform .25s var(--ease), box-shadow .25s; }
.metric, .svc, .tile, .conn { transition: transform .25s var(--ease), box-shadow .25s; }
.metric:hover, .svc:hover, .conn:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.metric { position: relative; isolation: isolate; overflow: visible; }
.metric::before { content: ""; position: absolute; inset: 25% 12% -8%; z-index: -1; border-radius: 50%; background: #6366f1; filter: blur(30px); opacity: .28; }
.metric:nth-child(2)::before { background: #8b5cf6; } .metric:nth-child(3)::before { background: #06b6d4; } .metric:nth-child(4)::before { background: #22c55e; }
.metric .value { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="dark"] .metric .value { background: linear-gradient(135deg, #c7d2fe, #ddd6fe 55%, #a5f3fc); -webkit-background-clip: text; background-clip: text; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .metric .value { background: linear-gradient(135deg, #c7d2fe, #ddd6fe 55%, #a5f3fc); -webkit-background-clip: text; background-clip: text; } }
.stack > *, .grid > *, tbody tr, .tiles .tile, .stepper li, .log li { animation: rise .5s var(--ease); }
@keyframes rise { from { transform: translateY(8px); } }
.grid > :nth-child(2), tbody tr:nth-child(2), .stack > :nth-child(2), .tile:nth-child(2) { animation-delay: .05s; }
.grid > :nth-child(3), tbody tr:nth-child(3), .stack > :nth-child(3), .tile:nth-child(3) { animation-delay: .1s; }
.grid > :nth-child(4), tbody tr:nth-child(4), .stack > :nth-child(4), .tile:nth-child(4) { animation-delay: .15s; }
.grid > :nth-child(n+5), tbody tr:nth-child(n+5), .stack > :nth-child(n+5), .tile:nth-child(n+5) { animation-delay: .2s; }

/* dashboard: donut, service cards, sparkline */
.donut-wrap { display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; }
.donut { width: 9rem; height: 9rem; transform: rotate(-90deg); }
.donut .track { stroke: var(--surface-2); }
.donut .val { stroke: url(#g-brand); }
.donut-label { display: grid; gap: 2px; }
.donut-label strong { font-size: 2rem; letter-spacing: -.02em; }
.svc-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
.svc { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.svc .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.live { width: .65rem; height: .65rem; border-radius: 50%; background: var(--fg-muted); flex: none; position: relative; }
.live.ok { background: var(--ok); } .live.err { background: var(--err); } .live.warn { background: var(--warn); }
.live.ok::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { to { transform: scale(2.6); opacity: 0; } }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 1.6rem; margin-top: var(--sp-1); }
.spark i { width: 6px; border-radius: 2px; background: var(--grad); transform-origin: bottom; }
.spark i.h1 { height: 15%; } .spark i.h2 { height: 30%; } .spark i.h3 { height: 45%; } .spark i.h4 { height: 60%; } .spark i.h5 { height: 75%; } .spark i.h6 { height: 90%; } .spark i.h7 { height: 100%; } .spark i.h0 { height: 6%; opacity: .4; }
@keyframes grow { from { transform: scaleY(0); } }
.bar::-webkit-progress-value { background: var(--grad); transition: width .9s var(--ease); }
.bar::-moz-progress-bar { background: var(--grad); }

/* toasts: slide in + progress */
.js .toast { animation: slide .4s var(--ease) both; position: relative; overflow: hidden; }
@keyframes slide { from { transform: translateX(110%); } }
.js .toast:not(.err)::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--grad); transform-origin: left; animation: drain 5s linear forwards; }
@keyframes drain { to { transform: scaleX(0); } }

/* skeleton while a boosted page loads */
.loading .content .stack > * { position: relative; overflow: hidden; }
.loading .content .stack > *::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* page transitions */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: .18s ease-in both vt-out; }
::view-transition-new(root) { animation: .28s var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: .4; transform: translateY(6px); } }

html:not(.js) .js-only { display: none !important; }
.no-js-hint { display: block; }

/* login */
.auth { background: linear-gradient(120deg, #312e81, #6d28d9, #0e7490, #4338ca); background-size: 300% 300%; animation: auth-bg 18s ease infinite; }
@keyframes auth-bg { 50% { background-position: 100% 50%; } }
.auth .card { background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); border-color: var(--glass-border); box-shadow: 0 30px 80px -20px rgba(15,10,60,.6); }
.auth .theme-toggle { background: var(--glass); }

/* wizards */
.stepper { list-style: none; display: flex; gap: var(--sp-2); padding: 0; margin: 0 0 var(--sp-5); counter-reset: s; }
.stepper li { flex: 1; display: flex; }
.stepper li > a, .stepper li > span { display: flex; align-items: center; gap: var(--sp-2); flex: 1; padding: var(--sp-2); border-radius: var(--r); color: var(--fg-muted); text-decoration: none; font-weight: 600; font-size: .9rem; position: relative; }
.stepper li::after { content: ""; }
.stepper .dot { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; border: 2px solid var(--border); flex: none; background: var(--surface); }
.stepper .dot .icon { width: 14px; height: 14px; }
.stepper li.done .dot { background: var(--grad); border-color: transparent; color: #fff; }
.stepper li.current .dot { border-color: #7c3aed; color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper li.current { color: var(--fg); } .stepper li.current .lbl { color: var(--fg); }
.stepper li > span::before, .stepper li > a::before { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; border-radius: 3px; background: var(--border); }
.stepper li.done > a::before, .stepper li.current > span::before { background: var(--grad); }
@media (max-width: 600px) { .stepper .lbl { display: none; } .stepper li.current .lbl { display: inline; } }
.wiz-form { display: grid; gap: var(--sp-4); }
.wiz-nav { display: flex; flex-direction: row-reverse; justify-content: space-between; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: var(--sp-2); padding: 0; }
.tiles { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.tiles.big { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.tile { position: relative; flex-direction: row; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-3); border: 1.5px solid var(--border); border-radius: var(--r); background: var(--surface); cursor: pointer; font-weight: 500; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile span { display: grid; gap: 2px; } .tile small { color: var(--fg-muted); font-weight: 400; }
.tile:has(input:checked) { border-color: #7c3aed; background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.tile:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.rwx { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.field-err { display: flex; align-items: center; gap: var(--sp-1); color: var(--err); font-weight: 500; font-size: .85rem; }
.field-err .icon { width: 15px; height: 15px; }
.tree ul { list-style: none; padding: 0; margin: 0 0 var(--sp-3); border: 1px solid var(--border); border-radius: var(--r); max-height: 20rem; overflow-y: auto; }
.tree li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--border); }
.tree li:first-child { border-top: 0; }
.tree li.locked { opacity: .55; } .tree li.locked label { cursor: not-allowed; }
.tree li .icon { color: var(--accent); }
.crumbs { font-size: .9rem; }
.summary { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-5); margin: 0; }
.summary dt { color: var(--fg-muted); font-weight: 600; } .summary dd { margin: 0; }
h3 { font-size: .95rem; margin: var(--sp-2) 0; }
.preview { border-left: 3px solid #7c3aed; }
.pw-row, .slider-row { display: flex; gap: var(--sp-2); align-items: center; }
.pw-row input { flex: 1; } .slider-row input[type="range"] { flex: 1; accent-color: #7c3aed; min-height: 0; padding: 0; border: 0; } .slider-row input:not([type]) { width: 6rem; }
.presets { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.presets .chip:hover { background: var(--accent-soft); color: var(--accent); }
.meter { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--sp-2); font-size: .8rem; color: var(--fg-muted); }
.meter span { height: 6px; border-radius: 3px; background: var(--surface-2); position: relative; overflow: hidden; }
.meter span::after { content: ""; position: absolute; inset: 0; width: var(--w, 0%); background: var(--err); transition: width .3s var(--ease), background .3s; }
.meter[data-score="2"] span::after { background: var(--warn); } .meter[data-score="3"] span::after, .meter[data-score="4"] span::after { background: var(--ok); }
.done-card { text-align: center; } .done-card .log { text-align: left; }
.done-icon { display: inline-grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: var(--grad); color: #fff; margin-bottom: var(--sp-3); animation: pop .5s var(--ease) both; }
.done-card.err .done-icon { background: var(--err); }
.done-icon .icon { width: 2rem; height: 2rem; }
@keyframes pop { from { transform: scale(.3); } }
.log { list-style: none; padding: 0; margin: var(--sp-4) auto; max-width: 32rem; display: grid; gap: var(--sp-2); }
.log li { display: flex; gap: var(--sp-2); align-items: center; } .log li.ok .icon { color: var(--ok); } .log li.err .icon { color: var(--err); }
.conn-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.conn { display: grid; gap: var(--sp-1); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r); justify-items: start; }
.conn code { word-break: break-all; }

/* command palette */
.palette { padding: 0; width: min(36rem, calc(100vw - 2rem)); margin-top: 12vh; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: var(--sp-4); font-size: 1.05rem; background: transparent; }
.palette input:focus-visible { outline: none; }
.palette ul { list-style: none; margin: 0; padding: var(--sp-2); max-height: 50vh; overflow-y: auto; }
.palette li { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); cursor: pointer; }
.palette li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.palette li small { margin-left: auto; color: var(--fg-muted); }
.palette .empty-row { color: var(--fg-muted); padding: var(--sp-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  body::before, .auth { animation: none !important; }
  .card:hover, .metric:hover, .svc:hover, .tile:hover, .conn:hover { transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}
.stepper li > a, .stepper li > span { padding: var(--sp-2) var(--sp-2) var(--sp-3) 0; } .stepper .dot { line-height: 1; font-size: .85rem; }
.stepper li > span::before, .stepper li > a::before { bottom: 0; }

/* ===================== v3: responsive, touch targets, OTP field ===================== */
html { overflow-x: hidden; }
img, svg, video { max-width: 100%; }
.content { padding-left: max(var(--sp-6), env(safe-area-inset-left)); padding-right: max(var(--sp-6), env(safe-area-inset-right)); padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom)); }
.page-head h1 { min-width: 0; overflow-wrap: anywhere; }
.page-head > :last-child { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
code, pre, td, dd, .muted, .callout, .toast p { overflow-wrap: anywhere; }
.grid { grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); }
.grid.metrics { grid-template-columns: repeat(auto-fit, minmax(min(9.5rem, 100%), 1fr)); }
.tiles { grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr)); }
.tiles.big { grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr)); }
.svc-grid { grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr)); }
.conn-grid { grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr)); }
.form { grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr)); }
.donut { width: min(9rem, 40vw); height: auto; aspect-ratio: 1; }
.quota-row { grid-template-columns: minmax(4rem, 8rem) minmax(0, 1fr) auto; }
.toasts, .js .toasts { right: max(var(--sp-4), env(safe-area-inset-right)); bottom: max(var(--sp-4), env(safe-area-inset-bottom)); }
.stepper-compact { display: none; }

/* touch: >= 44px targets on touch devices and narrow/zoomed layouts */
@media (pointer: coarse), (max-width: 1024px) {
  button, .btn, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, .nav-link, summary.btn, .chip, .crumbs a, .tree li > a { min-height: 44px; }
  .btn-sm, form.inline input, form.inline button { min-height: 44px; }
  label.check, .tile { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 1.35rem; height: 1.35rem; }
  .crumbs a { display: inline-flex; align-items: center; }
  .toast .x, .dialog-close { min-width: 44px; min-height: 44px; }
  td a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* tablets */
@media (max-width: 1024px) {
  .content { padding: var(--sp-5) max(var(--sp-5), env(safe-area-inset-right)) max(var(--sp-5), env(safe-area-inset-bottom)) max(var(--sp-5), env(safe-area-inset-left)); }
}

/* phones and 200% zoom: stacked table cards, compact stepper, full-screen sheets */
@media (max-width: 640px) {
  .content { padding: var(--sp-4) max(var(--sp-4), env(safe-area-inset-right)) max(var(--sp-4), env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left)); }
  .card { padding: var(--sp-4); }
  h1 { font-size: 1.3rem; }
  .card-head .search, .search input { width: 100%; }
  .stepper { display: none; }
  .stepper-compact { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); font-weight: 600; }
  .stepper-compact progress { width: 100%; }
  .wiz-nav { flex-direction: column; } .wiz-nav button { width: 100%; }
  .summary { grid-template-columns: 1fr; gap: var(--sp-1); } .summary dd { margin-bottom: var(--sp-2); }
  .quota-row { grid-template-columns: 1fr auto; } .quota-row progress { grid-column: 1 / -1; grid-row: 2; }
  dialog:not(.palette) { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .palette { margin-top: max(var(--sp-3), env(safe-area-inset-top)); width: calc(100vw - 1.5rem); }
  .js .toasts { left: max(var(--sp-3), env(safe-area-inset-left)); right: max(var(--sp-3), env(safe-area-inset-right)); width: auto; }
  .auth { padding: max(var(--sp-3), env(safe-area-inset-top)) var(--sp-3) var(--sp-3); align-items: start; }
  .auth .card { padding: var(--sp-5) var(--sp-4); margin-top: 3.5rem; }
  .donut-wrap { justify-content: center; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .auth { align-items: start; } .auth .card { margin: var(--sp-6) 0; }
  dialog:not(.palette) { max-height: 100dvh; overflow-y: auto; }
}

/* login: one OTP field that looks like 6 boxes (CSS only, autofill keeps working) */
.login-form { display: grid; gap: var(--sp-2); }
.login-form input + label { margin-top: var(--sp-2); }
.login-form button { margin-top: var(--sp-3); }
.otp-field { --cell: 2ch; font: 700 1.5rem/1 var(--mono); letter-spacing: 1ch; padding: 0 0 0 .5ch; width: calc(12ch + 2px); max-width: 100%; height: 3.2rem;
  background-image: linear-gradient(90deg, transparent calc(var(--cell) - 1px), var(--border) calc(var(--cell) - 1px));
  background-size: var(--cell) 100%; background-repeat: repeat-x; background-position: 0 0; justify-self: start; }
.otp-field::placeholder { letter-spacing: 1ch; }
.pw-row { flex-wrap: wrap; } .pw-row input { min-width: 0; flex: 1 1 10rem; }
td a, .card-head > a { display: inline-flex; align-items: center; min-height: 24px; }
.slider-row input[type="range"] { min-height: 44px; }
@media (pointer: coarse), (max-width: 1024px) { td a { min-height: 44px; } }
@media (pointer: coarse), (max-width: 1024px) {
  .card-head > a { display: inline-flex; align-items: center; min-height: 44px; }
  input[type="range"] { min-height: 44px; }
}

/* tables become stacked cards wherever their card is too narrow for the action columns (sidebar or not) */
.card:has(> .table-wrap) { container-type: inline-size; }
@container (max-width: 820px) {
  .table-wrap { overflow: visible; margin: 0; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap tr { border: 1px solid var(--border); border-radius: var(--r); margin-bottom: var(--sp-3); padding: var(--sp-2) var(--sp-3); background: var(--surface); }
  .table-wrap td { border: 0; padding: var(--sp-2) 0; display: grid; grid-template-columns: minmax(6.5rem, 35%) minmax(0, 1fr); gap: var(--sp-2); align-items: center; }
  .table-wrap td[data-label]::before { content: attr(data-label); font-size: .78rem; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em; }
  .table-wrap td.actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); white-space: normal; }
  .table-wrap td.actions > form.inline { margin: 0; }
  .table-wrap td.actions .more { flex-basis: 100%; }
  .table-wrap td.actions::before { display: none; }
  .table-wrap td[colspan] { display: block; }
  tbody tr:hover { background: var(--surface); }
  form.inline { display: flex; flex-wrap: wrap; }
  .more form.inline, td:not(.actions) form.inline, form.inline:has(input:not([type=hidden])) { width: 100%; }
  form.inline input { flex: 1 1 8rem; width: auto; }
  .more { display: block; } .more summary { width: 100%; }
}
.badge { white-space: nowrap; }
.table-wrap td > * { justify-self: start; }

/* ===================== v4: protocol pages, grouped service tiles ===================== */
ul.svc-grid, ul.svc-list { list-style: none; margin: 0; padding: 0; }   /* flush with the card title */
.svc-grid { grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); margin-bottom: var(--sp-4); }
.svc-grid > li { display: flex; }
.svc-grid .svc { flex: 1; min-width: 0; color: var(--fg); text-decoration: none; min-height: 44px; }
a.svc:hover { border-color: var(--accent); }
.svc .name { display: grid; overflow: visible; white-space: normal; }
.svc .name small { font-weight: 400; font-size: .75rem; color: var(--fg-muted); font-family: var(--mono); overflow-wrap: anywhere; }
.svc-group { margin: 0 0 var(--sp-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); }
.svc-list { display: grid; gap: var(--sp-3); }
.svc-list > li { display: grid; gap: var(--sp-2); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.svc-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.svc-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.svc-head .name { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.svc-ctl { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.svc-ctl form.inline { margin: 0; width: auto; }
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.copy-row code { min-width: 0; }
.proto-grid { align-items: start; }
.svc-grid + .svc-group { margin-top: var(--sp-5); }
.summary { grid-template-columns: max-content minmax(0, 1fr); } .summary dd { min-width: 0; } .summary .badge { white-space: normal; }
@media (max-width: 640px) { .summary { grid-template-columns: minmax(0, 1fr); } }
@container (max-width: 820px) { .table-wrap thead { display: block; } .table-wrap td.actions button { white-space: normal; text-align: left; } }
.table-wrap td .badge { white-space: normal; }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); } .chips form.inline { margin: 0; width: auto; }
[hidden] { display: none !important; }  /* stacked-table display:block must not reveal hidden rows */

/* ---- public pages (status, info, register) and request admin ---- */
.pub-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-2) var(--sp-4);
  background: var(--surface); border-bottom: 1px solid var(--border); }
.pub-head .brand { padding: var(--sp-2) 0; }
.pub-nav { display: flex; flex-wrap: wrap; gap: var(--sp-1); flex: 1 1 auto; }
.pub-nav .nav-link { min-height: 2.75rem; }
.pub { max-width: 56rem; margin: 0 auto; padding: var(--sp-6) var(--sp-4); }
.status-hero { display: flex; align-items: center; gap: var(--sp-4); }
.status-hero .done-icon { margin: 0; flex: none; }
.status-hero h2 { margin: 0; font-size: 1.25rem; }
.status-hero p { margin: 0; }
.status-hero.ok .done-icon { background: var(--ok); }
.status-hero.err .done-icon { background: var(--err); }
.status-hero.warn .done-icon { background: var(--warn); }
.status-list { list-style: none; margin: 0 0 var(--sp-3); padding: 0; }
.status-list > li { display: grid; gap: var(--sp-2); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.status-name { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); }
.status-pct { font-size: .85rem; }
.uptime { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; }
.uptime li { height: 1.5rem; border-radius: 3px; background: var(--surface-2); }
.uptime li.ok { background: var(--ok); } .uptime li.err { background: var(--err); } .uptime li.maint { background: var(--warn); }
.md h2 { margin-top: var(--sp-5); } .md h2:first-child { margin-top: 0; }
.md ul { padding-left: 1.2rem; } .md li { margin-bottom: var(--sp-1); }
.md table { margin-bottom: var(--sp-4); display: block; overflow-x: auto; }
.md th, .md td { padding: var(--sp-2) var(--sp-3); }
.md code { overflow-wrap: anywhere; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.count { margin-left: auto; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  font-size: .75rem; font-weight: 700; text-align: center; }
.req { padding: var(--sp-4) 0; border-top: 1px solid var(--border); }
.req h3 { margin: 0; font-size: 1rem; }
.req .summary { margin-bottom: var(--sp-3); }
label.check input[type="checkbox"] { flex: none; }
.md th, .md td { word-break: normal; overflow-wrap: normal; }
.req form.inline input { width: min(14rem, 100%); }

/* ===================== v5: top navigation (no sidebar), finer look ===================== */
:root { --topbar-h: 56px; --page-w: 80rem; }
.topbar { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--border); }
.topbar-in { max-width: var(--page-w); margin: 0 auto; height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 max(var(--sp-4), env(safe-area-inset-right)) 0 max(var(--sp-4), env(safe-area-inset-left)); }
.topbar .brand { padding: 0; font-size: .95rem; flex: none; }
.topbar .logo { width: 24px; height: 24px; }
.mainnav { flex: 1 1 auto; min-width: 0; }
.nav-list, .dd-menu { list-style: none; margin: 0; padding: 0; }
.nav-list { display: flex; align-items: center; gap: 2px; }
.topbar .nav-link { font-size: .875rem; padding: .375rem .625rem; gap: .45rem; white-space: nowrap; }
.dd { position: relative; }
.dd > summary { list-style: none; cursor: pointer; user-select: none; }
.dd > summary::-webkit-details-marker { display: none; }
.dd > summary .icon { width: 14px; height: 14px; transition: transform .15s; }
.dd[open] > summary .icon { transform: rotate(180deg); }
.dd > summary.active, .dd > summary.active:hover { color: var(--accent); background: var(--accent-soft); }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 13rem; padding: .3rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 8px 24px rgba(16,24,40,.14); }
.dd-end .dd-menu { left: auto; right: 0; }
.dd-menu .nav-link { width: 100%; }
.dd-menu form { margin: 0; }
.dd-menu button.nav-link { background: none; border: 0; font: inherit; font-size: .875rem; color: var(--fg-muted); cursor: pointer; box-shadow: none; text-align: left; }
.dd-menu button.nav-link:hover { background: var(--surface-2); color: var(--fg); }
.dd-note { padding: .4rem .625rem .5rem; margin-bottom: .3rem; font-size: .8rem; color: var(--fg-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.nav-link .count { margin-left: auto; }
.dd > summary .count { margin-left: .1rem; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-muted); flex: none; }
.sdot.ok { background: var(--ok); } .sdot.err { background: var(--err); } .sdot.maint { background: var(--warn); }
.topbar-tools { display: flex; align-items: center; gap: var(--sp-1); margin-left: auto; flex: none; }
.topbar-tools .btn { padding: .375rem .5rem; font-size: .85rem; gap: .4rem; }
.topbar .theme-toggle .label { display: none; }
.topbar .kbd { margin-left: 0; }
.avatar { list-style: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--grad); color: #fff; font-weight: 700; font-size: .85rem; }
.avatar::-webkit-details-marker { display: none; }
.menu-btn, .menu-close { display: none; }
.breadcrumbs { max-width: var(--page-w); margin: 0 auto; padding: var(--sp-4) var(--sp-6) 0; font-size: .8rem; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; color: var(--fg-muted); }
.breadcrumbs li { display: flex; align-items: center; }
.breadcrumbs li + li::before { content: "/"; margin-right: .35rem; opacity: .5; }
.breadcrumbs a { color: var(--fg-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--fg); }
.content { max-width: var(--page-w); margin: 0 auto; padding-top: var(--sp-4); }
/* finer look: less glow and shadow, thinner focus ring, calmer headings */
h1 { font-size: 1.375rem; }
:focus-visible { outline-width: 2px; }
body::before { opacity: .3; }
.metric::before { opacity: .12; }
.btn:not(.btn-ghost):not(.btn-danger):not(.chip), button:not(.btn-ghost):not(.danger):not(.chip):not(.x):not(.dialog-close):not(.nav-link) { box-shadow: 0 1px 2px rgba(79,70,229,.3); }
.btn-glow { animation: none; }
.metric:hover, .svc:hover, .conn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.toast { border-left-width: 3px; }

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }  /* a filter would trap the fixed sheet */
  .mainnav { display: none; position: fixed; inset: 0; z-index: 60; overflow-y: auto; background: var(--surface);
    padding: max(var(--sp-3), env(safe-area-inset-top)) max(var(--sp-4), env(safe-area-inset-right)) max(var(--sp-6), env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left)); }
  .mainnav:target, .nav-open .mainnav { display: block; }
  .menu-close { display: flex; margin-left: auto; width: max-content; }
  .nav-list { flex-direction: column; align-items: stretch; gap: var(--sp-1); margin-top: var(--sp-3); }
  .mainnav .nav-link { font-size: 1rem; padding: .625rem .75rem; min-height: 44px; }
  .mainnav .dd-menu { position: static; min-width: 0; padding: 0 0 0 var(--sp-4); border: 0; box-shadow: none; background: none; }
  .topbar-tools .kbd { display: none; }
  .topbar-tools .btn, .avatar { min-width: 44px; min-height: 44px; justify-content: center; }
  .avatar { width: 44px; height: 44px; }
  .breadcrumbs { padding: var(--sp-3) max(var(--sp-4), env(safe-area-inset-right)) 0 max(var(--sp-4), env(safe-area-inset-left)); }
}
@media (pointer: coarse), (max-width: 1024px) { .breadcrumbs a { display: inline-flex; align-items: center; min-height: 44px; } }
@media (max-width: 420px) { .menu-btn .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } .topbar-in { gap: var(--sp-2); } }
.qr { display: block; background: #fff; padding: 8px; border-radius: var(--r-sm); margin-bottom: var(--sp-3); }  /* dark modules need a light quiet zone in dark mode */

/* row action menus (⋯): may open past the table's horizontal scroll box */
.table-wrap:has(details.row-menu[open]) { overflow: visible; }
.row-menu .dd-menu { min-width: 10rem; text-align: left; }
.dd-menu button.danger-link { color: var(--err); }
.dd-form { display: grid; gap: .3rem; padding: .3rem; } .dd-form input { width: 100%; }

/* v6: selection UIs (ACL browser, rights matrix, pickers, chips) */
.js .no-js { display: none; }
.acl-grid { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .acl-grid { grid-template-columns: minmax(0, 1fr); } }
.browse, .browse ul, .ftree ul { list-style: none; margin: 0; padding: 0; }
.browse { margin: var(--sp-3) 0; border: 1px solid var(--border); border-radius: var(--r); }
.browse > li { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr); align-items: start; padding: .25rem .5rem; border-top: 1px solid var(--border); }
.browse > li:first-child { border-top: 0; }
.browse > li > details { grid-column: 1; grid-row: 1; }
.browse > li > details[open] { grid-column: 1 / -1; display: contents; }
.browse > li > details > ul { grid-column: 2; grid-row: 2; padding-left: .25rem; }
.browse summary, .ftree summary { list-style: none; cursor: pointer; width: 1.5rem; height: 2rem; display: grid; place-items: center; }
.browse summary::-webkit-details-marker, .ftree summary::-webkit-details-marker { display: none; }
.browse summary::before, .ftree summary::before { content: "▸"; color: var(--fg-muted); }
.browse details[open] > summary::before, .ftree details[open] > summary::before { content: "▾"; }
.browse .dname, .browse a, .browse li span { display: inline-flex; align-items: center; gap: .4rem; min-height: 2rem; }
.browse .dname { grid-column: 2; grid-row: 1; }
.browse .locked, .ftree .locked { opacity: .55; }
.ftree { border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-2) var(--sp-3); max-height: 18rem; overflow-y: auto; }
.ftree ul ul { padding-left: 1.25rem; }
.ftree li > details { display: block; }
.ftree li > details > summary { float: left; margin-left: -1.6rem; }
.ftree > ul { padding-left: 1.6rem; }
.ftree .icon, .browse .icon { color: var(--accent); }
.acl-add .rwx { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.acl-preview { font-family: var(--mono); }
.sel-filter { display: block; width: 100%; margin: .25rem 0; }
select[multiple] { min-height: 8rem; }
.matrix td, .matrix th { vertical-align: middle; } .matrix th small { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; }
.switch { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.switch input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 2.5rem; height: 1.4rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); position: relative; margin: 0; cursor: pointer; flex: none; transition: background .15s; }
.switch input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.4rem - 6px); height: calc(1.4rem - 6px); border-radius: 50%; background: var(--fg-muted); transition: transform .15s; }
.switch input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.switch input[type="checkbox"]:checked::after { transform: translateX(1.1rem); background: #fff; }
.bulk, .filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.filters label { display: flex; align-items: center; gap: var(--sp-2); }
.chips-box { display: flex; flex-wrap: wrap; gap: .35rem; margin: .35rem 0; }
.chips-box .chip { display: inline-flex; align-items: center; gap: .3rem; }
.row-menu { display: inline-block; vertical-align: middle; } td.actions { white-space: nowrap; }

/* ---- Telegram: link box, notification toggles, login code step ---- */
fieldset.checks { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
fieldset.checks legend { width: 100%; font-weight: 600; margin-bottom: var(--sp-2); }
fieldset.checks legend .hint { font-weight: 400; }
.tg-link { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.tg-link h3 { margin: 0 0 var(--sp-2); }
.tg-resend { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.tg-wait.ok { color: var(--ok); }

/* ---- S3 ---- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; border-bottom: 1px solid var(--border); }
.tabs .tab { padding: var(--sp-2) var(--sp-3); color: var(--fg-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px; display: inline-flex; align-items: center; }
.tabs .tab:hover { color: var(--fg); }
.tabs .tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .badge { margin-left: auto; }
.path ol { display: flex; flex-wrap: wrap; gap: var(--sp-1); list-style: none; margin: 0; padding: 0; min-width: 0; }
.path li { overflow-wrap: anywhere; }
.path li + li::before { content: "/"; color: var(--fg-muted); margin-right: var(--sp-1); }
.path [aria-current] { font-weight: 600; }
.dropzone .drop { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center; padding: var(--sp-6) var(--sp-4);
  border: 2px dashed var(--border); border-radius: var(--r); background: var(--surface-2); cursor: pointer; font-weight: 400; }
.dropzone .drop .icon { width: 1.75rem; height: 1.75rem; }
.dropzone.over .drop, .dropzone .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type="file"] { max-width: 100%; }
.js .dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.uploads { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.uploads li { display: grid; gap: var(--sp-1); overflow-wrap: anywhere; }
.uploads li.err { color: var(--err); } .uploads li.ok span { color: var(--ok); }
.preview-img { max-width: 100%; max-height: 70vh; display: block; border-radius: var(--r-sm); background: var(--surface-2); }
.preview-pdf { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--r-sm); }
.preview-text { max-height: 60vh; white-space: pre-wrap; overflow-wrap: anywhere; }
.callout.na { display: flex; gap: var(--sp-2); align-items: flex-start; }
fieldset[disabled] { opacity: .55; }
fieldset[disabled] * { cursor: not-allowed; }
.rights-form { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.rights { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); border: 0; padding: 0; margin: 0; }
.snippet { position: relative; display: grid; gap: var(--sp-2); }
.snippet pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.snippet button { justify-self: start; }
.card-head form.search { margin-left: auto; }
.table-wrap td a .icon { vertical-align: -.15em; margin-right: .3em; }
.dd-form { display: grid; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3); }
