/* Fixon design system. Tokens and rules are documented in docs/DESIGN.md.
   Every colour, radius, shadow and duration lives in :root. Never hardcode them below. */

/* ── Tokens ── */
:root {
  color-scheme: dark;

  /* Surfaces: bg is the page, bg2 cards/sidebar, bg3 inputs/hover, bg4 raised/active */
  --bg: #050709;
  --bg2: #090d16;
  --bg3: #0d1220;
  --bg4: #131b2c;
  --border: #141d2e;
  --border2: #1b2a42;
  --border3: #263752;

  /* Text */
  --text-strong: #f3f7fc;
  --text: #e2eaf6;
  --text-sub: #8aa2c0;
  --text-faint: #5f7898;
  --muted: #4a6280;

  /* Accents and their dim (opaque) / soft (translucent) / line (border) variants */
  --cyan: #00c8f0;
  --cyan-dim: #001c2a;
  --cyan-soft: rgb(0 200 240 / .1);
  --cyan-soft-2: rgb(0 200 240 / .18);
  --cyan-line: rgb(0 200 240 / .38);
  --blue: #4a87f5;
  --blue-dim: #0d1c3a;
  --blue-soft: rgb(74 135 245 / .12);
  --blue-line: rgb(74 135 245 / .34);
  --green: #10d9a8;
  --green-dim: #031f17;
  --green-soft: rgb(16 217 168 / .1);
  --green-line: rgb(16 217 168 / .32);
  --red: #ef4468;
  --red-dim: #390914;
  --red-soft: rgb(239 68 104 / .1);
  --red-soft-2: rgb(239 68 104 / .18);
  --red-line: rgb(239 68 104 / .38);
  --amber: #f0a020;
  --amber-dim: #351b03;
  --amber-soft: rgb(240 160 32 / .09);
  --amber-line: rgb(240 160 32 / .34);
  --purple: #a855f7;
  --purple-dim: #1c0935;
  --purple-soft: rgb(168 85 247 / .12);
  --purple-line: rgb(168 85 247 / .34);

  /* Overlays and effects */
  --highlight: rgb(255 255 255 / .04);
  --highlight-2: rgb(255 255 255 / .07);
  --hairline: rgb(140 170 220 / .08);
  --row-hover: rgb(120 160 230 / .035);
  --glass: rgb(7 10 17 / .74);
  --glass-strong: rgb(13 18 32 / .92);
  --overlay: rgb(2 4 8 / .64);
  --on-accent: #02131c;
  --qr-bg: #ffffff;
  --frame-bg: #000000;
  --focus: var(--cyan);

  --grad: linear-gradient(135deg, var(--cyan), var(--blue));
  --grad-text: linear-gradient(110deg, var(--cyan) 0%, var(--blue) 55%, var(--purple) 110%);
  --grad-surface: linear-gradient(180deg, var(--highlight), transparent 60%);
  --ambient: radial-gradient(900px 480px at 100% -10%, rgb(74 135 245 / .1), transparent 60%),
             radial-gradient(700px 420px at -10% 110%, rgb(0 200 240 / .05), transparent 60%);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238aa2c0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  /* Elevation */
  --shadow-inset: inset 0 1px 0 var(--highlight);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .45);
  --shadow: inset 0 1px 0 var(--highlight), 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px -18px rgb(0 0 0 / .7);
  --shadow-lg: inset 0 1px 0 var(--highlight), 0 0 0 1px rgb(0 0 0 / .3), 0 28px 80px -20px rgb(0 0 0 / .8);
  --glow-cyan: 0 6px 22px -8px rgb(0 200 240 / .6);
  --glow-green: 0 0 10px rgb(16 217 168 / .55);
  --glow-orb: radial-gradient(circle, rgb(0 200 240 / .16), transparent 62%);
  --btn-sheen: inset 0 1px 0 rgb(255 255 255 / .28);

  /* Radii */
  --radius-2xs: 3px;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Spacing (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --fs-2xs: 10.5px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-3xl: 26px;
  --fs-stat: 30px;
  --fs-display: 48px;

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-1: 120ms;
  --dur-2: 180ms;
  --dur-3: 260ms;

  /* Layout */
  --sidebar-w: 248px;
  --rail-w: 68px;
  --topbar-h: 56px;
  --content-max: 1360px;
  --z-sticky: 20;
  --z-drawer: 40;
  --z-remote: 50;
  --z-toast: 100;

  /* Legacy alias kept for older markup */
  --glow: var(--shadow);
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: var(--fs-md)/1.5 var(--font); font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  background: var(--ambient), var(--bg); background-attachment: fixed;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { color: var(--text-strong); letter-spacing: -.02em; font-weight: 600; }
a { color: var(--cyan); text-underline-offset: 3px; }
strong { font-weight: 600; color: var(--text); }
.mono, code, kbd { font-family: var(--mono); }
.mono, code { font-size: var(--fs-sm); }
.muted { color: var(--text-sub); }
.nowrap { white-space: nowrap; }
::selection { background: var(--cyan-soft-2); color: var(--text-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
* { scrollbar-width: thin; scrollbar-color: var(--border3) transparent; }

kbd {
  display: inline-flex; align-items: center; min-width: 18px; height: 18px; padding: 0 5px; justify-content: center;
  font-size: var(--fs-2xs); font-weight: 500; line-height: 1; color: var(--text-sub);
  background: var(--bg3); border: 1px solid var(--border3); border-radius: 5px; box-shadow: inset 0 -1px 0 var(--border2);
}
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ── Form controls ── */
input, select, textarea {
  width: 100%; min-height: 38px; padding: 8px 12px; font: inherit; font-size: var(--fs-md); color: var(--text);
  background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-sm); box-shadow: var(--shadow-inset);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
input:hover, select:hover, textarea:hover, input.is-hover { border-color: var(--border3); }
input:focus, select:focus, textarea:focus, input.is-focus {
  outline: none; border-color: var(--cyan-line); background: var(--bg2); box-shadow: 0 0 0 3px var(--cyan-soft);
}
input::placeholder { color: var(--muted); }
input.mono::placeholder { font-family: var(--font); font-size: var(--fs-md); }
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
input[aria-invalid="true"], input.is-invalid { border-color: var(--red-line); box-shadow: 0 0 0 3px var(--red-soft); }
select {
  appearance: none; cursor: pointer; padding-right: 34px;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
select option { background: var(--bg3); color: var(--text); }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

label { display: flex; flex-direction: column; gap: 6px; color: var(--text-sub); font-size: var(--fs-sm); font-weight: 500; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); color: var(--text-sub); font-size: var(--fs-sm); font-weight: 500; }
.field-hint { color: var(--text-faint); font-weight: 400; }
.fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fieldset legend { padding: 0; margin-bottom: 6px; }

.otp { font-family: var(--mono); font-size: var(--fs-lg); letter-spacing: .4em; text-align: center; }
.otp::placeholder { font-family: var(--font); font-size: var(--fs-md); letter-spacing: normal; }

.input-icon { position: relative; display: flex; align-items: center; min-width: 0; }
.input-icon > .ico { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.input-icon input { padding-left: 34px; }

.form-error {
  display: flex; gap: var(--sp-2); align-items: flex-start; padding: 9px 12px; font-size: var(--fs-base); color: var(--red);
  background: var(--red-soft); border: 1px solid var(--red-line); border-radius: var(--radius-sm);
}
.form-error::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: 7px; border-radius: 50%; background: currentColor; }

/* Choice cards (radio groups) */
.choice-grid { display: grid; gap: var(--sp-2); }
.choice { display: block; position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.choice-body {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 10px 40px; position: relative;
  background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-sm);
  transition: border-color var(--dur-1), background var(--dur-1), box-shadow var(--dur-1);
}
.choice-body::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; border: 1.5px solid var(--border3); background: var(--bg2); transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.choice:hover .choice-body { border-color: var(--border3); }
.choice input:checked + .choice-body { border-color: var(--cyan-line); background: var(--cyan-soft); }
.choice input:checked + .choice-body::before { border-color: var(--cyan); box-shadow: inset 0 0 0 3px var(--bg2), inset 0 0 0 7px var(--cyan); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice-title { color: var(--text); font-size: var(--fs-base); font-weight: 600; }
.choice-sub { color: var(--text-sub); font-size: var(--fs-sm); font-weight: 400; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px;
  font: 600 var(--fs-base)/1 var(--font); letter-spacing: -.005em; white-space: nowrap; text-decoration: none; cursor: pointer;
  color: var(--text); background: var(--bg3); border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
              box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease), filter var(--dur-1) var(--ease);
}
.btn .ico { width: 15px; height: 15px; stroke-width: 2; }
.btn:active:not(:disabled), .btn.is-active { transform: translateY(1px) scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: var(--on-accent); box-shadow: var(--btn-sheen), var(--shadow-sm), var(--glow-cyan); }
.btn-primary:hover:not(:disabled), .btn-primary.is-hover { filter: brightness(1.1) saturate(1.05); }
.btn-ghost { background: var(--highlight); color: var(--text); border-color: var(--border2); box-shadow: var(--shadow-inset); }
.btn-ghost:hover:not(:disabled), .btn-ghost.is-hover { background: var(--highlight-2); border-color: var(--border3); }
.btn-ghost.is-danger:hover:not(:disabled) { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
.btn-cyan { background: var(--cyan-soft); color: var(--cyan); border-color: var(--cyan-line); }
.btn-cyan:hover:not(:disabled), .btn-cyan.is-hover { background: var(--cyan-soft-2); box-shadow: var(--glow-cyan); }
.btn-green { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.btn-green:hover:not(:disabled), .btn-green.is-hover { filter: brightness(1.15); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.btn-danger:hover:not(:disabled), .btn-danger.is-hover { background: var(--red-soft-2); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: 7px; }
.btn-sm .ico { width: 14px; height: 14px; }
.btn-lg { min-height: 42px; padding: 0 18px; font-size: var(--fs-md); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; padding: 0; cursor: pointer;
  color: var(--text-sub); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1);
}
.icon-btn:hover, .icon-btn.is-hover { background: var(--highlight-2); color: var(--text); border-color: var(--border2); }

/* ── Brand ── */
.logo-mark {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--grad);
  box-shadow: var(--btn-sheen), var(--glow-cyan);
}
.logo-mark::after { content: ""; position: absolute; inset: 28% 24%; border: 3px solid var(--bg); border-radius: 4px; transform: rotate(45deg); }
.logo-mark.sm { width: 30px; height: 30px; border-radius: 9px; }
.logo-mark.sm::after { border-width: 2.5px; border-radius: 3px; }
.grad-text { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── Sign in ── */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(440px, 1fr); }
.auth-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-8);
  padding: clamp(32px, 6vw, 80px); border-right: 1px solid var(--hairline);
}
.auth-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--hairline) 1px, transparent 1px), linear-gradient(90deg, var(--hairline) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 30% 45%, black, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 30% 45%, black, transparent 75%);
}
.auth-hero::after { content: ""; position: absolute; width: 640px; height: 640px; left: -180px; top: 8%; background: var(--glow-orb); pointer-events: none; }
.hero-inner { position: relative; z-index: 1; display: flex; flex-direction: column; gap: var(--sp-6); max-width: 520px; margin: auto 0; }
.brand-lockup { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.03em; color: var(--text-strong); }
.brand-lockup .logo-mark { width: 40px; height: 40px; border-radius: 12px; }
.hero-title { font-size: clamp(34px, 3.6vw, var(--fs-display)); line-height: 1.06; letter-spacing: -.04em; font-weight: 700; }
.hero-lead { color: var(--text-sub); font-size: var(--fs-lg); max-width: 440px; }
.hero-points { list-style: none; padding: 0; margin: var(--sp-2) 0 0; display: grid; gap: var(--sp-4); }
.hero-points li { display: flex; gap: 14px; align-items: flex-start; }
.hero-points li > span:last-child { display: flex; flex-direction: column; gap: 1px; color: var(--text-sub); font-size: var(--fs-base); }
.hero-points strong { color: var(--text); font-size: var(--fs-md); }
.hp-ico {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px;
  color: var(--cyan); background: var(--cyan-soft); border: 1px solid var(--cyan-line);
}
.hp-ico .ico { width: 16px; height: 16px; }
.hero-preview {
  display: grid; gap: 10px; padding: var(--sp-4); margin-top: var(--sp-2); max-width: 400px;
  background: var(--glass); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.hp-row { display: flex; align-items: center; gap: var(--sp-3); }
.hp-bar { height: 8px; border-radius: var(--radius-pill); background: var(--bg4); }
.hp-w1 { width: 46%; } .hp-w2 { width: 34%; } .hp-w3 { width: 52%; }
.hp-pill { margin-left: auto; width: 44px; height: 16px; border-radius: var(--radius-pill); background: var(--bg4); }
.hp-pill.on { background: var(--green-soft); border: 1px solid var(--green-line); }
.hero-foot { position: relative; z-index: 1; color: var(--text-faint); font-size: var(--fs-sm); }

.auth-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--sp-12) var(--sp-6);
  background: linear-gradient(180deg, var(--bg2), var(--bg));
}
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--sp-5); }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.02em; color: var(--text-strong); }
.auth-head { display: flex; flex-direction: column; gap: 4px; }
.auth-head h2 { font-size: var(--fs-2xl); }
.auth-head p { color: var(--text-sub); }
.auth-form, .auth-form > div { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn-block { margin-top: 4px; }
.auth-foot { display: flex; align-items: center; gap: var(--sp-2); width: min(400px, 100%); margin-top: var(--sp-8); color: var(--text-faint); font-size: var(--fs-sm); }
.auth-foot .ico { width: 14px; height: 14px; }

/* Segmented tabs */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; background: var(--bg3); border: 1px solid var(--border2); border-radius: 10px; }
.tab {
  padding: 7px 10px; font: 600 var(--fs-base)/1.2 var(--font); color: var(--text-sub); background: none; border: 0; border-radius: 7px; cursor: pointer;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text-strong); background: var(--bg4); box-shadow: var(--shadow-sm), var(--shadow-inset); }

/* Stepper + QR */
.stepper { display: flex; align-items: center; gap: 10px; color: var(--text-faint); font-size: var(--fs-sm); font-weight: 500; }
.step { display: inline-flex; align-items: center; gap: 7px; }
.step b {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: var(--fs-2xs);
  border: 1px solid var(--border3); background: var(--bg3);
}
.step.current { color: var(--text); }
.step.current b { color: var(--cyan); background: var(--cyan-soft); border-color: var(--cyan-line); }
.step.done { color: var(--text-sub); }
.step.done b { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.step-sep { flex: 1; height: 1px; background: var(--border2); }
.numbered { display: flex; gap: 10px; align-items: flex-start; color: var(--text-sub); font-size: var(--fs-base); }
.num-badge {
  display: grid; place-items: center; flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%;
  font-size: var(--fs-2xs); font-weight: 600; color: var(--text); background: var(--bg4); border: 1px solid var(--border3);
}
.qr-frame {
  align-self: center; padding: 10px; background: var(--qr-bg); border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px var(--border3), 0 0 0 6px var(--cyan-soft), var(--shadow-lg);
}
.qr { display: block; width: 176px; height: 176px; }

/* ── App shell ── */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; overflow-y: auto;
  background: linear-gradient(180deg, var(--bg2), var(--bg)); border-right: 1px solid var(--hairline); z-index: var(--z-drawer);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { color: var(--text-strong); font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.02em; }
.brand-org { color: var(--text-faint); font-size: var(--fs-xs); font-weight: 500; }

.search-trigger {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; height: 34px; padding: 0 7px 0 10px; margin: 2px 0 8px;
  font: 500 var(--fs-base)/1 var(--font); color: var(--text-faint); background: var(--highlight); cursor: pointer;
  border: 1px solid var(--border2); border-radius: var(--radius-sm); box-shadow: var(--shadow-inset);
  transition: border-color var(--dur-1), color var(--dur-1), background var(--dur-1);
}
.search-trigger .ico { width: 15px; height: 15px; }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger:hover { color: var(--text-sub); border-color: var(--border3); background: var(--highlight-2); }
.search-trigger.compact { display: none; width: 220px; margin: 0; }

.nav-label { padding: 16px 10px 6px; color: var(--text-faint); font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .09em; }
.sidebar a {
  position: relative; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; flex: none;
  color: var(--text-sub); text-decoration: none; font-size: var(--fs-base); font-weight: 500; border-radius: var(--radius-sm);
  transition: background var(--dur-1), color var(--dur-1);
}
.sidebar a .ico { width: 17px; height: 17px; color: var(--text-faint); transition: color var(--dur-1); }
.sidebar a:hover, .sidebar a.is-hover { background: var(--highlight); color: var(--text); }
.sidebar a:hover .ico { color: var(--text-sub); }
.sidebar a.active { color: var(--text-strong); background: linear-gradient(90deg, var(--cyan-soft), var(--highlight) 85%); }
.sidebar a.active .ico { color: var(--cyan); }
.sidebar a.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--cyan); box-shadow: var(--glow-cyan);
}
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hairline); display: flex; align-items: center; gap: 6px; }
.me-chip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px; }
.me-text { min-width: 0; }
.me-name { color: var(--text); font-size: var(--fs-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { color: var(--text-faint); font-size: var(--fs-xs); text-transform: capitalize; }
.me-client { color: var(--cyan); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-switch {
  max-width: 108px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  font: inherit; font-size: var(--fs-xs); padding: 4px 6px;
}
.client-switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.nav-scrim { display: none; }
.nav-toggle { display: none; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--sp-3);
  height: var(--topbar-h); padding: 0 var(--sp-8); background: var(--glass); border-bottom: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-base); color: var(--text-faint); }
.crumbs .ico { width: 14px; height: 14px; }
.crumb-current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

main { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 28px var(--sp-8) var(--sp-16); }
.view:not([hidden]) { animation: view-in var(--dur-3) var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.view-head h1 { font-size: var(--fs-3xl); line-height: 1.15; letter-spacing: -.03em; }
.view-sub { margin-top: 4px; color: var(--text-sub); }
.head-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.head-actions select, .head-actions .input-icon { width: auto; min-width: 200px; }
.head-actions .input-icon input { min-width: 260px; }

/* ── Cards ── */
.card { position: relative; background: var(--grad-surface), var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; gap: 14px; padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: var(--fs-lg); }
.card-sub { color: var(--text-sub); font-size: var(--fs-base); margin-top: 2px; }
.card-body { display: flex; flex-direction: column; gap: var(--sp-5); padding: var(--sp-6); }
.card-foot { padding: 14px var(--sp-6); border-top: 1px solid var(--border); background: var(--highlight); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-ico, .dialog-ico {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px;
  color: var(--cyan); background: var(--cyan-soft); border: 1px solid var(--cyan-line);
}
.card-ico .ico, .dialog-ico .ico { width: 18px; height: 18px; }
.dialog-ico.success { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.dialog-ico.danger { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.settings-card { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.form-actions .test-result { margin-right: auto; }

.callout {
  display: flex; gap: var(--sp-3); align-items: flex-start; padding: 12px 14px; font-size: var(--fs-base); color: var(--text-sub);
  background: var(--blue-soft); border: 1px solid var(--blue-line); border-radius: var(--radius);
}
.callout .ico { flex: none; width: 17px; height: 17px; margin-top: 1px; color: var(--blue); }
.callout.is-warn { background: var(--amber-soft); border-color: var(--amber-line); }
.callout.is-warn .ico { color: var(--amber); }
.section-title { margin: var(--sp-6) 0 var(--sp-3); color: var(--text-strong); font-size: var(--fs-lg); font-weight: 600; }
.dialog-body-inner { display: flex; flex-direction: column; gap: var(--sp-4); }

.disclosure { border: 1px solid var(--border); border-radius: var(--radius); background: var(--highlight); }
.disclosure > summary {
  display: flex; align-items: center; gap: var(--sp-2); padding: 11px 14px; list-style: none; cursor: pointer;
  color: var(--text-sub); font-size: var(--fs-base); font-weight: 600; border-radius: var(--radius);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { color: var(--text); }
.disclosure > summary .ico { width: 15px; height: 15px; transition: transform var(--dur-2) var(--ease); }
.disclosure[open] > summary .ico { transform: rotate(90deg); }
.disclosure > .form-grid { padding: 4px 14px 16px; }

.test-result { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-base); color: var(--text-sub); }
.test-result:empty { display: none; }
.test-result::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.test-result.ok { color: var(--green); }
.test-result.fail { color: var(--red); }

/* ── Stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: var(--sp-5); }
.stat {
  --stat-accent: var(--blue); --stat-soft: var(--blue-soft); --stat-line: var(--blue-line);
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px; padding: 16px 18px;
  background: var(--grad-surface), var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  transition: border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px; opacity: .7;
  background: linear-gradient(90deg, transparent, var(--stat-accent) 50%, transparent);
}
.stat:hover { border-color: var(--border3); }
.stat-online { --stat-accent: var(--green); --stat-soft: var(--green-soft); --stat-line: var(--green-line); }
.stat-offline { --stat-accent: var(--muted); --stat-soft: var(--highlight); --stat-line: var(--border3); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.stat-label { color: var(--text-sub); font-size: var(--fs-sm); font-weight: 500; }
.stat-ico {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  color: var(--stat-accent); background: var(--stat-soft); border: 1px solid var(--stat-line);
}
.stat-offline .stat-ico { color: var(--text-sub); }
.stat-ico .ico { width: 16px; height: 16px; }
.stat-value { color: var(--text-strong); font: 700 var(--fs-stat)/1.1 var(--font); letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.stat-online .stat-value { color: var(--green); }
.stat-hint { color: var(--text-faint); font-size: var(--fs-sm); }

/* ── Toolbar, chips ── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: var(--sp-3); }
.toolbar .input-icon { flex: 1 1 260px; max-width: 380px; }
.toolbar select { width: auto; min-width: 170px; }
.chips { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg2); border: 1px solid var(--border2); border-radius: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; cursor: pointer;
  font: 600 var(--fs-sm)/1 var(--font); color: var(--text-sub); background: transparent; border: 0; border-radius: 7px;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.chip:hover, .chip.is-hover { color: var(--text); }
.chip.active { color: var(--text-strong); background: var(--bg4); box-shadow: var(--shadow-sm), var(--shadow-inset); }
.chip .dot { width: 6px; height: 6px; box-shadow: none; }

/* ── Tables ── */
.table-card { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th {
  padding: 10px 16px; text-align: left; white-space: nowrap; color: var(--text-faint); font-size: var(--fs-2xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; background: var(--highlight); border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 16px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody td { transition: background var(--dur-1); }
.table tbody tr:hover td, .table tbody tr.is-hover td { background: var(--row-hover); }
.table .skeleton-row:hover td, .table tr:has(> td.empty):hover td { background: none; }
.table-foot { padding: 10px 16px; color: var(--text-faint); font-size: var(--fs-sm); border-top: 1px solid var(--border); }
.table-foot:has(> span:empty) { display: none; }
.cell-main { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.cell-main.tight { gap: var(--sp-2); }
.cell-text { min-width: 0; }
.cell-sub { color: var(--text-sub); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.cell-truncate { display: block; max-width: clamp(160px, 22vw, 360px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-name { color: var(--text-strong); font-weight: 600; }
.you-tag { margin-left: 6px; padding: 1px 6px; border-radius: var(--radius-pill); font-size: var(--fs-2xs); font-weight: 600; color: var(--cyan); background: var(--cyan-soft); vertical-align: 1px; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 6px; }
.user-cell { display: flex; align-items: center; gap: var(--sp-3); }
.table select.inline { width: auto; min-height: 30px; padding: 4px 30px 4px 10px; font-size: var(--fs-sm); text-transform: capitalize; background-position: right 8px center; background-size: 14px; }

.os-tile {
  position: relative; display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px;
  color: var(--text-sub); background: var(--bg4); border: 1px solid var(--border2);
}
.os-tile .ico { width: 16px; height: 16px; }
.os-tile.os-windows { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-line); }
.os-tile.os-macos { color: var(--purple); background: var(--purple-soft); border-color: var(--purple-line); }
.os-tile.os-linux { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.status-dot { position: absolute; right: -3px; bottom: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); border: 2px solid var(--bg2); }
.status-dot.on { background: var(--green); box-shadow: var(--glow-green); }

/* Empty states */
.table td.empty { padding: 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: 56px var(--sp-6); text-align: center; }
.empty-ico {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 6px; border-radius: 14px;
  color: var(--text-sub); background: var(--grad-surface), var(--bg3); border: 1px solid var(--border2);
  box-shadow: 0 0 0 6px var(--highlight), var(--shadow);
}
.empty-ico .ico { width: 22px; height: 22px; }
.empty-title { color: var(--text); font-size: var(--fs-lg); font-weight: 600; }
.empty-text { max-width: 380px; color: var(--text-sub); font-size: var(--fs-base); }
.empty-state .btn { margin-top: 10px; }

/* Skeletons */
.skeleton {
  display: inline-block; height: 10px; border-radius: var(--radius-xs); vertical-align: middle;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%); background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-line { display: flex; align-items: center; gap: var(--sp-4); }
.skeleton-row td { padding: 14px 16px; }
.sk-tile { width: 32px; height: 32px; border-radius: 9px; }
.sk-avatar { width: 32px; height: 32px; border-radius: 50%; }
.sk-lg { width: 180px; } .sk-md { width: 110px; } .sk-sm { width: 64px; }
.sk-num { width: 52px; height: 28px; border-radius: var(--radius-sm); }

/* ── Status dots, badges, avatars ── */
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.dot-online { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot-offline { background: var(--muted); }
.dot.pulse { animation: pulse 2s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--green-line); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }

.badge, .os-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; white-space: nowrap;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; text-transform: capitalize;
  color: var(--text-sub); background: var(--highlight); border: 1px solid var(--border2); border-radius: var(--radius-pill);
}
.badge.online, .badge.active, .badge.resolved { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.badge.pending, .badge.prospect { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-line); }
.badge.offline, .badge.inactive { color: var(--text-sub); }
.badge.escalated { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.badge.warn { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.badge.remote { color: var(--purple); background: var(--purple-soft); border-color: var(--purple-line); }
.badge:is(.online, .active, .resolved, .pending, .prospect, .offline, .inactive, .escalated, .warn)::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge:is(.offline, .inactive)::before { background: var(--muted); }
.os-badge { text-transform: none; }
.badge.mono { font-family: var(--mono); font-weight: 500; text-transform: none; letter-spacing: -.01em; }
.badge.mono::before { display: none; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px; white-space: nowrap;
  font-size: var(--fs-2xs); font-weight: 600; line-height: 1;
  color: var(--cyan); background: var(--cyan-soft); border: 1px solid var(--cyan-line); border-radius: var(--radius-pill);
}
.os-windows { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-line); }
.os-macos { color: var(--purple); background: var(--purple-soft); border-color: var(--purple-line); }
.os-linux { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }

.avatar {
  --av-fg: var(--cyan); --av-bg: var(--cyan-soft); --av-line: var(--cyan-line);
  display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  font: 700 var(--fs-xs)/1 var(--font); letter-spacing: .02em; color: var(--av-fg); background: var(--av-bg);
  border: 1px solid var(--av-line); box-shadow: var(--shadow-inset);
}
.avatar.sm { width: 24px; height: 24px; font-size: 9.5px; }
.avatar.lg { width: 40px; height: 40px; font-size: var(--fs-sm); }
.avatar.square { border-radius: 9px; }
.avatar.tone-1 { --av-fg: var(--blue); --av-bg: var(--blue-soft); --av-line: var(--blue-line); }
.avatar.tone-2 { --av-fg: var(--green); --av-bg: var(--green-soft); --av-line: var(--green-line); }
.avatar.tone-3 { --av-fg: var(--purple); --av-bg: var(--purple-soft); --av-line: var(--purple-line); }
.avatar.tone-4 { --av-fg: var(--amber); --av-bg: var(--amber-soft); --av-line: var(--amber-line); }

.section-warn {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: 12px 14px; margin-bottom: 18px; font-size: var(--fs-base);
  color: var(--amber); background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: var(--radius);
}
.section-warn > .ico { flex: none; width: 17px; height: 17px; margin-top: 1px; }
.section-warn a { color: inherit; font-weight: 600; }
.section-warn.compact { margin: 0; padding: 9px 12px; font-size: var(--fs-sm); align-items: center; }
.section-warn.compact > .ico { margin: 0; width: 15px; height: 15px; }

.result-box-success { padding: 12px 14px; color: var(--text-sub); background: var(--green-soft); border: 1px solid var(--green-line); border-radius: var(--radius); }
.result-box-success-title { color: var(--green); font-weight: 600; margin-bottom: 2px; }

/* ── Remote session ── */
.remote-overlay { position: fixed; inset: 0; z-index: var(--z-remote); display: flex; flex-direction: column; background: var(--bg); animation: fade-in var(--dur-2) var(--ease); }
.remote-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); height: 52px; padding: 0 14px 0 16px; flex: none;
  background: var(--glass-strong); border-bottom: 1px solid var(--border2);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.remote-title { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; color: var(--text-strong); font-weight: 600; }
.remote-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
#remote-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-pill {
  display: inline-flex; align-items: center; gap: 7px; flex: none; height: 24px; padding: 0 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--green); background: var(--green-soft); border: 1px solid var(--green-line);
}
.live-pill .dot { width: 6px; height: 6px; }
.remote-actions { display: flex; align-items: center; gap: var(--sp-3); flex: none; }
.kbd-hint { display: inline-flex; align-items: center; gap: 6px; color: var(--text-faint); font-size: var(--fs-sm); }
.remote-stage { position: relative; flex: 1; background: var(--frame-bg); }
.remote-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--frame-bg); }

/* ── Device drawer ── */
.drawer-scrim {
  position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--overlay);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fade-in var(--dur-2) var(--ease);
}
.drawer {
  position: fixed; inset: 0 0 0 auto; z-index: var(--z-drawer); display: flex; flex-direction: column; width: min(580px, 100vw);
  background: var(--grad-surface), var(--bg2); border-left: 1px solid var(--border3); box-shadow: var(--shadow-lg);
  animation: drawer-in var(--dur-3) var(--ease-out);
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(28px); } }
.drawer-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-4); border-bottom: 1px solid var(--border); }
.drawer-title { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.drawer-title .os-tile { width: 40px; height: 40px; border-radius: 11px; }
.drawer-title .os-tile .ico { width: 18px; height: 18px; }
.drawer-title h2 { font-size: var(--fs-xl); line-height: 1.25; overflow-wrap: anywhere; }
.drawer-title .cell-sub { max-width: none; white-space: normal; }
.drawer-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.meta-note { font-size: var(--fs-sm); }
.drawer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-6); border-bottom: 1px solid var(--border); background: var(--highlight); }
.drawer-actions .menu { margin-left: auto; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--sp-6) var(--sp-8); }
.drawer-section { padding: var(--sp-5) 0; }
.drawer-section + .drawer-section { border-top: 1px solid var(--border); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; min-height: 30px; margin-bottom: var(--sp-3); }
.section-head h3 { font-size: var(--fs-md); }
.section-note { margin-top: var(--sp-2); font-size: var(--fs-sm); }
.micro-label { color: var(--text-faint); font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.pill-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.empty-state.compact { padding: var(--sp-8) var(--sp-4); }
.inline-form { display: flex; gap: var(--sp-2); }
.inline-form select { flex: 1; min-width: 0; }

/* Device link: the device name in a table row, opens the drawer */
.device-link { padding: 0; font: inherit; font-weight: 600; text-align: left; color: var(--text-strong); background: none; border: 0; border-radius: 4px; cursor: pointer; }
.device-link:hover { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; }

/* Key/value grid */
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px var(--sp-5); margin: 0; }
.kv-grid > div { min-width: 0; }
.kv-grid > .span-2 { grid-column: 1 / -1; }
.kv-grid dt { margin-bottom: 3px; color: var(--text-faint); font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.kv-grid dd { margin: 0; color: var(--text); font-size: var(--fs-base); overflow-wrap: anywhere; }

/* Disk usage */
.disk-head { margin: var(--sp-5) 0 var(--sp-2); }
.disk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.disk-top { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: 6px; font-size: var(--fs-sm); }
.disk-name { color: var(--text); }
.disk-use { color: var(--text-sub); text-align: right; font-variant-numeric: tabular-nums; }
.disk-use.warn { color: var(--amber); }
progress.usage {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; border: 0;
  border-radius: var(--radius-pill); overflow: hidden; background: var(--bg4); color: var(--cyan);
}
progress.usage::-webkit-progress-bar { background: var(--bg4); border-radius: var(--radius-pill); }
progress.usage::-webkit-progress-value { background: var(--cyan); border-radius: var(--radius-pill); }
progress.usage::-moz-progress-bar { background: var(--cyan); border-radius: var(--radius-pill); }
progress.usage.warn::-webkit-progress-value { background: var(--amber); }
progress.usage.warn::-moz-progress-bar { background: var(--amber); }
.sk-block { display: block; width: 100%; height: 30px; }

/* Dropdown menu (details/summary) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .ico:last-child { width: 13px; height: 13px; margin-left: -2px; color: var(--text-sub); transition: transform var(--dur-2) var(--ease); }
.menu[open] > summary .ico:last-child { transform: rotate(180deg); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 2; display: flex; flex-direction: column; min-width: 180px; padding: var(--sp-1);
  background: var(--grad-surface), var(--bg2); border: 1px solid var(--border3); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: dialog-in var(--dur-2) var(--ease-out);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; cursor: pointer; text-align: left;
  font: 500 var(--fs-base)/1 var(--font); color: var(--text); background: transparent; border: 0; border-radius: var(--radius-xs);
}
.menu-item .ico { width: 15px; height: 15px; color: var(--text-sub); }
.menu-item:hover:not(:disabled), .menu-item.is-hover { background: var(--bg4); }
.menu-item.is-danger:hover:not(:disabled) { color: var(--red); }
.menu-item.is-danger:hover:not(:disabled) .ico { color: var(--red); }
.menu-item:disabled { opacity: .45; cursor: not-allowed; }

/* Command console */
.console { display: flex; flex-direction: column; gap: 10px; }
.console-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.console-bar select { width: auto; min-width: 150px; }
.console-input { min-height: 96px; resize: vertical; font: var(--fs-sm)/1.55 var(--mono); tab-size: 4; }
.console-input::placeholder { color: var(--muted); }
.console-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.console-actions .btn { flex: none; }
.history { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.history-item {
  max-width: 220px; height: 24px; padding: 0 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
  font: 500 var(--fs-xs)/22px var(--mono); color: var(--text-sub); background: var(--highlight); border: 1px solid var(--border2); border-radius: var(--radius-pill);
  transition: color var(--dur-1), border-color var(--dur-1);
}
.history-item:hover { color: var(--text); border-color: var(--border3); }
.console-result { display: flex; flex-direction: column; gap: var(--sp-2); }
.console-result-head { display: flex; align-items: center; gap: var(--sp-2); }
.console-result-head .btn { margin-left: auto; }
.console-output {
  margin: 0; max-height: 380px; overflow: auto; padding: var(--sp-3) 14px; white-space: pre; tab-size: 4; user-select: text;
  font: var(--fs-sm)/1.55 var(--mono); color: var(--text); background: var(--frame-bg); border: 1px solid var(--border2); border-radius: var(--radius-sm);
}
.console-output.is-empty { color: var(--text-sub); font-family: var(--font); }

/* Busy spinner (inside buttons while a slow call runs) */
.spinner { flex: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Copy field (read-only value + copy button) */
.copy-field { display: flex; gap: var(--sp-2); margin: var(--sp-2) 0; }
.copy-field input { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--text-strong); }
.result-note { font-size: var(--fs-sm); }

/* ── Dialogs ── */
dialog, .dialog-surface {
  width: min(460px, calc(100vw - 32px)); padding: 0; color: var(--text);
  background: var(--grad-surface), var(--bg2); border: 1px solid var(--border3); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: dialog-in var(--dur-3) var(--ease-out); }
dialog::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog[open]::backdrop { animation: fade-in var(--dur-2) var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
.dialog-body { display: flex; flex-direction: column; gap: var(--sp-4); padding: 22px var(--sp-6) var(--sp-5); }
.dialog-head { position: relative; display: flex; align-items: flex-start; gap: 14px; padding-right: 32px; margin-bottom: 2px; }
.dialog-head h3 { font-size: var(--fs-xl); line-height: 1.3; }
.dialog-sub { margin-top: 3px; color: var(--text-sub); font-size: var(--fs-base); }
.dialog-x { position: absolute; top: -6px; right: -10px; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: var(--sp-2); margin: 6px calc(-1 * var(--sp-6)) calc(-1 * var(--sp-5));
  padding: 14px var(--sp-6); border-top: 1px solid var(--border); background: var(--highlight); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.dialog-body .form-grid { gap: var(--sp-3); }
.cred { display: flex; flex-direction: column; gap: 5px; padding: 11px 14px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-sm); }
.cred-label { color: var(--text-faint); font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.cred code { color: var(--text-strong); font-size: var(--fs-lg); user-select: all; word-break: break-all; }
.cred code.cred-secret { color: var(--green); letter-spacing: .04em; }

.cred-row { display: flex; align-items: center; gap: var(--sp-3); }
.cred-row code { flex: 1; min-width: 0; }
.cred-row .btn { flex: none; }
.dialog-wide { width: min(620px, calc(100vw - 32px)); }
.dialog-ico.warn { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }

/* Checkbox cards: .choice with a square box (same API as radio choice cards) */
.choice.check .choice-body::before { border-radius: var(--radius-2xs); }
.choice.check input:checked + .choice-body::before { border-color: var(--cyan); background: var(--cyan); box-shadow: inset 0 0 0 2px var(--bg2); }
.choice input:disabled + .choice-body { opacity: .5; cursor: not-allowed; }
.choice:has(input:disabled) { cursor: not-allowed; }
.choice:has(input:disabled):hover .choice-body { border-color: var(--border2); }

/* ── Approvals (AI agent requests) ── */
.approval-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2); height: 34px; padding: 0 6px 0 10px; cursor: pointer;
  font: 600 var(--fs-base)/1 var(--font); color: var(--amber); background: var(--amber-soft);
  border: 1px solid var(--amber-line); border-radius: var(--radius-pill);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
  animation: fade-in var(--dur-2) var(--ease);
}
.approval-pill .ico { width: 16px; height: 16px; }
.approval-pill:hover { background: var(--highlight-2); border-color: var(--amber); }
.approval-count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--radius-pill);
  font: 700 var(--fs-xs)/1 var(--font); font-variant-numeric: tabular-nums; color: var(--on-accent); background: var(--amber);
}
.approvals-note { margin-bottom: var(--sp-4); }

.ap-head-text { min-width: 0; }
.ap-head-text h3 { overflow-wrap: anywhere; }
.ap-kicker { display: block; margin-bottom: 3px; color: var(--amber); }
.ap-block { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ap-reason { color: var(--text); font-size: var(--fs-md); white-space: pre-wrap; overflow-wrap: anywhere; }
.ap-reason.is-empty { color: var(--text-sub); font-style: italic; }
.console-output.ap-command { max-height: 240px; color: var(--text-strong); border-color: var(--amber-line); }
.ap-running { display: flex; align-items: center; gap: var(--sp-3); padding: 12px 14px; color: var(--text-sub); font-size: var(--fs-base); background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); }
.ap-running .spinner { color: var(--cyan); width: 16px; height: 16px; }
.ap-expiry { margin-right: auto; align-self: center; color: var(--amber); font: 500 var(--fs-sm)/1 var(--mono); font-variant-numeric: tabular-nums; }
.dialog-wide .dialog-actions { flex-wrap: wrap; }
.ap-detail-row td, .table tbody tr.ap-detail-row:hover td { background: var(--highlight); }
.table tbody tr.is-open td { border-bottom-color: transparent; }
/* inline-size containment: long command lines scroll inside the row instead of widening the table */
.ap-detail { contain: inline-size; display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-2) 0 var(--sp-3); }
.ap-meta { color: var(--text-faint); font-size: var(--fs-sm); }
.ap-toggle .ico { transition: transform var(--dur-2) var(--ease); }
.ap-toggle[aria-expanded="true"] .ico { transform: rotate(90deg); }

/* ── AI access (Settings) ── */
.settings-stack { display: flex; flex-direction: column; gap: var(--sp-6); }
.scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.scope-list { display: flex; flex-direction: column; gap: var(--sp-2); padding: 14px 16px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); font-size: var(--fs-base); color: var(--text); }
.check-list li { display: flex; gap: 10px; align-items: flex-start; }
.check-list .ico { flex: none; width: 15px; height: 15px; margin-top: 2px; stroke-width: 2.2; color: var(--green); }
.check-list.no .ico { color: var(--red); }
.token-head { margin: var(--sp-1) 0 calc(-1 * var(--sp-2)); }
.pill-row.tight { margin: 0; gap: 6px; flex-wrap: nowrap; }
.table tr.is-dim td, .table tr.is-dim .device-name { color: var(--text-sub); }
.console-output.wrap { white-space: pre-wrap; word-break: break-all; }

/* ── Nav count badge (Alerts) ── */
.nav-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px; margin-left: auto; border-radius: var(--radius-pill);
  font: 700 var(--fs-2xs)/1 var(--font); font-variant-numeric: tabular-nums;
  color: var(--amber); background: var(--amber-soft); border: 1px solid var(--amber-line);
}
.nav-count.is-critical { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }

/* ── Small shared pieces ── */
.cbx { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; flex: none; cursor: pointer; accent-color: var(--cyan); box-shadow: none; }
.cbx:focus { box-shadow: none; }
.table .col-check { width: 1%; padding-right: 0; }
.table tbody tr.is-selected td { background: var(--cyan-soft); }
.form-actions .push-start, .dialog-actions .push-start { margin-right: auto; }
.head-tabs { min-width: 260px; }
.stat-critical { --stat-accent: var(--red); --stat-soft: var(--red-soft); --stat-line: var(--red-line); }
.stat-warning { --stat-accent: var(--amber); --stat-soft: var(--amber-soft); --stat-line: var(--amber-line); }
.stat-neutral { --stat-accent: var(--muted); --stat-soft: var(--highlight); --stat-line: var(--border3); }
.stat-neutral .stat-ico { color: var(--text-sub); }

/* Sticky action bar for a multi-selection */
.select-bar {
  position: sticky; bottom: var(--sp-4); z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  margin-top: var(--sp-4); padding: 10px 12px 10px 16px; background: var(--glass-strong); border: 1px solid var(--border3);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: toast-in var(--dur-3) var(--ease-out);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.select-bar-count { margin-right: auto; color: var(--text-strong); font-size: var(--fs-base); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Alerts ── */
.alert-stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.alert-group { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.alert-group-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: 12px 16px; }
.alert-group-toggle {
  flex: 1 1 320px; min-width: 0; display: flex; align-items: center; gap: var(--sp-3); padding: 0; cursor: pointer; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; border-radius: var(--radius-sm);
}
.alert-group-toggle > .ico { width: 15px; height: 15px; color: var(--text-faint); transition: transform var(--dur-2) var(--ease); }
.alert-group-toggle[aria-expanded="true"] > .ico { transform: rotate(90deg); }
.alert-group-toggle:hover .alert-group-title { color: var(--cyan); }
.check-tile {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px;
  color: var(--blue); background: var(--blue-soft); border: 1px solid var(--blue-line);
}
.check-tile .ico { width: 16px; height: 16px; }
.sev-critical .check-tile { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.sev-warning .check-tile { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.alert-group-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.alert-group-title { color: var(--text-strong); font-weight: 600; transition: color var(--dur-1); }
.alert-group-hint { color: var(--text-sub); font-size: var(--fs-sm); }
.alert-group-actions, .alert-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.alert-group-body { border-top: 1px solid var(--border); }
.alert-client { display: flex; align-items: baseline; gap: var(--sp-2); padding: 10px 16px 4px; }
.alert-client + .alert-row { border-top: 0; }
.alert-client-count { color: var(--text-faint); font-size: var(--fs-xs); }
.alert-row + .alert-client { border-top: 1px solid var(--border); margin-top: var(--sp-1); }
.alert-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3);
  padding: 10px 16px; border-top: 1px solid var(--border); transition: background var(--dur-1);
}
.alert-row:hover { background: var(--row-hover); }
.alert-row:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.alert-row.is-busy { opacity: .6; }
.alert-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alert-line { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.alert-msg { color: var(--text); font-size: var(--fs-base); overflow-wrap: anywhere; }
.alert-meta { color: var(--text-faint); font-size: var(--fs-sm); }
.low-priority > .alert-stack { padding: 4px 14px 14px; }
.low-priority .alert-group { box-shadow: none; }

/* ── Scripts ── */
.script-layout { display: grid; grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(300px, 340px); gap: var(--sp-4); align-items: start; }
.script-side { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3); }
.script-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 470px); overflow-y: auto; }
.script-item { display: flex; align-items: center; gap: var(--sp-1); padding-right: var(--sp-1); border-radius: var(--radius-sm); transition: background var(--dur-1); }
.script-item:hover { background: var(--highlight); }
.script-item.active { background: var(--bg4); box-shadow: var(--shadow-inset); }
.script-sk { padding: 10px; }
.script-pick {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; cursor: pointer; text-align: left;
  font: inherit; color: var(--text); background: none; border: 0; border-radius: var(--radius-sm);
}
.script-pick .cell-sub { max-width: none; }
.script-name { color: var(--text-strong); font-size: var(--fs-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-item.active .script-name { color: var(--cyan); }
.script-head-text { flex: 1; min-width: 0; }
.script-head-text h3 { overflow-wrap: anywhere; }
.script-head-action { flex: none; }
.script-body { min-height: 300px; resize: vertical; font: var(--fs-sm)/1.55 var(--mono); tab-size: 2; white-space: pre; overflow: auto; }
textarea:read-only, input:read-only { color: var(--text-sub); }

/* Rollout dialog */
.ro-kicker { display: block; margin-bottom: 3px; color: var(--cyan); }
.ro-step { display: flex; flex-direction: column; gap: var(--sp-3); }
.ro-scripts { max-height: 46vh; overflow-y: auto; padding: 2px; }
.pick-toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.pick-toolbar .input-icon { flex: 1 1 220px; }
.pick-list { max-height: min(44vh, 420px); overflow-y: auto; overscroll-behavior: contain; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); }
.pick-group + .pick-group { border-top: 1px solid var(--border); }
.pick-group-head {
  position: sticky; top: 0; z-index: 1; display: flex; flex-direction: row; align-items: center; gap: var(--sp-3); padding: 8px 12px; cursor: pointer;
  color: var(--text-strong); font-size: var(--fs-base); font-weight: 600; background: var(--bg2); border-bottom: 1px solid var(--border);
}
.pick-meta { margin-left: auto; color: var(--text-faint); font-size: var(--fs-xs); font-weight: 500; font-variant-numeric: tabular-nums; }
.pick-row {
  display: flex; flex-direction: row; align-items: center; gap: var(--sp-3); padding: 7px 12px; cursor: pointer;
  color: var(--text); font-size: var(--fs-base); font-weight: 400; transition: background var(--dur-1);
}
.pick-row:hover { background: var(--row-hover); }
.pick-row:has(.cbx:checked) { background: var(--cyan-soft); }
.pick-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-name { color: var(--text-strong); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-state { flex: none; color: var(--text-sub); font-size: var(--fs-sm); }
.pick-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.pick-counter { padding-bottom: 9px; color: var(--text); font-size: var(--fs-base); font-weight: 600; font-variant-numeric: tabular-nums; }
.pick-wait { width: 200px; }
.ro-device-list { list-style: none; margin: 0; padding: 4px 14px 14px; display: grid; gap: 6px; max-height: 200px; overflow-y: auto; font-size: var(--fs-base); }
.ro-device-list li { display: flex; align-items: center; gap: var(--sp-2); }
.ro-device-list .muted { margin-left: auto; font-size: var(--fs-sm); }

/* Runs: segmented progress (SVG rects) */
.run-progress { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.seg-bar { display: block; width: 100%; max-width: 240px; height: 6px; border-radius: var(--radius-pill); background: var(--bg4); overflow: hidden; }
.run-progress.wide .seg-bar { max-width: none; height: 8px; }
.seg-done { fill: var(--green); }
.seg-failed { fill: var(--red); }
.seg-running { fill: var(--blue); }
.seg-waiting { fill: var(--amber); }
.seg-skipped { fill: var(--muted); }
.run-counts { color: var(--text-sub); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.run-head { align-items: center; flex-wrap: wrap; }
.run-head-text { flex: 1; min-width: 0; }
.run-head-text h3 { overflow-wrap: anywhere; }
.run-head-actions { display: flex; align-items: center; gap: var(--sp-2); }
.run-body { margin: 4px 14px 14px; }
.run-error-sub { color: var(--red); }
.run-card .table-card { box-shadow: none; }

/* Command palette */
.palette { width: min(560px, calc(100vw - 32px)); margin: 12vh auto auto; overflow: hidden; }
.palette-search { display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-search > .ico { color: var(--text-faint); }
.palette-search input { height: 100%; min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: var(--fs-lg); }
.palette-search input:focus { background: transparent; box-shadow: none; }
.palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; height: 40px; padding: 0 10px; cursor: pointer; text-align: left;
  font: 500 var(--fs-md)/1 var(--font); color: var(--text-sub); background: transparent; border: 0; border-radius: var(--radius-sm);
}
.palette-item .ico { color: var(--text-faint); }
.palette-item:hover, .palette-item.active { color: var(--text-strong); background: var(--bg4); }
.palette-item.active .ico { color: var(--cyan); }
.palette-hint { margin-left: auto; color: var(--text-faint); font-size: var(--fs-xs); opacity: 0; }
.palette-item.active .palette-hint { opacity: 1; }
.palette-empty { padding: var(--sp-6); text-align: center; color: var(--text-sub); }
.palette-foot { display: flex; gap: var(--sp-4); padding: 10px 16px; color: var(--text-faint); font-size: var(--fs-xs); border-top: 1px solid var(--border); background: var(--highlight); }

/* ── Toasts ── */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; pointer-events: auto; font-size: var(--fs-base); color: var(--text);
  background: var(--glass-strong); border: 1px solid var(--border3); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: toast-in var(--dur-3) var(--ease-out);
}
.toast-ico { display: grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%; color: var(--green); background: var(--green-soft); }
.toast-ico .ico { width: 12px; height: 12px; stroke-width: 2.4; }
.toast.error .toast-ico { color: var(--red); background: var(--red-soft); }
.toast-msg { padding-top: 1px; }
.toast.leaving { animation: toast-out var(--dur-2) ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.97); } }

/* ── Responsive ── */
@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .sidebar { align-items: center; padding: 14px 10px; overflow: visible; }
  .brand { padding: 6px 0 12px; }
  .brand-text, .sidebar .search-trigger, .me-text { display: none; }
  .nav-label { width: 28px; height: 1px; padding: 0; margin: 12px 0; font-size: 0; background: var(--border2); }
  .sidebar a { width: 44px; height: 40px; padding: 0; justify-content: center; }
  .sidebar a.active::before { left: -10px; }
  .sidebar a span {
    position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%) translateX(-4px); z-index: 5;
    padding: 5px 9px; white-space: nowrap; font-size: var(--fs-sm); color: var(--text); background: var(--bg4);
    border: 1px solid var(--border3); border-radius: var(--radius-xs); box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none; transition: opacity var(--dur-1), transform var(--dur-1) var(--ease);
  }
  .sidebar a:hover span, .sidebar a:focus-visible span { opacity: 1; transform: translateY(-50%); }
  .sidebar-foot { flex-direction: column; width: 100%; }
  .me-chip { flex: none; padding: 0; }
  .search-trigger.compact { display: flex; }
  .sidebar a .nav-count { position: absolute; top: 1px; right: -2px; min-width: 17px; height: 16px; padding: 0 4px; margin: 0; }
}

@media (max-width: 1000px) {
  .script-layout { grid-template-columns: minmax(0, 1fr); }
  .script-side, #script-form, #script-empty, .automation-side { grid-column: auto; }
  .automation-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .script-list { max-height: 240px; }
}

@media (max-width: 960px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { min-height: 100vh; padding: var(--sp-10) var(--sp-5); }
  .auth-mobile-brand { display: flex; }
}

@media (max-width: 1000px) {
  .hide-md { display: none; }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); height: 100%; align-items: stretch; padding: 14px 12px; overflow-y: auto;
    box-shadow: var(--shadow-lg); transform: translateX(-102%); visibility: hidden;
    transition: transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur-3) var(--ease-out); }
  .brand { padding: 6px 8px 14px; }
  .brand-text, .me-text { display: flex; }
  .me-text { display: block; }
  .sidebar .search-trigger { display: flex; }
  .nav-label { width: auto; height: auto; padding: 16px 10px 6px; margin: 0; font-size: var(--fs-2xs); background: none; }
  .sidebar a { width: auto; height: 40px; padding: 0 10px; justify-content: flex-start; }
  .sidebar a.active::before { left: -12px; }
  .sidebar a span {
    position: static; transform: none; opacity: 1; padding: 0; font-size: inherit; color: inherit;
    background: none; border: 0; box-shadow: none; pointer-events: auto;
  }
  .sidebar-foot { flex-direction: row; }
  .me-chip { flex: 1; }
  .sidebar a .nav-count { position: static; margin-left: auto; }
  .stat-grid:has(> .stat:nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .head-tabs { min-width: 0; flex-basis: 100%; }
  .alert-row { grid-template-columns: minmax(0, 1fr); }
  .alert-actions .btn-label, .alert-group-actions .btn-label { display: none; }
  .alert-group-head { padding: 12px; }
  .alert-row, .alert-client { padding-left: 12px; padding-right: 12px; }
  .select-bar { bottom: var(--sp-3); }
  .pick-state { display: none; }
  .pick-wait { width: 100%; }
  .run-head-actions { width: 100%; }
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--overlay);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity var(--dur-3) var(--ease);
  }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .nav-toggle { display: inline-grid; margin-left: -6px; }

  .topbar { padding: 0 var(--sp-3) 0 var(--sp-4); }
  .search-trigger.compact { width: 34px; padding: 0; justify-content: center; }
  .search-trigger.compact span, .search-trigger.compact kbd { display: none; }

  main { padding: var(--sp-5) var(--sp-4) var(--sp-12); }
  .view-head { margin-bottom: var(--sp-5); }
  .view-head h1 { font-size: var(--fs-2xl); }
  .head-actions { width: 100%; }
  .head-actions > * { flex: 1 1 auto; }
  .head-actions select, .head-actions .input-icon, .head-actions .input-icon input { min-width: 0; }

  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; gap: 2px; }
  .stat-ico, .stat-hint { display: none; }
  .stat-value { font-size: var(--fs-2xl); }

  .toolbar .input-icon { flex-basis: 100%; max-width: none; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
  .hide-sm { display: none; }
  .table td, .table th { padding-left: 12px; padding-right: 12px; }
  .row-actions .btn + .btn { margin-left: 4px; }
  .row-actions .btn { width: 30px; padding: 0; gap: 0; font-size: 0; }
  .cell-sub { max-width: 160px; }

  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card-head, .card-body { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .card-foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .dialog-body { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .dialog-actions { margin-left: calc(-1 * var(--sp-5)); margin-right: calc(-1 * var(--sp-5)); padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .dialog-actions .btn { flex: 1; }
  .ap-expiry { flex-basis: 100%; text-align: center; padding-bottom: var(--sp-1); }
  .approval-pill-label { display: none; }
  .approval-pill { padding: 0 6px 0 8px; }
  .scope-grid { grid-template-columns: minmax(0, 1fr); }
  .pill-row.tight { flex-wrap: wrap; }
  .kbd-hint { display: none; }
  .toasts { left: 16px; right: 16px; bottom: 16px; width: auto; }

  .drawer { width: 100%; border-left: 0; }
  .drawer-head, .drawer-actions, .drawer-body { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .console-bar select { flex: 1; }
}

@media (max-width: 520px) {
  .table td, .table th { padding-left: 10px; padding-right: 10px; }
  .user-cell > .avatar, .cell-main > .avatar { display: none; }
  .table .nowrap { white-space: normal; }
  .table select.inline { padding-right: 24px; background-position: right 6px center; }
}

@media (max-width: 420px) {
  .chips { width: 100%; }
  .chip { flex: 1; justify-content: center; }
  .kv-grid { grid-template-columns: minmax(0, 1fr); }
  .console-actions { flex-direction: column-reverse; align-items: stretch; }
}

/* ── Patches ── */
.day-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day-grid .choice-body, .class-grid .choice-body { padding: 8px 10px 8px 32px; }
.day-grid .choice-body::before, .class-grid .choice-body::before { left: 10px; }
.class-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.patch-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.patch-item { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: 10px 0; }
.patch-item + .patch-item { border-top: 1px solid var(--border); }
.patch-item .cell-sub { overflow-wrap: anywhere; }
.patch-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: none; justify-content: flex-end; }
.patch-note { margin: 0 0 var(--sp-3); color: var(--text-sub); font-size: var(--fs-sm); }

@media (max-width: 520px) {
  .day-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .class-grid { grid-template-columns: minmax(0, 1fr); }
  .patch-item { flex-direction: column; }
  .patch-meta { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}


/* ── Fleet command ── */
.fleet-workspace { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.fleet-tree { background: var(--grad-surface), var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--sp-4); position: sticky; top: calc(var(--sp-4) + 54px); }
.fleet-tree .section-head { margin-bottom: var(--sp-2); }
.fleet-tree-list { display: flex; flex-direction: column; gap: 2px; }
.fleet-tree-item { display: flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 8px; border: 0; border-radius: 7px; background: transparent; color: var(--text-sub); font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; }
.fleet-tree-item:hover { background: var(--bg3); color: var(--text); }
.fleet-tree-item.active { background: var(--cyan-soft); color: var(--cyan); }
.fleet-tree-item .count { margin-left: auto; color: var(--text-faint); font: var(--fs-2xs) var(--mono); }
.fleet-main { min-width: 0; }
.fleet-main .table { table-layout: fixed; }
.fleet-main .table th, .fleet-main .table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fleet-main .table th:nth-child(1) { width: 4%; }
.fleet-main .table th:nth-child(2) { width: 23%; }
.fleet-main .table th:nth-child(3) { width: 13%; }
.fleet-main .table th:nth-child(4) { width: 17%; }
.fleet-main .table th:nth-child(5) { width: 12%; }
.fleet-main .table th:nth-child(6) { width: 11%; }
.fleet-main .table th:nth-child(7) { width: 11%; }
.fleet-main .table th:nth-child(8) { width: 9%; }
.fleet-main .table .cell-text { min-width: 0; }
.fleet-main .table .cell-sub, .fleet-main .table .device-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fleet-main .table .tag-list { flex-wrap: nowrap; overflow: hidden; }
.fleet-main .table .row-actions { overflow: visible; }
@media (max-width: 1100px) { .fleet-workspace { grid-template-columns: 1fr; } .fleet-tree { position: static; display: none; } }

/* ── Device cockpit drawer ── */
#device-drawer { width: min(960px, 100vw); }
#device-drawer .drawer-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--sp-6); align-content: start; }
#device-drawer .drawer-section { min-width: 0; }
#dd-overview-section, #dd-toolbox, #dd-patches { grid-column: 1 / -1; }
#device-drawer .drawer-body { padding-bottom: var(--sp-6); }
#dd-overview .empty-state { max-width: 620px; margin: 0 auto; padding: var(--sp-4) var(--sp-3); }
#device-drawer .drawer-section { padding: var(--sp-4) 0; }
#device-drawer .section-head { margin-bottom: var(--sp-2); }
#device-drawer .form-grid { gap: 8px 12px; }
#device-drawer .field { gap: 4px; }
#device-drawer #note-body { min-height: 56px; height: 56px; }
#device-drawer #run-command { min-height: 68px; height: 68px; }
#device-drawer .section-note { margin: 4px 0 0; }
#device-drawer #dd-note-list .empty-state { padding: var(--sp-2); }
#device-drawer #dd-note-list .empty-ico { width: 30px; height: 30px; }
#device-drawer #dd-note-list .empty-title { font-size: var(--fs-md); }
#device-drawer .console-actions { margin-top: 6px; }
#dd-tags, #dd-run { grid-column: 1; }
#dd-notes { grid-column: 2; }
#dd-assign { grid-column: 1 / -1; }
#device-drawer .drawer-section + .drawer-section { border-top: 1px solid var(--border); }
@media (max-width: 760px) { #device-drawer { width: 100vw; } #device-drawer .drawer-body { display: block; } }

.report-sources { margin-top: var(--sp-4); }
.report-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.report-card { display: flex; flex-direction: column; }
.report-card .card-body { gap: var(--sp-3); }
.report-card .btn { align-self: flex-start; margin-top: auto; }
@media (max-width: 1100px) { .report-grid { grid-template-columns: 1fr; } }

#view-reports .kv { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); padding: 6px 0; border-bottom: 1px solid var(--border); }
#view-reports .kv:last-of-type { border-bottom: 0; }
#view-reports .kv span:first-child { color: var(--text-faint); font-size: var(--fs-sm); }
#view-reports .kv span:last-child { color: var(--text); font-size: var(--fs-sm); text-align: right; }

/* ── Service Desk ── */
.sd-layout { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(320px, 360px); gap: var(--sp-4); align-items: start; min-width: 0; }
.sd-layout > * { min-width: 0; }
.sd-toolbar { display: flex; align-items: center; gap: 10px; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border2); flex-wrap: wrap; }
.sd-toolbar .input-icon { flex: 1 1 220px; min-width: 0; max-width: none; }
.sd-toolbar .input-icon input { width: 100%; }
.sd-toolbar select { width: auto; min-width: 160px; }
.sd-toolbar .btn { margin-left: auto; }
.sd-table { table-layout: fixed; min-width: 0; }
.sd-table th:nth-child(1), .sd-table td:nth-child(1) { width: 100px; }
.sd-table th:nth-child(2), .sd-table td:nth-child(2) { width: 118px; }
.sd-table th:nth-child(4), .sd-table td:nth-child(4) { width: 17%; }
.sd-table th:nth-child(5), .sd-table td:nth-child(5) { width: 78px; }
.sd-table th:nth-child(6), .sd-table td:nth-child(6) { width: 104px; }
.sd-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-table td.sd-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.sd-table tbody tr[data-ticket] { cursor: pointer; }
.sd-table tbody tr[data-ticket]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.sd-table tbody tr.is-selected td { background: var(--cyan-soft); }
.sd-table .sd-num { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-sub); }
.sd-table .badge { white-space: nowrap; }
.sd-detail { position: sticky; top: 84px; min-height: 220px; min-width: 0; max-height: calc(100vh - 160px); overflow-y: auto; }
.sd-detail .card-body { display: flex; flex-direction: column; gap: var(--sp-3); }
.sd-detail .card-head { gap: var(--sp-3); align-items: flex-start; }
.sd-detail .card-head > div { min-width: 0; }
.sd-detail .card-head .badge { flex: 0 0 auto; }
.sd-detail h3 { font-size: var(--fs-lg); line-height: 1.3; overflow-wrap: anywhere; }
.sd-detail .sd-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.sd-detail .sd-meta dt { margin-bottom: 2px; color: var(--text-faint); font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.sd-detail .sd-meta dd { margin: 0; color: var(--text); font-size: var(--fs-base); overflow-wrap: anywhere; }
.sd-detail .sd-desc { color: var(--text-sub); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 140px; overflow: auto; }
.sd-detail .sd-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
#view-service-desk .table-foot { display: flex; align-items: center; gap: var(--sp-3); }
.sd-pager { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sd-pager .btn { min-height: 30px; padding: 4px 10px; }
.sd-pager .btn:disabled { opacity: .45; cursor: default; }
@media (max-width: 1100px) {
  .sd-layout { grid-template-columns: 1fr; }
  .sd-detail { position: static; }
}

/* ── Automation library ── */
.auto-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.auto-tag { border: 1px solid var(--border2); background: transparent; color: var(--text-sub); border-radius: 999px; padding: 4px 9px; font-size: var(--fs-xs); cursor: pointer; }
.auto-tag:hover { color: var(--text); border-color: var(--border3); }
.auto-tag.active { color: var(--cyan); border-color: var(--cyan-line); background: var(--cyan-soft); }
.auto-tag .n { color: var(--text-faint); margin-left: 4px; }
.auto-views { display: flex; flex-direction: column; gap: 2px; }
.auto-view { display: flex; align-items: center; justify-content: space-between; border: 0; background: transparent; color: var(--text-sub); padding: 7px 8px; border-radius: var(--radius-sm); font-size: var(--fs-sm); cursor: pointer; text-align: left; }
.auto-view:hover { background: var(--highlight); color: var(--text); }
.auto-view.active { background: var(--bg4); color: var(--cyan); }
.script-side { grid-column: 1; }
#script-form, #script-empty { grid-column: 2; }
.automation-side { grid-column: 3; display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.automation-card { min-width: 0; }
.automation-card .card-head { align-items: flex-start; gap: var(--sp-2); }
.automation-card .card-head h3 { font-size: var(--fs-lg); }
.automation-card .card-body { display: flex; flex-direction: column; gap: 8px; }
.auto-run-name { font-weight: 600; overflow-wrap: anywhere; }
.auto-run-meta { color: var(--text-sub); font-size: var(--fs-sm); }
.auto-kv { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); color: var(--text-sub); font-size: var(--fs-sm); }
.auto-kv b { color: var(--text); font-weight: 500; }
.auto-health-bar { height: 5px; border-radius: 999px; background: var(--bg4); overflow: hidden; }
.auto-health-bar i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.auto-health-bar i.pct-0 { width: 0; }
.auto-health-bar i.pct-25 { width: 25%; }
.auto-health-bar i.pct-50 { width: 50%; }
.auto-health-bar i.pct-80 { width: 80%; }
.auto-health-bar i.pct-100 { width: 100%; }
.auto-schedule { display: flex; flex-direction: column; gap: 1px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.auto-schedule:last-child { border-bottom: 0; }
.auto-schedule b { font-size: var(--fs-sm); font-weight: 500; overflow-wrap: anywhere; }
.auto-schedule span { color: var(--text-faint); font-size: var(--fs-xs); }
.script-item .auto-item-meta { display: block; margin-top: 2px; color: var(--text-faint); font-size: var(--fs-2xs); }
.script-item .auto-item-tags { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.script-item .auto-item-tags span { border: 1px solid var(--border2); border-radius: 999px; padding: 1px 6px; color: var(--text-faint); font-size: 10px; }
