/* ctOS Gatekeeper admin — WinBox 4.3–inspired shell (layout language only).
   Binding: docts/Gatekeeper/working/admin-winbox-shell.md */

:root,
html[data-color-mode="dark"] {
  color-scheme: dark;
  --bg0: #1b1d21;
  --bg1: #22252b;
  --bg2: #2a2e36;
  --panel: #262a32;
  --surface: #1f2329;
  --surface-2: #2c313a;
  --surface-3: #343a45;
  --nav: #1a1c20;
  --nav-hover: #252830;
  --nav-active: #1e3a5f;
  --chrome: #22252b;
  --ink: #e8eaed;
  --ink-soft: #c5cad3;
  --ink-head: #aeb4bf;
  --muted: #8b93a0;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #4c8dff;
  --accent-deep: #2f6fe0;
  --accent-2: #6aa1ff;
  --accent-ink: #ffffff;
  --warn: #e0a03c;
  --danger: #e57373;
  --ok: #5dcf8a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --overlay: rgba(0, 0, 0, 0.55);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --row-hover: rgba(76, 141, 255, 0.1);
  --row-sel: rgba(76, 141, 255, 0.18);
  --focus-ring: rgba(76, 141, 255, 0.35);
  --check-border-hover: rgba(76, 141, 255, 0.7);
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --control-h: 30px;
  --gk-row-h: 28px;
  --gk-head-h: 28px;
  --gk-cell-control-h: 24px;
  --gap: 10px;
  --radius: 4px;
  --nav-w: 212px;
  --top-h: 40px;
  --status-h: 26px;
}

html[data-color-mode="light"] {
  color-scheme: light;
  --bg0: #e8eaee;
  --bg1: #f3f4f6;
  --bg2: #ffffff;
  --panel: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #eef0f3;
  --surface-3: #e4e7ec;
  --nav: #f0f1f4;
  --nav-hover: #e4e6eb;
  --nav-active: #d6e6ff;
  --chrome: #f7f8fa;
  --ink: #1c2330;
  --ink-soft: #3a4556;
  --ink-head: #5a6577;
  --muted: #6b7585;
  --line: rgba(20, 30, 45, 0.1);
  --line-strong: rgba(20, 30, 45, 0.18);
  --accent: #2f7cf6;
  --accent-deep: #1f63d4;
  --accent-2: #2563eb;
  --accent-ink: #ffffff;
  --warn: #b7791f;
  --danger: #c53030;
  --ok: #1f8f55;
  --shadow: 0 8px 20px rgba(20, 35, 55, 0.1);
  --overlay: rgba(20, 30, 40, 0.4);
  --chip-bg: rgba(20, 30, 45, 0.05);
  --row-hover: rgba(47, 124, 246, 0.08);
  --row-sel: rgba(47, 124, 246, 0.14);
  --focus-ring: rgba(47, 124, 246, 0.3);
  --check-border-hover: rgba(47, 124, 246, 0.65);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg0);
}

body.theme-winbox {
  background: var(--bg0);
}

#app {
  height: 100%;
  min-height: 100vh;
}

/* —— Winbox app shell —— */
.wb-app.shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  width: 100%;
  max-width: none;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.wb-nav {
  display: flex;
  flex-direction: column;
  background: var(--nav);
  border-right: 1px solid var(--line-strong);
  min-height: 0;
}

.wb-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--top-h);
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.wb-nav-mark,
.gk-logo-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
  color: var(--accent-ink);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.gk-logo {
  display: block;
  width: 100%;
  height: 100%;
}

.gk-logo--mark {
  width: 28px;
  height: 28px;
}

.gk-logo--inline {
  width: clamp(2rem, 4vw, 2.6rem);
  height: clamp(2rem, 4vw, 2.6rem);
  flex: 0 0 auto;
}

.gk-logo--hero {
  width: clamp(3.75rem, 12vw, 5rem);
  height: clamp(3.75rem, 12vw, 5rem);
  filter: drop-shadow(0 10px 20px color-mix(in srgb, #1f5fd6 30%, transparent));
}

.gk-logo--stage {
  width: 100%;
  height: auto;
}

.gk-logo--watermark {
  width: 100%;
  height: auto;
}

.gk-logo-hero {
  display: grid;
  place-items: center;
}

.wb-nav-product {
  font-weight: 650;
  font-size: 0.84rem;
  line-height: 1.1;
}

.wb-nav-plane {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wb-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 12px;
  overflow: auto;
  flex: 1 1 auto;
}

.wb-nav-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 8px 0 6px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.wb-nav-item:hover {
  background: var(--nav-hover);
  color: var(--ink);
}

.wb-nav-item.active {
  background: var(--nav-active);
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}

.wb-nav-glyph {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--mono);
}

.wb-nav-item.active .wb-nav-glyph {
  background: var(--accent);
  color: var(--accent-ink);
}

.wb-nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-stage {
  display: grid;
  grid-template-rows: var(--top-h) minmax(0, 1fr) var(--status-h);
  min-width: 0;
  min-height: 0;
  background: var(--bg1);
}

.wb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line-strong);
}

.wb-top-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.wb-top-window {
  font-weight: 650;
  font-size: 0.92rem;
}

.wb-top-path {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wb-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.wb-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}

.wb-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}

/* —— Profile menu —— */
.wb-profile {
  position: relative;
  flex: 0 0 auto;
}

.wb-profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  margin: 0;
  padding: 0 6px 0 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: none;
}

.wb-profile-trigger:hover,
.wb-profile.is-open .wb-profile-trigger {
  border-color: var(--accent);
  color: var(--ink);
}

.wb-profile-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.wb-profile-avatar {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: var(--accent-ink);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-family: var(--mono);
}

.wb-profile-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
  margin-right: 2px;
}

.wb-profile.is-open .wb-profile-caret {
  transform: rotate(180deg);
}

.wb-profile-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: min(260px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.wb-profile-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.wb-profile-email {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
  line-height: 1.3;
}

.wb-profile-meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 0.7rem;
  color: var(--muted);
}

.wb-profile-meta-sep { opacity: 0.5; }

.wb-profile-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.wb-profile-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.wb-profile-danger {
  color: var(--danger);
  margin-top: 2px;
}

.wb-profile-danger:hover {
  background: rgba(197, 48, 48, 0.1);
  color: var(--danger);
}

.wb-workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.wb-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--chrome);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}

.wb-status-sep { opacity: 0.45; }
.wb-status-spacer { flex: 1 1 auto; }
.wb-status-email { font-family: var(--mono); font-size: 0.68rem; }
.wb-status-ok { color: var(--ok); }
.wb-status-err { color: var(--danger); }

/* Floating toasts (success / error) — not status-bar text */
.gk-toast-host {
  position: fixed;
  right: 16px;
  bottom: 28px;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 24px));
}

/* Temporary rate-limit account / connection lockout */
.gk-rate-lockout {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: color-mix(in srgb, #0f172a 55%, transparent);
  backdrop-filter: blur(2px);
}

.gk-rate-lockout-card {
  width: min(28rem, 100%);
  padding: 1.35rem 1.5rem 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--line-strong, #cbd5e1);
  background: var(--panel, #fff);
  color: var(--ink, #0f172a);
  box-shadow: var(--shadow, 0 12px 40px rgba(15, 23, 42, 0.25));
  text-align: center;
}

.gk-rate-lockout-card h2 {
  margin: 0 0 0.65rem;
  font-size: 1.15rem;
}

.gk-rate-lockout-msg {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink-soft, #334155);
}

.gk-rate-lockout-label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #64748b);
}

.gk-rate-lockout-count {
  margin-top: 0.35rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent, #1d4ed8);
}

.gk-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: min(280px, 100%);
  max-width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.gk-toast.gk-toast-in {
  opacity: 1;
  transform: translateY(0);
}

.gk-toast.gk-toast-out {
  opacity: 0;
  transform: translateY(6px);
}

.gk-toast-ok {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line-strong));
  border-left: 3px solid var(--ok);
}

.gk-toast-error {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line-strong));
  border-left: 3px solid var(--danger);
}

.gk-toast-info {
  border-left: 3px solid var(--accent);
}

.gk-toast-msg {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.gk-toast-close {
  flex: 0 0 auto;
  height: 22px;
  width: 22px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  box-shadow: none;
  border-radius: 4px;
}

.gk-toast-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  filter: none;
}

/* —— Auth: WinBox connect pane (RIGHT dock; mirrored from WinBox left) —— */
.wb-auth {
  --wb-auth-label-w: clamp(4.5rem, 22vw, 5.75rem);
  --wb-auth-panel-w: clamp(20rem, 40vw, 28rem);
  --wb-auth-qr-size: 200px;
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--wb-auth-panel-w);
  align-items: stretch;
  margin: 0;
  padding: 0;
  background: var(--bg0);
  overflow-x: hidden;
}

.wb-auth-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-items: stretch;
  overflow: hidden;
  background-color: #ffffff;
  background-image: none;
  border-right: 1px solid rgba(20, 40, 80, 0.08);
  color: #1a2436;
}

html[data-color-mode="dark"] .wb-auth-stage,
html[data-color-mode="light"] .wb-auth-stage {
  background-color: #ffffff;
  background-image: none;
  color: #1a2436;
}

.wb-ad {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: grid;
  align-content: center;
  gap: clamp(1rem, 2.8vh, 1.75rem);
  padding: clamp(1.25rem, 4vw, 3rem) clamp(1.25rem, 5vw, 3.5rem);
  background: #ffffff;
}

.wb-ad-ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.wb-ad-ambient::before {
  content: "";
  position: absolute;
  inset: -8%;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(33, 99, 232, 0.09) 1px, transparent 0);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 70% at 55% 45%, #000 10%, transparent 78%);
  opacity: 1;
  animation: wb-ad-drift 36s linear infinite;
}

.wb-ad-watermark {
  position: absolute;
  right: -4%;
  bottom: -6%;
  width: clamp(14rem, 42vw, 22rem);
  opacity: 0.07;
  transform: rotate(-8deg);
  filter: grayscale(0.15);
  animation: wb-ad-wm 14s ease-in-out infinite;
}

.wb-ad-watermark--b {
  right: auto;
  left: -10%;
  top: -8%;
  bottom: auto;
  width: clamp(10rem, 30vw, 16rem);
  opacity: 0.045;
  transform: rotate(18deg);
  animation-duration: 18s;
  animation-direction: reverse;
}

.wb-ad-ring {
  position: absolute;
  right: 12%;
  top: 18%;
  width: clamp(9rem, 26vw, 14rem);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(33, 99, 232, 0.12);
  box-shadow: inset 0 0 0 18px rgba(33, 99, 232, 0.03);
  animation: wb-ad-ring 10s ease-in-out infinite;
}

.wb-ad-ring--2 {
  right: 18%;
  top: 26%;
  width: clamp(5.5rem, 16vw, 8.5rem);
  border-color: rgba(33, 99, 232, 0.16);
  box-shadow: inset 0 0 0 10px rgba(33, 99, 232, 0.035);
  animation-duration: 7.5s;
  animation-direction: reverse;
}

.wb-ad-copy {
  position: relative;
  z-index: 1;
  max-width: min(34rem, 100%);
  display: grid;
  gap: clamp(0.65rem, 1.6vh, 1rem);
  animation: wb-ad-rise 0.7s ease-out both;
}

.wb-ad-brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wb-ad-brand {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1.65rem, 4.2vw, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #122038;
}

.wb-ad-tagline {
  margin: 0;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 500;
  color: #2163e8;
  line-height: 1.35;
}

.wb-ad-slides {
  position: relative;
  min-height: clamp(8rem, 24vh, 11.5rem);
  margin-top: 0.35rem;
}

.wb-ad-slide {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  gap: 0.45rem;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.wb-ad-slide.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.wb-ad-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b778c;
}

.wb-ad-title {
  margin: 0;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 650;
  line-height: 1.25;
  color: #15233a;
}

.wb-ad-body {
  margin: 0;
  max-width: 36ch;
  font-size: clamp(0.86rem, 1.8vw, 0.98rem);
  line-height: 1.5;
  color: #445166;
}

.wb-ad-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 0.15rem;
}

.wb-ad-dot {
  width: 8px;
  height: 8px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: rgba(33, 99, 232, 0.22);
  box-shadow: none;
  cursor: pointer;
  transition: width 0.2s ease, background 0.2s ease;
}

.wb-ad-dot.is-active {
  width: 22px;
  background: #2163e8;
}

.wb-ad-dot:hover {
  background: #4b94ff;
}

.wb-ad-dot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(33, 99, 232, 0.35);
}

.wb-ad-platform {
  margin: 0.85rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(20, 40, 80, 0.08);
  display: grid;
  gap: 0.55rem;
}

.wb-ad-platform-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a8699;
}

.wb-ad-platform-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.wb-os-sep {
  width: 1px;
  height: 1.35rem;
  margin: 0 0.15rem;
  background: rgba(20, 40, 80, 0.12);
  flex: 0 0 auto;
}

.wb-os-badge,
.wb-win-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.1rem;
  padding: 0.4rem 0.7rem 0.4rem 0.55rem;
  border: 1px solid rgba(20, 40, 80, 0.12);
  border-radius: 999px;
  background: #f5f7fb;
  color: #1a2333;
  box-shadow: none;
}

.wb-os-mark,
.wb-win-mark {
  width: 1.2rem;
  height: 1.2rem;
  flex: 0 0 auto;
}

.wb-win-mark {
  color: #0078d4;
}

.wb-android-mark {
  color: #3ddc84;
}

.wb-bt-mark {
  color: #0082fc;
}

.wb-os-badge-line {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  white-space: nowrap;
  line-height: 1.15;
  font-size: 0.92rem;
}

.wb-os-badge-line strong {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.wb-os-badge-line span {
  font-weight: 500;
  font-size: 0.84rem;
  color: #6b778c;
}

.wb-ad-platform-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .wb-os-sep {
    display: none;
  }
}

.gk-logo--watermark {
  width: 100%;
  height: auto;
  display: block;
}

@keyframes wb-ad-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes wb-ad-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-14px, -14px, 0); }
}

@keyframes wb-ad-wm {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  50% { transform: rotate(-6deg) translateY(-10px); }
}

@keyframes wb-ad-ring {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .wb-ad-ambient::before,
  .wb-ad-watermark,
  .wb-ad-ring,
  .wb-ad-copy {
    animation: none !important;
  }

  .wb-ad-slide {
    transition: none;
  }
}

.wb-auth-panel,
.wb-auth-card {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* Gatekeeper connect pane — warm slate, not WinBox flat gray */
  background:
    linear-gradient(180deg, #f7f5f1 0%, #f0ece4 48%, #ebe6dc 100%);
  border: none;
  border-radius: 0;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.55);
  overflow: hidden;
  color: var(--ink);
}

html[data-color-mode="dark"] .wb-auth-panel,
html[data-color-mode="dark"] .wb-auth-card {
  background:
    linear-gradient(180deg, #1a1f29 0%, #151a22 55%, #12161d 100%);
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.04);
}

.wb-auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(80, 70, 50, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent);
}

html[data-color-mode="dark"] .wb-auth-head {
  border-bottom-color: rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
}

.wb-auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wb-auth-brand h1 {
  margin: 0;
  font-size: clamp(0.92rem, 2.4vw, 1rem);
  font-weight: 650;
  color: var(--ink);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.wb-auth-brand p {
  margin: 2px 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wb-auth-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  flex-shrink: 0;
  padding: 0 clamp(8px, 2vw, 14px);
  border-bottom: 1px solid rgba(80, 70, 50, 0.1);
  background: rgba(60, 50, 35, 0.04);
}

html[data-color-mode="dark"] .wb-auth-tabs {
  border-bottom-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.wb-auth-tab {
  height: 34px;
  padding: 0 clamp(10px, 2.5vw, 14px);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  box-shadow: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: clamp(0.8rem, 2.2vw, 0.875rem);
}

.wb-auth-tab:hover {
  color: var(--ink-soft);
}

.wb-auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.wb-auth-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  /* Modest top inset — large vh padding collided with store when viewport shrinks (DevTools, short screens) */
  padding: clamp(0.85rem, 2.5vh, 1.5rem) 16px 16px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 55% at 50% 0%, rgba(47, 124, 246, 0.08), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18));
  border-top: 1px solid rgba(80, 70, 50, 0.06);
}

/*
 * Password backup open: no inner scroll, no clipped fields.
 * Shrink QR + hide decorative chrome so email/password/button fully fit in the pane.
 */
.wb-auth-body:has(#password-backup[open]) {
  --wb-auth-qr-size: 148px;
  gap: 0.4rem;
  padding-top: 0.65rem;
  padding-bottom: 18px;
  justify-content: flex-start;
  overflow: hidden;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-hero {
  display: none;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-store {
  display: none;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-qr-hint {
  display: none;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-qr-lead {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-backup {
  flex: 0 0 auto;
  margin-top: 0.35rem;
  padding-bottom: 0.75rem;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-backup-note {
  display: none;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-form {
  gap: 0.55rem;
}

.wb-auth-body:has(#password-backup[open]) .wb-auth-actions {
  margin-top: 0.15rem;
}

html[data-color-mode="dark"] .wb-auth-body {
  background:
    radial-gradient(ellipse 90% 55% at 50% 0%, rgba(76, 141, 255, 0.12), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%);
  border-top-color: rgba(255, 255, 255, 0.05);
}

.wb-auth-store {
  margin-top: auto;
  padding-top: 0.35rem;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 2;
  /* Opaque band so form never paints through the badge */
  background: linear-gradient(180deg, transparent, rgba(240, 236, 228, 0.92) 28%);
}

html[data-color-mode="dark"] .wb-auth-store {
  background: linear-gradient(180deg, transparent, rgba(18, 22, 29, 0.92) 28%);
}

.cas-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.7rem 0.45rem 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(20, 40, 80, 0.14);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  position: relative;
  z-index: 1;
}

html[data-color-mode="dark"] .cas-brand {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: none;
}

.cas-logo {
  display: block;
  width: 100%;
  height: 100%;
}

.cas-logo--footer {
  width: 1.85rem;
  height: 1.85rem;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 4px rgba(21, 72, 184, 0.36));
}

.cas-brand-copy {
  display: grid;
  gap: 0.08rem;
  line-height: 1.15;
  white-space: nowrap;
}

.cas-brand-name {
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cas-brand-product {
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--ink-soft);
}

.wb-auth-hero {
  display: grid;
  place-items: center;
  padding: 4px 0 2px;
  position: relative;
  flex-shrink: 0;
}

.wb-auth-hero::before {
  content: "";
  position: absolute;
  width: clamp(4.5rem, 14vw, 6rem);
  height: clamp(4.5rem, 14vw, 6rem);
  border-radius: 28%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), transparent 55%),
    radial-gradient(circle at 50% 50%, rgba(47, 124, 246, 0.14), transparent 70%);
  pointer-events: none;
}

html[data-color-mode="dark"] .wb-auth-hero::before {
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.08), transparent 55%),
    radial-gradient(circle at 50% 50%, rgba(76, 141, 255, 0.18), transparent 70%);
}

.wb-auth-form {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  align-content: start;
  scrollbar-width: thin;
}

/* Login / Activate field labels — always above the control (never overlays the value) */
.wb-auth-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
  margin: 0.4rem 0 0;
  min-width: 0;
}

.wb-auth-float {
  position: static;
  display: block;
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  pointer-events: none;
  transform: none;
  background: transparent;
}

.wb-auth-field:focus-within .wb-auth-float {
  color: var(--accent);
}

.wb-auth-field input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  height: 2.85rem;
  margin: 0;
  padding: 0 0.85rem;
  border: 1px solid rgba(90, 80, 60, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.25;
  box-shadow: none;
}

html[data-color-mode="dark"] .wb-auth-field input {
  background: rgba(20, 24, 32, 0.92);
  border-color: var(--line-strong);
}

.wb-auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.wb-auth-field input::placeholder {
  color: transparent;
}

.wb-auth-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 2px 0 0;
  padding: 0;
  justify-content: stretch;
}

.wb-auth-actions::before {
  content: none;
  display: none;
}

.wb-auth-connect {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  box-shadow: none;
}

.wb-auth-connect:hover {
  filter: brightness(1.05);
}

.wb-auth-qr {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  margin: 0.15rem 0 0;
  padding: 0;
  text-align: center;
  flex: 0 1 auto;
  min-height: 0;
}

/* display:grid above would otherwise override the HTML hidden attribute */
.wb-auth-qr[hidden] {
  display: none !important;
}

.wb-auth-qr-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 550;
}

.wb-auth-qr-lead {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.wb-auth-backup {
  margin-top: auto;
  width: 100%;
  flex: 0 0 auto;
  border: 1px solid rgba(90, 80, 60, 0.16);
  border-radius: 8px;
  padding: 0.35rem 0.65rem 0.65rem;
  background: rgba(90, 80, 60, 0.03);
  box-sizing: border-box;
}

html[data-color-mode="dark"] .wb-auth-backup {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.wb-auth-backup > summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0;
  color: var(--ink-soft);
  list-style: none;
  user-select: none;
}

.wb-auth-backup > summary::-webkit-details-marker {
  display: none;
}

.wb-auth-backup[open] > summary {
  color: var(--ink);
  margin-bottom: 0.15rem;
}

.wb-auth-backup-note {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
}

.wb-auth-qr-divider::before,
.wb-auth-qr-divider::after {
  content: "";
  height: 1px;
  background: rgba(90, 80, 60, 0.18);
}

html[data-color-mode="dark"] .wb-auth-qr-divider::before,
html[data-color-mode="dark"] .wb-auth-qr-divider::after {
  background: rgba(255, 255, 255, 0.12);
}

.wb-auth-qr-frame {
  box-sizing: border-box;
  width: var(--wb-auth-qr-size, 200px);
  height: var(--wb-auth-qr-size, 200px);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(90, 80, 60, 0.16);
  background: #fff;
  display: grid;
  place-items: center;
  margin-inline: auto;
  flex-shrink: 0;
}

html[data-color-mode="dark"] .wb-auth-qr-frame {
  border-color: rgba(255, 255, 255, 0.14);
}

.wb-auth-qr-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.wb-auth-qr-skeleton {
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding: 0.5rem;
}

.wb-auth-qr-hint {
  margin: 0;
  max-width: 16rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.wb-auth-qr--account {
  margin: 0.75rem 0;
  justify-items: start;
  text-align: left;
}

.wb-auth-body .error,
.wb-auth-body .ok {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .wb-auth {
    --wb-auth-panel-w: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 34vh) minmax(0, 1fr);
  }

  .wb-auth-stage {
    min-height: clamp(160px, 34vh, 260px);
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .wb-ad {
    align-content: end;
    padding-bottom: clamp(0.85rem, 2vh, 1.25rem);
  }

  .wb-ad-watermark {
    width: clamp(9rem, 38vw, 14rem);
    opacity: 0.055;
  }

  .wb-ad-ring {
    opacity: 0.55;
  }

  .wb-ad-slides {
    min-height: 5.75rem;
  }

  .wb-ad-body {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .wb-auth-panel,
  .wb-auth-card {
    min-height: 0;
  }
}

@media (max-width: 420px) {
  .wb-auth-actions {
    grid-template-columns: 1fr;
  }
}

.auth-topbar { display: none; }

/* —— Theme icon toggle —— */
.gk-theme-control {
  display: inline-flex;
  align-items: center;
}

.gk-theme-toggle {
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: none;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.gk-theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface-2);
}

.gk-theme-toggle:active {
  transform: scale(0.94);
}

.gk-theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.gk-theme-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
}

.gk-theme-svg {
  width: 16px;
  height: 16px;
  display: block;
}

.gk-theme-toggle[data-theme-pref="light"] { color: #d4a017; }
.gk-theme-toggle[data-theme-pref="dark"] { color: var(--accent); }
.gk-theme-toggle[data-theme-pref="system"] { color: var(--ink-soft); }

html[data-color-mode="light"] .gk-theme-toggle[data-theme-pref="light"] {
  color: #b7791f;
}

/* —— Panels / module windows —— */
.panel {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: none;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 650;
}

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}

.panel-head h2 { margin-bottom: 2px; }
.panel-head p,
.muted,
.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.brand-sub {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}

.gk-module {
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--top-h) - var(--status-h) - 20px);
  overflow: hidden;
}

.gk-module-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.gk-module-title {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: var(--control-h);
  white-space: nowrap;
}

.gk-module-tools {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  overflow: visible;
}

.gk-module-tools .search-field {
  margin: 0;
  flex: 0 1 14rem;
  width: 14rem;
  max-width: 14rem;
  min-width: 8rem;
}

.gk-module-tools .gk-field:not(.search-field) {
  margin: 0;
  flex: 0 0 auto;
  width: max-content;
  max-width: none;
}

.gk-module-tools .gk-field:not(.search-field) select {
  width: 8.25rem;
  flex: 0 0 8.25rem;
}

.gk-module-tools label,
.gk-module-tools .gk-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  height: var(--control-h);
  min-height: var(--control-h);
  font-weight: 600;
  color: var(--ink-soft);
  overflow: visible;
}

.gk-module-tools .gk-field-label {
  white-space: nowrap;
  flex: 0 0 auto;
  font-size: 0.72rem;
}

.gk-module-tools input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.gk-module-tools select {
  height: var(--control-h);
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
}

.gk-module-tools > button {
  flex: 0 0 auto;
  height: var(--control-h);
  box-sizing: border-box;
  padding: 0 12px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .gk-module-bar {
    grid-template-columns: 1fr;
  }

  .gk-module-title {
    grid-column: 1;
    grid-row: 1;
  }

  .gk-module-tools {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .gk-module-tools .search-field {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-width: 6rem;
  }

  .gk-subtabs {
    grid-row: 3;
  }
}

.gk-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  grid-column: 1 / -1;
  grid-row: 2;
  width: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0 -10px -8px;
  padding: 0 6px;
  background: var(--surface-2);
}

.gk-subtab {
  height: 34px;
  padding: 0 14px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  box-shadow: none;
  margin-bottom: -1px;
  cursor: pointer;
}

.gk-subtab:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.gk-subtab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

.gk-subtab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.gk-module-body {
  padding: 10px;
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.gk-module-pane[hidden] { display: none !important; }

.gk-stat-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.track-summary-note {
  margin: 0 0 0.75rem;
}

.track-summary-wrap {
  display: grid;
  gap: 0;
}

/* —— Forms —— */
/* Control Plane input forms: always 3 columns; a lone field never full-row. */
.gk-form-grid,
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.gk-form-grid.two,
.grid.two,
.gk-form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gk-form-grid > label,
.gk-form-grid > .gk-field,
.gk-form-grid > .gk-pw-label,
.grid > label,
.grid > .gk-field {
  min-width: 0;
  max-width: 100%;
  grid-column: auto;
}

/* Checkbox groups: full remaining row — must beat `.gk-form-grid > .gk-field` */
.gk-form-grid > fieldset.gk-field-span,
.gk-form-grid > fieldset.gk-fieldset-span,
.gk-form-grid > fieldset.gk-field.gk-fieldset-span {
  grid-column: 1 / -1;
}

.gk-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  grid-column: 1 / -1;
  width: 100%;
}

.gk-form-grid > .gk-form-actions {
  grid-column: 1 / -1;
}

.gk-inline-editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.gk-inline-editor-bar > strong {
  margin: 0;
  font-size: 0.95rem;
}

/* Field labels never span full row; checkbox fieldsets + helper copy may. */
.gk-field-span {
  grid-column: auto;
  min-width: 0;
  max-width: 100%;
}

fieldset.gk-field-span,
fieldset.gk-fieldset-span {
  grid-column: 1 / -1;
}

.gk-form-grid > p.gk-field-span,
.gk-form-grid > .muted.gk-field-span,
p.gk-field-span {
  grid-column: 1 / -1;
}

.gk-pw-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.account-pw-form.gk-form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.account-pw-form .gk-pw-label {
  width: 100%;
  max-width: 100%;
}

.account-pw-actions.gk-form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 12px;
  width: 100%;
  margin-top: 4px;
}

.account-pw-status {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.account-pw-status[hidden] {
  display: none !important;
}

.account-pw-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.gk-pw-field {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.gk-pw-field input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.gk-pw-toggle {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background: var(--surface-2, #f3f5f7);
  color: var(--text-muted, #5c6670);
  border: 1px solid var(--border, #c9c9d1);
  border-left: 0;
  box-shadow: none;
}

.gk-pw-toggle:hover {
  color: var(--accent, #0b57d0);
  background: var(--surface-2, #eef2f6);
}

.gk-pw-toggle.is-revealed {
  color: var(--accent, #0b57d0);
}

.gk-pw-icon {
  width: 16px;
  height: 16px;
  display: block;
}

.auth-link-head {
  align-items: start;
  margin-bottom: 8px;
}

.auth-link-head h2 {
  margin: 0 0 4px;
}

.auth-link-head .muted {
  margin: 0;
}

.auth-link-head-actions.gk-form-actions {
  justify-content: flex-end;
  margin: 0;
  padding: 0;
  grid-column: auto;
}

.auth-link-grid-wrap {
  margin: 10px 0 8px;
  overflow-x: auto;
}

.auth-link-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.auth-link-table th,
.auth-link-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, #dde1e6);
  vertical-align: middle;
}

.auth-link-table th {
  font-weight: 600;
  color: var(--muted, #5c6670);
}

.auth-link-actions-col {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.auth-link-table th.auth-link-actions-col {
  text-align: right;
}

.wb-auth-forgot {
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
}

.wb-auth-forgot a {
  color: var(--accent, #0b57d0);
  text-decoration: none;
}

.wb-auth-forgot a:hover {
  text-decoration: underline;
}

.wb-auth .wb-auth-actions.gk-form-actions {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-content: stretch;
  gap: 0;
  margin: 2px 0 0;
  padding: 0;
}

@media (max-width: 420px) {
  .wb-auth .wb-auth-actions.gk-form-actions {
    grid-template-columns: 1fr;
  }
}

.gk-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
}

.gk-field-label,
label:not(.gk-field):not(.row):not(.gk-perm-item):not(.wb-auth-row):not(.wb-auth-field):not(.gk-check-label):not(.gk-check) {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  min-width: 0;
}

.gk-field-label { display: block; }

label:not(.gk-field):not(.row):not(.gk-perm-item):not(.wb-auth-field):not(.gk-check-label):not(.gk-check) > input,
label:not(.gk-field):not(.row):not(.gk-perm-item):not(.wb-auth-field):not(.gk-check-label):not(.gk-check) > select,
label:not(.gk-field):not(.row):not(.gk-perm-item):not(.wb-auth-field):not(.gk-check-label):not(.gk-check) > textarea {
  font-weight: 400;
  color: var(--ink);
}

.account-stack {
  display: grid;
  gap: var(--gap);
}

.plan-features-panel .panel-head {
  margin-bottom: 0.75rem;
}

.plan-feat-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 6px;
  overflow: hidden;
}

.plan-feat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: var(--panel-bg, #fff);
  border-bottom: 1px solid var(--line, #e5e7eb);
}

.plan-feat-row:last-child {
  border-bottom: 0;
}

.plan-feat-row.is-current {
  background: color-mix(in srgb, var(--accent, #2563eb) 6%, transparent);
}

.plan-feat-name {
  display: block;
  font-weight: 600;
  color: var(--ink, #111);
}

.plan-feat-key {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.plan-feat-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.chip.plan-feat-included {
  background: color-mix(in srgb, #16a34a 18%, transparent);
  color: #166534;
}

.chip.plan-feat-unlock {
  background: color-mix(in srgb, var(--accent, #2563eb) 14%, transparent);
  color: var(--accent, #1d4ed8);
}

.chip.plan-feat-muted {
  opacity: 0.75;
}

.plan-feat-lock {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line, #d1d5db);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
}

.plan-upgrade-quote {
  margin: 0 0 0.75rem;
}

.plan-quote-card {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  background: var(--panel-bg-soft, #f9fafb);
}

.plan-quote-title {
  font-weight: 700;
  margin-bottom: 0.65rem;
}

.plan-quote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.65rem 1rem;
  margin: 0;
}

.plan-quote-grid dt {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.plan-quote-grid dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
}

.plan-quote-due dd {
  font-size: 1.05rem;
}

.plan-quote-note {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.plan-upgrade-actions {
  margin-top: 0.25rem;
}

label.row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 8px;
  font-weight: 400;
  color: var(--muted);
}

.gk-field-hint {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
}

/* Web filter mode hint — must read clearly under the domains field */
.gk-field-hint[data-web-hint] {
  margin-top: 2px;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink-soft);
}

.gk-field-span { grid-column: auto; min-width: 0; max-width: 100%; }

fieldset.gk-field-span,
fieldset.gk-fieldset-span {
  grid-column: 1 / -1;
}

input, select, textarea, button { font: inherit; }

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  height: var(--control-h);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 0 8px;
  border-radius: var(--radius);
  min-width: 0;
}

textarea {
  height: auto;
  min-height: 72px;
  padding: 8px;
  resize: vertical;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 22px;
}

button {
  height: var(--control-h);
  border: 1px solid var(--accent-deep);
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: var(--accent-ink);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
  border-radius: var(--radius);
  white-space: nowrap;
  box-shadow: none;
}

button:hover { filter: brightness(1.05); }
input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
input:read-only {
  opacity: 0.85;
  cursor: default;
  background: var(--surface-2);
  color: var(--ink-soft);
}

button.secondary,
.chrome-btn {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
}

button.secondary.danger {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line-strong));
  color: var(--danger);
}

button.secondary.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  filter: brightness(1.02);
}

button.secondary:hover,
.chrome-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
  filter: none;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  flex: 0 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--surface);
  cursor: pointer;
  vertical-align: middle;
  box-shadow: none;
  accent-color: var(--accent);
}

input[type="checkbox"]:hover { border-color: var(--check-border-hover); }

input[type="checkbox"]:checked {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' stroke='%23ffffff' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.2L4.8 8.5 9.5 3.5'/%3E%3C/svg%3E");
  background-size: 10px 10px;
  background-position: center;
  background-repeat: no-repeat;
}

input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

input[type="radio"] {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: 0 0 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* —— Perm / CRUD helpers —— */
.gk-perm-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 12px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  max-height: 280px;
  overflow: auto;
}

.gk-perm-item {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 3px 0;
  font-weight: 400;
  color: inherit;
  min-width: 0;
}

.gk-perm-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gk-perm-slug { font-size: 0.78rem; color: var(--ink); line-height: 1.25; }
.gk-perm-desc {
  font-size: 0.7rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gk-ceiling { display: flex; flex-wrap: wrap; gap: 6px; }

.gk-inline-editor {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.priv-hint {
  margin: 0;
  font-size: 0.78rem;
}

.priv-console {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.priv-console > .kpi-strip {
  margin: 0;
}

/* bar styles live with form actions block above */

.gk-crud-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.gk-crud-toolbar .gk-field {
  min-width: 11rem;
  max-width: 15rem;
}

/* search-field default margin would push the sibling button 10px below the input */
.gk-crud-toolbar .search-field {
  margin-bottom: 0;
}

.gk-crud-toolbar > button {
  align-self: flex-end;
  height: var(--control-h);
}

.gk-crud-matrix .gk-grid-scroll { margin-top: 0; }
.gk-crud-matrix .gk-grid-th,
.gk-crud-matrix .gk-grid-td { justify-content: center; }
.gk-crud-matrix .gk-grid-th:first-child,
.gk-crud-matrix .gk-grid-td:first-child { justify-content: flex-start; }
.gk-crud-na { color: var(--muted); font-size: 0.76rem; }

/* —— Feedback —— */
.error, .wb-status-err { color: var(--danger); }
.ok, .wb-status-ok { color: var(--ok); }
.mono { font-family: var(--mono); }

.chip {
  display: inline-block;
  border: 1px solid var(--line-strong);
  padding: 1px 6px;
  font-size: 0.68rem;
  font-family: var(--mono);
  background: var(--chip-bg);
  line-height: 1.35;
  border-radius: 3px;
}

.chip-ok {
  border-color: rgba(93, 207, 138, 0.45);
  color: var(--ok);
  background: rgba(93, 207, 138, 0.1);
}

.chip-warn {
  border-color: rgba(224, 160, 60, 0.5);
  color: var(--warn);
  background: rgba(224, 160, 60, 0.1);
}

a.link, a.muted.link {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.8rem;
}
a.link:hover, a.muted.link:hover { text-decoration: underline; }

/* —— KPI —— */
.kpi-strip,
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kpi, .stat {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  display: grid;
  gap: 2px;
  border-radius: var(--radius);
}

.kpi-value, .stat-value {
  font-family: var(--mono);
  font-size: 1.05rem;
  color: var(--accent);
  line-height: 1.15;
}

.kpi-label, .stat-label {
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.notice, .notice-warn {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--line-strong);
  background: var(--surface);
  font-size: 0.8rem;
}

.notice-warn {
  border-left-color: var(--warn);
  color: var(--warn);
}

/* —— Data grid —— */
.gk-grid-host {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  min-width: 0;
}

.gk-grid-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: var(--radius);
}

.gk-grid-table {
  display: grid;
  min-width: 720px;
  width: 100%;
}

.gk-grid-head,
.gk-grid-row {
  display: grid;
  grid-template-columns: var(--gk-cols);
  gap: 0;
  align-items: stretch;
}

.gk-grid-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: var(--gk-head-h);
  height: var(--gk-head-h);
  background: var(--surface-3);
  border-bottom: 1px solid var(--line-strong);
}

.gk-grid-th,
.gk-grid-td {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-right: 1px solid var(--line);
  min-width: 0;
  height: 100%;
  overflow: hidden;
  font-size: 0.78rem;
  line-height: 1.2;
}

.gk-grid-th:last-child,
.gk-grid-td:last-child { border-right: none; }

.gk-grid-th {
  color: var(--ink-head);
  font-size: 0.7rem;
  font-weight: 650;
}

.gk-grid-row {
  min-height: var(--gk-row-h);
  height: var(--gk-row-h);
  border-bottom: 1px solid var(--line);
}

.gk-grid-row:hover { background: var(--row-hover); }
.gk-grid-empty { padding: 24px 14px; text-align: center; }

.gk-cell-input {
  width: 100%;
  height: var(--gk-cell-control-h) !important;
  min-height: var(--gk-cell-control-h) !important;
  padding: 0 6px !important;
  font-size: 0.76rem;
}

.gk-grid-td .chip {
  padding: 0 5px;
  font-size: 0.66rem;
  line-height: 1.3;
  white-space: nowrap;
}

.gk-grid-td .cell-actions {
  flex-wrap: nowrap;
  gap: 4px;
  width: 100%;
}

.gk-grid-td .cell-actions button {
  height: var(--gk-cell-control-h);
  padding: 0 8px;
  font-size: 0.72rem;
}

.gk-grid-td .cell-title,
.gk-grid-td .cell-plain {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
  font-weight: 400;
  color: var(--ink);
}

.gk-grid-td .cell-title {
  font-weight: 500;
}
.gk-grid-td .cell-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  color: var(--muted);
  font-size: 0.7rem;
}

.gk-grid-td .cell-sub { margin-top: 0; }
.gk-grid-td input[type="checkbox"] { flex: 0 0 14px; }

.gk-grid-td .cell-stack {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
}

.gk-align-left { justify-content: flex-start; }
.gk-align-center { justify-content: center; }
.gk-align-right { justify-content: flex-end; }

.packages-toolbar {
  margin-bottom: 12px;
}

.packages-orders-title {
  margin: 22px 0 8px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink-head);
}

.packages-console .gk-grid-host {
  margin-top: 4px;
}

.gk-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}

.gk-pager-meta { color: var(--muted); font-size: 0.74rem; }
.gk-pager-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.gk-pager-size {
  display: inline-grid;
  grid-template-columns: auto 64px;
  gap: 6px;
  align-items: center;
  margin: 0;
  font-size: 0.74rem;
}

.gk-pager-size select { height: 26px; }
.gk-pager-controls button { height: 26px; padding: 0 8px; }
.gk-pager-page { color: var(--muted); font-size: 0.74rem; }

/* —— Credential / misc —— */
.credential {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(47, 124, 246, 0.35);
  border-left-width: 3px;
  background: var(--surface);
  border-radius: var(--radius);
}

.credential-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.credential-title { margin: 0; font-size: 0.86rem; font-weight: 650; }
.credential-instruction {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.credential-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.credential-code {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  word-break: break-all;
  background: var(--bg0);
  border: 1px solid var(--line-strong);
  padding: 8px 10px;
  user-select: all;
  min-height: var(--control-h);
  border-radius: var(--radius);
}

.credential-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 10px 0 0;
  font-size: 0.78rem;
}

.credential-meta dt { color: var(--muted); }
.credential-meta dd {
  margin: 0;
  word-break: break-all;
  font-family: var(--mono);
}

.credential-actions { margin-top: 10px; }

.search-field {
  max-width: 20rem;
  margin-bottom: 10px;
}

.gk-module-tools .search-field {
  margin-bottom: 0;
}

.cell-title { display: block; font-weight: 500; }
.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--mono);
  margin-top: 1px;
}

.cell-actions {
  justify-content: flex-end;
  gap: 4px;
  margin: 0;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--muted);
}

.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-danger { background: var(--danger); }
.dot-idle { background: var(--line-strong); }

.empty-state {
  padding: 24px 14px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.empty-title { margin: 0 0 4px; font-weight: 650; }

.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;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.dialog {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
}

.dialog-message { margin: 0 0 12px; }
.dialog-actions { justify-content: flex-end; }

.table-wrap { margin-top: 10px; width: 100%; overflow-x: auto; }

/* legacy top tabs (unused in wb shell) */
.tabs, .tab, .command-bar, .command-bar-meta, .role-chip, .ctx-chip { display: none; }

@media (max-width: 900px) {
  .wb-app.shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .wb-nav {
    border-right: none;
    border-bottom: 1px solid var(--line-strong);
  }

  .wb-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    overflow: auto;
    max-height: 120px;
  }

  .wb-nav-item {
    width: auto;
    grid-template-columns: 22px auto;
    padding-right: 10px;
  }

  .wb-stage {
    min-height: 70vh;
  }

  .gk-form-grid,
  .gk-form-grid.two,
  .grid.two,
  .gk-form-grid.three { grid-template-columns: 1fr; }

  .kpi-strip,
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .panel-head { grid-template-columns: 1fr; }
  .gk-perm-list { grid-template-columns: 1fr; }
  .credential-code-row { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .kpi-strip,
  .stat-row { grid-template-columns: 1fr; }

  .wb-top {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--top-h);
    padding: 8px 10px;
  }

  .wb-top-right { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .gk-pager { flex-direction: column; align-items: stretch; }
}

.mail-lead {
  margin: 0 0 14px;
  max-width: 52rem;
}

.gk-module-body:has(.mail-templates-pane.is-active) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.mail-templates-pane.is-active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  height: 100%;
}

.mail-templates {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  flex: 1;
  height: 100%;
}

.mail-tpl-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.mail-tpl-toolbar-title {
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.mail-tpl-toolbar-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
}

.mail-tpl-count {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 8px;
  background: var(--surface);
}

.mail-tpl-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}

.mail-tpl-list-panel,
.mail-tpl-preview {
  min-height: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mail-tpl-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.mail-tpl-item {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 10px;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  border: 1px solid transparent;
}

.mail-tpl-item:hover {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.mail-tpl-item.is-selected {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.mail-tpl-item:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

.mail-tpl-order {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.mail-tpl-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mail-tpl-title {
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.25;
  color: var(--ink);
}

.mail-tpl-id {
  font-size: 0.7rem;
  color: var(--ink-soft);
  word-break: break-all;
}

.mail-tpl-empty {
  padding: 14px;
}

.mail-tpl-preview {
  padding: 14px;
  overflow: auto;
}

.mail-tpl-preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.mail-tpl-edit-help {
  margin: 0 0 10px;
  font-size: 0.78rem;
}

.mail-chip-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.mail-chip-toolbar-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-right: 4px;
}

.mail-chip-insert {
  height: 26px;
  padding: 0 8px;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--ink);
  font-size: 0.72rem;
  cursor: pointer;
}

.mail-chip-insert:hover {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.mail-chip-hint {
  font-size: 0.78rem;
}

.mail-chip-editor {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
}

.mail-chip-editor:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}

.mail-chip-editor-body {
  min-height: 180px;
  max-height: 42vh;
  overflow: auto;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.8rem;
}

.mail-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  margin: 0 2px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line-strong));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  user-select: none;
  vertical-align: baseline;
  cursor: default;
}

.mail-tpl-edit-actions {
  margin-top: 8px;
}

.mail-tpl-save-error {
  margin: 0 0 8px;
  color: var(--danger, #b42318);
  font-size: 0.8rem;
}

.mail-tpl-preview-empty {
  margin: auto 0;
  padding: 18px 8px;
  text-align: left;
}

.mail-tpl-preview-empty-title {
  font-weight: 650;
  margin-bottom: 6px;
}

.mail-tpl-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex: 0 0 auto;
}

.mail-tpl-preview-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.mail-tpl-preview-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.3;
}

.mail-tpl-pending {
  margin: 0;
}

.mail-tpl-msg {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--ink) 3%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mail-tpl-msg-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.mail-tpl-msg-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.mail-tpl-msg-subject {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}

.mail-tpl-msg-body {
  margin: 0;
  padding: 12px;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--ink);
  overflow: auto;
}

.mail-tpl-modal[hidden] {
  display: none !important;
}

.mail-tpl-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.mail-tpl-modal-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, #0b1220 48%, transparent);
}

.mail-tpl-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(78dvh, 720px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  box-shadow: 0 18px 48px color-mix(in srgb, #0b1220 28%, transparent);
  overflow: hidden;
}

.mail-tpl-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.mail-tpl-modal-body {
  padding: 14px;
  overflow: auto;
  min-height: 0;
}

@media (max-width: 980px) {
  .gk-module-body:has(.mail-templates-pane.is-active) {
    overflow: auto;
  }

  .mail-templates {
    height: auto;
    flex: 0 0 auto;
  }

  .mail-tpl-layout {
    grid-template-columns: 1fr;
  }

  .mail-tpl-preview {
    display: none;
  }

  .mail-tpl-list-panel {
    max-height: calc(100dvh - 220px);
  }
}

.gk-module-status {
  display: inline-flex;
  align-items: center;
  height: var(--control-h);
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: var(--surface);
}

.gk-module-status.ok {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line-strong));
  color: var(--ok);
}

.gk-module-status.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line-strong));
  color: var(--warn);
}

.gk-check-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 1.25rem;
  margin-top: 0.35rem;
}

.gk-check {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-weight: 500;
  font-size: 0.9rem;
  max-width: 100%;
}

.gk-check input {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}

/* CRUD / action checkboxes — clear square controls + label, horizontal wrap */
.gk-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 4px);
  background: var(--surface, #fff);
  cursor: pointer;
  user-select: none;
}

.gk-check-label:hover {
  border-color: var(--accent, #0b57d0);
}

.gk-check-label:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent, #0b57d0) 55%, var(--line, #e5e7eb));
  background: color-mix(in srgb, var(--accent, #0b57d0) 8%, var(--surface, #fff));
}

.gk-check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
  padding: 0;
  align-self: center;
}

fieldset.gk-fieldset-span .row,
fieldset.gk-field-span .row,
.gk-check-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin: 0.25rem 0 0;
}

.gk-form-grid > fieldset.gk-fieldset-span,
.gk-form-grid > fieldset.gk-field-span {
  margin: 0;
  padding: 0.65rem 0.85rem 0.75rem;
  border: 1px solid var(--line-strong, #c9c9d1);
  border-radius: var(--radius, 4px);
  background: var(--surface-2, #f7f8fa);
  min-width: 0;
}

.gk-form-grid > fieldset.gk-fieldset-span > legend,
.gk-form-grid > fieldset.gk-field-span > legend {
  padding: 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft, #5c6670);
}

.gk-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.gk-details {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.65rem 0.85rem;
}

.gk-details > summary {
  cursor: pointer;
  font-weight: 600;
  list-style-position: outside;
}

.gk-details[open] > summary {
  margin-bottom: 0.75rem;
}

.gk-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.gk-inline-select {
  max-width: 100%;
  min-width: 8rem;
}
