/* =========================================================================
   AVR — Aywa Voice Runtime · Dashboard
   Design system: premium dark, dev-platform aesthetic (Linear / Vercel)
   Token-first, single source of truth.
   ========================================================================= */

:root {
  /* — Surfaces ——————————————————————————————————————————— */
  --bg: #0a0a0c;
  --bg-grid: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.025) 1px, transparent 0);
  --panel: #0e0e11;
  --panel-2: #131318;
  --panel-3: #18181f;
  --panel-raised: #1c1c24;
  --overlay: rgba(5, 5, 8, 0.72);

  /* — Borders ———————————————————————————————————————————— */
  --line: rgba(255, 255, 255, 0.07);
  --line-soft: rgba(255, 255, 255, 0.045);
  --line-strong: rgba(255, 255, 255, 0.12);

  /* — Text ——————————————————————————————————————————————— */
  --text: #fafafa;
  --text-soft: #d4d4d8;
  --muted: #8b8b95;
  --muted-2: #5d5d68;

  /* — Brand & accents ——————————————————————————————————— */
  --brand-violet: #8b5cf6;
  --brand-violet-soft: #a78bfa;
  --brand-cyan: #22d3ee;
  --brand-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 55%, #06b6d4 100%);
  --accent: var(--brand-violet-soft);
  --accent-strong: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.30);
  --accent-cyan-glow: rgba(34, 211, 238, 0.22);

  /* — Semantic state colors ———————————————————————————— */
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);

  /* — Radii ——————————————————————————————————————————————— */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;

  /* — Shadows ————————————————————————————————————————————— */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
  --ring: 0 0 0 3px var(--accent-glow);

  /* — Typography ————————————————————————————————————————— */
  --font-sans: "Inter", "Geist", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, SFMono-Regular,
    "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01", "ss03", "cv02";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  accent-color: var(--accent);
}

* {
  box-sizing: border-box;
}

*::selection {
  background: var(--accent-glow);
  color: var(--text);
}

*:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grid);
  background-size: 32px 32px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

select,
[data-resource],
[data-editor-tab],
[data-select-resource],
[data-modal-select],
[data-modal-select-input],
[data-action] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
}

a {
  color: var(--brand-cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--bg);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* =========================================================================
   Boot screen
   ========================================================================= */

.boot-screen {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 500;
  gap: 12px;
  height: 100vh;
  justify-content: center;
  letter-spacing: 0.01em;
}

.boot-screen img {
  border-radius: var(--r-lg);
  box-shadow: 0 0 32px var(--accent-glow);
}

/* =========================================================================
   App shell
   ========================================================================= */

.app-shell {
  background: var(--bg);
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

/* =========================================================================
   Sidebar
   ========================================================================= */

.sidebar {
  background: linear-gradient(180deg, #0c0c10 0%, #0a0a0c 100%);
  border-right: 1px solid var(--line);
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

.sidebar::after {
  background: linear-gradient(180deg, transparent, var(--bg) 92%);
  bottom: 0;
  content: "";
  height: 56px;
  left: 0;
  pointer-events: none;
  position: absolute;
  right: 0;
}

.brand {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 12px;
  min-height: 60px;
  padding: 0 16px;
}

.brand img {
  border-radius: var(--r-md);
  box-shadow: 0 4px 18px -6px var(--accent-glow);
  height: 32px;
  width: 32px;
}

.brand-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-title strong {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 18px;
}

.brand-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-collapse-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--muted);
  display: inline-flex;
  height: 28px;
  justify-content: center;
  margin-left: auto;
  transition: background 120ms ease, color 120ms ease;
  width: 28px;
}

.sidebar-collapse-button:hover {
  background: var(--panel-2);
  color: var(--text);
}

.org-switcher-shell {
  margin: 12px;
  position: relative;
}

.org-switcher {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  display: flex;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  transition: border-color 120ms ease, background 120ms ease;
  width: 100%;
}

.org-switcher:hover {
  background: var(--panel-3);
  border-color: var(--line-strong);
}

.org-avatar {
  align-items: center;
  background: var(--brand-gradient);
  border-radius: var(--r-xs);
  color: #fff;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  height: 22px;
  justify-content: center;
  width: 22px;
}

.org-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-chevrons {
  color: var(--muted-2);
}

.org-menu {
  background: color-mix(in srgb, var(--panel) 96%, #fff 4%);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  left: 0;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
}

.org-menu-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  padding: 6px 8px;
  text-transform: uppercase;
}

.org-menu-item {
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 2px;
  padding: 8px;
  text-align: left;
  width: 100%;
}

.org-menu-item:hover,
.org-menu-item.active {
  background: var(--panel-2);
}

.org-menu-main {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-menu-sub,
.org-menu-empty {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-menu-empty {
  padding: 8px;
}

.org-menu-actions {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 6px;
}

.org-menu-create {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
  min-height: 34px;
  padding: 8px;
  width: 100%;
}

.org-menu-create:hover {
  background: var(--panel-2);
}

.sidebar-search {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  display: flex;
  gap: 8px;
  height: 34px;
  margin: 0 12px 14px;
  padding: 0 10px;
  transition: border-color 120ms ease;
}

.sidebar-search:hover {
  border-color: var(--line-strong);
}

.sidebar-search span {
  flex: 1;
  font-size: 12.5px;
}

.sidebar-search kbd {
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  min-width: 20px;
  padding: 2px 5px;
  text-align: center;
}

.nav {
  flex: 1;
  overflow: auto;
  padding: 4px 8px 132px;
}

.nav-group {
  margin-bottom: 18px;
}

.nav-title {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 10px 8px;
  text-transform: uppercase;
}

.nav-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-soft);
  display: flex;
  font-size: 13.5px;
  font-weight: 500;
  gap: 10px;
  min-height: 32px;
  padding: 0 10px;
  text-decoration: none;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
  width: 100%;
}

.nav-button:hover {
  background: var(--panel-2);
  color: var(--text);
}

.nav-button.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(34, 211, 238, 0.10));
  border-color: rgba(139, 92, 246, 0.28);
  color: #fff;
  position: relative;
}

.nav-button.active::before {
  background: var(--brand-gradient);
  border-radius: 999px;
  content: "";
  height: 14px;
  left: -1px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
}

.nav-button.child {
  color: var(--muted);
  font-size: 13px;
  min-height: 30px;
}

.nav-button.parent {
  margin-top: 2px;
}

.nav-children {
  display: grid;
  gap: 1px;
  margin: 2px 0 8px 14px;
}

.nav-icon,
.button-icon {
  color: currentColor;
  flex: 0 0 auto;
  height: 16px;
  opacity: 0.8;
  width: 16px;
}

.nav-button.active .nav-icon {
  color: var(--brand-violet-soft);
  opacity: 1;
}

.side-footer {
  background: linear-gradient(180deg, transparent, #0a0a0c 30%);
  border-top: 1px solid var(--line-soft);
  bottom: 0;
  display: grid;
  gap: 10px;
  left: 0;
  padding: 12px;
  position: absolute;
  right: 0;
}

.credit-row {
  align-items: center;
  color: var(--text-soft);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
}

.credit-row span {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
}

.credit-row strong {
  color: var(--text);
  font-weight: 600;
}

.side-footer-button {
  justify-content: center;
  width: 100%;
}

/* =========================================================================
   Main area
   ========================================================================= */

.main {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(14, 14, 17, 0.7);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 18px;
}

.crumb {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12.5px;
  gap: 8px;
  min-width: 0;
}

.crumb strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.monitor-pill {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  display: flex;
  font-size: 12px;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  white-space: nowrap;
}

.monitor-dot {
  background: var(--ok);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--ok);
  height: 7px;
  width: 7px;
}

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

/* =========================================================================
   Workspace (rail + detail)
   ========================================================================= */

.workspace {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.workspace-single {
  grid-template-columns: minmax(0, 1fr);
}

.workspace-list {
  grid-template-columns: minmax(0, 1fr);
}

.workspace-list .resource-rail {
  border-right: 0;
}

.workspace-list .rail-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 84px;
  padding: 18px 24px 14px;
}

.workspace-list .rail-title {
  display: grid;
  gap: 3px;
  justify-content: start;
}

.workspace-list .rail-create-button {
  width: auto;
}

.workspace-list .rail-search {
  padding: 12px 24px;
}

.workspace-list .table-wrap {
  padding: 0 24px 24px;
}

.workspace-list .resource-table {
  min-width: 860px;
}

.back-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 20px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.back-button:hover {
  border-color: var(--text-soft);
  color: var(--text);
}

.back-button svg {
  width: 12px;
  height: 12px;
}

.surface,
.list-surface,
.detail-surface {
  background: var(--panel);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-width: 0;
  overflow: hidden;
}

.list-surface {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.list-surface.with-filters {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.detail-surface {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.detail-surface.editor-owned-header {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.detail-surface.empty-owned-header {
  grid-template-rows: minmax(0, 1fr);
}

.detail-overlay-backdrop {
  background: rgba(4, 8, 18, 0.54);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  inset: 0;
  position: fixed;
  z-index: 20;
}

.detail-drawer {
  background: var(--panel);
  border-left: 1px solid var(--line-strong);
  box-shadow: -26px 0 60px rgba(0, 0, 0, 0.28);
  display: grid;
  height: 100vh;
  inset: 0 0 0 auto;
  max-width: 100vw;
  position: fixed;
  width: min(1040px, calc(100vw - 260px));
  z-index: 21;
}

.detail-drawer .detail-surface {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.detail-drawer .detail-body {
  flex: 1;
}

.resource-rail {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.rail-header {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 12px;
  min-height: 108px;
  padding: 14px 14px 12px;
}

.rail-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-width: 0;
}

.rail-title h1 {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 20px;
  margin: 0;
}

.rail-title span {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 11px;
}

.rail-create-button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 500;
  width: 100%;
}

.rail-create-button:hover {
  background: var(--panel-3);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.rail-search {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 8px;
  padding: 10px 14px;
}

.rail-search svg {
  color: var(--muted-2);
  height: 14px;
  width: 14px;
}

.rail-search input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  height: 30px;
  min-width: 0;
  padding: 0 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}

.rail-search input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  outline: none;
}

.rail-search input::placeholder,
.field-row input::placeholder,
.field-row textarea::placeholder,
.filter-bar input::placeholder {
  color: var(--muted-2);
}

/* =========================================================================
   Surface header / titles
   ========================================================================= */

.surface-header {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 18px;
}

.surface-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.surface-title h1,
.surface-title h2 {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 20px;
  margin: 0;
}

.surface-title span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.save-status {
  color: var(--muted);
  font-size: 12px;
  min-width: 48px;
  text-align: right;
}

.save-status.saving {
  color: var(--warn);
}

.save-status.saved {
  color: var(--ok);
}

.save-status.error {
  color: var(--danger);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================================
   Tabs
   ========================================================================= */

.resource-tabs {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 10px 14px;
}

.tab-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--muted);
  display: inline-flex;
  font-size: 12.5px;
  font-weight: 500;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
  white-space: nowrap;
}

.tab-button:hover {
  background: var(--panel-2);
  color: var(--text);
}

.tab-button.active {
  background: var(--panel-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.filter-bar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  padding: 10px 14px;
}

.filter-bar input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  min-height: 32px;
  padding: 6px 9px;
  width: 100%;
}

.filter-bar input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  outline: none;
}

/* =========================================================================
   Buttons
   ========================================================================= */

.primary-button,
.secondary-button,
.icon-button {
  align-items: center;
  border-radius: var(--r-sm);
  display: inline-flex;
  font-size: 13px;
  font-weight: 500;
  gap: 7px;
  height: 32px;
  justify-content: center;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 0 12px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease,
    box-shadow 120ms ease, transform 80ms ease;
  white-space: nowrap;
}

.primary-button span,
.secondary-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.primary-button {
  background: #fafafa;
  border: 1px solid #fafafa;
  color: #0a0a0c;
  font-weight: 600;
}

.primary-button:hover:not(:disabled) {
  background: #ffffff;
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.primary-button:active:not(:disabled) {
  transform: translateY(0.5px);
}

.primary-button:disabled {
  background: var(--panel-3);
  border-color: var(--line);
  color: var(--muted-2);
  cursor: not-allowed;
}

.secondary-button,
.icon-button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: var(--panel-3);
  border-color: var(--line-strong);
}

.secondary-button:disabled,
.icon-button:disabled {
  background: var(--panel-2);
  color: var(--muted-2);
  cursor: not-allowed;
  opacity: 0.6;
}

.compact-row-button {
  height: 28px;
  padding: 0 10px;
}

.icon-button {
  padding: 0;
  width: 32px;
}

.danger-icon-button {
  color: var(--danger);
}

.danger-icon-button:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: rgba(251, 113, 133, 0.35);
}

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrap {
  min-height: 0;
  overflow: auto;
}

.resource-table {
  border-collapse: collapse;
  color: var(--text-soft);
  min-width: 720px;
  width: 100%;
}

.resource-table th {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 10.5px;
  font-weight: 700;
  height: 36px;
  letter-spacing: 0.06em;
  padding: 0 14px;
  position: sticky;
  text-align: left;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

.resource-table td {
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  height: 52px;
  padding: 0 14px;
  vertical-align: middle;
}

.resource-row {
  cursor: pointer;
  transition: background 100ms ease;
}

.resource-row:hover {
  background: var(--panel-2);
}

.resource-row.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.10), rgba(34, 211, 238, 0.04));
  box-shadow: inset 3px 0 0 var(--accent);
}

.rail-list-table {
  min-width: 0;
}

.rail-list-table td {
  height: auto;
  padding: 12px 14px;
}

.rail-list-table strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.rail-row-meta {
  color: var(--muted);
  display: block;
  font-size: 11.5px;
  line-height: 16px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-row-id {
  color: var(--muted);
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 15px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-table {
  min-width: 0;
}

.public-key-panel {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 18px 0;
  padding: 16px;
}

.public-key-panel > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.public-key-panel span,
.public-key-panel small {
  color: var(--muted);
  font-size: 12px;
}

.public-key-panel strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* =========================================================================
   Helpers
   ========================================================================= */

.mono {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 12px;
}

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

.muted-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.latency {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* =========================================================================
   Badges
   ========================================================================= */

.badge {
  align-items: center;
  background: var(--info-soft);
  border: 1px solid rgba(96, 165, 250, 0.30);
  border-radius: 999px;
  color: var(--info);
  display: inline-flex;
  flex: 0 1 auto;
  font-size: 11px;
  font-weight: 600;
  height: 22px;
  letter-spacing: 0.01em;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 0 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-soft);
  border-color: rgba(52, 211, 153, 0.30);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-soft);
  border-color: rgba(251, 191, 36, 0.30);
  color: var(--warn);
}

/* =========================================================================
   Detail body / empty state
   ========================================================================= */

.detail-body {
  background: var(--panel);
  min-height: 0;
  overflow: auto;
  padding: 32px clamp(20px, 3vw, 36px);
}

.empty-state {
  align-content: center;
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 10px;
  min-height: 320px;
  padding: 36px;
  text-align: center;
}

.empty-state span {
  justify-self: center;
  max-width: 460px;
}

.empty-state .primary-button {
  justify-self: center;
  margin-top: 10px;
}

.empty-state-icon {
  align-items: center;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.10));
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 999px;
  box-shadow: 0 0 32px var(--accent-glow);
  color: var(--brand-violet-soft);
  display: inline-flex;
  height: 52px;
  justify-content: center;
  justify-self: center;
  width: 52px;
}

.empty-state-icon svg {
  height: 22px;
  width: 22px;
}

.detail-empty-state {
  min-height: calc(100vh - 92px);
}

/* =========================================================================
   Editor (assistant detail)
   ========================================================================= */

.editor-titlebar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
}

.editor-titlebar h2 {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 20px;
  margin: 0;
}

.editor-title-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.editor-tabs {
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding: 0 18px;
}

.editor-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  height: 40px;
  padding: 0;
  position: relative;
  transition: color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}

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

.editor-tab.active {
  color: var(--text);
}

.editor-tab.active::after {
  background: var(--brand-gradient);
  border-radius: 999px 999px 0 0;
  bottom: -1px;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  right: 0;
}

/* =========================================================================
   Forms
   ========================================================================= */

.field-grid {
  display: grid;
  gap: 14px;
}

.section-panel {
  display: grid;
  gap: 10px;
}

.field-row {
  display: grid;
  gap: 6px;
}

.field-row label {
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
}

.field-row input,
.field-row select,
.field-row textarea,
.schema-add-row input,
.schema-add-row select,
.auth-panel input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  min-height: 34px;
  padding: 7px 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  width: 100%;
}

.readonly-field {
  align-items: center;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-soft);
  display: flex;
  min-height: 34px;
  padding: 7px 10px;
}

.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus,
.schema-add-row input:focus,
.schema-add-row select:focus,
.auth-panel input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  outline: none;
}

.field-row textarea {
  font-family: var(--font-sans);
  line-height: 1.55;
  min-height: 108px;
  resize: vertical;
}

.field-row textarea[data-autosave-path="model.messages.system"],
.field-row textarea[data-autosave-path="systemPrompt"] {
  font-family: var(--font-mono);
  font-size: 12.5px;
  min-height: 320px;
}

.prompt-editor-block {
  display: grid;
  gap: 8px;
}

.prompt-editor-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.prompt-editor-head label {
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
}

.prompt-editor-block .field-row > label:empty {
  display: none;
}

.field-hint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 16px;
}

.slider-field {
  gap: 8px;
}

.slider-field-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.slider-field input[type="range"] {
  accent-color: var(--accent);
  cursor: pointer;
  min-height: 24px;
  padding: 0;
}

.slider-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.voice-id-control {
  display: grid;
  gap: 4px;
}

.provider-estimate {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  display: grid;
  gap: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
}

.provider-estimate div {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
}

.provider-estimate div + div {
  border-left: 1px solid var(--line-soft);
}

.provider-estimate span {
  color: var(--muted);
  font-size: 11px;
}

.provider-estimate strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.field-row.invalid input,
.field-row.invalid select,
.field-row.invalid textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.checkbox-row label {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-soft);
  display: flex;
  font-size: 13px;
  gap: 10px;
  min-height: 36px;
  padding: 0 12px;
  transition: border-color 120ms ease, background 120ms ease;
}

.checkbox-row label:hover {
  background: var(--panel-3);
  border-color: var(--line-strong);
}

.checkbox-row input {
  min-height: 0;
  padding: 0;
  width: 16px;
}

.section-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 20px 0 10px;
}

.section-title h3 {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
}

.form-columns {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.assistant-overview-grid {
  gap: 16px;
}

.assistant-stack-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

.json-preview {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: #a5f3fc;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

/* =========================================================================
   Cards (AVR card system, ex-vapi-*)
   ========================================================================= */

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

.avr-stat-card,
.avr-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 120ms ease, background 120ms ease;
}

.avr-stat-card:hover,
.avr-card:hover {
  border-color: var(--line-strong);
}

.avr-stat-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.avr-stat-card > div:first-child {
  align-items: baseline;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 500;
  justify-content: space-between;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.avr-stat-card span,
.avr-card-header span {
  color: var(--muted);
  font-size: 12px;
}

.avr-stat-card strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stacked-bar {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  display: flex;
  gap: 3px;
  height: 6px;
  overflow: hidden;
}

.stacked-bar i {
  background: var(--brand-violet-soft);
  display: block;
}

.stacked-bar i:nth-child(2) {
  background: var(--brand-cyan);
}

.stacked-bar i:nth-child(3) {
  background: var(--info);
}

.stacked-bar i:nth-child(4) {
  background: #f472b6;
}

.avr-card-header {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px 14px;
}

.avr-card-header h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 18px;
  margin: 0 0 3px;
}

.avr-card-body {
  display: grid;
  gap: 14px;
  padding: 16px 18px 20px;
}

/* =========================================================================
   Metrics / summary tiles
   ========================================================================= */

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

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

.metric-tile,
.summary-item {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  transition: border-color 120ms ease;
}

.metric-tile:hover,
.summary-item:hover {
  border-color: var(--line-strong);
}

.metric-tile span,
.summary-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.metric-tile strong,
.summary-item strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  overflow-wrap: anywhere;
}

/* =========================================================================
   Action rows / test grids
   ========================================================================= */

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

.test-action-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.test-action-grid .primary-button,
.test-action-grid .secondary-button {
  width: 100%;
}

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

.test-preflight-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 12px;
}

.test-preflight-card.ready {
  border-color: rgba(52, 211, 153, 0.35);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.10);
}

.test-preflight-card.blocked {
  border-color: rgba(251, 191, 36, 0.35);
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.10);
}

.test-preflight-card span,
.test-preflight-card small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 16px;
}

.test-preflight-card strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 17px;
  overflow-wrap: anywhere;
}

/* =========================================================================
   Schema / composer / transcript
   ========================================================================= */

.schema-add-row {
  align-items: center;
  margin-top: 12px;
}

.composer-status {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 18px;
  padding: 10px 12px;
}

.transcript-preview {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  max-height: 140px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.live-transcript-preview {
  max-height: 220px;
}

/* =========================================================================
   Timeline
   ========================================================================= */

.timeline {
  display: grid;
  gap: 0;
}

.timeline-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 64px 12px minmax(0, 1fr);
  min-width: 0;
  padding: 0 0 14px;
}

.timeline-time {
  display: grid;
  gap: 2px;
  justify-items: end;
  padding-top: 2px;
}

.timeline-time strong {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 11px;
}

.timeline-time span {
  color: var(--muted-2);
  font-size: 10px;
  text-align: right;
}

.timeline-dot {
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.14);
  height: 8px;
  margin-top: 6px;
  width: 8px;
}

.timeline-content {
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
  padding-bottom: 12px;
}

.timeline-title {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.timeline-title strong {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-content p,
.timeline-loading,
.timeline-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 17px;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

/* =========================================================================
   Integrations / chips
   ========================================================================= */

.integration-grid {
  display: grid;
  gap: 12px;
}

.integration-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 10px;
  padding: 12px;
}

.integration-card strong {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

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

.integration-chip {
  align-items: center;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 12px;
  gap: 7px;
  min-height: 28px;
  padding: 3px 5px 3px 10px;
  transition: border-color 120ms ease, background 120ms ease;
}

.integration-chip:hover {
  background: var(--panel-raised);
  border-color: var(--accent);
}

.integration-chip > span:first-child {
  font-size: 12px;
}

/* =========================================================================
   Segmented & misc controls
   ========================================================================= */

.expiry-segmented {
  display: flex;
  width: fit-content;
}

.expiry-segmented button {
  white-space: nowrap;
}

.fit-button {
  width: fit-content;
}

.segmented {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: inline-flex;
  overflow: hidden;
  padding: 2px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: var(--r-xs);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  height: 28px;
  padding: 0 12px;
  transition: background 120ms ease, color 120ms ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active {
  background: var(--brand-gradient);
  color: #fff;
}

.mini-toggle {
  align-items: center;
  color: var(--text-soft);
  display: inline-flex;
  font-size: 12.5px;
  gap: 8px;
  min-height: 30px;
}

.mini-toggle input {
  min-height: 0;
  width: 16px;
}

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

.resource-selection-list {
  grid-template-columns: minmax(0, 1fr);
}

.selection-card {
  align-items: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 10px;
  min-height: 56px;
  padding: 10px 12px;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.selection-card:hover,
.selection-card.active {
  background: var(--panel);
  border-color: rgba(99, 102, 241, 0.38);
}

.selection-card input {
  margin-top: 3px;
  min-height: 0;
  width: 16px;
}

.selection-card span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.selection-card strong {
  font-size: 13px;
  font-weight: 600;
}

.selection-card small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advanced-stack {
  display: grid;
  gap: 14px;
}

.advanced-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  padding-top: 18px;
}

.advanced-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.advanced-section-head {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
}

.advanced-section-head h3 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
  margin: 0;
}

.advanced-section-head span,
.fallback-title span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 17px;
  margin-top: 2px;
}

.fallback-block,
.fallback-list,
.fallback-row {
  display: grid;
  gap: 10px;
}

.fallback-title,
.inline-control-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.fallback-title strong {
  font-size: 13px;
  font-weight: 600;
}

.fallback-row {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px;
}

.inline-control-row > .field-row {
  flex: 1;
}

.inline-control-row > .field-row > label:empty {
  display: none;
}

.compact-action-row {
  justify-content: flex-end;
}

.compact-action-row > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.message-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-chip {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
}

.message-chip.active {
  background: var(--panel);
  border-color: rgba(99, 102, 241, 0.42);
  color: var(--text);
}

.message-chip input {
  min-height: 0;
  width: 14px;
}

/* =========================================================================
   Modals
   ========================================================================= */

.modal-backdrop {
  align-items: center;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 30;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(820px, 92vh);
  max-width: 880px;
  min-height: 380px;
  overflow: hidden;
  width: min(880px, 96vw);
}

.modal-header,
.modal-footer {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 18px;
}

.modal-header {
  border-bottom: 1px solid var(--line-soft);
}

.modal-header h2 {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.modal-body {
  background: var(--panel);
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.modal-footer {
  border-top: 1px solid var(--line-soft);
}

.modal-context-banner {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.modal-context-banner > span {
  align-items: center;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: inline-flex;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.modal-context-banner strong,
.modal-context-banner small {
  display: block;
}

.modal-context-banner strong {
  font-size: 13px;
  font-weight: 650;
}

.modal-context-banner small {
  color: var(--muted);
  font-size: 12px;
  line-height: 17px;
  margin-top: 1px;
}

.modal-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
}

.modal-section .section-title {
  margin: 0;
}

/* =========================================================================
   Choice cards / template picker
   ========================================================================= */

.choice-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-card {
  align-items: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  display: grid;
  font: inherit;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.choice-card:hover {
  background: var(--panel-3);
  border-color: var(--line-strong);
}

.choice-card:disabled,
.choice-card[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.52;
}

.choice-card:disabled:hover,
.choice-card[aria-disabled="true"]:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.choice-card.selected {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(34, 211, 238, 0.06));
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-glow);
}

.choice-card strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.choice-card span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 16px;
}

.choice-card.compact {
  min-height: 76px;
}

.assistant-create-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.1fr);
}

.template-list,
.template-preview {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.template-preview {
  align-content: start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
}

.template-preview p {
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
  margin: 0;
}

/* =========================================================================
   Toast
   ========================================================================= */

.toast {
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  bottom: 24px;
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  left: 50%;
  max-width: min(520px, calc(100vw - 24px));
  opacity: 0;
  padding: 11px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================================================================
   Auth panel
   ========================================================================= */

.auth-panel {
  align-items: center;
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.08), rgba(251, 191, 36, 0.02));
  border-bottom: 1px solid rgba(251, 191, 36, 0.20);
  color: var(--text-soft);
  display: none;
  font-size: 12.5px;
  gap: 10px;
  padding: 9px 16px;
}

.auth-panel.open {
  display: flex;
}

.auth-panel input {
  border-color: rgba(251, 191, 36, 0.30);
  flex: 1;
  min-height: 32px;
}

.auth-shell {
  min-height: 100vh;
}

.auth-gate {
  align-items: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.08), transparent 34%),
    var(--bg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: rgba(18, 18, 21, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  display: grid;
  gap: 22px;
  max-width: 460px;
  padding: 28px;
  width: min(100%, 460px);
}

.auth-card h1 {
  font-size: 26px;
  line-height: 1.15;
  margin: 8px 0;
}

.auth-card p {
  color: var(--text-soft);
  margin: 0;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form input {
  min-height: 42px;
}

/* =========================================================================
   Active call widget (floating)
   ========================================================================= */

.active-call-widget {
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  bottom: 22px;
  box-shadow: var(--shadow-lg), 0 0 24px var(--accent-glow);
  color: var(--text);
  display: grid;
  gap: 10px;
  padding: 12px;
  position: fixed;
  right: 22px;
  width: 248px;
  z-index: 8;
}

.active-call-handle,
.active-call-body,
.active-call-actions {
  align-items: center;
  display: flex;
}

.active-call-handle {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  justify-content: space-between;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.active-call-body {
  justify-content: space-between;
}

.active-call-body strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-call-actions {
  gap: 6px;
}

.active-call-actions .icon-button {
  height: 30px;
  width: 30px;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .brand-title,
  .nav-title,
  .nav-label,
  .org-label,
  .org-chevrons,
  .sidebar-search span,
  .sidebar-search kbd {
    display: none;
  }

  .brand,
  .org-switcher,
  .sidebar-search {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .nav-button {
    justify-content: center;
  }

  .nav-children {
    margin-left: 0;
  }

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

  .detail-drawer {
    width: calc(100vw - 72px);
  }

  .detail-surface {
    min-height: 560px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    min-height: 0;
    position: static;
  }

  .sidebar::after {
    display: none;
  }

  .side-footer {
    position: static;
  }

  .brand {
    justify-content: flex-start;
    padding: 0 14px;
  }

  .brand-title,
  .nav-label {
    display: grid;
  }

  .nav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 8px;
  }

  .nav-group {
    display: flex;
    flex: 0 0 auto;
    margin: 0;
  }

  .nav-title {
    display: none;
  }

  .nav-button {
    width: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
    padding: 10px 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    padding: 0;
  }

  .workspace-list .rail-header,
  .workspace-list .rail-search,
  .workspace-list .table-wrap {
    padding-left: 12px;
    padding-right: 12px;
  }

  .workspace-list .rail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-list .rail-create-button {
    width: 100%;
  }

  .detail-drawer {
    inset: 0;
    width: 100vw;
  }

  .surface-header,
  .top-actions,
  .form-columns,
  .filter-bar,
  .metric-grid,
  .summary-grid,
  .test-action-grid,
  .test-preflight-grid,
  .choice-grid,
  .assistant-create-layout,
  .selection-list {
    grid-template-columns: 1fr;
  }

  .surface-header,
  .top-actions,
  .detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* ===== Linear-style sober components ===== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--panel);
}
.page-header-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-header-title h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.page-header-meta { font-size: 12.5px; color: var(--muted); }
.page-header-stats { display: flex; align-items: center; gap: 24px; }
.page-header-stats > div { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.page-header-stats span { font-size: 10.5px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted-2); }
.page-header-stats strong { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
  vertical-align: middle;
  margin-right: 8px;
}
.status-ok { background: var(--ok); }
.status-warn { background: var(--warn); }
.status-idle { background: var(--muted-2); }

.check-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--panel);
}
.check-row {
  display: grid;
  grid-template-columns: 16px minmax(180px, 1.2fr) minmax(0, 2fr) minmax(80px, auto) minmax(80px, auto);
  align-items: center;
  gap: 16px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  transition: background 80ms ease;
}
.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: var(--panel-2); }
.check-row .status-dot { margin-right: 0; }
.check-name { color: var(--text); font-weight: 500; font-family: var(--font-mono); font-size: 12.5px; }
.check-detail { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.check-scope { color: var(--muted); font-size: 11.5px; text-align: right; }
.check-status { font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-align: right; color: var(--muted); text-transform: lowercase; }
.check-status-ok { color: var(--ok); }
.check-status-warn { color: var(--warn); }

.kpi-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background: var(--panel);
}
.kpi-label { font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.metric-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.metric-group {
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--panel);
  overflow: hidden;
}
.metric-group-title {
  padding: 10px 14px;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-2);
}
.metric-group-rows { display: flex; flex-direction: column; }
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); font-size: 12.5px; }
.metric-row strong { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

.raw-snapshot { margin-top: 4px; }
.raw-snapshot summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  list-style: none;
  user-select: none;
}
.raw-snapshot summary::-webkit-details-marker { display: none; }
.raw-snapshot summary::before { content: "▸ "; color: var(--muted-2); }
.raw-snapshot[open] summary::before { content: "▾ "; }
.raw-snapshot pre { margin-top: 8px; }

/* ===== API key sober detail ===== */

.kv-block {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--panel);
  overflow: hidden;
}
.kv-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row > span { color: var(--muted); font-size: 12.5px; }
.kv-row > strong { color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.kv-row > code { font-family: var(--font-mono); font-size: 12px; color: var(--text-soft); }

.reveal-card {
  border: 1px solid rgba(139, 92, 246, 0.30);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.06), var(--panel));
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.reveal-card-head { display: flex; flex-direction: column; gap: 2px; }
.reveal-card-head strong { font-size: 13px; font-weight: 600; color: var(--text); }
.reveal-card-head span { font-size: 12px; color: var(--muted); }
.reveal-card-body { display: flex; align-items: center; gap: 8px; }
.reveal-card-body code {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid rgba(251, 113, 133, 0.25);
  border-radius: var(--r-xl);
  background: rgba(251, 113, 133, 0.04);
}
.danger-zone > div { display: flex; flex-direction: column; gap: 2px; }
.danger-zone strong { font-size: 13px; font-weight: 600; color: var(--text); }
.danger-zone span { font-size: 12px; color: var(--muted); }
.danger-button {
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid rgba(251, 113, 133, 0.40);
  background: transparent;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease;
}
.danger-button:hover { background: rgba(251, 113, 133, 0.10); border-color: var(--danger); }
.danger-button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.30); }
.compact-danger-button {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-height: 34px;
}

/* AVR sober overrides (page-wide audit) */

.empty-state-icon { display: none !important; }
.empty-state { gap: 10px; padding: 36px 0; text-align: left; align-items: flex-start; }
.empty-state strong { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; color: var(--text); }
.empty-state span { font-size: 12.5px; color: var(--muted); max-width: 520px; line-height: 1.5; }
.empty-state .primary-button { margin-top: 6px; }

.monitor-pill, .monitor-dot, .monitor-text { display: none !important; }
.top-stat {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.top-stat + .top-stat { margin-left: 4px; }

.stacked-bar { display: none !important; }
.avr-stat-grid { display: none !important; }
.avr-card, .avr-card-header, .avr-card-body { all: unset; display: block; }
.avr-card { margin: 0; }
.avr-card-header { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px; }
.avr-card-header span:last-child { display: none; }
.avr-card-body { display: flex; flex-direction: column; gap: 14px; }

.test-preflight-grid, .test-preflight-card, .test-action-grid { all: unset; }
.test-action-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-grid { display: none; }

.integration-grid, .integration-card, .chip-row { all: unset; display: block; }
.section-panel { all: unset; display: block; }

.choice-grid { display: flex; flex-direction: column; gap: 0; }
.choice-card { all: unset; }

.radio-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.radio-row {
  display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 12px;
  padding: 12px 14px; background: transparent; border: 0; cursor: pointer; text-align: left;
  border-bottom: 1px solid var(--line-soft); color: var(--text); transition: background 80ms ease;
}
.radio-row:last-child { border-bottom: 0; }
.radio-row:hover { background: var(--panel-2); }
.radio-row.selected { background: var(--panel-2); }
.radio-mark {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; position: relative;
}
.radio-row.selected .radio-mark { border-color: var(--text); }
.radio-row.selected .radio-mark::after {
  content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--text);
}
.radio-label { display: flex; flex-direction: column; gap: 2px; }
.radio-label strong { font-size: 13px; font-weight: 500; color: var(--text); }
.radio-label span { font-size: 12px; color: var(--muted); }

.inline-check { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-soft); margin-top: 4px; }

.assistant-create-layout, .template-list, .template-preview { all: unset; display: block; }

.assistant-create-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 0.92fr) minmax(320px, 1.08fr);
}

.assistant-create-main,
.template-preview,
.phone-number-import-flow {
  min-width: 0;
}

.assistant-create-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.prominent-field input {
  font-size: 15px;
  min-height: 42px;
}

.template-list {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.template-option {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  display: grid;
  gap: 12px;
  grid-template-columns: 16px minmax(0, 1fr);
  min-height: 62px;
  padding: 12px 14px;
  text-align: left;
}

.template-option:last-child {
  border-bottom: 0;
}

.template-option:hover,
.template-option.selected {
  background: var(--panel-2);
}

.template-option-check {
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  height: 14px;
  position: relative;
  width: 14px;
}

.template-option.selected .template-option-check {
  border-color: var(--text);
}

.template-option.selected .template-option-check::after {
  background: var(--text);
  border-radius: 50%;
  content: '';
  inset: 3px;
  position: absolute;
}

.template-option strong,
.template-preview-head strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.template-option small,
.template-preview-head p,
.template-preview-head span,
.provider-stack span,
.phone-import-header span,
.phone-import-summary span,
.phone-number-binding-panel span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.template-preview {
  align-content: start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 16px;
  padding: 16px;
}

.template-preview-head p {
  margin: 6px 0 0;
}

.flow-tabs {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
}

.flow-tabs span {
  color: var(--muted);
  font-size: 11.5px;
  min-width: 0;
  overflow: hidden;
  padding: 8px 6px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-tabs span:first-child {
  background: var(--panel-3);
  color: var(--text);
}

.provider-stack,
.phone-import-summary,
.phone-number-binding-panel {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  overflow: hidden;
}

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

.provider-stack div,
.phone-import-summary div,
.phone-number-binding-panel div {
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
  padding: 12px;
}

.provider-stack div:nth-last-child(-n + 2),
.phone-import-summary div,
.phone-number-binding-panel div {
  border-bottom: 0;
}

.provider-stack div:nth-child(odd),
.phone-number-binding-panel div:first-child {
  border-right: 1px solid var(--line-soft);
}

.provider-stack strong,
.phone-import-summary strong,
.phone-number-binding-panel strong {
  color: var(--text);
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.phone-number-import-flow {
  display: grid;
  gap: 16px;
}

.phone-import-header {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 12px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  padding: 12px;
}

.phone-import-header strong {
  color: var(--text);
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.phone-import-mark {
  align-items: center;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: inline-flex;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.phone-import-summary,
.phone-number-binding-panel {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.phone-number-binding-panel {
  margin-bottom: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor-title-actions .badge { display: none; }

.integration-hero {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
}

.integration-hero h3,
.integration-section-head h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.integration-hero span,
.integration-section-head span,
.integration-provider-main span,
.integration-provider-state small,
.credential-create-banner small {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

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

.integration-summary-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
}

.integration-summary-tile span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.integration-summary-tile strong {
  color: var(--text);
  display: block;
  font-size: 18px;
  font-weight: 600;
  margin-top: 6px;
}

.integration-stack {
  display: grid;
  gap: 14px;
}

.integration-marketplace {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.integration-marketplace-head {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-width: 0;
  padding: 14px;
}

.integration-marketplace-head > div {
  min-width: 0;
}

.integration-marketplace-head .secondary-button {
  flex: 0 0 auto;
  min-width: 0;
}

.integration-marketplace-head strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.integration-marketplace-head span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 17px;
  margin-top: 4px;
}

.integration-category-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.integration-category-chip {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 12px;
  gap: 8px;
  min-height: 32px;
  padding: 5px 8px 5px 10px;
}

.integration-category-chip:hover,
.integration-category-chip.active {
  background: var(--panel-raised);
  border-color: var(--accent);
  color: var(--text);
}

.integration-category-chip strong {
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  min-width: 22px;
  padding: 2px 6px;
  text-align: center;
}

.integration-card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  min-width: 0;
}

.integration-market-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  padding: 14px;
}

.integration-market-card.ready {
  border-color: color-mix(in srgb, var(--ok) 30%, var(--line));
}

.integration-market-card.needs-setup {
  border-color: color-mix(in srgb, var(--warn) 24%, var(--line));
}

.integration-market-card-head {
  align-items: flex-start;
  display: grid;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr);
  min-width: 0;
}

.integration-market-card-head > div {
  min-width: 0;
}

.integration-market-card-head strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.integration-market-card-head span:last-child {
  color: var(--muted);
  display: -webkit-box;
  font-size: 12px;
  line-height: 17px;
  margin-top: 3px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.integration-usage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.integration-usage-list span {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 11px;
  max-width: 100%;
  overflow: hidden;
  padding: 3px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.integration-market-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.integration-market-meta small {
  color: var(--muted);
  flex: 1 1 100%;
  font-size: 11px;
  margin-left: 0;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
}

.integration-market-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.integration-market-actions .secondary-button {
  justify-self: stretch;
  min-width: 0;
  width: 100%;
}

.connected-credentials-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.compact-resource-table th,
.compact-resource-table td {
  padding-bottom: 10px;
  padding-top: 10px;
}

.inline-empty-state {
  border: 0;
  border-radius: 0;
}

.integration-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.integration-section-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
}

.integration-provider-list {
  display: grid;
  min-width: 0;
}

.integration-provider-row {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 240px) minmax(112px, max-content);
  min-width: 0;
  padding: 12px 14px;
}

.integration-provider-row:last-child { border-bottom: 0; }
.integration-provider-row.ready { background: color-mix(in srgb, var(--ok) 7%, transparent); }
.integration-provider-row.needs-setup { background: color-mix(in srgb, var(--warn) 5%, transparent); }

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

.integration-provider-main strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.integration-provider-main span:last-child {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.integration-provider-icon,
.credential-create-banner > span {
  align-items: center;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-soft);
  display: inline-flex;
  flex-shrink: 0;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.provider-icon {
  height: 17px;
  width: 17px;
}

.integration-provider-state {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.integration-provider-state small {
  max-width: 240px;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-align: right;
  text-overflow: ellipsis;
}

.integration-provider-row > .secondary-button {
  max-width: 180px;
  min-width: 0;
  width: 100%;
}

.credential-create-banner {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  gap: 12px;
  padding: 12px;
}

.credential-create-banner strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.credential-create-summary {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
}

.credential-create-summary > div {
  border-bottom: 1px solid var(--line);
  min-width: 0;
  padding: 10px 12px;
}

.credential-create-summary > div:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.credential-create-summary > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.credential-create-summary span {
  color: var(--text-muted);
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
}

.credential-create-summary strong {
  color: var(--text);
  display: block;
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.credential-readonly-grid {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
}

.credential-readonly-grid > div {
  min-width: 0;
  padding: 10px 12px;
}

.credential-readonly-grid > div:first-child {
  border-right: 1px solid var(--line);
}

.credential-readonly-grid span {
  color: var(--text-muted);
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
}

.credential-readonly-grid strong {
  color: var(--text);
  display: block;
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.advanced-credential-fields {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
}

.advanced-credential-fields summary {
  color: var(--text-soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.advanced-credential-fields .field-grid {
  margin-top: 12px;
}

.inline-audio {
  display: block;
  height: 32px;
  margin-top: 8px;
  max-width: 280px;
  width: 100%;
}

@media (max-width: 900px) {
  .assistant-create-layout,
  .provider-stack,
  .phone-import-summary,
  .phone-number-binding-panel {
    grid-template-columns: 1fr;
  }
  .flow-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .phone-import-header {
    grid-template-columns: 38px minmax(0, 1fr);
  }
  .phone-import-header .badge {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .credential-create-summary {
    grid-template-columns: 1fr;
  }
  .credential-create-summary > div {
    border-right: 0 !important;
  }
  .credential-create-summary > div:nth-last-child(2) {
    border-bottom: 1px solid var(--line);
  }
  .credential-readonly-grid {
    grid-template-columns: 1fr;
  }
  .credential-readonly-grid > div:first-child {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }
  .provider-stack div:nth-child(odd),
  .phone-number-binding-panel div:first-child {
    border-right: 0;
  }
  .provider-stack div:nth-last-child(-n + 2),
  .phone-import-summary div,
  .phone-number-binding-panel div {
    border-bottom: 1px solid var(--line-soft);
  }
  .provider-stack div:last-child,
  .phone-import-summary div:last-child,
  .phone-number-binding-panel div:last-child {
    border-bottom: 0;
  }
  .page-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .page-header-stats { width: 100%; justify-content: space-between; gap: 12px; }
  .page-header-stats > div { text-align: left; }
  .check-row { grid-template-columns: 16px 1fr auto; }
  .check-detail, .check-scope { display: none; }
  .kv-row { grid-template-columns: 110px 1fr; }
  .integration-hero,
  .integration-section-head,
  .integration-marketplace-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .integration-marketplace-head .secondary-button {
    width: 100%;
  }
  .integration-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .integration-provider-row {
    grid-template-columns: 1fr;
  }
  .integration-provider-row > .secondary-button {
    max-width: 100%;
  }
  .integration-provider-state {
    align-items: flex-start;
  }
  .integration-provider-state small {
    max-width: 100%;
    text-align: left;
  }
  .integration-card-grid {
    grid-template-columns: 1fr;
  }
  .integration-market-meta small {
    flex-basis: 100%;
    margin-left: 0;
  }
}
