/* Mailu panel: slate neutrals, steel-blue accent, peach highlight. Light and dark via tokens. */
:root {
  --bg: #f3f5f8; --panel: #ffffff; --panel-2: #f8fafc; --fg: #1c2733; --muted: #5b6b7e; --line: #dde3ea; --line-strong: #c3ccd8;
  --accent: #2f5f8a; --accent-fg: #ffffff; --accent-soft: #e6eef6; --accent-ink: #2f5f8a;
  --peach: #f4a583; --peach-soft: #fdeee6; --peach-ink: #8a4423;
  --ok: #17693f; --ok-bg: #e5f5ec; --bad: #b42318; --bad-bg: #fdecea;
  --warn: #8a4b00; --warn-bg: #fff1de; --code-bg: #edf1f5;
  --shadow: 0 1px 2px rgba(28,39,51,.06), 0 1px 1px rgba(28,39,51,.04);
  --shadow-lg: 0 10px 30px rgba(28,39,51,.14);
  --hero-a: #1f4668; --hero-b: #2f5f8a;
  /* spacing, radius, type scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-card: 16px;
  --fs-sm: 13px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 24px;
  --side-w: 248px; --top-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11171f; --panel: #19212b; --panel-2: #1e2833; --fg: #e6edf4; --muted: #9fb0c3; --line: #2a3644; --line-strong: #3a4859;
    --accent: #8dbbe4; --accent-fg: #0d1824; --accent-soft: #1f3044; --accent-ink: #8dbbe4;
    --peach: #f2b48f; --peach-soft: #2e2621; --peach-ink: #f2b48f;
    --ok: #4cc58a; --ok-bg: #12301f; --bad: #ff8f85; --bad-bg: #3a1a17;
    --warn: #f5b25c; --warn-bg: #3a2a10; --code-bg: #212c38; --shadow: 0 1px 2px rgba(0,0,0,.35); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
    --hero-a: #12283d; --hero-b: #2a4f73;
  }
}
:root[data-theme="dark"] {
  --bg: #11171f; --panel: #19212b; --panel-2: #1e2833; --fg: #e6edf4; --muted: #9fb0c3; --line: #2a3644; --line-strong: #3a4859;
  --accent: #8dbbe4; --accent-fg: #0d1824; --accent-soft: #1f3044; --accent-ink: #8dbbe4;
  --peach: #f2b48f; --peach-soft: #2e2621; --peach-ink: #f2b48f;
  --ok: #4cc58a; --ok-bg: #12301f; --bad: #ff8f85; --bad-bg: #3a1a17;
  --warn: #f5b25c; --warn-bg: #3a2a10; --code-bg: #212c38; --shadow: 0 1px 2px rgba(0,0,0,.35); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  --hero-a: #12283d; --hero-b: #2a4f73;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 Inter, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--fg); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: var(--fs-xl); letter-spacing: -.01em; } h2 { font-size: var(--fs-lg); } h3 { font-size: var(--fs-md); }
a { color: var(--accent-ink); }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-fg); padding: 8px 12px; z-index: 100; border-radius: var(--r-md); }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); font-size: var(--fs-sm); }
.mono, code { font: 12.5px ui-monospace, Consolas, monospace; }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* ---------------------------------------------------------------- app shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; padding: 16px 12px; overflow-y: auto; z-index: 40; }
.side-brand { padding: 4px 8px 12px; }
.brand { font-weight: 700; font-size: 18px; color: var(--fg); text-decoration: none; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.brand svg { width: 28px; height: 28px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); text-decoration: none; color: var(--muted); font-weight: 500; position: relative; }
.side-nav a .ico { width: 20px; height: 20px; }
.side-nav a:hover { background: var(--code-bg); color: var(--fg); }
.side-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.side-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--peach); }
.side-nav .nav-sep { border-top: 1px solid var(--line); margin-top: 10px; }
.side-nav .nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 12px 4px; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.side-foot a { color: var(--muted); text-decoration: none; }
.side-foot a:hover { color: var(--fg); text-decoration: underline; }
.foot-links { display: flex; gap: 6px 14px; flex-wrap: wrap; }
.main-col { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.page-title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spacer { flex: 1; }
.menu-btn { display: none; }
main.content, main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 24px 56px; display: flex; flex-direction: column; gap: 20px; flex: 1; }
main:focus, h1[tabindex="-1"]:focus { outline: none; }
.scrim { display: none; }
.user-menu > summary { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); min-height: 40px; }
.user-menu > summary:hover { border-color: var(--line-strong); }
.user-menu .um-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: var(--fs-sm); }
.user-menu .menu-list { min-width: 240px; }
.um-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.um-head .um-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.um-head .um-mail { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-md); color: var(--fg); text-decoration: none; background: transparent; border: 0; font: inherit; font-weight: 500; cursor: pointer; min-height: 38px; text-align: left; }
.menu-item:hover { background: var(--code-bg); filter: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.foot { width: 100%; padding: 16px 24px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: var(--fs-sm); border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 290px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,16,24,.5); z-index: 35; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  main.content, main { padding: 16px 16px 48px; }
  .side-nav a[aria-current="page"]::before { left: -12px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; background: var(--panel-2); }
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
main > .stack { gap: 20px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1; min-width: 160px; }
.subpanel { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; margin: 0 0 10px; width: 100%; }

/* ---------------------------------------------------------------- stats and charts */
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 18px; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label ico" "value value" "sub sub"; gap: 4px 10px; align-items: center; }
.stat-ico { grid-area: ico; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.stat-ico .ico { width: 20px; height: 20px; }
.stat-label { grid-area: label; font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.stat-value { grid-area: value; font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: anywhere; }
.stat-sub { grid-area: sub; font-size: 12.5px; color: var(--muted); }
.stat.peach { background: var(--peach-soft); border-color: transparent; }
.stat.peach .stat-ico { background: var(--peach); color: #3a1c0a; }
.stat.peach .stat-label, .stat.peach .stat-sub { color: var(--peach-ink); }
.stat.bad { background: var(--bad-bg); border-color: transparent; }
.stat.bad .stat-ico { background: var(--bad); color: var(--bad-bg); }
.stat.bad .stat-label, .stat.bad .stat-sub, .stat.bad .stat-value { color: var(--bad); }
.stat.blue { background: var(--accent-soft); border-color: transparent; }
.stat.blue .stat-ico { background: var(--accent); color: var(--accent-fg); }
.stat.blue .stat-label, .stat.blue .stat-sub { color: var(--accent-ink); }
.gauge { width: 132px; height: 132px; display: block; flex: none; }
.gauge-track { fill: none; stroke: var(--code-bg); stroke-width: 9; }
.gauge-fill { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; }
.gauge.warn .gauge-fill { stroke: var(--peach); }
.gauge.full .gauge-fill { stroke: var(--bad); }
.gauge-text { fill: var(--fg); font-size: 22px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.gauge-sub { fill: var(--muted); font-size: 8px; text-anchor: middle; }
.spark { display: block; width: 100%; height: 36px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark .spark-area { fill: var(--accent-soft); stroke: none; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); list-style: none; margin: 0; padding: 0; }
.legend > * { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.legend i.peach { background: var(--peach); }

/* progress bars */
.bar-wrap { margin-bottom: 14px; }
.bar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.bar { height: 8px; border-radius: 99px; background: var(--code-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.full > i { background: repeating-linear-gradient(45deg, var(--warn), var(--warn) 6px, transparent 6px, transparent 9px); }

/* ---------------------------------------------------------------- forms and buttons */
label, .lbl { display: block; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md); font: inherit; background: var(--panel); color: var(--fg); min-height: 40px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; box-shadow: 0 0 0 4px var(--accent-soft); }
input::placeholder { color: var(--muted); opacity: .75; }
textarea { resize: vertical; min-height: 84px; line-height: 1.45; display: block; }
textarea[aria-invalid="true"] { border-color: var(--bad); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.suffix { display: flex; align-items: stretch; }
.suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.suffix .at { padding: 0 10px; display: flex; align-items: center; background: var(--code-bg); border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; color: var(--muted); font-size: 13px; word-break: break-all; }
button, .btn { font: inherit; padding: 8px 16px; border-radius: var(--r-md); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; font-weight: 600; }
button:hover:not(:disabled), .btn:hover { filter: brightness(1.08); }
button.ghost, .btn.ghost { background: transparent; color: var(--accent-ink); border-color: var(--line-strong); }
button.ghost:hover:not(:disabled), .btn.ghost:hover { background: var(--accent-soft); filter: none; }
button.danger, .btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.danger:hover:not(:disabled) { background: var(--bad-bg); filter: none; }
button.small, .btn.small { padding: 4px 11px; min-height: 32px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.icon-btn { padding: 6px 9px; }
button.icon-btn { min-width: 36px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 3px 12px; font-size: 12.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.pill.peach { background: var(--peach-soft); color: var(--peach-ink); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); text-transform: uppercase; }
.avatar.a1 { background: var(--peach-soft); color: var(--peach-ink); }
.avatar.a2 { background: var(--ok-bg); color: var(--ok); }
.avatar.a3 { background: var(--code-bg); color: var(--fg); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: var(--accent); }
input[type=search] { max-width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--fg); font-size: var(--fs-sm); }
.field-err { color: var(--bad); font-size: var(--fs-sm); margin-top: 4px; }
input[aria-invalid="true"] { border-color: var(--bad); }
.pw-row { display: flex; gap: 6px; align-items: stretch; flex-wrap: wrap; }
.pw-row input { flex: 1; min-width: 160px; }
.pw-info { min-height: 18px; }
.pw-near { color: var(--warn); }
.pw-str.s0, .pw-str.s1, .bad-text { color: var(--bad); font-weight: 600; } .pw-str.s2 { color: var(--warn); font-weight: 600; } .pw-str.s3 { color: var(--ok); font-weight: 600; }
.full-text { color: var(--warn); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }

/* ---------------------------------------------------------------- feedback */
.msg { padding: 11px 14px; border-radius: var(--r-md); font-size: 14px; border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.msg.err { background: var(--bad-bg); color: var(--bad); }
.msg.good { background: var(--ok-bg); color: var(--ok); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.info { background: var(--accent-soft); color: var(--accent-ink); }
.msg.banner { align-items: center; flex-wrap: wrap; }
.banner .grow { flex: 1; min-width: 200px; }
.small-msg { font-size: var(--fs-sm); padding: 8px 10px; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.mute { background: var(--code-bg); color: var(--muted); }
.badge.admin { background: var(--peach-soft); color: var(--peach-ink); }
.badge .ico { width: 12px; height: 12px; stroke-width: 3; }
.steps li b .ico, .checklist .ck .ico { width: 14px; height: 14px; stroke-width: 3; }
/* one calm onboarding notice instead of stacked warnings (main.js banners) */
.onboard { align-items: flex-start; padding: 14px 16px; }
.onboard strong { display: block; font-size: var(--fs-md); }
.onboard p { margin: 2px 0 0; }
.onboard ul { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.onboard li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--panel); color: var(--fg); border-radius: var(--r-md); padding: 10px 12px; }
.onboard li > span { flex: 1; min-width: 200px; }
.onboard li b { display: block; }
.onboard li small { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
.loading { padding: 24px; text-align: center; color: var(--muted); }
.empty { padding: 32px 12px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--fg); margin-bottom: 4px; }
/* Toasts: top-right under the top bar on desktop, bottom on phones. dom.js moves #toasts into an open modal dialog
   so they stay above its backdrop; the box itself ignores pointer events so it never blocks the page beneath. */
#toasts { position: fixed; top: calc(var(--top-h) + 12px); right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; width: min(calc(100vw - 32px), 380px); pointer-events: none; text-align: left; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--fg); color: var(--bg); padding: 10px 8px 10px 14px; border-radius: var(--r-md); font-size: 14px; line-height: 1.45; box-shadow: var(--shadow-lg); }
.toast > .ico { margin-top: 2px; }
.toast.err { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast.err { color: #2a0906; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast.err { color: #2a0906; } }
.toast-main { flex: 1; min-width: 0; }
.toast-text { white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.toast.open .toast-text { display: block; max-height: min(40vh, 260px); overflow-y: auto; }
button.toast-more { background: transparent; border: 0; color: inherit; padding: 0; margin-top: 4px; min-height: 24px; font-size: 13px; font-weight: 600; text-decoration: underline; }
button.toast-x { background: transparent; border: 0; color: inherit; min-height: 28px; min-width: 28px; padding: 2px 6px; flex: none; }
button.toast-more:hover:not(:disabled), button.toast-x:hover:not(:disabled) { filter: none; opacity: .8; }
.toast :focus-visible { outline-color: currentColor; }
@media (max-width: 640px) {
  #toasts { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); right: 12px; left: 12px; width: auto; flex-direction: column-reverse; }
}
.offline { position: sticky; top: 0; z-index: 90; background: var(--bad); color: #fff; text-align: center; padding: 8px 12px; font-size: var(--fs-sm); }
.skel-wrap { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; }
.skel { height: 16px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--code-bg), var(--line), var(--code-bg)); background-size: 200% 100%; animation: sk 1.4s ease infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---------------------------------------------------------------- tabs, steps, checklist */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 8px 14px; min-height: 44px; font-weight: 600; }
.tabs button:hover:not(:disabled) { color: var(--fg); filter: none; }
.tabs button[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tabs button .count { margin-left: 6px; background: var(--code-bg); color: var(--muted); border-radius: 99px; padding: 0 7px; font-size: 12px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; padding: 0; margin: 0; list-style: none; }
.steps li { flex: 1; min-width: 150px; display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); font-size: 13px; color: var(--muted); background: var(--panel); }
.steps li b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--code-bg); font-size: 12px; flex: none; }
.steps li.done { color: var(--ok); } .steps li.done b { background: var(--ok); color: #fff; }
.steps li.now { color: var(--fg); border-color: var(--accent); } .steps li.now b { background: var(--accent); color: var(--accent-fg); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--muted); background: var(--panel); }
.checklist li.now { border-color: var(--accent); color: var(--fg); background: var(--accent-soft); }
.checklist li.done { color: var(--ok); }
.checklist .ck { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--code-bg); font-size: 12px; flex: none; }
.checklist li.done .ck { background: var(--ok); color: #fff; }
.checklist li.now .ck { background: var(--accent); color: var(--accent-fg); }

/* ---------------------------------------------------------------- lists, records, tables */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .main { flex: 1; min-width: 180px; word-break: normal; overflow-wrap: anywhere; }
.item .main small { display: block; color: var(--muted); font-size: 12.5px; }
.item .acts, .row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rec { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; display: grid; gap: 6px; background: var(--panel); }
.rec-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rec-head .type { font-weight: 700; font-size: 12px; background: var(--code-bg); border-radius: 6px; padding: 1px 7px; }
.rec-field { display: flex; gap: 8px; align-items: flex-start; }
.rec-field .k { width: 74px; flex: none; font-size: 12px; color: var(--muted); padding-top: 3px; }
.rec-field code { flex: 1; min-width: 0; max-height: 120px; overflow: auto; }
.rec .hint { margin: 0; }
.plans { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.plan { border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; background: var(--panel); }
.plan.cur { border-color: var(--accent); background: var(--accent-soft); }
.plan .price { font-size: 22px; font-weight: 700; margin: 4px 0; }
.plan ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.plan-act { margin-top: 10px; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tbody tr:hover td { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: var(--fs-sm); } .kv dd { margin: 0; word-break: break-word; }
.kv-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv-row .k { width: 110px; flex: none; font-size: var(--fs-sm); color: var(--muted); }
.kv-row code { flex: 1; min-width: 0; }
.cred { align-items: flex-start; }
.cred code { font-size: 14px; }
.danger-zone { border-color: var(--bad); }
.how { font-size: var(--fs-sm); }
.how summary { cursor: pointer; color: var(--accent-ink); padding: 4px 0; }
.how ol { margin: 6px 0; padding-left: 20px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; padding-top: 8px; }
button.sort, button.linkish { background: transparent; border: 0; color: inherit; padding: 0; min-height: 0; font: inherit; text-transform: inherit; letter-spacing: inherit; font-weight: inherit; }
button.linkish { color: var(--accent-ink); text-decoration: underline; font-weight: 600; }

/* menus (details.menu) */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
/* The list is position:fixed and placed by dom.js (placeMenu) so it always stays inside the viewport and is not
   clipped by scroll containers; it stays invisible until it has been placed. */
details.menu .menu-list { position: fixed; left: 0; top: 0; visibility: hidden; z-index: 60; min-width: 190px; max-width: calc(100vw - 16px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-lg); text-align: left; }
details.menu .menu-list.placed { visibility: visible; }
details.menu .menu-list button { justify-content: flex-start; width: 100%; text-align: left; white-space: normal; }
details.menu .menu-list button.ghost { border-color: transparent; color: var(--fg); font-weight: 500; }
details.menu .menu-list button.danger { border-color: transparent; }

/* ---------------------------------------------------------------- auth */
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero { position: relative; overflow: hidden; background: linear-gradient(150deg, var(--hero-a), var(--hero-b) 70%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth-hero::after { content: ""; position: absolute; width: 380px; height: 380px; right: -120px; bottom: -120px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--peach), transparent 68%); opacity: .55; pointer-events: none; }
.auth-hero .brand { color: #fff; }
.auth-hero h1 { font-size: 32px; color: #fff; }
.auth-hero p { margin: 0; max-width: 420px; color: #e3ecf5; font-size: 16px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 24px 0; background: var(--bg); }
.auth { width: 100%; max-width: 420px; margin: 0 auto; padding: 36px 16px; display: flex; flex-direction: column; gap: 16px; }
.auth-panel .auth { background: transparent; }
.auth .brand { justify-content: center; font-size: 24px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth form button[type=submit] { justify-content: center; }
.auth.wide { max-width: 720px; }
.auth h2 { font-size: var(--fs-md); margin: 12px 0 4px; }
@media (max-width: 800px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
}

/* ---------------------------------------------------------------- dialogs */
dialog { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--panel); color: var(--fg); padding: 22px; width: min(92vw, 420px); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10,16,24,.5); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog .row { justify-content: flex-end; }
dialog.wide { width: min(94vw, 560px); }
dialog h3 { font-size: var(--fs-sm); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------------------------------------------------------------- utilities */
[hidden] { display: none !important; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button.small .ico, .btn .ico { width: 16px; height: 16px; }
.logo { width: 28px; height: 28px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 10px; }
.offscreen { position: fixed; opacity: 0; left: -999px; }
.chip { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; color: var(--fg); padding: 2px 4px; border-radius: var(--r-md); }
.chip:hover { background: var(--accent-soft); }
.chip-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: var(--fs-sm); }

@media (max-width: 640px) {
  .user-menu .um-name, .menu-t { display: none; }
  .user-menu > summary { padding-right: 4px; }
  .rec-field { flex-direction: column; gap: 2px; } .rec-field .k { width: auto; }
  .item .acts { width: 100%; }
  .card { padding: 16px; }
  table.stackable thead { position: absolute; left: -9999px; }
  table.stackable, table.stackable tbody, table.stackable tr, table.stackable td { display: block; width: 100%; }
  table.stackable tr { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 12px; margin-bottom: 10px; background: var(--panel); }
  table.stackable td { border: 0; padding: 4px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; text-align: right; }
  table.stackable tbody tr:hover td { background: transparent; }
  table.stackable td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .kv { grid-template-columns: 1fr; }
  .kv-row .k { width: 100%; }
}
/* iOS Safari zooms the page when a focused control has a font smaller than 16px. */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }
}
/* Touch screens: every tappable control is at least 44px tall (WCAG 2.5.5 / Apple HIG). */
@media (pointer: coarse) {
  button, .btn, button.small, .btn.small, .menu-item, details.menu > summary, .tabs button { min-height: 44px; }
  button.icon-btn, button.toast-x { min-width: 44px; }
  button.sort, button.linkish, button.toast-more { min-height: 32px; padding-top: 6px; padding-bottom: 6px; }
  input, select { min-height: 44px; }
  input[type=checkbox], input[type=radio] { min-height: 0; width: 22px; height: 22px; }
  details.menu .menu-list { gap: 0; min-width: 220px; }
  .how summary { padding: 10px 0; }
}
@media print { .sidebar, .topbar, .foot, #toasts, .scrim { display: none; } .app { display: block; } }
