/* Teora UI — Studio design system (cabinet light/dark + panel dark ops) */
/* Tokens: docs/studio_design_spec.md */

:root,
[data-theme="light"] {
  --studio-bg: #f6f5f1;
  --studio-sidebar: #efeee9;
  --studio-main: #f6f5f1;
  --studio-card: #ffffff;
  --studio-input: #ffffff;
  --studio-elevated: #ffffff;
  --studio-text: #14161c;
  --studio-text-soft: rgba(20, 22, 28, 0.78);
  --studio-text-muted: rgba(20, 22, 28, 0.55);
  --studio-text-faint: rgba(20, 22, 28, 0.45);
  --studio-text-dim: rgba(20, 22, 28, 0.4);
  --studio-border: rgba(20, 22, 28, 0.1);
  --studio-border-strong: rgba(20, 22, 28, 0.16);
  --studio-gold: #9a7b52;
  --studio-gold-hover: #8a6c48;
  --studio-gold-wash: rgba(154, 123, 82, 0.12);
  --studio-gold-border: rgba(154, 123, 82, 0.4);
  --studio-danger: #b54a4a;
  --studio-danger-border: rgba(181, 74, 74, 0.35);
  --studio-danger-wash: rgba(181, 74, 74, 0.1);
  --studio-ok-badge-bg: rgba(154, 123, 82, 0.14);
  --studio-muted-badge-bg: rgba(20, 22, 28, 0.06);
  --studio-primary-fg: #0b0c10;
  --studio-radius-sm: 8px;
  --studio-radius-md: 10px;
  --studio-radius-lg: 12px;
  --studio-radius-xl: 14px;
  --studio-sidebar-width: 248px;
  --studio-font: "Onest", system-ui, sans-serif;
  --studio-mono: "JetBrains Mono", ui-monospace, monospace;

  --bg: var(--studio-bg);
  --surface: var(--studio-card);
  --text: var(--studio-text);
  --muted: var(--studio-text-muted);
  --border: var(--studio-border);
  --accent: var(--studio-gold);
  --field-bg: var(--studio-input);
  --sidebar-w: var(--studio-sidebar-width);
}

[data-theme="dark"] {
  --studio-bg: #0b0c10;
  --studio-sidebar: #0d0e12;
  --studio-main: #101114;
  --studio-card: #16181f;
  --studio-input: #0d0e12;
  --studio-elevated: #14161c;
  --studio-text: #f4f4f1;
  --studio-text-soft: rgba(244, 244, 241, 0.78);
  --studio-text-muted: rgba(244, 244, 241, 0.55);
  --studio-text-faint: rgba(244, 244, 241, 0.45);
  --studio-text-dim: rgba(244, 244, 241, 0.4);
  --studio-border: rgba(255, 255, 255, 0.08);
  --studio-border-strong: rgba(255, 255, 255, 0.12);
  --studio-gold: #d4b896;
  --studio-gold-hover: #e0c6a4;
  --studio-gold-wash: rgba(212, 184, 150, 0.12);
  --studio-gold-border: rgba(212, 184, 150, 0.45);
  --studio-danger: #e8a0a0;
  --studio-danger-border: rgba(232, 160, 160, 0.35);
  --studio-danger-wash: rgba(232, 160, 160, 0.12);
  --studio-ok-badge-bg: rgba(212, 184, 150, 0.14);
  --studio-muted-badge-bg: rgba(244, 244, 241, 0.06);
  --studio-primary-fg: #0b0c10;
}

/* Panel ops chrome: cooler sidebar, same gold atoms */
[data-surface="panel"] {
  --studio-sidebar: #0a0b0f;
}

[data-theme="dark"] .form-row input:-webkit-autofill,
[data-theme="dark"] .form-row input:-webkit-autofill:hover,
[data-theme="dark"] .form-row input:-webkit-autofill:focus,
[data-theme="dark"] .form-row textarea:-webkit-autofill,
[data-theme="dark"] .form-row textarea:-webkit-autofill:hover,
[data-theme="dark"] .form-row textarea:-webkit-autofill:focus,
[data-theme="dark"] .form-row select:-webkit-autofill,
[data-theme="dark"] .form-row select:-webkit-autofill:hover,
[data-theme="dark"] .form-row select:-webkit-autofill:focus,
[data-theme="dark"] .studio-field input:-webkit-autofill,
[data-theme="dark"] .studio-field textarea:-webkit-autofill,
[data-theme="dark"] .studio-field select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--studio-input) inset;
  box-shadow: 0 0 0 1000px var(--studio-input) inset;
  -webkit-text-fill-color: var(--studio-text);
  caret-color: var(--studio-gold);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--studio-font);
  background: var(--studio-bg);
  color: var(--studio-text);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

a,
button,
summary,
[role="button"],
.studio-chip,
.teo-select__trigger,
.data-table tr[data-href] {
  cursor: pointer;
}

/* ——— Shell ——— */
.app-shell {
  display: grid;
  grid-template-columns: var(--studio-sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  width: auto;
  flex-shrink: 0;
  background: var(--studio-sidebar);
  border-right: 1px solid var(--studio-border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.studio-brand {
  margin: 0 0 1.5rem;
  padding: 0 0.15rem;
}

.studio-brand__title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--studio-text);
  line-height: 1.2;
}

.studio-brand__subtitle {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--studio-text-faint);
}

.studio-nav {
  flex: 1;
  min-height: 0;
}

.studio-nav__group {
  margin: 1rem 0 0.35rem;
  padding: 0 0.6rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--studio-text-faint);
}

.studio-nav__group:first-child {
  margin-top: 0;
}

.sidebar a,
.studio-nav a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: var(--studio-radius-sm);
  color: var(--studio-text-soft);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 0.1rem;
}

.sidebar a:hover,
.studio-nav a:hover {
  color: var(--studio-text);
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .sidebar a:hover,
[data-theme="light"] .studio-nav a:hover {
  background: rgba(20, 22, 28, 0.04);
}

.sidebar a.active,
.studio-nav a.active {
  color: var(--studio-gold);
  background: var(--studio-gold-wash);
  font-weight: 500;
}

.studio-sidebar-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--studio-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.studio-sidebar-footer .muted {
  font-size: 0.8rem;
}

.studio-account-chip {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--studio-radius-sm);
  text-decoration: none;
  color: var(--studio-text-soft);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.studio-account-chip:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--studio-text);
}

[data-theme="light"] .studio-account-chip:hover {
  background: rgba(20, 22, 28, 0.04);
}

.studio-account-chip.is-active {
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
}

.studio-account-chip__row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}

.studio-account-chip__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
  border: 1px solid var(--studio-gold-border);
}

.studio-account-chip__org {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--studio-text);
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.studio-account-chip.is-active .studio-account-chip__org {
  color: var(--studio-gold);
}

.studio-account-chip__email {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--studio-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studio-account-chip.is-active .studio-account-chip__email {
  color: rgba(212, 184, 150, 0.65);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--studio-text-muted);
  padding: 0.35rem 0.15rem;
  font-size: 0.8rem;
  text-align: left;
  font-family: inherit;
}

.btn-ghost:hover {
  color: var(--studio-text);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--studio-main);
}

.topbar,
.studio-utility {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.75rem;
  border-bottom: 1px solid var(--studio-border);
  background: var(--studio-main);
}

.content {
  padding: 1.5rem 1.75rem;
  max-width: 100%;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-header h1,
.page-title {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.page-lead {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--studio-text-muted);
  max-width: 42rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0;
}

.edit-actions--bottom {
  margin: 0.75rem 0 0;
}

.edit-actions__right {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.edit-actions__delete {
  order: 1;
}

.edit-actions__save-close {
  order: 2;
}

.edit-actions__save {
  order: 3;
}

/* ——— Cards / KPI ——— */
.card,
.card-surface {
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-lg);
  padding: 1.25rem;
  min-width: 0;
  max-width: 100%;
}

.muted {
  color: var(--studio-text-muted);
  font-size: 0.875rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.stats-grid .card p.muted,
.kpi-card .kpi-label {
  margin: 0;
  font-size: 0.875rem;
  color: var(--studio-text-muted);
}

.stats-grid h3,
.kpi-card .kpi-value {
  margin: 0.35rem 0 0;
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1.15;
}

.kpi-card .kpi-value--alert {
  color: var(--studio-danger);
}

.feeds-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (min-width: 900px) {
  .feeds-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.feed-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.feed-card__head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.link-gold {
  color: var(--studio-gold) !important;
  text-decoration: none !important;
  font-size: 0.875rem;
  font-weight: 500;
}

.link-gold:hover {
  color: var(--studio-gold-hover) !important;
  text-decoration: underline !important;
  text-decoration-color: var(--studio-gold) !important;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--studio-radius-md);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: var(--studio-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.25;
  cursor: pointer;
}

[data-theme="light"] .btn {
  border-color: var(--studio-border-strong);
}

.btn:hover {
  border-color: var(--studio-gold-border);
  color: var(--studio-gold);
}

.btn-primary {
  background: var(--studio-gold);
  border-color: transparent;
  color: var(--studio-primary-fg);
}

.btn-primary:hover {
  background: var(--studio-gold-hover);
  border-color: transparent;
  color: var(--studio-primary-fg);
}

.btn-danger {
  background: transparent;
  border-color: var(--studio-danger-border);
  color: var(--studio-danger);
}

.btn-danger:hover {
  background: var(--studio-danger-wash);
  border-color: var(--studio-danger);
  color: var(--studio-danger);
}

.btn-login-primary {
  background: #14161c;
  border-color: transparent;
  color: #f4f4f1;
}

.btn-login-primary:hover {
  background: #0b0c10;
  color: #f4f4f1;
  border-color: transparent;
}

.content a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text),
.entry-grid a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text) {
  color: var(--studio-gold);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.content a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):hover,
.entry-grid a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):hover {
  color: var(--studio-gold-hover);
}

.content a.muted,
.entry-grid a.muted {
  color: var(--studio-text-muted);
  text-decoration: none;
}

.content a.muted:hover,
.entry-grid a.muted:hover {
  color: var(--studio-text);
  text-decoration: underline;
  text-decoration-color: var(--studio-gold);
}

.content a.link-text:not(.btn),
.entry-grid a.link-text:not(.btn) {
  color: var(--studio-text);
  text-decoration: none;
  font-weight: 500;
}

.content a.link-text:not(.btn):hover,
.entry-grid a.link-text:not(.btn):hover,
.data-table tr:hover .link-text {
  color: var(--studio-gold);
}

/* ——— Forms ——— */
.form-row,
.form-field,
.studio-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.form-row label,
.form-field label,
.studio-field label {
  color: rgba(244, 244, 241, 0.7);
  font-size: 0.85rem;
}

[data-theme="light"] .form-row label,
[data-theme="light"] .form-field label,
[data-theme="light"] .studio-field label {
  color: rgba(20, 22, 28, 0.7);
}

.form-row input,
.form-row textarea,
.form-row select,
.form-field input,
.form-field textarea,
.form-field select,
.studio-field input,
.studio-field textarea,
.studio-field select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--studio-radius-md);
  border: 1px solid var(--studio-border-strong);
  background: var(--studio-input);
  color: var(--studio-text);
  font-family: inherit;
  font-size: 0.875rem;
  caret-color: var(--studio-gold);
}

.form-row input::placeholder,
.form-row textarea::placeholder,
.form-field input::placeholder,
.studio-field input::placeholder {
  color: var(--studio-text-dim);
}

.form-row input:hover,
.form-row textarea:hover,
.form-row select:hover,
.form-field input:hover,
.form-field textarea:hover,
.form-field select:hover {
  border-color: rgba(212, 184, 150, 0.35);
}

[data-theme="light"] .form-row input:hover,
[data-theme="light"] .form-row textarea:hover,
[data-theme="light"] .form-row select:hover {
  border-color: rgba(154, 123, 82, 0.35);
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus,
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus,
.studio-field input:focus,
.studio-field textarea:focus,
.studio-field select:focus,
.teo-select__trigger:focus {
  outline: none;
  border-color: rgba(212, 184, 150, 0.55);
  box-shadow:
    0 0 0 1px rgba(212, 184, 150, 0.22),
    0 0 10px rgba(212, 184, 150, 0.16),
    0 0 20px rgba(212, 184, 150, 0.08);
}

[data-theme="light"] .form-row input:focus,
[data-theme="light"] .form-row textarea:focus,
[data-theme="light"] .form-row select:focus,
[data-theme="light"] .teo-select__trigger:focus {
  border-color: rgba(154, 123, 82, 0.55);
  box-shadow:
    0 0 0 1px rgba(154, 123, 82, 0.22),
    0 0 10px rgba(154, 123, 82, 0.12),
    0 0 20px rgba(154, 123, 82, 0.06);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  column-gap: 1.75rem;
  row-gap: 1rem;
}

.form-grid > .form-row,
.form-grid > .field-error {
  margin-bottom: 0;
}

.form-grid > .form-row-full,
.form-grid > .field-error {
  grid-column: 1 / -1;
}

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

@media (max-width: 720px) {
  .form-grid-provider {
    grid-template-columns: 1fr;
  }
}

.form-grid-worker-panel .form-row-full {
  grid-column: 1 / -1;
}

.form-grid-worker-panel .form-row-full.form-actions {
  margin-bottom: 0;
}

form.form-grid {
  position: relative;
}

form.form-grid > input[type="hidden"][name="csrfmiddlewaretoken"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.form-grid-inline {
  grid-template-columns: minmax(14rem, 1fr) auto;
}

.form-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.field-help {
  margin: 0.28rem 0 0;
  font-size: 0.8rem;
  color: var(--studio-text-muted);
}

.field-error {
  color: var(--studio-danger);
  font-size: 0.8rem;
  margin-top: 0.28rem;
}

/* ——— Custom select ——— */
.teo-select {
  position: relative;
  width: 100%;
}

.teo-select__native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.teo-select__trigger {
  width: 100%;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  background: var(--studio-input);
  color: var(--studio-text);
  border: 1px solid var(--studio-border-strong);
  border-radius: var(--studio-radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  text-align: left;
}

.studio-filters .teo-select__trigger {
  min-height: 2.45rem;
  border-radius: var(--studio-radius-sm);
}

.teo-select__trigger--placeholder {
  color: var(--studio-text-dim);
}

.teo-select__chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid var(--studio-gold);
  border-bottom: 1.5px solid var(--studio-gold);
  transform: rotate(45deg);
  flex-shrink: 0;
  margin-top: -0.2rem;
}

.teo-select__menu {
  display: none;
  position: absolute;
  z-index: 40;
  top: calc(100% + 0.3rem);
  left: 0;
  right: 0;
  max-height: 16rem;
  overflow: auto;
  background: var(--studio-elevated);
  border: 1px solid rgba(212, 184, 150, 0.28);
  border-radius: var(--studio-radius-lg);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 20px rgba(212, 184, 150, 0.06);
  padding: 0.35rem;
}

.teo-select.is-open .teo-select__menu {
  display: block;
}

.teo-select__option {
  padding: 0.55rem 0.7rem;
  border-radius: var(--studio-radius-sm);
  font-size: 0.875rem;
  color: var(--studio-text-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.teo-select__option:hover,
.teo-select__option.is-active {
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
}

.teo-select__option.is-selected {
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
}

.teo-select__option.is-selected::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--studio-gold);
  flex-shrink: 0;
}

/* ——— Filters ——— */
.studio-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-lg);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.studio-filters .form-row {
  margin: 0;
  min-width: 12rem;
  flex: 1;
}

.studio-filters__meta {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--studio-text-dim);
  align-self: center;
}

.studio-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--studio-border-strong);
  background: transparent;
  color: var(--studio-text-soft);
  font-size: 0.8rem;
  font-family: inherit;
  text-decoration: none;
}

.studio-chip.is-active,
.studio-chip--active {
  color: var(--studio-gold);
  background: var(--studio-gold-wash);
  border-color: var(--studio-gold-border);
}

/* ——— Tables ——— */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.data-table,
.studio-table {
  width: 100%;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td,
.studio-table th,
.studio-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.85rem 0.75rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

[data-theme="light"] .data-table th,
[data-theme="light"] .data-table td {
  border-bottom-color: rgba(20, 22, 28, 0.08);
}

.data-table th,
.studio-table th {
  color: var(--studio-text-faint);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.data-table tr[data-href]:hover,
.studio-table tr[data-href]:hover {
  background: rgba(212, 184, 150, 0.06);
}

td.row-actions {
  white-space: normal;
  overflow-wrap: normal;
}

td.row-actions a {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0.2rem 0;
  white-space: normal;
}

.data-table code.uuid-compact,
.mono {
  font-family: var(--studio-mono);
  font-size: 0.75rem;
  display: inline-block;
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

code {
  font-family: var(--studio-mono);
  font-size: 0.8em;
}

/* ——— Badges ——— */
.badge {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.12rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--studio-text-faint);
  background: var(--studio-muted-badge-bg);
}

.badge--ok {
  color: var(--studio-gold);
  background: var(--studio-ok-badge-bg);
}

.badge--muted {
  color: var(--studio-text-faint);
  background: var(--studio-muted-badge-bg);
}

/* ——— Alerts / toasts ——— */
.alert,
.studio-toast {
  margin: 0 0 0.75rem;
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  background: var(--studio-elevated);
  color: var(--studio-text-soft);
}

.alert-success,
.studio-toast--success {
  border-color: var(--studio-gold-border);
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
}

.alert-error,
.studio-toast--error {
  border-color: var(--studio-danger-border);
  background: var(--studio-danger-wash);
  color: var(--studio-danger);
}

.alert-info,
.studio-toast--info {
  border-color: var(--studio-gold-border);
  background: var(--studio-gold-wash);
}

/* ——— Modal ——— */
.studio-modal {
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-xl);
  background: var(--studio-elevated);
  color: var(--studio-text);
  padding: 1.2rem;
  width: min(28rem, calc(100vw - 2rem));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.studio-modal::backdrop {
  background: rgba(5, 6, 10, 0.72);
  backdrop-filter: blur(4px);
}

.studio-modal h2,
.studio-modal__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.studio-modal__body {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--studio-text-muted);
}

.studio-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.studio-confirm-page {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 3rem;
}

.studio-confirm-page .studio-modal {
  display: block;
  position: relative;
}

/* ——— Login (dark glass; forced data-theme=dark, cookie ignored) ——— */
html:has(body.studio-login-body) {
  background: #0b0c10;
  overflow: hidden;
}

.studio-login-body {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: #f4f4f1;
  background:
    radial-gradient(1100px 640px at 18% 8%, rgba(212, 184, 150, 0.2), transparent 58%),
    radial-gradient(900px 560px at 92% 0%, rgba(154, 123, 82, 0.16), transparent 52%),
    linear-gradient(160deg, #0b0c10, #101114 42%, #0b0c10);
}

.studio-login-body .home-aurora {
  position: absolute;
  inset: -15%;
  pointer-events: none;
  z-index: 0;
}

.studio-login-body .aurora-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.55;
  will-change: transform;
  mix-blend-mode: screen;
}

.studio-login-body .aurora-a {
  width: 46%;
  aspect-ratio: 1;
  left: 6%;
  top: 18%;
  background: radial-gradient(circle, rgba(212, 184, 150, 0.55) 0%, transparent 70%);
  animation: auroraDriftA 18s ease-in-out infinite;
}

.studio-login-body .aurora-b {
  width: 42%;
  aspect-ratio: 1;
  right: 4%;
  top: 22%;
  background: radial-gradient(circle, rgba(154, 123, 82, 0.48) 0%, transparent 70%);
  animation: auroraDriftB 22s ease-in-out infinite;
}

.studio-login-body .aurora-c {
  width: 34%;
  aspect-ratio: 1;
  left: 34%;
  top: 42%;
  background: radial-gradient(circle, rgba(156, 170, 188, 0.26) 0%, transparent 70%);
  animation: auroraDriftC 26s ease-in-out infinite;
}

.studio-login-body--panel .aurora-teal {
  width: 44%;
  aspect-ratio: 1;
  right: 18%;
  bottom: 14%;
  top: auto;
  left: auto;
  background: radial-gradient(circle, rgba(61, 155, 143, 0.5) 0%, transparent 70%);
  animation: auroraDriftTeal 24s ease-in-out infinite;
}

@keyframes auroraDriftA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(8%, 12%) scale(1.12); }
  66% { transform: translate(-6%, 18%) scale(0.92); }
}

@keyframes auroraDriftB {
  0%, 100% { transform: translate(0, 0) scale(1.05); }
  40% { transform: translate(-12%, 10%) scale(1.18); }
  70% { transform: translate(6%, 16%) scale(0.9); }
}

@keyframes auroraDriftC {
  0%, 100% { transform: translate(0, 0) scale(0.95); }
  50% { transform: translate(10%, -8%) scale(1.2); }
}

@keyframes auroraDriftTeal {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40% { transform: translate(-14%, -10%) scale(1.16); }
  72% { transform: translate(6%, -18%) scale(0.9); }
}

.studio-login-body .page-enter {
  animation: fadeUp 0.35s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .studio-login-body .aurora-blob,
  .studio-login-body .page-enter {
    animation: none;
  }
}

.studio-login-body .entry-grid,
.studio-login-body .studio-login-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-width: none;
  margin: 0;
  padding: 2rem;
  background: rgba(22, 24, 31, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  color: #f4f4f1;
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.studio-login-body .muted {
  color: rgba(244, 244, 241, 0.55);
}

.studio-login-body .login-lead {
  margin: 0.7rem 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.studio-login-body .form-row {
  gap: 0.35rem;
  margin-bottom: 0;
}

.studio-login-body .form-row label {
  color: rgba(244, 244, 241, 0.55);
  font-size: 0.9rem;
}

.studio-login-body .form-row input {
  background: #0d0e12;
  color: #f4f4f1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  caret-color: #d4b896;
  box-shadow: none;
}

.studio-login-body .form-row input:hover {
  border-color: rgba(212, 184, 150, 0.35);
}

.studio-login-body .form-row input:focus,
.studio-login-body .form-row input:focus-visible {
  outline: none;
  box-shadow: none;
  border-color: rgba(212, 184, 150, 0.45);
}

.studio-login-body .form-row input:-webkit-autofill,
.studio-login-body .form-row input:-webkit-autofill:hover,
.studio-login-body .form-row input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0d0e12 inset;
  box-shadow: 0 0 0 1000px #0d0e12 inset;
  -webkit-text-fill-color: #f4f4f1;
  caret-color: #d4b896;
}

.studio-login-body a {
  color: #d4b896;
}

.studio-login-body .login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0;
  min-height: 0;
}

.studio-login-body .login-brand img {
  display: block;
  max-width: min(100%, 16rem);
  max-height: 4.5rem;
  width: auto;
  height: auto;
  margin: 0 auto 1rem;
  object-fit: contain;
}

.studio-login-body .login-brand h1,
.studio-login-body .entry-grid h1 {
  margin: 0;
  width: 100%;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-align: center;
  color: #f4f4f1;
  line-height: 1.15;
}

.studio-login-body .entry-grid-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.studio-login-body .field-error {
  color: #e8a0a0;
}

.studio-login-body .login-submit,
.studio-login-body .btn-login-primary {
  display: flex;
  width: 100%;
  margin-top: 0.85rem;
  min-height: 48px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  background: #d4b896;
  border: none;
  border-radius: 8px;
  color: #0b0c10;
}

.studio-login-body .login-submit:hover,
.studio-login-body .btn-login-primary:hover {
  background: #e0c6a4;
  border-color: transparent;
  color: #0b0c10;
}

.studio-login-body .login-session {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.studio-login-body .login-session form {
  display: inline;
  margin-left: 0.5rem;
}

.studio-login-body .login-session .btn {
  padding: 0.2rem 0.55rem;
  min-height: 0;
  font-size: 0.85rem;
  color: #f4f4f1;
  border-color: rgba(255, 255, 255, 0.18);
  background: transparent;
}

.studio-login-body .login-session .btn:hover {
  border-color: rgba(212, 184, 150, 0.45);
  color: #e0c6a4;
}

@media (max-width: 400px) {
  .studio-login-body {
    padding: 0.75rem;
  }

  .studio-login-body .studio-login-card {
    padding: 1.5rem 1.25rem;
  }
}

.login-brand-preview {
  display: block;
  max-width: 16rem;
  max-height: 4.5rem;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #f6f5f1;
  padding: 0.75rem 1rem;
  border-radius: var(--studio-radius-md);
}

.brand-slot-preview--dark {
  background: #14161c;
}

.brand-slot-preview--favicon {
  width: 2.75rem;
  height: 2.75rem;
  max-width: 2.75rem;
  max-height: 2.75rem;
  padding: 0.4rem;
}

.brand-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1rem;
  align-items: start;
}

.brand-editor__slot {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-thumb-well {
  height: 6.25rem;
  display: flex;
  align-items: center;
  margin-bottom: 0.85rem;
}

.brand-thumb {
  position: relative;
  display: inline-flex;
  max-width: 100%;
}

.brand-thumb .login-brand-preview {
  max-width: 100%;
}

.brand-thumb__remove {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #14161c;
  color: #f4f4f1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.brand-thumb__remove svg {
  width: 0.7rem;
  height: 0.7rem;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
}

.brand-thumb__remove:hover {
  background: var(--studio-danger);
  border-color: transparent;
  color: #fff;
}

@media (max-width: 860px) {
  .brand-editor {
    grid-template-columns: 1fr;
  }
}

.panel-brand--logo .panel-brand-mark {
  display: none;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  display: block;
  max-width: 9.5rem;
  max-height: 2rem;
  width: auto;
  height: auto;
  object-fit: contain;
}

.brand-logo--dark {
  display: none;
}

[data-theme="dark"] .brand-logo--light {
  display: none;
}

[data-theme="dark"] .brand-logo--dark {
  display: block;
}

/* ——— Panel surface ——— */
[data-surface="panel"] .sidebar {
  background: var(--studio-sidebar);
}

[data-surface="panel"] .panel-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1.5rem;
  padding: 0 0.15rem;
}

[data-surface="panel"] .panel-brand-mark {
  width: 0.55rem;
  height: 1.35rem;
  border-radius: 2px;
  background: var(--studio-gold);
  box-shadow: none;
  flex-shrink: 0;
}

[data-surface="panel"] .panel-brand-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--studio-text);
}

[data-surface="panel"] .panel-brand-subtitle {
  font-size: 0.72rem;
  color: var(--studio-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.15rem;
}

[data-surface="panel"] .studio-nav a.active,
[data-surface="panel"] .sidebar a.active {
  position: relative;
  box-shadow: inset 2px 0 0 var(--studio-gold);
}

.panel-topbar-left,
.panel-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-toolbar.page-toolbar-spaced {
  margin-bottom: 1.25rem;
  padding-bottom: 0.15rem;
}

.panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0 0 1.1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--studio-border);
}

.content nav.panel-tabs a:not(.btn):not(.btn-primary) {
  color: var(--studio-text-soft);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.content nav.panel-tabs a:not(.btn):not(.btn-primary):hover {
  color: var(--studio-text);
  text-decoration: none;
}

.content nav.panel-tabs a.active:not(.btn):not(.btn-primary) {
  color: var(--studio-gold);
  font-weight: 600;
  border-bottom-color: var(--studio-gold);
}

.form-actions--end {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.form-actions--split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.form-actions--split .form-actions__primary {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.panel-tabs--notebook {
  align-items: flex-end;
  gap: 0.4rem;
  margin: 0 0 -1px;
  padding: 0 0.85rem;
  border-bottom: none;
  position: relative;
  z-index: 1;
}

.content nav.panel-tabs--notebook a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text),
.content nav.panel-tabs--notebook a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):hover,
.content nav.panel-tabs--notebook a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):focus {
  text-decoration: none;
  border-bottom: none;
  margin: 0;
  padding: 0.55rem 1.15rem 0.62rem;
  border: 1px solid var(--studio-border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  background: color-mix(in srgb, var(--studio-card) 55%, var(--studio-main));
  color: var(--studio-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.content nav.panel-tabs--notebook a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):hover {
  color: var(--studio-text);
  background: color-mix(in srgb, var(--studio-card) 78%, var(--studio-main));
}

.content nav.panel-tabs--notebook a.active:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text),
.content nav.panel-tabs--notebook a.active:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):hover {
  color: var(--studio-text);
  font-weight: 600;
  background: var(--studio-card);
  padding-top: 0.72rem;
  box-shadow: inset 0 2px 0 var(--studio-gold);
}

.card-form {
  width: 100%;
  max-width: none;
}

.client-provision-card {
  width: 100%;
  max-width: min(72rem, 100%);
}

.form-grid-client-provision {
  width: 100%;
  max-width: none;
  grid-template-columns: 1fr;
  column-gap: 1.75rem;
  row-gap: 1rem;
}

@media (min-width: 640px) {
  .form-grid-client-provision {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 2rem;
  }
}

.form-grid-client-provision .form-row {
  margin-bottom: 0;
}

.form-grid-client-provision .form-actions {
  grid-column: 1 / -1;
  margin-top: 0.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--studio-border);
}

.entry-grid {
  max-width: 28rem;
  margin: 4rem auto;
  padding: 1.25rem;
}

.entry-grid-form {
  width: 100%;
  max-width: 100%;
}

.entry-grid-form .form-row {
  width: 100%;
  max-width: 100%;
}

.entry-grid-form .form-row input {
  width: 100%;
  max-width: 100%;
}

.entry-grid h1 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.entry-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.kv {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.kv dt {
  margin: 0;
  color: var(--studio-text-muted);
  font-weight: 500;
}

.kv dd {
  margin: 0;
}

.section-h {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--studio-text);
}

/* ——— Switch ——— */
.form-row.form-switch-row {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.form-switch-row-text {
  flex: 1;
  min-width: 0;
}

.form-switch-label {
  font-weight: 500;
  display: block;
}

.form-switch,
.studio-switch {
  position: relative;
  display: inline-block;
  width: 2.5rem;
  height: 1.4rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
  cursor: pointer;
}

.form-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.form-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--studio-border-strong);
  transition: background 0.18s ease, border-color 0.18s ease;
}

[data-theme="light"] .form-switch-track {
  background: rgba(20, 22, 28, 0.1);
}

.form-switch-track::after {
  content: "";
  position: absolute;
  width: 1.05rem;
  height: 1.05rem;
  left: 0.15rem;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 50%;
  background: rgba(244, 244, 241, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease, background 0.18s ease;
}

.form-switch-input:focus-visible + .form-switch-track {
  outline: 2px solid var(--studio-gold);
  outline-offset: 2px;
}

.form-switch-input:checked + .form-switch-track {
  background: var(--studio-gold-wash);
  border-color: var(--studio-gold-border);
}

.form-switch-input:checked + .form-switch-track::after {
  transform: translate(1.05rem, -50%);
  background: var(--studio-gold);
}

.form-switch-input:disabled + .form-switch-track {
  opacity: 0.5;
  cursor: not-allowed;
}

.stack-gap > * + * {
  margin-top: 1rem;
}

/* Channel / worker preview styles appended below */
/* РџР°РЅРµР»СЊ: РР-СЃРѕС‚СЂСѓРґРЅРёРє вЂ” РєР°РЅР°Р»С‹, РёРЅСЃС‚СЂСѓРјРµРЅС‚С‹, handoff */
.section-h {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.channel-slots-wrap {
  margin-top: 0.25rem;
}

.channel-slot-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--field-bg);
}

.channel-slot-legend {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0.35rem;
  color: var(--muted);
}

.channel-slot-recessed {
  display: none !important;
}

.channel-probe-actions {
  margin: 0.35rem 0 0;
}

.channel-probe-result {
  margin: 0.35rem 0 0;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.channel-probe-result--pending {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.channel-probe-result--ok {
  border: 1px solid #234235;
  color: #bbf7d0;
  background: #0f1a12;
}

.channel-probe-result--err {
  border: 1px solid #5b1e1e;
  color: #fecaca;
  background: #1a0f0f;
}

.channel-add-wrap {
  margin: 0.25rem 0 0;
}

.channel-site-fields {
  --ch-primary: #2563eb;
  --ch-accent: #0d9488;
  --tg-launcher-bg: #2563eb;
  --tg-launcher-fg: #f2f5fa;
  --tg-head-bg: #2563eb;
  --tg-head-fg: #f2f5fa;
  --tg-head-muted: rgba(242, 245, 250, 0.62);
  --tg-body-bg: #b8cfe8;
  --tg-body-fg: #141922;
  --tg-foot-bg: #e8edf2;
  --tg-foot-fg: #141922;
  --tg-foot-muted: rgba(20, 25, 34, 0.58);
  --tg-bot-bg: #ffffff;
  --tg-bot-fg: #141922;
  --tg-bot-role: rgba(20, 25, 34, 0.58);
  --tg-user-bg: #d9e8f7;
  --tg-user-fg: #141922;
  --tg-user-role: rgba(20, 25, 34, 0.58);
}

.channel-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.65rem 1rem;
  align-items: flex-end;
  margin-bottom: 0.35rem;
}

.channel-preview-caption {
  margin: 0.75rem 0 0.35rem !important;
}

.channel-preview-block {
  margin-top: 0.25rem;
}

.ch-tg-mock {
  --ch-tg-page-min-h: 320px;
  --ch-tg-mock-min-h: 352px;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.ch-tg-mock--embed,
.ch-tg-mock--widget {
  min-height: var(--ch-tg-mock-min-h);
}

.ch-tg-browser {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.ch-tg-browser-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: #2a2f3a;
  color: #c8cdd8;
  font-size: 0.68rem;
}

.ch-tg-dots {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

.ch-tg-dots i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5c6370;
}

.ch-tg-dots i:first-child {
  background: #e85d5d;
}

.ch-tg-dots i:nth-child(2) {
  background: #e6b035;
}

.ch-tg-dots i:nth-child(3) {
  background: #4caf50;
}

.ch-tg-url {
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

.ch-tg-browser-body--embed,
.ch-tg-mock--widget .ch-tg-browser-body {
  min-height: var(--ch-tg-page-min-h);
  background: linear-gradient(165deg, #dfe6ee 0%, #c5d3e3 45%, #b0c4d8 100%);
}

.ch-tg-browser-body {
  position: relative;
  min-height: 196px;
  background: linear-gradient(165deg, #dfe6ee 0%, #c5d3e3 45%, #b0c4d8 100%);
}

.ch-tg-fake-page {
  position: absolute;
  inset: 0.65rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.ch-tg-fake-page::before {
  content: "";
  display: block;
  height: 10px;
  margin: 0.75rem 0.75rem 0.5rem;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ch-primary), var(--ch-accent));
  opacity: 0.35;
}

.ch-tg-fake-page::after {
  content: "";
  display: block;
  height: 7px;
  margin: 0 0.75rem 0.35rem;
  max-width: 62%;
  border-radius: 3px;
  background: rgba(80, 96, 120, 0.2);
}

/* Р’СЃС‚СЂРѕРµРЅРЅС‹Р№ С‡Р°С‚: С„РѕРЅ-СЃС‚СЂР°РЅРёС†Р° РЅР° РІРµСЃСЊ Р±Р»РѕРє; РёРјРёС‚Р°С†РёСЏ С‚РµРєСЃС‚Р° СЃРІРµСЂС…Сѓ, С‡Р°С‚ СЃРЅРёР·Сѓ вЂ” РЅРµ РїРµСЂРµРєСЂС‹РІР°РµС‚ РїРѕР»РѕСЃРєРё. */
.ch-tg-embed-page {
  position: relative;
  min-height: var(--ch-tg-page-min-h);
  box-sizing: border-box;
}

.ch-tg-fake-page--embed {
  position: absolute;
  inset: 0.65rem;
  z-index: 0;
  pointer-events: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.ch-tg-fake-page--embed::before {
  margin: 1rem 1rem 0.55rem;
  max-width: 42%;
}

.ch-tg-fake-page--embed::after {
  margin: 0 1rem 0.4rem;
  max-width: 28%;
}

.ch-tg-embed-slot {
  position: relative;
  z-index: 2;
  min-height: var(--ch-tg-page-min-h);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  /* СЂРµР·РµСЂРІ РїРѕРґ ::before + ::after В«С€Р°РїРєРёВ» СЃС‚СЂР°РЅРёС†С‹, С‡С‚РѕР±С‹ С‡Р°С‚ РЅРµ РЅР°РµР·Р¶Р°Р» */
  padding: 5.25rem 1rem 1.25rem;
}

.ch-tg-widget-float {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0.45rem;
  z-index: 2;
}

.ch-tg-launcher {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  cursor: default;
  flex-shrink: 0;
  background: var(--tg-launcher-bg);
  color: var(--tg-launcher-fg);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}

.ch-tg-launcher::after {
  content: "";
  display: block;
  width: 18px;
  height: 14px;
  margin: 17px auto 0;
  border-radius: 4px 4px 4px 0;
  border: 2px solid currentColor;
  opacity: 0.92;
  box-sizing: border-box;
}

.ch-tg-shell {
  width: min(288px, 92vw);
  max-height: 220px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.ch-tg-shell--embed {
  width: min(300px, 92%);
  flex-shrink: 0;
  max-height: none;
  min-height: 200px;
  border-radius: 12px;
  box-shadow: 0 14px 44px rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.ch-tg-shell--embed .ch-tg-scroll {
  min-height: 7.5rem;
}

.ch-tg-head {
  flex-shrink: 0;
  padding: 0.45rem 0.6rem;
  background: var(--tg-head-bg);
  color: var(--tg-head-fg);
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  line-height: 1.2;
}

.ch-tg-head-title {
  font-size: 0.82rem;
  font-weight: 600;
}

.ch-tg-head-sub {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--tg-head-muted);
}

.ch-tg-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0.45rem 0.5rem;
  background: var(--tg-body-bg);
  color: var(--tg-body-fg);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ch-tg-msg {
  max-width: 92%;
  padding: 0.38rem 0.55rem 0.45rem;
  font-size: 0.76rem;
  line-height: 1.35;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.ch-tg-msg p {
  margin: 0.12rem 0 0;
}

.ch-tg-msg-role {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ch-tg-msg--bot {
  align-self: flex-start;
  border-radius: 4px 12px 12px 12px;
  background: var(--tg-bot-bg);
  color: var(--tg-bot-fg);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.ch-tg-msg--bot .ch-tg-msg-role {
  color: var(--tg-bot-role);
}

.ch-tg-msg--user {
  align-self: flex-end;
  border-radius: 12px 4px 12px 12px;
  background: var(--tg-user-bg);
  color: var(--tg-user-fg);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.ch-tg-msg--user .ch-tg-msg-role {
  color: var(--tg-user-role);
}

.ch-tg-foot {
  flex-shrink: 0;
  padding: 0.42rem 0.55rem;
  font-size: 0.72rem;
  background: var(--tg-foot-bg);
  color: var(--tg-foot-muted);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.ch-tg-input-ph {
  color: var(--tg-foot-muted);
}

.channel-preview-embed .ch-tg-launcher {
  display: none;
}

.channel-embed-block {
  margin-top: 0.85rem;
}

.channel-embed-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.channel-embed-code {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.75rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 14rem;
}

.channel-embed-code-inner {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: inherit;
  color: var(--text);
}

.stats-row-active {
  background: var(--studio-gold-wash);
}

.worker-thread-content {
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: 0.84rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 10rem;
  overflow: auto;
}

.color-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.color-field input[type="color"] {
  width: 100%;
  max-width: 8.5rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.worker-tools-row .tool-flag-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.worker-tools-row .tool-flag-label {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.handoff-panel .handoff-extra {
  margin-top: 0.5rem;
}

.studio-login-body .login-remember {
  flex-direction: row;
  align-items: center;
}

.studio-login-body .login-remember label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: rgba(244, 244, 241, 0.72);
}

.studio-login-body .login-remember input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  accent-color: #d4b896;
  flex: 0 0 auto;
}

.crm-snippet {
  margin: 0 0 0.75rem;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  border-radius: var(--studio-radius-md);
  background: var(--studio-input);
  border: 1px solid var(--studio-border);
}

.badge--danger {
  background: var(--studio-danger-wash);
  color: var(--studio-danger);
  border-color: var(--studio-danger-border);
}

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

.studio-nav a.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.nav-count {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.32rem;
  border-radius: 999px;
  background: var(--studio-gold);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.15rem;
  text-align: center;
}

.cabinet-tabbar {
  display: none;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1.1rem;
}

.content nav.settings-tabs a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text),
.content nav.settings-tabs a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):hover,
.content nav.settings-tabs a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text):focus {
  color: var(--studio-text-soft);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.content nav.settings-tabs a:not(.btn):hover {
  background: rgba(20, 22, 28, 0.04);
  color: var(--studio-text);
}

.content nav.settings-tabs a.active:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text) {
  color: var(--studio-gold);
  background: var(--studio-gold-wash);
  border-color: var(--studio-gold-border);
}

.crm-toolbar {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.crm-search input {
  width: 100%;
  border: 1px solid var(--studio-border);
  background: var(--studio-card);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  color: var(--studio-text);
}

.content nav.crm-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.content nav.crm-tabs a:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text) {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--studio-border);
  background: var(--studio-card);
  color: var(--studio-text-soft);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}

.content nav.crm-tabs a.active:not(.btn),
.content nav.crm-tabs a:not(.btn):hover {
  color: var(--studio-text);
  border-color: var(--studio-gold-border);
  text-decoration: none;
}

.content nav.crm-tabs a.active:not(.btn) {
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
}

.crm-tab-count {
  color: var(--studio-text-muted);
  font-variant-numeric: tabular-nums;
}

.crm-filter-wrap {
  position: relative;
  justify-self: end;
}

.crm-filter-pop > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--studio-border);
  background: var(--studio-card);
  color: var(--studio-text);
  font-size: 0.85rem;
  font-weight: 500;
}

.crm-filter-pop > summary::-webkit-details-marker {
  display: none;
}

.crm-filter-pop[open] > summary {
  border-color: var(--studio-gold-border);
  color: var(--studio-gold);
}

.crm-filter-form {
  display: none;
}

.crm-filter-pop[open] .crm-filter-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  z-index: 6;
  width: min(36rem, 70vw);
  padding: 0.9rem;
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-lg);
  box-shadow: 0 12px 32px rgba(20, 22, 28, 0.08);
}

.crm-filter-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
}

.crm-list {
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-xl);
  overflow: hidden;
}

.content a.crm-row:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text) {
  display: grid;
  grid-template-columns: 40px minmax(0, 1.15fr) minmax(0, 2fr) auto auto;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--studio-border);
  color: var(--studio-text);
  text-decoration: none;
}

.content a.crm-row:not(.btn):hover {
  background: rgba(154, 123, 82, 0.06);
  text-decoration: none;
}

.crm-rows a.crm-row:last-child {
  border-bottom: 0;
}

.crm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.crm-avatar--lg {
  width: 48px;
  height: 48px;
  font-size: 0.9rem;
}

.crm-who {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.crm-who__name {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.crm-who__contact,
.crm-side__contact {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  color: var(--studio-text-muted);
  font-size: 0.82rem;
}

.crm-who__contact span,
.crm-row__summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-row__summary {
  color: var(--studio-text-muted);
  font-size: 0.875rem;
}

.crm-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}

.crm-channel::before {
  content: "·";
  margin-right: 0.35rem;
}

.crm-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--studio-gold);
  box-shadow: 0 0 0 3px var(--studio-gold-wash);
}

.crm-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.crm-pill--new {
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
  border-color: var(--studio-gold-border);
}

.crm-pill--work {
  background: rgba(59, 110, 165, 0.12);
  color: #3b6ea5;
}

.crm-pill--ok {
  background: rgba(58, 125, 84, 0.12);
  color: #3a7d54;
}

.crm-pill--no {
  background: var(--studio-muted-badge-bg);
  color: var(--studio-text-muted);
}

[data-theme="dark"] .crm-pill--work {
  color: #9ec0e6;
  background: rgba(142, 180, 224, 0.16);
}

[data-theme="dark"] .crm-pill--ok {
  color: #9ed4b0;
  background: rgba(141, 202, 164, 0.16);
}

.crm-row__time {
  color: var(--studio-text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.crm-list__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.75rem 1rem 0.9rem;
}

.crm-list__foot p {
  margin: 0;
}

.crm-pager {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

.crm-demo-note,
.crm-empty {
  margin: 0;
}

.crm-back {
  margin: 0 0 0.75rem;
}

.crm-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 24rem);
  gap: 1rem;
  align-items: start;
}

.crm-chat,
.crm-side {
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-xl);
  padding: 1rem 1.1rem 1.15rem;
}

.crm-chat__head h2,
.crm-side__name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.crm-chat__head p,
.crm-side__head p {
  margin: 0.2rem 0 0;
}

.crm-side__head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.crm-side__contact {
  margin: 0 0 0.75rem;
  color: var(--studio-text);
  font-weight: 500;
}

.crm-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.crm-actions .btn {
  width: 100%;
  min-height: 2.4rem;
  padding: 0 0.4rem;
  font-size: 0.82rem;
  gap: 0.35rem;
}

.crm-actions .crm-icon {
  width: 0.95rem;
  height: 0.95rem;
}

html.js .crm-status-save {
  display: none;
}

.crm-status {
  margin-bottom: 0.85rem;
}

.crm-status-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.6rem;
  padding: 0 2rem 0 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--studio-radius-md);
  background: var(--studio-muted-badge-bg);
  color: var(--studio-text-muted);
}

.crm-status-field.crm-tone--new {
  background: var(--studio-gold-wash);
  color: var(--studio-gold);
  border-color: var(--studio-gold-border);
}

.crm-status-field.crm-tone--work {
  background: rgba(59, 110, 165, 0.12);
  color: #3b6ea5;
  border-color: rgba(59, 110, 165, 0.35);
}

.crm-status-field.crm-tone--ok {
  background: rgba(58, 125, 84, 0.12);
  color: #3a7d54;
  border-color: rgba(58, 125, 84, 0.35);
}

.crm-status-field.crm-tone--no {
  background: var(--studio-muted-badge-bg);
  color: var(--studio-text-muted);
  border-color: var(--studio-border-strong);
}

[data-theme="dark"] .crm-status-field.crm-tone--work {
  color: #9ec0e6;
  background: rgba(142, 180, 224, 0.16);
  border-color: rgba(142, 180, 224, 0.4);
}

[data-theme="dark"] .crm-status-field.crm-tone--ok {
  color: #9ed4b0;
  background: rgba(141, 202, 164, 0.16);
  border-color: rgba(141, 202, 164, 0.4);
}

.crm-status-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.crm-status-field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0.45rem 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  background-image: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
}

.crm-status-field select::-ms-expand {
  display: none;
}

.crm-status-field select:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}

.crm-status-field .crm-chevron {
  position: absolute;
  right: 0.7rem;
  width: 1rem;
  height: 1rem;
  color: currentColor;
  pointer-events: none;
}

[data-theme="dark"] .crm-tone--work { color: #9ec0e6; }
[data-theme="dark"] .crm-tone--ok { color: #9ed4b0; }

.crm-note textarea {
  width: 100%;
  min-height: 5.4rem;
  font: inherit;
  color: var(--studio-text);
  background: var(--studio-input);
  border: 1px solid var(--studio-border-strong);
  border-radius: var(--studio-radius-md);
  padding: 0.7rem 0.85rem;
  resize: vertical;
}

.crm-note textarea::placeholder {
  color: var(--studio-text-faint);
}

.crm-status .crm-status-save {
  margin-top: 0.5rem;
}

.crm-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--studio-text-muted);
}

.crm-kicker--gold {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--studio-gold);
}

.crm-acc {
  margin-top: 1rem;
}

.crm-acc > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  list-style: none;
  cursor: pointer;
  color: var(--studio-text);
}

.crm-acc > summary::-webkit-details-marker {
  display: none;
}

.crm-acc > summary::marker {
  content: "";
}

.crm-acc__title {
  font-weight: 600;
}

.crm-acc__sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--studio-text-faint);
}

.crm-acc > summary .crm-chevron {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  color: var(--studio-text-muted);
  transition: transform 0.15s ease;
}

.crm-acc[open] > summary .crm-chevron {
  transform: rotate(180deg);
}

.crm-acc--more {
  border-top: 1px solid var(--studio-border);
  padding-top: 0.9rem;
}

.crm-summary-box {
  background: var(--studio-gold-wash);
  border-radius: var(--studio-radius-lg);
  padding: 0.85rem 1rem;
  color: var(--studio-text-soft);
  line-height: 1.55;
}

.crm-summary-box .crm-summary,
.crm-note-block .crm-summary {
  margin: 0;
  white-space: pre-wrap;
}

.crm-note-block .crm-desk-label {
  margin-bottom: 0.45rem;
}

.crm-note {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.crm-kv {
  margin-top: 0.7rem;
}

.crm-history {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.crm-history p {
  margin: 0.2rem 0 0;
}

.crm-thread {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.crm-day {
  margin: 0.85rem 0 0.45rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--studio-text-muted);
}

.crm-bubble {
  max-width: min(100%, 34rem);
  padding: 0.7rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--studio-border);
  background: var(--studio-bg);
}

.crm-bubble--visitor {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}

.crm-bubble--agent {
  align-self: flex-end;
  background: var(--studio-gold-wash);
  border-color: var(--studio-gold-border);
  border-bottom-right-radius: 6px;
}

.crm-bubble__text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.crm-bubble__meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--studio-text-muted);
}

.crm-system,
.crm-chat__hint {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--studio-text-muted);
}

.crm-search input:focus-visible,
.crm-status select:focus-visible,
.crm-note textarea:focus-visible,
.crm-filter-form select:focus-visible,
.crm-filter-form input:focus-visible,
.crm-filter-pop > summary:focus-visible,
.content a.crm-row:focus-visible,
.content nav.crm-tabs a:focus-visible,
.content nav.settings-tabs a:focus-visible,
.studio-nav a:focus-visible,
.cabinet-tabbar a:focus-visible,
.crm-actions a:focus-visible,
.crm-acc > summary:focus-visible {
  outline: 2px solid var(--studio-gold);
  outline-offset: 2px;
}

.crm-status-field select:focus,
.crm-status-field select:focus-visible {
  outline: none;
}

.crm-status-field:focus-within {
  outline: 2px solid var(--studio-gold);
  outline-offset: 2px;
}

.crm-only-mobile {
  display: none;
}

.crm-summary-box.crm-only-desk,
.crm-note-block.crm-only-desk {
  margin-top: 1.05rem;
}

@media (min-width: 721px) {
  .crm-acc--more {
    margin-top: 1.05rem;
  }
}

@media (max-width: 720px) {
  [data-surface="cabinet"] .app-shell {
    grid-template-columns: 1fr;
  }

  [data-surface="cabinet"] .sidebar {
    min-height: 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-right: 0;
    border-bottom: 1px solid var(--studio-border);
  }

  [data-surface="cabinet"] .studio-brand {
    margin: 0;
  }

  [data-surface="cabinet"] .studio-brand__subtitle,
  [data-surface="cabinet"] .studio-nav,
  [data-surface="cabinet"] .studio-account-chip__org,
  [data-surface="cabinet"] .studio-account-chip__email {
    display: none;
  }

  [data-surface="cabinet"] .studio-sidebar-footer {
    margin: 0;
    padding: 0;
    border: 0;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
  }

  [data-surface="cabinet"] .studio-account-chip {
    width: auto;
    padding: 0;
  }

  [data-surface="cabinet"] .content {
    padding: 1rem 0.85rem 5.6rem;
  }

  .cabinet-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: var(--studio-sidebar);
    border-top: 1px solid var(--studio-border);
    padding: 0.2rem 0.15rem calc(0.25rem + env(safe-area-inset-bottom));
  }

  .cabinet-tabbar a {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-width: 0;
    padding: 0.28rem 0.1rem;
    border-radius: 10px;
    color: var(--studio-text-muted);
    text-decoration: none;
    font-size: 0.62rem;
    line-height: 1.15;
    text-align: center;
  }

  .cabinet-tabbar a.active {
    color: var(--studio-gold);
    font-weight: 600;
  }

  .tab-ico {
    position: relative;
    display: inline-flex;
  }

  .tab-ico svg {
    width: 1.35rem;
    height: 1.35rem;
  }

  .cabinet-tabbar .nav-count {
    position: absolute;
    top: -0.35rem;
    right: -0.55rem;
    min-width: 0.95rem;
    height: 0.95rem;
    line-height: 0.95rem;
    font-size: 0.58rem;
  }

  .crm-toolbar {
    grid-template-columns: 1fr auto;
  }

  .content nav.crm-tabs {
    grid-column: 1 / -1;
  }

  .crm-filter-pop[open] .crm-filter-form {
    position: static;
    width: auto;
    margin-top: 0.45rem;
    grid-template-columns: 1fr;
  }

  .content a.crm-row:not(.btn):not(.btn-primary):not(.btn-danger):not(.link-gold):not(.link-text) {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    grid-template-areas:
      "avatar name time"
      "avatar contact contact"
      "avatar summary summary"
      "avatar pill pill";
  }

  .crm-avatar { grid-area: avatar; }
  .crm-who__name { grid-area: name; }
  .crm-row__time { grid-area: time; justify-self: end; }
  .crm-who__contact { grid-area: contact; }
  .crm-row__summary { grid-area: summary; }
  .crm-row .crm-pill { grid-area: pill; }
  .crm-who { display: contents; }

  .crm-layout {
    display: flex;
    flex-direction: column;
  }

  .crm-side {
    order: -1;
  }

  .crm-only-desk {
    display: none;
  }

  .crm-only-mobile {
    display: block;
    border-top: 1px solid var(--studio-border);
    padding-top: 0.85rem;
    margin-top: 0.85rem;
  }
}


