﻿/* ============================================================
   THEME TOKENS
   - Coral (light) values derived from index.html
   - Dark values derived from gutmasks-tabs.html
   ============================================================ */

/* Screen-reader only utility */
.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;
}

:root {
  --radius: 14px;
  --shadow: 0 6px 16px rgba(0, 0, 0, .06);
  --shadow-strong: 0 18px 60px rgba(0, 0, 0, .25);
  --sidebarW: 240px;
  --sidebarCollapsedW: 78px;
  --headerH: 64px;

  /* Motion */
  --t-fast: 120ms;
  --t-med: 180ms;
}

html[data-theme="coral"] {
  --bg: #f7f7fb;
  --surface: rgba(255, 255, 255, .86);
  --surface2: rgba(255, 255, 255, .68);
  --surface3: rgba(255, 255, 255, .92);
  --surface-solid: #ffffff;
  --text: #111;
  --muted: rgba(17, 17, 17, .65);
  --border: rgba(17, 17, 17, .12);
  --line: rgba(17, 17, 17, .12);
  --brand: #6a5cff;
  --brand2: #3b4fd8;
  --hero: #ff4fa7;
  --dev: #6a5cff;
  --mgr: #3b4fd8;
  --tst: #ff8a3d;

  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;

  --header-grad: linear-gradient(90deg, rgba(255, 79, 167, .24) 0%, rgba(106, 92, 255, .18) 55%, rgba(59, 79, 216, .18) 100%);
  --bg-grad: linear-gradient(180deg, #fafafe 0%, var(--bg) 100%);
}

html[data-theme="dark"] {
  --bg: #0b0f14;
  --surface: #111826;
  --surface2: #0f1624;
  --surface3: rgba(255, 255, 255, .03);
  --surface-solid: #111826;
  --text: #e8eef7;
  --muted: #9db0c7;
  --border: rgba(255, 255, 255, .10);
  --line: rgba(255, 255, 255, .10);
  --brand: #8b5cf6;
  --brand2: #4f46e5;
  --hero: #ff5aa5;
  --dev: #8b5cf6;
  --mgr: #4f46e5;
  --tst: #f59e0b;

  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;

  --header-grad: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .02));
  --bg-grad:
    radial-gradient(1100px 600px at 10% 0%, rgba(79, 70, 229, .20), transparent 55%),
    radial-gradient(900px 600px at 90% 20%, rgba(139, 92, 246, .18), transparent 55%),
    linear-gradient(180deg, #070a0f, #0b0f14 35%, #0b0f14);
  --shadow: 0 10px 25px rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font: 14px/1.35 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg-grad);
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none
}

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

::selection {
  background: rgba(106, 92, 255, .25);
}

body::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

body::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, .35);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .20);
}

html[data-theme="dark"] body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, .05);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  height: var(--headerH);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: var(--header-grad);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  letter-spacing: .2px;
  justify-self: start;
  min-width: 0;
}

.brand-logo-img {
  max-width: 168px;
  max-height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--dev), var(--mgr));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mgr), transparent 84%);
  flex-shrink: 0;
}

.brand-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--dev), var(--mgr));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mgr), transparent 84%);
}

.headerCenter {
  justify-self: center;
  min-width: 0;
}

.modeSwitch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.modeOpt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.modeOpt.active {
  color: var(--text);
  background: color-mix(in srgb, var(--brand), transparent 86%);
  border-color: color-mix(in srgb, var(--brand), transparent 64%);
}

.headerRight {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  justify-self: end;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  user-select: none;
}

.pill .chip {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--dev);
}

.iconbtn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
}

.iconbtn:hover {
  filter: brightness(0.98);
}

html[data-theme="dark"] .iconbtn:hover {
  filter: brightness(1.08);
}

.notif-btn {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  padding: 0 4px;
  display: none;
}

.notif-badge.visible {
  display: block;
}

.acc.unread {
  border-left: 3px solid var(--accent);
}

.main {
  flex: 1;
  display: flex;
  height: calc(100vh - var(--headerH));
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebarW);
  border-right: 1px solid var(--border);
  background: var(--surface2);
  backdrop-filter: blur(10px);
  padding: 12px;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width var(--t-med) ease;
}

.sidebar.collapsed {
  width: var(--sidebarCollapsedW);
}

.sbTop {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 10px;
  min-height: 38px;
  transition: gap var(--t-med) ease;
}

.sidebar.collapsed .sbTop {
  gap: 0;
}

.sbTop b {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  flex: 1;
  min-width: 0;
  transition: opacity var(--t-med) ease, flex var(--t-med) ease;
}

.sidebar.collapsed .sbTop b {
  opacity: 0;
  flex: 0;
  pointer-events: none;
}

.sbToggle {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface3);
  cursor: pointer;
  flex-shrink: 0;
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: gap var(--t-med) ease, padding var(--t-med) ease;
}

.sidebar.collapsed .nav a {
  gap: 0;
  padding: 10px 13px;
}

.nav a:hover {
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] .nav a:hover {
  background: rgba(255, 255, 255, .04);
}

.nav a.active {
  background: rgba(79, 70, 229, .12);
  border-color: rgba(79, 70, 229, .25);
}

.nav .ni {
  width: 28px;
  height: 28px;
  min-width: 28px;
  flex-shrink: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .05);
}

html[data-theme="dark"] .nav .ni {
  background: rgba(255, 255, 255, .06);
}

.nav .nl {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  opacity: 1;
  transition: opacity var(--t-med) ease, flex var(--t-med) ease;
}

.sidebar.collapsed .nl {
  opacity: 0;
  flex: 0;
  pointer-events: none;
}

.nav .nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  flex-shrink: 0;
  margin-left: auto;
  box-shadow: 0 0 0 2px var(--surface2, #fff);
}

.nav .nav-badge[hidden] {
  display: none;
}

.sidebar.collapsed .nav .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  margin-left: 0;
}

.sidebar.collapsed .nav a {
  position: relative;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 14px 16px 28px;
  overflow-x: hidden;
  overflow-y: scroll;
  height: 100%;
  min-height: 0;
}

.content::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.content::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, .35);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] .content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .20);
}

html[data-theme="dark"] .content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, .05);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* ============================================================
   CONTROLS
   ============================================================ */
.topRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.leftRow {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.rightRow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.breadcrumb {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 160px;
}

.breadcrumb b {
  color: var(--text);
  font-weight: 800;
}

.search {
  width: 340px;
  max-width: 42vw;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.selectwrap {
  position: relative;
}

.selectwrap:after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 9px;
  color: var(--muted);
  pointer-events: none;
}

select.select {
  appearance: none;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 34px 10px 12px;
  cursor: pointer;
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.btn:hover {
  filter: brightness(0.98);
}

html[data-theme="dark"] .btn:hover {
  filter: brightness(1.08);
}

.btn.primary {
  background: rgba(106, 92, 255, .14);
  border-color: rgba(106, 92, 255, .28);
}

.btn.danger {
  border-color: rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .10);
}

.btn.small {
  padding: 7px 9px;
  border-radius: 12px;
  font-size: 12px;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn.ghost:hover {
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] .btn.ghost:hover {
  background: rgba(255, 255, 255, .06);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: var(--muted);
}

.badge.ok .dot {
  background: var(--ok);
}

.badge.warn .dot {
  background: var(--warn);
}

.badge.bad .dot {
  background: var(--bad);
}

.badge.role-dev {
  border-color: rgba(106, 92, 255, .35);
  color: var(--dev);
  background: rgba(106, 92, 255, .10);
}

.badge.role-dev .dot {
  background: var(--dev);
}

.badge.role-mgr {
  border-color: rgba(59, 79, 216, .35);
  color: var(--mgr);
  background: rgba(59, 79, 216, .10);
}

.badge.role-mgr .dot {
  background: var(--mgr);
}

.badge.role-tst {
  border-color: rgba(245, 158, 11, .25);
  color: rgba(255, 225, 170, .95);
}

.badge.role-tst .dot {
  background: var(--tst);
}

.badge.badgeSelect,
.badge.badgeToggle {
  cursor: pointer;
  position: relative;
  user-select: none;
}

.badge.badgeSelect:not(.open):hover,
.badge.badgeToggle:hover {
  filter: brightness(0.98);
}

html[data-theme="dark"] .badge.badgeSelect:not(.open):hover,
html[data-theme="dark"] .badge.badgeToggle:hover {
  filter: brightness(1.06);
}

.badge.badgeSelect {
  padding-right: 12px;
}

.badge.badgeSelect .caret {
  margin-left: 4px;
  font-size: 10px;
  opacity: .7;
}

.badge.badgeSelect [data-badge-value] {
  font-weight: 700;
}

/* Dropdown badges: hide dots by default, keep for status widgets */
.badge.badgeSelect .dot {
  display: none;
}

.badge.badgeSelect[data-ver-status] .dot,
.badge.badgeSelect[data-portal-status] .dot {
  display: inline-block;
}

/* Remove dots for specific non-dropdown badges */
.badge.role-mgr .dot,
.badge.role-dev .dot {
  display: none;
}

.builderTop .badge .dot,
.maskCol .panelH .badge .dot {
  display: none;
}

/* notify_on_add: green when on, gray when off */
[data-notify-state]:not(.off) .dot {
  background: var(--ok);
}

[data-show-archived]:not(.off) .dot {
  background: var(--ok);
}

.badgeMenu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  min-width: 150px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  z-index: 60;
}

.badgeMenu button {
  all: unset;
  cursor: pointer;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
}

.badgeMenu button:hover {
  background: rgba(0, 0, 0, .08);
}

.badge.badgeSelect.open .badgeMenu {
  display: flex;
}

.badge.readonly {
  cursor: default;
  pointer-events: none;
  border-style: dashed;
  background: transparent;
  opacity: .75;
}

.badge.readonly.role-dev,
.badge.readonly.role-mgr {
  opacity: 1;
  border-style: solid;
}

.badge.readonly .dot {
  opacity: .6;
}

.badge.off {
  opacity: .75;
}

.badge.off .dot {
  background: var(--muted);
}

/* ============================================================
   ACCORDIONS: GUTMASKS + VERSIONS
   ============================================================ */
.list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.versionsList {
  gap: 0;
  margin-top: 12px;
}

.versionsList>.acc {
  margin: 0;
}

.versionsList>.acc+.acc {
  margin-top: 1px;
}

.acc {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.acc[data-gm] {
  overflow: visible;
  position: relative;
  z-index: 0;
}

.acc[data-gm].menuOpen {
  z-index: 30;
}

.acc.gmStyle {
  overflow: visible;
  position: relative;
  z-index: 0;
}

.acc.gmStyle.menuOpen {
  z-index: 30;
}

.acc[data-gm]>.accHead {
  border-radius: 16px 16px 0 0;
  background-clip: padding-box;
}

.acc[data-gm]:not(.open)>.accHead {
  border-radius: 16px;
}

.acc[data-gm]>.accBody {
  border-radius: 0 0 16px 16px;
  padding-bottom: 0;
  background-clip: padding-box;
}

.acc.gmStyle>.accHead {
  border-radius: 16px 16px 0 0;
  background-clip: padding-box;
}

.acc.gmStyle:not(.open)>.accHead {
  border-radius: 16px;
}

.acc.gmStyle>.accBody {
  border-radius: 0 0 16px 16px;
  padding-bottom: 0;
  background-clip: padding-box;
}

#view-portals .acc.gmStyle>.accBody {
  padding-bottom: 12px;
}

/* ===== Team Groups accordion body ===== */

#view-groups .acc.gmStyle>.accBody {
  padding-bottom: 12px;
}

.groupSection {
  margin-bottom: 12px;
}

.groupSection b {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.groupActions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

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

.memberChip,
.grantChip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.grantChip.muted {
  opacity: 0.5;
  font-style: italic;
}

.chipClose {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.chipClose:hover {
  color: var(--danger);
}

.hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 8px 0;
}

.code-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
  margin: 12px 0;
}

.acc[data-ver] {
  overflow: visible;
  position: relative;
  z-index: 0;
}

.acc[data-ver].menuOpen {
  z-index: 30;
}

.acc.archived {
  opacity: .65;
}

.acc.archived>.accHead {
  background: rgba(239, 68, 68, .06);
}

.acc.archived>.accHead:hover {
  background: rgba(239, 68, 68, .10);
}

html[data-theme="dark"] .acc.archived>.accHead {
  background: rgba(239, 68, 68, .14);
}

html[data-theme="dark"] .acc.archived>.accHead:hover {
  background: rgba(239, 68, 68, .20);
}

.accHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
}

.accHead:hover {
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] .accHead:hover {
  background: rgba(255, 255, 255, .06);
}

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

.gmQuickEdit {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease;
}

.gmQuickEdit:hover {
  background: var(--surface2);
  border-color: var(--border);
}

html[data-theme="dark"] .gmQuickEdit:hover {
  background: rgba(255, 255, 255, .06);
}

.gmQuickEdit:focus-visible {
  outline: none;
  border-color: var(--dev);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, .18);
}

.notifQuickAction {
  padding: 4px;
}

.verQuickEdit {
  padding: 4px 8px;
  gap: 6px;
  justify-content: center;
}

.verQuickEdit .accTitle {
  text-align: center;
}

.portalMeta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.portalMeta .metaChip {
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
}

.portalMeta .metaChip b {
  color: var(--text);
}

.portalMeta .metaChip,
.portalInfo .metaChip,
.portalInfo .badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}

.portalInfo .metaChip {
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
}

.portalInfo .metaChip b {
  color: var(--text);
}

.portalHead {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.portalNameBtn {
  padding: 4px 8px;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.portalNameBtn .accTitle {
  text-align: left;
}

.portalServer {
  font-size: 12px;
  color: var(--muted);
  padding-left: 8px;
}

.portalDetails {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.portalInfo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.portalPanel {
  margin-top: 10px;
}

.procRow {
  flex-wrap: wrap;
  align-items: flex-start;
}

.accIcon {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(139, 92, 246, .12), rgba(79, 70, 229, .08));
}

.accTitle {
  min-width: 0;
}

.accTitle .t {
  display: block;
  font-weight: 900;
  line-height: 1.1;
}

.accTitle .d {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

.accRight {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chev {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.accBody {
  display: none;
  box-sizing: border-box;
  height: 0;
  opacity: 0;
  overflow: hidden;
  border-top: 1px dashed var(--border);
  background: var(--surface2);
  padding: 12px;
  transition: height var(--t-med) ease, opacity var(--t-med) ease;
  will-change: height, opacity;
}

.acc.open > .accBody {
  display: block;
  height: auto;
  opacity: 1;
  overflow: visible;
}

.gmDescription {
  margin: 0 0 10px;
  color: var(--muted);
}

/* Notification "quoted" body — used for access_request justification text
   that the Hero requester provided. Rendered after the From/email line in
   notifications_list.inja inside .accBody. */
.notifJustification {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
}

.newVersionRow {
  margin: 12px -12px 0 -12px;
  padding: 16px 24px;
  min-height: 54px;
  border-radius: 0 0 16px 16px;
  border: none;
  border-top: 1px solid var(--line);
  background: var(--surface2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.newVersionRow:hover {
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] .newVersionRow:hover {
  background: rgba(255, 255, 255, .06);
}

.subAcc .accIcon {
  width: 30px;
  height: 30px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .05);
}

html[data-theme="dark"] .subAcc .accIcon {
  background: rgba(255, 255, 255, .06);
}

.actionRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.actionLeft {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actionRight {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.reqBtn {
  position: relative;
}

.reqBadge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--bad);
  border: 2px solid var(--surface2);
}

/* ============================================================
   VERSION OPEN: MASK LIST + BUILDER
   ============================================================ */
.versionMeta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.versionMeta .metaLeft,
.versionMeta .metaMid,
.versionMeta .metaRight {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.versionMeta .metaMid {
  flex: 1 1 auto;
  justify-content: center;
}

.versionMeta .metaRight {
  justify-content: flex-end;
}

.spaceBadge {
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
}

.spaceBadge .label {
  font-weight: 600;
  color: var(--text);
}

.spaceBadge .family {
  font-weight: 600;
}

.spaceBadge .lock {
  color: var(--muted);
}

.spaceBadge.missing {
  border-color: rgba(239, 68, 68, .45);
  background: rgba(239, 68, 68, .10);
  color: var(--bad);
}

.spaceBadge.missing .lock,
.spaceBadge.missing .family {
  color: var(--bad);
}

.metaChip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
}

.metaChip b {
  color: var(--text);
}

.split {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 12px;
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  transition: grid-template-columns var(--t-med) ease;
}

.split.maskCollapsed {
  grid-template-columns: 56px 1fr;
}

.split> :not(.maskBridge) {
  position: relative;
  z-index: 1;
}

.split .maskCol {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.split .maskCol .panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.split .maskCol .panelB {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.maskBridge {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 0;
  pointer-events: none;
  background: var(--surface);
  z-index: 0;
}

.maskBridge::after {
  content: "";
  position: absolute;
  right: -10px;
  top: -6px;
  bottom: -6px;
  width: 12px;
  background: inherit;
  border-radius: 0 12px 12px 0;
}

@media (max-width: 1100px) {
  .split {
    grid-template-columns: 1fr;
  }

  .maskBridge {
    display: none;
  }

  .search {
    width: 100%;
    max-width: 100%;
  }
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panelH {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.panelH b {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}

.panelB {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, .10);
  background: var(--surface3);
  cursor: pointer;
}

html[data-theme="dark"] .mItem {
  border-color: rgba(255, 255, 255, .10);
}

.mItem:hover {
  filter: brightness(0.99);
}

html[data-theme="dark"] .mItem:hover {
  filter: brightness(1.05);
}

.mItem.active {
  outline: 2px solid rgba(139, 92, 246, .22);
  border-color: rgba(139, 92, 246, .25);
}

.mItem .meta {
  font-size: 12px;
  color: var(--muted);
}

.mItem>div {
  flex: 1;
  min-width: 0;
}

.maskQuickEdit {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease;
}

.maskQuickEdit>div {
  min-width: 0;
}

.maskQuickEdit b,
.maskQuickEdit .meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.maskQuickEdit:hover {
  background: var(--surface2);
  border-color: var(--border);
}

html[data-theme="dark"] .maskQuickEdit:hover {
  background: rgba(255, 255, 255, .06);
}

.maskQuickEdit:hover b {
  text-decoration: none;
}

.maskQuickEdit:hover .meta {
  color: var(--text);
}

.maskQuickEdit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, .18);
}

/* --- Mask letter avatar (always rendered, shown only when collapsed) --- */
.mItem .mLetter {
  display: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 10px;
  background: rgba(139, 92, 246, .12);
  color: rgba(139, 92, 246, 1);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  justify-content: center;
  align-items: center;
}

/* --- Mask panel collapsed state --- */
.split.maskCollapsed .panelH b,
.split.maskCollapsed .panelH .badge {
  display: none;
}

.split.maskCollapsed .maskActions {
  display: none;
}

.split.maskCollapsed .mItem {
  padding: 6px;
  justify-content: center;
  border-color: transparent;
  background: transparent;
}

.split.maskCollapsed .mItem .mLetter {
  display: grid;
}

.split.maskCollapsed .maskQuickEdit,
.split.maskCollapsed .mItem [data-mask-copy] {
  display: none;
}

.split.maskCollapsed .mItem.active {
  background: rgba(139, 92, 246, .08);
}

.split.maskCollapsed .panelH {
  justify-content: center;
  padding: 8px 4px;
}

.split.maskCollapsed .panelB {
  padding: 6px;
  gap: 4px;
}

.maskColToggle {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface3);
  cursor: pointer;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.maskColToggle:hover {
  filter: brightness(0.96);
}

html[data-theme="dark"] .maskColToggle:hover {
  filter: brightness(1.1);
}

.maskActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.builder {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 320px;
  height: min(660px, 62vh);
  resize: vertical;
  display: flex;
  flex-direction: column;
}

.builderTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.builderTop .left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.builderTop .right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.builderBody {
  display: grid;
  grid-template-columns: 250px 1fr;
  flex: 1;
  min-height: 0;
  position: relative;
}

@media (max-width: 1024px) {
  .builderBody {
    grid-template-columns: 180px 1fr;
  }

  .palette h3 {
    font-size: 14px;
  }
}

@media (max-width: 768px) {
  .builderBody {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .palette {
    border-right: none;
    border-bottom: 1px dashed var(--border);
    max-height: 160px;
    overflow-y: auto;
  }

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

  .paletteCategory {
    width: 100%;
  }

  .builder-row {
    flex-wrap: wrap;
  }
}

.palette {
  border-right: 1px dashed var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.paletteList {
  margin-top: 10px;
  overflow: auto;
  min-height: 0;
  padding-right: 6px;
}

.paletteList::-webkit-scrollbar {
  width: 10px;
}

.paletteList::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, .28);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

html[data-theme="dark"] .paletteList::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .18);
}

html[data-theme="dark"] .paletteList::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, .04);
}

.palette h3 {
  margin: 0;
  font-size: 13px;
}

.palette p {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface3);
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
}

.block small {
  color: var(--muted);
}

.canvas {
  padding: 14px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.canvasHint {
  border: 2px dashed rgba(139, 92, 246, .28);
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(139, 92, 246, .07), rgba(79, 70, 229, .05));
}

.canvasStage {
  flex: 1;
  min-height: 0;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface3);
  position: relative;
  overflow: auto;
}

.canvasEmpty {
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(139, 92, 246, .28);
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(139, 92, 246, .07), rgba(79, 70, 229, .05));
  color: var(--muted);
  pointer-events: none;
}

.canvasEmpty b {
  color: var(--text);
}

.canvasWidget {
  position: absolute;
  left: var(--widget-left, 0);
  top: var(--widget-top, 0);
  min-width: 160px;
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px;
  cursor: grab;
  user-select: none;
}

.canvasWidget:active {
  cursor: grabbing;
}

.canvasWidget .wmeta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.canvasWidget .wtools {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.canvasWidget .wtools .btn {
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 12px;
}

.canvasList {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface3);
}

.wrow .wmeta {
  font-size: 12px;
  color: var(--muted);
}

/* ============================================================
   BUILDER — Grid Framework (Layer 1)
   12-column grid-based rows and blocks for MaskBuilder v2.
   ============================================================ */

.builder-canvas {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.builder-row {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-sm, 8px);
  align-items: stretch;
  padding: 10px 28px 10px 24px;
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  position: relative;
  transition: border-color var(--t-fast, 150ms) ease;
  overflow: hidden;
  user-select: none;
}

.builder-row:hover {
  border-color: rgba(139, 92, 246, .35);
}

.builder-row.sortable-ghost,
.builder-row--ghost {
  opacity: 0.3;
  border: 2px dashed rgba(139, 92, 246, .6);
  background: rgba(139, 92, 246, .06);
}

.builder-row--fallback {
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  transform: rotate(0.5deg);
}

.builder-row-handle {
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 36px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity var(--t-fast, 150ms) ease, background var(--t-fast, 150ms) ease;
}

.builder-row-handle:hover {
  background: rgba(139, 92, 246, .10);
  color: var(--primary, #8b5cf6);
}

.builder-row:hover .builder-row-handle {
  opacity: 1;
}

.builder-row-handle:active {
  cursor: grabbing;
}

.builder-row-actions {
  position: absolute;
  right: 4px;
  top: 4px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--t-fast, 150ms) ease;
}

.builder-row:hover .builder-row-actions {
  opacity: 1;
}

.btn-row-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: rgba(239, 68, 68, .10);
  color: var(--danger, #ef4444);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast, 150ms) ease, color var(--t-fast, 150ms) ease;
}

.btn-row-delete:hover {
  background: rgba(239, 68, 68, .25);
  color: #dc2626;
}

.builder-block {
  width: calc(var(--block-cols) / 12 * 100% - 8px);
  min-width: 80px;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface3);
  padding: 8px;
  position: relative;
  transition: border-color var(--t-fast, 150ms) ease, box-shadow var(--t-fast, 150ms) ease;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.builder-block:hover {
  border-color: rgba(139, 92, 246, .3);
}

.builder-block--selected {
  border-color: rgba(139, 92, 246, .7);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, .25);
}

.builder-block--empty {
  border: 2px dashed rgba(139, 92, 246, .25);
  background: linear-gradient(180deg, rgba(139, 92, 246, .04), rgba(79, 70, 229, .03));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.builder-error-muted {
  color: var(--muted);
}

.builder-error-bad {
  color: var(--bad);
}

.builder-block.sortable-ghost,
.builder-block--ghost {
  opacity: 0.3;
  border: 2px dashed rgba(139, 92, 246, .6);
  background: rgba(139, 92, 246, .08);
}

.builder-block--fallback {
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  transform: rotate(1deg);
}

.builder-block-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t-fast, 150ms) ease;
}

.builder-block:hover .builder-block-actions {
  opacity: 1;
}

.builder-block-actions .btn {
  padding: 3px 6px;
  font-size: 11px;
  border-radius: 8px;
  min-width: 0;
}

.builder-block-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.builder-block-handle:active {
  cursor: grabbing;
}

/* Resize handle on right edge of block */
.builder-block-resize {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  opacity: 0;
  transition: opacity var(--t-fast, 150ms) ease;
  z-index: 2;
}

.builder-block-resize::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 24px;
  border-radius: 2px;
  background: rgba(139, 92, 246, .5);
}

.builder-block:hover .builder-block-resize {
  opacity: 1;
}

.builder-block--resizing {
  opacity: 0.8;
  border-color: rgba(139, 92, 246, .7);
}

/* Read-only canvas (published/archived versions) */
.builder-canvas--readonly .builder-block-resize,
.builder-canvas--readonly .builder-block-actions,
.builder-canvas--readonly .builder-row-handle,
.builder-canvas--readonly .btn-row-delete,
.builder-canvas--readonly .builder-row-gap,
.builder-canvas--readonly .builder-sub-row--drop {
  display: none;
}

.builder-readonly-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 4px 8px;
  border-radius: 8px;
  background: var(--accent-bg, rgba(139, 92, 246, .06));
  border: 1px solid var(--accent-border, rgba(139, 92, 246, .2));
  color: var(--muted);
  font-size: 13px;
}

.builder-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

.builder-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Stacked layout: multiple sub-rows in a block */
.builder-block[data-layout="stacked"] {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 4px);
}

.builder-sub-row {
  padding: 4px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  min-height: 32px;
}

.builder-sub-row-add {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  background: none;
  width: 100%;
  transition: border-color var(--t-fast, 150ms) ease;
}

.builder-sub-row-add:hover {
  border-color: rgba(139, 92, 246, .4);
  color: var(--accent, rgba(139, 92, 246, 1));
}

.builder-sub-row--drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px;
  border: 2px dashed rgba(139, 92, 246, .3);
  border-radius: 8px;
  background: rgba(139, 92, 246, .04);
  color: var(--muted);
  font-size: 11px;
  transition: min-height var(--t-fast, 150ms) ease, border-color var(--t-fast, 150ms) ease, background var(--t-fast, 150ms) ease;
}

.builder-sub-row--drop:empty::before {
  content: "Drop widget here";
  color: var(--muted);
}

.builder-sub-row--drop-ghost {
  opacity: 0.4;
}

/* Row gap drop zones — thin by default, expand on drag hover */
.builder-row-gap {
  min-height: 3px;
  border-radius: 4px;
  background: rgba(139, 92, 246, .04);
  transition: min-height 200ms ease, background 200ms ease, border 200ms ease, box-shadow 200ms ease;
}

.builder-row-gap--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 2px dashed var(--border);
  color: var(--muted);
  font-size: 13px;
  background: transparent;
}

/* SortableJS adds sortable-ghost class inside the gap when dragging over */
.builder-row-gap.sortable-chosen,
.builder-row-gap:has(.sortable-ghost) {
  min-height: 24px;
  background: rgba(139, 92, 246, .14);
  border: 2px dashed rgba(139, 92, 246, .55);
  box-shadow: 0 0 8px rgba(139, 92, 246, .12);
}

.builder-row-gap--ghost {
  opacity: 0.3;
}

.builder-add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--t-fast, 150ms) ease, color var(--t-fast, 150ms) ease;
}

.builder-add-row:hover {
  border-color: rgba(139, 92, 246, .4);
  color: var(--accent, rgba(139, 92, 246, 1));
}

/* Save status badge for auto-save feedback */
.save-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  transition: opacity var(--t-fast, 150ms) ease;
}

.save-status--saved {
  color: var(--ok, #10b981);
  background: rgba(16, 185, 129, .1);
}

.save-status--saving {
  color: var(--muted);
  background: rgba(107, 114, 128, .1);
  animation: pulse 1s ease-in-out infinite;
}

.save-status--error {
  color: var(--bad, #ef4444);
  background: rgba(239, 68, 68, .1);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* Widget design-mode preview (inside builder blocks) */
.widget-design {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  font-size: 12px;
  pointer-events: none;
}

.widget-design--inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.widget-design--action {
  align-items: flex-start;
}

.widget-label {
  font-weight: 500;
  font-size: 12px;
  color: var(--fg);
}

.widget-input,
.widget-textarea,
.widget-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg-input, var(--surface));
  color: var(--muted);
  cursor: default;
}

.widget-textarea {
  resize: none;
  min-height: 48px;
}

.widget-checkbox {
  width: 14px;
  height: 14px;
  cursor: default;
}

.widget-button {
  border: 1px solid var(--accent, rgba(139, 92, 246, 1));
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 12px;
  background: var(--accent, rgba(139, 92, 246, 1));
  color: #fff;
  cursor: default;
  font-weight: 500;
}

.widget-hint {
  font-size: 11px;
  color: var(--muted);
}

.widget-meta {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  font-family: monospace;
}

/* Display widget design styles */
.widget-design--display {
  gap: 6px;
}

.widget-label-text {
  display: block;
}

.widget-label-text--small {
  font-size: 11px;
}

.widget-label-text--medium {
  font-size: 13px;
  font-weight: 500;
}

.widget-label-text--large {
  font-size: 16px;
  font-weight: 600;
}

.widget-label-text--default {
  color: var(--fg);
}

.widget-label-text--muted {
  color: var(--muted);
}

.widget-label-text--accent {
  color: var(--accent, #8b5cf6);
}

.widget-label-text--danger {
  color: var(--bad, #ef4444);
}

.widget-label-text[data-align="center"] {
  text-align: center;
}

.widget-label-text[data-align="right"] {
  text-align: right;
}

.widget-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.widget-divider--dashed {
  border-top-style: dashed;
}

.widget-divider--dotted {
  border-top-style: dotted;
}

.widget-divider--muted {
  border-color: var(--muted);
}

.widget-divider--accent {
  border-color: var(--accent, #8b5cf6);
}

.widget-image {
  max-width: 100%;
  border-radius: 4px;
}

.widget-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
}

.widget-image-placeholder-icon {
  font-size: 24px;
  opacity: 0.5;
}

.widget-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.widget-badge--success {
  background: rgba(34, 197, 94, .15);
  color: #22c55e;
}

.widget-badge--warning {
  background: rgba(234, 179, 8, .15);
  color: #eab308;
}

.widget-badge--error {
  background: rgba(239, 68, 68, .15);
  color: #ef4444;
}

.widget-badge--info {
  background: rgba(139, 92, 246, .15);
  color: var(--accent, #8b5cf6);
}

.widget-progress-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.widget-progress-track {
  height: 6px;
  background: var(--surface2, rgba(255, 255, 255, .06));
  border-radius: 3px;
  overflow: hidden;
}

.widget-progress-fill {
  height: 100%;
  border-radius: 3px;
  width: 50%;
  transition: width var(--t-fast, 150ms) ease;
}

.widget-progress-fill--default {
  background: var(--accent, #8b5cf6);
}

.widget-progress-fill--success {
  background: #22c55e;
}

.widget-progress-fill--warning {
  background: #eab308;
}

.widget-progress-fill--error {
  background: #ef4444;
}

/* Choice widget design styles */
.widget-radio-group,
.widget-multiselect-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.widget-radio-option,
.widget-multiselect-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg);
  cursor: default;
}

.widget-radio {
  accent-color: var(--accent, #8b5cf6);
  width: 14px;
  height: 14px;
}

.widget-toggle-track {
  display: inline-block;
  width: 32px;
  height: 16px;
  border-radius: 8px;
  background: var(--border);
  position: relative;
}

.widget-toggle-thumb {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fg);
  position: absolute;
  top: 2px;
  left: 2px;
}

/* Container widget design styles */
.widget-design--container {
  padding: 0;
}

.widget-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.widget-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface2, rgba(255, 255, 255, .03));
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
}

.widget-section-toggle {
  font-size: 10px;
  color: var(--muted);
}

.widget-section-title {
  flex: 1;
}

.widget-section-body {
  padding: 8px;
}

.widget-section-placeholder,
.widget-card-placeholder {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.widget-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.widget-card--elevation-0 {
  box-shadow: none;
}

.widget-card--elevation-1 {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.widget-card--elevation-2 {
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.widget-card--elevation-3 {
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}

.widget-card-header {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}

.widget-card-body {
  padding: 8px;
}

/* ============================================================
   RUNTIME FORM (Preview mode)
   ============================================================ */
.runtime-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 720px;
  margin: 0 auto;
}

.runtime-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.runtime-row:last-child {
  margin-bottom: 0;
}

.runtime-block {
  flex: 0 0 calc(var(--block-cols, 12) / 12 * 100% - 16px);
  min-width: 0;
}

.runtime-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.runtime-field--inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.runtime-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.runtime-required {
  color: var(--bad, #ef4444);
}

.runtime-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--t-fast, 150ms) ease;
}

.runtime-input:focus {
  border-color: var(--accent, #8b5cf6);
  outline: none;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, .15);
}

.runtime-input[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea.runtime-input {
  resize: vertical;
}

select.runtime-input {
  cursor: pointer;
}

.runtime-checkbox {
  accent-color: var(--accent, #8b5cf6);
}

.runtime-hint {
  font-size: 11px;
  color: var(--muted);
}

.runtime-error {
  font-size: 11px;
  color: var(--bad, #ef4444);
}

.runtime-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--t-fast, 150ms) ease, background var(--t-fast, 150ms) ease;
}

.runtime-button:hover {
  opacity: 0.85;
}

.runtime-button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.runtime-button--primary {
  background: var(--accent, #8b5cf6);
  color: #fff;
}

.runtime-button--secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.runtime-button--danger {
  background: var(--bad, #ef4444);
  color: #fff;
}

.runtime-button--ghost {
  background: transparent;
  color: var(--text);
}

.runtime-button--small {
  padding: 4px 12px;
  font-size: 12px;
}

.runtime-button--medium {
  padding: 8px 20px;
  font-size: 14px;
}

.runtime-button--large {
  padding: 12px 28px;
  font-size: 16px;
}

.runtime-hidden {
  display: none;
}

.runtime-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Runtime display widgets */
.runtime-field--display {
  gap: 2px;
}

.runtime-label-text {
  display: block;
}

.runtime-label-text--small {
  font-size: 12px;
}

.runtime-label-text--medium {
  font-size: 14px;
  font-weight: 500;
}

.runtime-label-text--large {
  font-size: 18px;
  font-weight: 600;
}

.runtime-label-text--default {
  color: var(--text);
}

.runtime-label-text--muted {
  color: var(--muted);
}

.runtime-label-text--accent {
  color: var(--accent, #8b5cf6);
}

.runtime-label-text--danger {
  color: var(--bad, #ef4444);
}

.runtime-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.runtime-divider--dashed {
  border-top-style: dashed;
}

.runtime-divider--dotted {
  border-top-style: dotted;
}

.runtime-divider--muted {
  border-color: var(--muted);
}

.runtime-divider--accent {
  border-color: var(--accent, #8b5cf6);
}

.runtime-image {
  max-width: 100%;
  border-radius: 4px;
}

.runtime-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
}

.runtime-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.runtime-badge--success {
  background: rgba(34, 197, 94, .15);
  color: #22c55e;
}

.runtime-badge--warning {
  background: rgba(234, 179, 8, .15);
  color: #eab308;
}

.runtime-badge--error {
  background: rgba(239, 68, 68, .15);
  color: #ef4444;
}

.runtime-badge--info {
  background: rgba(139, 92, 246, .15);
  color: var(--accent, #8b5cf6);
}

.runtime-progress {
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  border: none;
  background: var(--surface2, rgba(255, 255, 255, .06));
}

.runtime-progress::-webkit-progress-bar {
  background: var(--surface2, rgba(255, 255, 255, .06));
  border-radius: 4px;
}

.runtime-progress::-webkit-progress-value {
  border-radius: 4px;
  background: var(--accent, #8b5cf6);
}

.runtime-progress--success::-webkit-progress-value {
  background: #22c55e;
}

.runtime-progress--warning::-webkit-progress-value {
  background: #eab308;
}

.runtime-progress--error::-webkit-progress-value {
  background: #ef4444;
}

/* Runtime choice widget styles */
.runtime-radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.runtime-radio-option,
.runtime-multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.runtime-radio {
  accent-color: var(--accent, #8b5cf6);
}

.runtime-multiselect-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.runtime-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.runtime-toggle-input {
  display: none;
}

.runtime-toggle-track {
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border);
  position: relative;
  transition: background var(--t-fast, 150ms) ease;
}

.runtime-toggle-input:checked+.runtime-toggle-track {
  background: var(--accent, #8b5cf6);
}

.runtime-toggle-thumb {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left var(--t-fast, 150ms) ease;
}

.runtime-toggle-input:checked+.runtime-toggle-track .runtime-toggle-thumb {
  left: 20px;
}

.runtime-toggle-label {
  font-size: 14px;
  color: var(--text);
}

/* Runtime container widget styles */
.runtime-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.runtime-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface2, rgba(255, 255, 255, .03));
  font-weight: 500;
  color: var(--text);
}

.runtime-section[data-collapsible] .runtime-section-header {
  cursor: pointer;
}

.runtime-section-toggle {
  font-size: 12px;
  transition: transform var(--t-fast, 150ms) ease;
}

.runtime-section[data-collapsed] .runtime-section-toggle {
  transform: rotate(-90deg);
}

.runtime-section-title {
  flex: 1;
}

.runtime-section-body {
  padding: 14px;
}

.runtime-section[data-collapsed] .runtime-section-body {
  display: none;
}

.runtime-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.runtime-card--elevation-0 {
  box-shadow: none;
}

.runtime-card--elevation-1 {
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

.runtime-card--elevation-2 {
  box-shadow: 0 3px 10px rgba(0, 0, 0, .15);
}

.runtime-card--elevation-3 {
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}

.runtime-card-header {
  padding: 10px 14px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.runtime-card-body {
  padding: 14px;
}


@media (max-width: 600px) {
  .runtime-block {
    flex: 0 0 100%;
  }
}

/* ============================================================
   SIDEPAGE (RIGHT DRAWER)
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .42);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t-med) ease, visibility 0s linear var(--t-med);
  z-index: 60;
}

.overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--t-med) ease;
}

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  width: min(520px, 94vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform var(--t-med) ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawerH {
  height: var(--headerH);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.drawerH b {
  font-size: 14px;
}

.drawerB {
  padding: 14px;
  overflow: auto;
}

.drawerF {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.formRow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

label {
  font-size: 12px;
  color: var(--muted);
}

input.inp,
select.inp,
textarea.inp {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

select.inp {
  appearance: none;
  cursor: pointer;
}

textarea.inp {
  min-height: 90px;
  resize: vertical;
}

.drawerActions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.formBlock {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  padding: 14px;
}

.formBlock-spaced {
  margin-top: 12px;
}

.checkRow {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text);
  line-height: 1.4;
}

.checkRow input {
  margin-top: 2px;
}

.listBlock {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.listBlock li + li {
  margin-top: 6px;
}

.supportHelpShell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.supportHelpHead {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.supportHelpHead b {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.supportHelpBody,
.supportHelpForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.supportFieldCard {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface2);
  padding: 14px;
}

.supportFieldCard label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.supportFieldCard .inp {
  width: 100%;
  background: var(--surface3);
}

.supportFieldCard textarea.inp {
  min-height: 142px;
}

.supportNotice {
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--surface2);
  padding: 12px 14px;
}

.supportHelpActions {
  display: flex;
  justify-content: flex-start;
}

.supportDirectLinks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
}

.supportDirectLinks a {
  color: inherit;
}

/* ===== DRAWER TABS ===== */
.drawer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
}

.drawer-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

.drawer-tab:hover {
  color: var(--text);
}

.drawer-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== RELATION ITEMS ===== */
.formRow--relation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.relation-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.relation-type {
  font-weight: 600;
  color: var(--accent);
}

.relation-arrow {
  color: var(--muted);
}

.relation-target {
  color: var(--text);
}

.relation-condition {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.smallmuted {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0;
}

input.inp.mini,
textarea.inp.mini {
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.iconGrid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

@media (max-width: 520px) {
  .iconGrid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   BUILDER: OFFLINE OVERLAY
   ============================================================ */
.builder-offline-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-overlay, rgba(0, 0, 0, .55));
  backdrop-filter: blur(2px);
  pointer-events: all;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-fast) ease, visibility var(--t-fast) ease;
}

.builder-offline-overlay.active {
  opacity: 1;
  visibility: visible;
}

.builder-offline-overlay .offline-message {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
}

.builder-offline-overlay .offline-message .offline-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: builder-spin 0.7s linear infinite;
  margin-bottom: 12px;
}

@keyframes builder-spin {
  to {
    transform: rotate(360deg);
  }
}

.ico {
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface3);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ico.active {
  outline: 2px solid rgba(139, 92, 246, .28);
  border-color: rgba(139, 92, 246, .25);
}

.chipList {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.access-section {
  margin-bottom: 14px;
}

.access-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.access-section-head b {
  font-size: 13px;
}

.chip-x {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 0 2px;
}

.chip-x:hover {
  color: var(--danger);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface3);
}

.chip button {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
}

.hr {
  border-top: 1px dashed var(--border);
  margin: 12px 0;
}

/* ============================================================
   PORTALS: FAMILY LAYOUT (SENIOR)
   ============================================================ */
.portalLayout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 12px;
  margin-top: 12px;
}

.portalCol {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.portalFleet {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portalFleet .acc {
  box-shadow: none;
}

.portalFleet .accHead {
  background: var(--surface3);
}

.portalFleet .accBody {
  background: transparent;
}

.portalGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.portalGrid .span2 {
  grid-column: 1 / -1;
}

.tokenLine {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.delimCustom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.notice {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
}

.notice.warn {
  border-color: rgba(245, 158, 11, .45);
  background: rgba(245, 158, 11, .10);
  color: #b45309;
}

html[data-theme="dark"] .notice.warn {
  color: #fbbf24;
}

.notice.ok {
  border-color: rgba(34, 197, 94, .45);
  background: rgba(34, 197, 94, .10);
  color: var(--ok);
}

.notice.bad {
  border-color: rgba(239, 68, 68, .45);
  background: rgba(239, 68, 68, .10);
  color: var(--bad);
}

.portalLogs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portalLogs .logItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface3);
  font-size: 12px;
  color: var(--muted);
}

.portalLogs .logItem b {
  color: var(--text);
}

.spaceBoard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.spaceCard {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  background: var(--surface3);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.spaceCard.dev {
  border-color: rgba(106, 92, 255, .35);
  background:
    radial-gradient(240px 120px at 10% 0%, rgba(106, 92, 255, .18), transparent 60%),
    var(--surface3);
}

.spaceCard.user {
  border-color: rgba(59, 79, 216, .35);
  background:
    radial-gradient(240px 120px at 10% 0%, rgba(59, 79, 216, .18), transparent 60%),
    var(--surface3);
}

html[data-theme="dark"] .spaceCard.dev {
  background:
    radial-gradient(240px 120px at 10% 0%, rgba(106, 92, 255, .24), transparent 60%),
    var(--surface2);
}

html[data-theme="dark"] .spaceCard.user {
  background:
    radial-gradient(240px 120px at 10% 0%, rgba(59, 79, 216, .24), transparent 60%),
    var(--surface2);
}

.spaceHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.spaceTitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.spaceDot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--dev);
  box-shadow: 0 0 0 4px rgba(106, 92, 255, .15);
}

.spaceCard.user .spaceDot {
  background: var(--mgr);
  box-shadow: 0 0 0 4px rgba(59, 79, 216, .14);
}

.spaceMeta {
  font-size: 12px;
  color: var(--muted);
}

.spaceActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.spaceList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spaceRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.spaceRow .wmeta {
  font-size: 12px;
  color: var(--muted);
}

.panelTags,
.portalActions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.codeLine {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface3);
  padding: 8px 10px;
  font-size: 12px;
}

.policyRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .portalLayout {
    grid-template-columns: 1fr;
  }

  .portalGrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .spaceBoard {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MODAL (PREVIEW + CONFIRM)
   ============================================================ */
.modalWrap {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, .45);
  z-index: 80;
  padding: 16px;
}

.modalWrap.open {
  display: grid;
}

.modal {
  width: min(620px, 96vw);
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-strong);
  overflow: hidden;
}

.modalH {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.modalB {
  padding: 14px;
}

.modalF {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.drawerF:empty,
.modalF:empty {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.field input {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface3);
  padding: 10px 12px;
  color: var(--text);
}

/* Mask JSON modal textarea */
.mask-json-area {
  width: 100%;
  min-height: 340px;
  max-height: 60vh;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.5;
  tab-size: 2;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface3);
  color: var(--text);
  padding: 12px;
  resize: vertical;
  white-space: pre;
  overflow: auto;
}

.mask-json-area:focus {
  outline: none;
  border-color: var(--primary, #8b5cf6);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, .18);
}

.mask-json-error {
  color: var(--danger, #ef4444);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 100px;
  overflow: auto;
}

/* ====== UI CLEANUP OVERRIDES (less nested rectangles) ====== */

.subAcc {
  margin-top: 12px;
  padding: 0;
}

/* Versions: nested space (full width), background tint (no borders) */
.subAcc [data-ver].acc,
.subAcc [data-portal].acc {
  border: none;
  box-shadow: none;
  background: rgba(0, 0, 0, .018);
  border-radius: 0;
}

html[data-theme="dark"] .subAcc [data-ver].acc,
html[data-theme="dark"] .subAcc [data-portal].acc {
  background: rgba(255, 255, 255, .03);
}

.subAcc [data-ver].acc.open,
.subAcc [data-portal].acc.open {
  background: rgba(106, 92, 255, .07);
}

html[data-theme="dark"] .subAcc [data-ver].acc.open,
html[data-theme="dark"] .subAcc [data-portal].acc.open {
  background: rgba(139, 92, 246, .10);
}

.subAcc [data-ver].acc>.accHead,
.subAcc [data-portal].acc>.accHead {
  border-radius: 0;
  padding: 12px;
  background: transparent;
}

.subAcc [data-ver].acc+[data-ver].acc,
.subAcc [data-portal].acc+[data-portal].acc {
  border-top: 1px solid var(--line);
}

.subAcc .newVersionRow {
  margin: 12px -12px 0 -12px;
  border-radius: 0 0 16px 16px;
}

.subAcc [data-ver].acc .accIcon,
.subAcc [data-portal].acc .accIcon {
  border: none;
  background: transparent;
}

.subAcc [data-ver].acc .accBody,
.subAcc [data-portal].acc .accBody {
  border-top: none;
  background: transparent;
  padding: 12px 12px 14px;
  overflow-x: clip;
}

/* Make chevron a true button + allow clicking it */
.chev {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding: 0;
  outline: none;
}

.subAcc [data-ver].acc .chev,
.subAcc [data-portal].acc .chev {
  border: none;
  background: transparent;
}

/* Reduce inner containers outlines */
.versionMeta {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
  gap: 8px;
}

.metaChip {
  border: none;
  background: rgba(0, 0, 0, .045);
  color: var(--muted);
}

html[data-theme="dark"] .metaChip {
  background: rgba(255, 255, 255, .04);
}

/* Masks list area + Builder area: clean blocks without borders */
.panel,
.builder {
  border: none;
  box-shadow: none;
  background: var(--surface);
}

.panelH,
.builderTop {
  border-bottom: none;
  background: transparent;
  padding: 12px 12px 8px;
}

.panelB {
  padding: 8px 12px 12px;
}

.mItem {
  border: none;
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] .mItem {
  background: rgba(255, 255, 255, .04);
}

.mItem.active {
  outline: none;
  background: rgba(139, 92, 246, .14);
  box-shadow: inset 3px 0 0 rgba(139, 92, 246, .55);
}

/* Builder internals */
.builderBody {
  grid-template-columns: 260px 1fr;
  gap: 14px;
  padding: 12px;
}

.palette {
  border-right: none;
  padding: 0;
}

.block {
  border: none;
  background: rgba(0, 0, 0, .04);
}

html[data-theme="dark"] .block {
  background: rgba(255, 255, 255, .05);
}

.canvas {
  padding: 0;
}

.canvasStage {
  margin-top: 0;
  border: 2px dashed rgba(139, 92, 246, .30);
  background:
    radial-gradient(600px 260px at 20% 10%, rgba(139, 92, 246, .10), transparent 55%),
    radial-gradient(600px 260px at 90% 60%, rgba(79, 70, 229, .08), transparent 55%),
    rgba(0, 0, 0, .02);
}

html[data-theme="dark"] .canvasStage {
  background:
    radial-gradient(600px 260px at 20% 10%, rgba(139, 92, 246, .16), transparent 55%),
    radial-gradient(600px 260px at 90% 60%, rgba(79, 70, 229, .14), transparent 55%),
    rgba(255, 255, 255, .02);
}

.canvasEmpty {
  border: none;
  background: transparent;
  inset: 16px;
}

/* Slightly more space between top header row and first gutmask */
#view-gutmasks .topRow {
  margin-bottom: 14px;
}

/* Error message (renderError) */
.error-message {
  padding: 2rem;
  color: var(--bad);
}

/* Muted text (replaces inline style="color:var(--muted)") */
.muted-text {
  color: var(--muted);
}

/* ======================== UTILITY CLASSES ======================== */

.hidden {
  display: none;
}

.empty-state {
  padding: 2rem;
  color: var(--muted);
}

.empty-state-sm {
  padding: 1rem;
  color: var(--muted);
  font-size: 13px;
}

.clickable {
  cursor: pointer;
}

.flex-spacer {
  flex: 1;
}

.time-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.req-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.req-decline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.req-panel-gap {
  margin-top: 10px;
}

.drawer-actions-mt {
  margin-top: 16px;
}

.settings-pad {
  padding: 1.5rem;
}

.settings-section-mt {
  margin-top: 1.5rem;
}

.invite-admin-panel h3 {
  margin: 0 0 6px;
}

.invite-admin-head {
  margin-bottom: 16px;
}

.invite-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.invite-admin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.invite-admin-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  padding: 14px;
}

.invite-admin-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 6px;
}

.invite-admin-code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  font-weight: 700;
  word-break: break-all;
}

.invite-admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.invite-admin-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.invite-admin-status-active {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, var(--border));
}

.invite-admin-status-expired,
.invite-admin-status-exhausted {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
}

.builder-block-min {
  min-height: 120px;
}

.pill-user {
  gap: 6px;
}

@media (max-width: 980px) {
  .header {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    justify-items: stretch;
    height: auto;
    padding: 10px 14px;
    row-gap: 10px;
  }

  .brand,
  .headerCenter,
  .headerRight {
    justify-self: stretch;
  }

  .headerCenter {
    display: flex;
    justify-content: center;
  }

  .headerRight {
    justify-content: space-between;
  }
}

/* ======================== HOME PAGE ======================== */

.home-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-grad, var(--bg));
  padding: 24px;
}

.home-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow);
  text-align: center;
}

.admin-page,
.status-page {
  min-height: 100vh;
  overflow: auto;
}

.admin-page {
  background: var(--bg-grad, var(--bg));
}

.admin-page .home-page {
  align-items: flex-start;
  padding-top: 28px;
  padding-bottom: 40px;
}

.admin-main {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.admin-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.admin-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-top: 3px solid color-mix(in srgb, var(--brand), transparent 42%);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-top h1 {
  margin: 4px 0 6px;
  font-size: 24px;
}

.admin-top .subtitle {
  margin: 0;
  color: var(--muted);
}

.admin-eyebrow {
  margin: 0;
  color: color-mix(in srgb, var(--brand), var(--muted) 35%);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.admin-nav a:hover,
.admin-nav a:focus-visible {
  border-color: color-mix(in srgb, var(--brand), transparent 56%);
  background: color-mix(in srgb, var(--brand), transparent 92%);
}

.admin-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.adminPanelTitle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.adminPanelTitle h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.adminPanelTitle .subtitle {
  margin: 0;
  color: var(--muted);
}

.admin-card {
  max-width: 920px;
  text-align: left;
}

.admin-card .home-brand,
.admin-card h1,
.admin-card > .subtitle {
  text-align: center;
}

.admin-summary {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--muted);
}

.admin-summary p {
  margin: 0;
}

.admin-empty {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--muted);
  text-align: center;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  padding: 16px;
}

.stat-card-warn {
  border-color: rgba(245, 158, 11, .34);
  background: rgba(245, 158, 11, .08);
}

.stat-card-error {
  border-color: rgba(239, 68, 68, .34);
  background: rgba(239, 68, 68, .08);
}

.stat-value {
  color: var(--text);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.adminQuickGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.adminQuickCard {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
}

.adminQuickCard:hover {
  border-color: color-mix(in srgb, var(--brand), transparent 70%);
  background: color-mix(in srgb, var(--brand), transparent 92%);
}

.adminQuickCard strong {
  color: var(--text);
  font-size: 15px;
}

.adminQuickCard span {
  color: var(--muted);
  font-size: 13px;
}

.supportTicketList {
  display: grid;
  gap: 12px;
}

.supportTicketCard {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
}

.supportTicketCard.resolved {
  opacity: .74;
}

.supportTicketActionMessage {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.supportTicketActionMessage.warn {
  border-color: var(--warning, var(--border));
}

.supportTicketHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.supportTicketHead h2 {
  margin: 3px 0 0;
  font-size: 16px;
}

.supportTicketMeta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.supportTicketBody {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.supportTicketBody p {
  margin: 0;
  overflow-wrap: anywhere;
}

.supportTicketBody strong {
  color: var(--text);
}

.supportTicketBody a,
.adminMetricCard a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.supportTicketReplyHint {
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.supportTicketActions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-page {
  background: var(--bg-grad, var(--bg));
}

.status-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.status-brand {
  width: min(960px, calc(100vw - 32px));
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-logo {
  font-size: 18px;
  font-weight: 900;
}

.brand-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-main {
  width: min(960px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.status-hero {
  display: grid;
  gap: 10px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-operational {
  border-color: rgba(34, 197, 94, .28);
}

.status-incident {
  border-color: rgba(245, 158, 11, .36);
}

.status-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--surface2);
  font-size: 22px;
}

.status-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
}

.status-overall {
  margin: 0;
  color: var(--muted);
}

.status-section {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-section-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.status-section-muted {
  color: var(--muted);
}

.status-incident-card,
.status-resolved-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  padding: 14px;
}

.status-incident-card + .status-incident-card,
.status-resolved-card + .status-resolved-card {
  margin-top: 10px;
}

.status-incident-header,
.status-resolved-card {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-incident-title {
  margin: 10px 0 0;
  font-size: 16px;
}

.status-incident-body {
  margin: 8px 0 0;
  color: var(--muted);
}

.status-incident-time,
.status-resolved-time {
  color: var(--muted);
  font-size: 12px;
}

.status-resolved-title {
  font-weight: 700;
}

.status-footer {
  width: min(960px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
}

.status-admin-panel {
  display: grid;
  gap: 14px;
}

.panel-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
}

.panel-section h2 {
  margin: 0;
  font-size: 17px;
}

.incident-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge.badge-investigating,
.badge.badge-degraded,
.badge.badge-monitoring,
.badge.badge-maintenance,
.badge.badge-open {
  border-color: rgba(245, 158, 11, .32);
  background: rgba(245, 158, 11, .10);
  color: var(--warn);
}

.badge.badge-outage {
  border-color: rgba(239, 68, 68, .32);
  background: rgba(239, 68, 68, .10);
  color: var(--bad);
}

.badge.badge-resolved,
.badge.badge-operational {
  border-color: rgba(34, 197, 94, .32);
  background: rgba(34, 197, 94, .10);
  color: var(--ok);
}

@media (max-width: 720px) {
  .admin-main,
  .status-main,
  .status-brand,
  .status-footer {
    width: min(100vw - 20px, 960px);
  }

  .admin-top,
  .supportTicketHead,
  .status-resolved-card {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-nav,
  .incident-actions,
  .supportTicketActions {
    justify-content: stretch;
  }

  .admin-nav a,
  .incident-actions .btn,
  .supportTicketActions .btn {
    justify-content: center;
    width: 100%;
  }

  .status-title {
    font-size: 23px;
  }
}

.home-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--text);
}

.home-card .subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.home-brand {
  margin-bottom: 28px;
}

.home-brand span {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.home-brand img {
  max-width: 220px;
  max-height: 56px;
  object-fit: contain;
}

.home-brand .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dev);
  margin-left: 2px;
  vertical-align: super;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.home-actions a,
.home-actions button {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: opacity var(--t-fast);
}

.home-actions a:hover,
.home-actions button:hover {
  opacity: 0.9;
}

.home-btn-primary {
  background: var(--dev);
  color: #fff;
}

.home-btn-secondary {
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
}

.home-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.home-error {
  background: rgba(239, 68, 68, .10);
  border: 1px solid rgba(239, 68, 68, .25);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--bad);
  font-size: 13px;
  margin-top: 16px;
}

.home-success {
  background: rgba(34, 197, 94, .10);
  border: 1px solid rgba(34, 197, 94, .25);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--ok);
  font-size: 13px;
  margin-top: 16px;
}

.home-user {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.home-theme-btn {
  position: fixed;
  top: 16px;
  right: 16px;
}

/* ======================== CONTACT FORM (Public /contact page) ======================== */

.contact-form {
  width: 100%;
  text-align: left;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

#contact-result {
  margin-top: 16px;
  text-align: left;
}

#contact-result p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

/* ======================== AUTH PAGES (Login / Register) ======================== */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-grad, var(--bg));
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow);
}

[data-brand-palette="ocean"] {
  --brand: #1570ef;
  --brand2: #0ea5e9;
  --dev: #1570ef;
  --mgr: #0369a1;
}

[data-brand-palette="forest"] {
  --brand: #0a7b4f;
  --brand2: #22c55e;
  --dev: #15803d;
  --mgr: #166534;
}

[data-brand-palette="midnight"] {
  --brand: #5850ec;
  --brand2: #7c3aed;
  --dev: #6366f1;
  --mgr: #4338ca;
}

[data-brand-palette="sunset"] {
  --brand: #dd6b20;
  --brand2: #f59e0b;
  --dev: #ea580c;
  --mgr: #c2410c;
}

.licenseWatermark {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--brand), transparent 72%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface), transparent 8%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.adminMetricGrid,
.adminFormGrid,
.adminKeyValue {
  display: grid;
  gap: 14px;
}

.adminMetricGrid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.adminMetricCard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface2);
}

.adminMetricCard span,
.adminKeyValue span {
  color: var(--muted);
  font-size: 12px;
}

.adminMetricCard strong,
.adminKeyValue strong {
  font-size: 18px;
}

.adminMetricCard small {
  color: var(--muted);
}

.adminFormGrid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.adminFormWide {
  grid-column: 1 / -1;
}

.adminKeyValue {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 16px;
}

.adminKeyValue > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface2);
}

.adminKeyValue strong {
  overflow-wrap: anywhere;
}

.adminTagList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brandPreview {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.brandPreview strong {
  font-size: 20px;
}

.adminAuditActions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0 16px;
}

.adminAuditTable {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.adminAuditRow {
  display: grid;
  grid-template-columns: 170px 160px 90px 90px 1fr 2fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface2);
}

.adminAuditHead {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.adminAuditRow code {
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .adminFormGrid,
  .adminAuditRow {
    grid-template-columns: 1fr;
  }

  .adminAuditActions .btn {
    justify-content: center;
    width: 100%;
  }
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--text);
  text-align: center;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-field {
  margin-bottom: 18px;
}

.auth-field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-fast);
}

.auth-field input:focus {
  border-color: var(--dev);
}

.auth-field textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  font-size: 14px;
  outline: none;
  resize: vertical;
  transition: border-color var(--t-fast);
}

.auth-field textarea:focus {
  border-color: var(--dev);
}

.auth-field .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.field-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.username-warning {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--dev) 12%, transparent);
}

.auth-submit {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: none;
  background: var(--dev);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity var(--t-fast);
}

.auth-submit:hover {
  opacity: 0.9;
}

.auth-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-card--setup {
  max-width: 480px;
}

.auth-submit--block {
  display: block;
  text-align: center;
  text-decoration: none;
}

.auth-error {
  background: rgba(239, 68, 68, .10);
  border: 1px solid rgba(239, 68, 68, .25);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--bad);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.auth-error.visible {
  display: block;
}

.auth-success {
  background: rgba(34, 197, 94, .10);
  border: 1px solid rgba(34, 197, 94, .25);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--ok);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.auth-success.visible {
  display: block;
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

.auth-link a {
  color: var(--dev);
  text-decoration: none;
}

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

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand span {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.auth-brand img {
  max-width: 220px;
  max-height: 56px;
  object-fit: contain;
}

.auth-oauth-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.auth-brand .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dev);
  margin-left: 2px;
  vertical-align: super;
}

.auth-theme-btn {
  position: fixed;
  top: 16px;
  right: 16px;
}

/* ========================= COMMENTS / FEEDBACK =========================
   Feedback is rendered inside the shared #drawer (see overlays.inja).
   Filter tabs use the generic .drawer-tabs component (see drawer-tabs rules above).
*/

/* Shared red counter pill used for open-feedback counters. Matches .nav-badge
   visual language so the same metric reads identically in the sidebar and
   on the version accordion Feedback button. */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 10px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  border: 0;
}

.commentsList {
  display: flex;
  flex-direction: column;
}

.commentCard {
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  transition: background .15s;
}

.commentCard:last-child {
  border-bottom: none;
}

.commentCard.resolved {
  opacity: .75;
}

.commentCard.rejected {
  opacity: .7;
}

.commentMeta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: .78rem;
  color: var(--text-muted);
}

.commentAuthor {
  font-weight: 600;
  color: var(--text);
}

.commentTime {
  font-size: .74rem;
}

.commentBody p {
  margin: 0;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--text);
}

.commentRejectReason {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--bad);
  background: var(--bad-light, rgba(220, 38, 38, .08));
  border-left: 3px solid var(--bad);
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
}

.commentDecider {
  color: var(--text-muted);
}

.commentActions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.commentRejectForm {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.commentRejectForm textarea {
  width: 100%;
}

.commentRejectActions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ----- Inbox view ----- */

.inboxList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.inboxGroup {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.inboxGroupHead {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.inboxGroupTitle {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: .95rem;
  flex: 1 1 auto;
  min-width: 0;
}

.inboxGroupMeta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Comments inbox accordion items */
#inboxList .acc {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

#inboxList .acc .accHead {
  padding: 12px 14px;
}

#inboxList .acc .accLeft {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#inboxList .acc .accIcon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

#inboxList .acc .accTitle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

#inboxList .acc .accTitle .t {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

#inboxList .acc .accTitle .d {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

#inboxList .acc .accBody {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#inboxList .acc .comment-preview {
  margin: 0;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#inboxList .acc .comment-details {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

#inboxList .acc .email-badge {
  font-size: .8rem;
  color: var(--muted);
  background: var(--surface2);
  padding: 4px 8px;
  border-radius: 4px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#inboxList .inboxQuickAction {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
}

/* ========================= ACCESSIBILITY =========================
   Focus styles, skip navigation, ARIA landmark visuals.
   Keep outline: none only where box-shadow/border replacement is present.
*/

/* Skip-to-content link: visible only on keyboard focus */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 8px;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--dev, #8b5cf6);
  color: #fff;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-to-content:focus-visible {
  top: 0;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Global keyboard focus indicator for interactive elements that strip outline
   without providing an alternative (search, select, accordion chevron). */
.search:focus-visible,
select.select:focus-visible {
  outline: 2px solid var(--dev, #8b5cf6);
  outline-offset: 1px;
  border-color: var(--dev, #8b5cf6);
}

.chev:focus-visible {
  outline: 2px solid var(--dev, #8b5cf6);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Auth page input focus: add box-shadow in addition to border change */
.auth-field input:focus-visible,
.auth-field input:focus {
  border-color: var(--dev, #8b5cf6);
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .18);
}
.cookieConsentBanner[hidden] { display: none; }
.cookieConsentBanner {
  position: fixed;
  inset: auto 20px 20px 20px;
  z-index: 90;
  display: flex;
  justify-content: center;
}
.cookieConsentCard {
  width: min(720px, 100%);
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: 1px solid var(--line, rgba(255,255,255,.14));
  border-radius: 18px;
  background: var(--panel, rgba(19,23,34,.96));
  color: #eef2ff;
  box-shadow: 0 18px 40px rgba(0,0,0,.28);
}
.cookieConsentText strong {
  color: #ffffff;
}
.cookieConsentText p {
  margin: 6px 0 0;
  color: #c8d1e6;
}
.cookieConsentText a,
.cookieConsentMeta a {
  color: #dbe4ff;
}
.cookieConsentMeta {
  font-size: 12px;
  color: #aeb7cc;
}
.cookieConsentActions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.cookieConsentBtn {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
}
.cookieConsentBtn.primary {
  background: var(--accent, #ff7a59);
  color: #fff;
}
.cookieConsentBtn.secondary {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.cookieConsentError {
  margin: 8px 0 0;
  color: #ffb4b4;
}
@media (max-width: 820px) {
  .cookieConsentCard {
    flex-direction: column;
    align-items: flex-start;
  }
  .cookieConsentActions {
    width: 100%;
  }
}
