/* Balance CRM · Liquid Glass. The application owns state; this layer owns presentation. */
:root {
  --bg: #070a10;
  --rail: rgba(15, 21, 33, 0.88);
  --surface: rgba(22, 30, 45, 0.84);
  --surface2: rgba(30, 41, 60, 0.72);
  --input: rgba(7, 12, 22, 0.5);
  --line: rgba(170, 197, 243, 0.14);
  --text: #edf3ff;
  --muted: #a4b2c8;
  --blue: #8bc1ff;
  --accent: #79b8ff;
  --green: #8bdfbf;
  --amber: #efc98b;
  --red: #ffa7b7;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --radius: 20px;
  --radius-control: 12px;
  --sidebar-width: 228px;
  --duration: 220ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --glow: 0 5px 24px rgba(75, 145, 242, 0.2);
  color-scheme: dark;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}
html {
  min-width: 320px;
  background: var(--bg);
}
body {
  background:
    radial-gradient(ellipse at 8% 0%, rgba(48, 91, 166, 0.15), transparent 800px),
    radial-gradient(ellipse at 95% 65%, rgba(62, 68, 136, 0.07), transparent 700px), var(--bg);
}
* {
  scrollbar-width: thin;
  scrollbar-color: #35435b transparent;
}
::selection {
  background: rgba(121, 184, 255, 0.3);
  color: var(--text);
}
button,
a,
summary,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button,
input,
select,
textarea {
  transition:
    background-color var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}
input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--input);
  min-height: 46px;
  padding: 11px 13px;
}
input::placeholder,
textarea::placeholder {
  color: #8d9db6;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(121, 184, 255, 0.12);
}
input[type='checkbox'],
input[type='radio'] {
  min-height: 20px;
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
input:disabled,
select:disabled,
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
h1 {
  font-size: clamp(25px, 2.4vw, 34px);
  font-weight: 650;
  letter-spacing: -0.045em;
}
h2 {
  font-weight: 620;
  letter-spacing: -0.025em;
}
h3 {
  font-weight: 600;
}
small {
  color: var(--muted);
}
.skip-link {
  position: fixed;
  z-index: 100;
  top: -70px;
  left: 24px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #081525;
  text-decoration: none;
}
.skip-link:focus {
  top: 18px;
}
.app-shell {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  min-height: 100dvh;
  transition: grid-template-columns 300ms var(--ease);
}
.app-rail {
  width: auto;
  height: calc(100dvh - 32px);
  position: sticky;
  top: 16px;
  padding: 22px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--rail);
  align-items: stretch;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  min-height: 42px;
  flex-shrink: 0;
  border-radius: 14px;
  background: linear-gradient(145deg, #a4d2ff, #6ca7f1);
  color: #0b1a30;
  border: 1px solid rgba(180, 215, 255, 0.45);
  font-size: 31px;
  box-shadow: var(--glow);
}
.rail-brand-copy {
  min-width: 0;
  white-space: nowrap;
}
.rail-brand-copy strong {
  display: block;
  font-size: 16px;
  letter-spacing: -0.025em;
}
.rail-brand-copy small {
  display: block;
  font-size: 11px;
  margin-top: 4px;
}
.rail-caption {
  margin: 34px 14px 14px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.app-rail nav {
  margin-top: 0;
  gap: 5px;
}
.app-rail nav .btn {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 550;
  text-align: left;
}
.app-rail nav .btn svg {
  width: 19px;
  height: 19px;
}
.app-rail nav .btn:hover {
  background: rgba(121, 184, 255, 0.06);
  color: var(--text);
}
.app-rail nav .btn.active {
  color: #b6d9ff;
  background: linear-gradient(100deg, rgba(121, 184, 255, 0.15), rgba(121, 184, 255, 0.04));
  box-shadow:
    inset 2px 0 0 var(--accent),
    inset 0 0 0 1px rgba(121, 184, 255, 0.14);
}
.rail-foot {
  border-top: 1px solid var(--line);
  margin-top: auto;
  padding: 18px 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.rail-profile {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.rail-profile-copy {
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-profile-copy small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
}
.sidebar-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(121, 184, 255, 0.04);
  display: grid;
  place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}
.sidebar-toggle svg {
  width: 16px;
  height: 16px;
}
html[data-sidebar='collapsed'] {
  --sidebar-width: 80px;
}
html[data-sidebar='collapsed'] .rail-brand-copy,
html[data-sidebar='collapsed'] .rail-caption,
html[data-sidebar='collapsed'] .rail-profile-copy,
html[data-sidebar='collapsed'] .app-rail nav .btn span {
  display: none;
}
html[data-sidebar='collapsed'] .rail-brand {
  padding: 0;
  justify-content: center;
}
html[data-sidebar='collapsed'] .app-rail nav {
  margin-top: 32px;
}
html[data-sidebar='collapsed'] .app-rail nav .btn {
  justify-content: center;
  padding: 12px;
}
html[data-sidebar='collapsed'] .rail-foot {
  flex-direction: column;
  padding-left: 0;
  padding-right: 0;
}
html[data-sidebar='collapsed'] .sidebar-toggle svg {
  transform: rotate(180deg);
}
.app-main {
  min-width: 0;
}
.app-header {
  height: 72px;
  gap: 14px;
  padding: 0 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(19, 26, 40, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  top: 16px;
}
.header-brand {
  font-size: 13px;
  letter-spacing: 0.12em;
}
.header-brand span {
  font-size: 11px;
}
.cabinet-switch {
  margin-left: 8px;
}
.cabinet-switch .btn {
  min-height: 34px;
  font-size: 11px;
  padding: 8px 10px;
}
.user-switch select {
  min-height: 38px;
  max-width: 140px;
  background: var(--input);
  border-radius: 10px;
}
.avatar {
  border-color: rgba(121, 184, 255, 0.24);
  background: linear-gradient(140deg, #233c62, #182944);
  color: #c8e2ff;
}
.entity-nav {
  background: transparent;
  border-bottom: 1px solid var(--line);
  margin-top: 12px;
  padding: 8px 6px 14px;
  gap: 6px;
}
.entity-nav .btn {
  font-size: 13px;
  min-height: 42px;
  border-radius: 12px;
  padding: 9px 14px;
}
.entity-nav .btn.active {
  background: rgba(121, 184, 255, 0.1);
  color: #c0deff;
  box-shadow: inset 0 0 0 1px rgba(121, 184, 255, 0.12);
}
.entity-nav .btn:hover {
  background: rgba(121, 184, 255, 0.05);
}
.main-content,
.canvas-main {
  padding: 30px 6px 120px;
}
.main-content.settings-main {
  padding: 24px 0 0;
}
.page-heading {
  margin-bottom: 26px;
}
.page-heading p {
  margin-top: 8px;
}
.eyebrow {
  color: var(--blue);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 10px;
}
.btn {
  min-height: 44px;
  border-radius: var(--radius-control);
  background: rgba(121, 184, 255, 0.055);
  border-color: var(--line);
  color: #d8e5fa;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
}
.btn:hover {
  background: rgba(121, 184, 255, 0.1);
  border-color: rgba(121, 184, 255, 0.3);
}
.btn:active:not(:disabled),
.brand-mark:active {
  transform: scale(0.98);
}
.btn.primary {
  color: #071627;
  background: linear-gradient(145deg, #9acbff, #79b8ff);
  border-color: rgba(190, 221, 255, 0.5);
  box-shadow: var(--glow);
  font-weight: 650;
}
.btn.primary:hover {
  background: #afd6ff;
  box-shadow: 0 5px 28px rgba(75, 145, 242, 0.3);
}
.btn.danger {
  color: var(--red);
  background: rgba(246, 152, 168, 0.07);
  border-color: rgba(246, 152, 168, 0.23);
}
.btn.danger:hover {
  background: rgba(246, 152, 168, 0.13);
}
.btn.icon-btn {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 10px;
  border-radius: 12px;
}
.btn.link {
  min-height: 0;
  color: #a4ceff;
  background: none;
}
.btn.subtle {
  background: none;
}
.pill {
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(121, 184, 255, 0.09);
  border: 1px solid rgba(121, 184, 255, 0.12);
  color: #afd2ff;
}
.pill.green {
  color: var(--green);
  background: rgba(113, 215, 178, 0.08);
  border-color: rgba(113, 215, 178, 0.16);
}
.pill.amber {
  color: var(--amber);
  background: rgba(234, 192, 130, 0.08);
  border-color: rgba(234, 192, 130, 0.16);
}
.pill.demo {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
  font-size: 9px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 26px;
}
.metric-card {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(30, 44, 66, 0.8), rgba(20, 28, 42, 0.72));
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  min-width: 0;
}
.metric-card > div {
  min-width: 0;
}
.metric-card span {
  color: var(--muted);
  font-size: 12px;
}
.metric-card strong {
  display: block;
  font-size: clamp(22px, 2vw, 30px);
  letter-spacing: -0.04em;
  font-weight: 600;
  margin: 12px 0 8px;
  overflow-wrap: anywhere;
}
.metric-card small {
  font-size: 11px;
}
.metric-card > svg {
  box-sizing: content-box;
  width: 18px;
  height: 18px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(121, 184, 255, 0.07);
  color: var(--blue);
}
.search {
  border-color: var(--line);
  background: var(--input);
  border-radius: 12px;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(121, 184, 255, 0.12);
}
.search input {
  min-height: 44px;
}
.segment,
.entity-tabs {
  background: rgba(7, 12, 22, 0.45);
  border-color: var(--line);
  border-radius: 13px;
}
.segment .btn,
.entity-tabs .btn {
  border-radius: 10px;
}
.segment .btn.active,
.entity-tabs .btn.active {
  background: rgba(121, 184, 255, 0.13);
  color: #c8e1ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.board {
  gap: 14px;
  grid-template-columns: repeat(var(--columns), minmax(214px, 1fr));
  padding-bottom: 18px;
}
.board-column {
  padding: 18px 12px 12px;
  border: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 28, 42, 0.62);
  min-height: 410px;
}
.board-column > header {
  padding-left: 2px;
  font-size: 12px;
  font-weight: 650;
}
.board-column > header::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--stage);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--stage) 10%, transparent);
}
.board-column > header > span:first-of-type {
  flex: 1;
}
.column-total {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
  margin-bottom: 18px;
}
.record-tile {
  background: linear-gradient(140deg, rgba(33, 47, 69, 0.92), rgba(25, 35, 53, 0.9));
  border-color: var(--line);
  border-radius: 14px;
  padding: 17px 15px;
  margin-bottom: 12px;
  box-shadow:
    0 5px 16px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.record-tile h3 {
  font-weight: 550;
  margin-bottom: 15px;
}
.record-tile strong {
  color: #c5e0ff;
  font-size: 16px;
  letter-spacing: -0.025em;
  font-weight: 600;
}
.record-tile p {
  color: var(--muted);
}
.record-tile:hover {
  border-color: rgba(121, 184, 255, 0.4);
  background: rgba(35, 51, 76, 0.94);
  box-shadow: 0 9px 24px rgba(0, 0, 0, 0.2);
}
.btn.column-add {
  min-height: 44px;
  border-color: var(--line);
  border-radius: 12px;
  font-size: 12px;
  color: var(--muted);
}
.table-wrap,
.record-panel,
.pipeline-card,
.integration-card,
.bot-card,
.api-playground,
.data-cards section,
.task-card,
.quote-main,
.quote-catalog,
.manager-home-grid > section,
.cabinet-cards > article {
  background: var(--surface);
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.record-panel {
  padding: 26px;
}
th {
  background: rgba(26, 37, 56, 0.92);
  color: var(--muted);
  font-weight: 550;
  border-color: var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
td {
  border-color: rgba(170, 197, 243, 0.08);
}
tbody tr {
  transition: background-color var(--duration) var(--ease);
}
tbody tr:hover {
  background: rgba(121, 184, 255, 0.045);
}
.empty {
  padding: 32px 18px;
  color: var(--muted);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  white-space: normal;
}
.empty > svg {
  width: 26px;
  height: 26px;
  padding: 14px;
  box-sizing: content-box;
  color: #8db8ed;
  background: rgba(121, 184, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.empty strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
}
.empty p {
  max-width: 340px;
  font-size: 12px;
}
.stage-ribbon {
  gap: 6px;
}
.stage-ribbon .btn {
  background: rgba(121, 184, 255, 0.04);
  border-radius: 12px;
  border: 1px solid var(--line);
  min-height: 44px;
}
.stage-ribbon .btn.active {
  background: rgba(121, 184, 255, 0.13);
  border-color: rgba(121, 184, 255, 0.4);
  color: #cee5ff;
  box-shadow: 0 4px 16px rgba(64, 139, 247, 0.08);
}
.form-group h3,
.divider,
.section {
  border-color: var(--line);
}
.control > span,
.event p,
.event .metadata,
.event-head time,
.trace-row > span,
.trace-caption,
.note-composer > div,
.trace,
.quote-policy,
.quote-table small {
  color: var(--muted);
}
.control {
  margin-bottom: 22px;
}
.record-field .field-cog {
  min-height: 30px;
  width: 30px;
  height: 30px;
  padding: 6px;
}
.tabs {
  gap: 20px;
  border-color: var(--line);
}
.tabs .btn {
  border-radius: 0;
  background: none;
  min-height: 44px;
}
.tabs .btn.active {
  color: #c4e0ff;
  border-bottom-color: var(--accent);
}
.task-row {
  background: rgba(113, 215, 178, 0.05);
  border-color: rgba(113, 215, 178, 0.18);
  border-radius: 14px;
}
.task-row.done {
  background: rgba(121, 184, 255, 0.03);
  border-color: var(--line);
}
.task-check {
  min-height: 36px;
  width: 36px;
  height: 36px;
}
.event-symbol {
  border-radius: 10px;
  background: rgba(121, 184, 255, 0.1);
  color: var(--blue);
}
.event-symbol.auto {
  background: rgba(113, 215, 178, 0.08);
  color: var(--green);
}
.event-symbol.error {
  background: rgba(246, 152, 168, 0.09);
  color: var(--red);
}
details,
.readonly-value,
.note-composer,
.field-preview,
.queue-row {
  background: rgba(12, 19, 31, 0.6);
  border-color: var(--line);
  border-radius: 14px;
}
.trace {
  border-color: var(--line);
}
summary {
  min-height: 44px;
}
.chat-bubble {
  background: rgba(121, 184, 255, 0.09);
  border-color: rgba(121, 184, 255, 0.18);
}
.chat-bubble.from-client {
  background: rgba(135, 148, 186, 0.12);
}
.settings-layout {
  gap: 20px;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: calc(100dvh - 130px);
}
.settings-nav {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  padding: 22px 10px;
  top: 104px;
  height: auto;
  max-height: calc(100dvh - 124px);
  box-shadow: var(--shadow);
}
.settings-nav h2 {
  font-size: 16px;
  margin-bottom: 16px;
  padding-bottom: 18px;
  border-color: var(--line);
}
.settings-nav > .btn {
  border-radius: 12px;
  min-height: 44px;
  font-size: 12px;
  padding: 11px 12px;
  color: var(--muted);
}
.settings-nav > .btn.active {
  color: #c5e1ff;
  background: rgba(121, 184, 255, 0.11);
  box-shadow: inset 2px 0 var(--accent);
}
.settings-nav > .btn svg {
  color: inherit;
}
.settings-note p {
  color: var(--muted);
}
.settings-content {
  padding: 8px 8px 120px;
}
.settings-form section {
  border-color: var(--line);
}
.integration-card {
  padding: 24px;
}
.service-mark,
.bot-badge,
.catalog-icon {
  background: rgba(121, 184, 255, 0.08);
  border-color: rgba(121, 184, 255, 0.2);
  border-radius: 14px;
  color: var(--blue);
}
.integration-card .btn {
  display: flex;
}
.manager-stats > button {
  background: linear-gradient(140deg, rgba(34, 49, 73, 0.8), rgba(20, 28, 42, 0.8));
  border-color: var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.manager-stats strong {
  font-size: 34px;
  color: #d4e8ff;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.manager-stats small,
.manager-deal small,
.cabinet-cards p,
.cabinet-cards li,
.permission-summary > div {
  color: var(--muted);
}
.manager-deal {
  border-color: var(--line);
  border-radius: 10px;
}
.manager-deal:hover {
  background: rgba(121, 184, 255, 0.04);
}
.deal-total {
  background: rgba(121, 184, 255, 0.08);
  border-color: var(--line);
  color: #c8e4ff;
}
.quote-summary .quote-grand-total {
  border-color: var(--line);
}
.mini-stages > span {
  background: rgba(121, 184, 255, 0.04);
}
.pipeline-sheet,
.bot-workspace {
  border-color: var(--line);
  border-radius: 18px;
  background: rgba(13, 20, 32, 0.6);
}
.sheet-header {
  background: #162033;
  border-right-color: var(--line);
}
.sheet-header > small,
.sheet-header > span,
.sheet-row-number {
  color: var(--muted);
}
.sheet-row-number,
.sheet-corner {
  background: #111a29;
  border-color: var(--line);
}
.sheet-cell {
  border-color: var(--line);
}
.sheet-cell:hover {
  background: rgba(121, 184, 255, 0.04);
}
.sheet-cell .automation-block,
.flow-node {
  background: linear-gradient(140deg, rgba(35, 49, 73, 0.98), rgba(21, 31, 48, 0.98));
  border-color: rgba(121, 184, 255, 0.2);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.empty-cell {
  border-color: var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
}
.empty-cell:hover {
  background: rgba(121, 184, 255, 0.06);
}
.node-editor {
  background: rgba(18, 27, 42, 0.95);
  border-color: var(--line);
}
.info {
  background: rgba(121, 184, 255, 0.06);
  border-color: rgba(121, 184, 255, 0.17);
  color: #b7cce8;
  border-radius: 14px;
}
.success-info {
  background: rgba(113, 215, 178, 0.06);
  border-color: rgba(113, 215, 178, 0.18);
}
.drawer-backdrop {
  background: rgba(3, 6, 12, 0.65);
  backdrop-filter: blur(5px);
  animation: glass-fade-in 200ms var(--ease);
}
.drawer,
.modal {
  background: rgba(22, 31, 48, 0.94);
  border: 1px solid rgba(180, 205, 255, 0.2);
  border-radius: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.drawer {
  animation: glass-drawer-in 280ms var(--ease);
}
.drawer > header {
  padding: 26px;
}
.drawer > footer {
  background: rgba(121, 184, 255, 0.035);
  border-color: var(--line);
}
.modal {
  padding: 32px;
  animation: glass-modal-in 240ms var(--ease);
}
.modal::backdrop {
  background: rgba(3, 6, 12, 0.65);
  backdrop-filter: blur(5px);
  animation: glass-fade-in 200ms var(--ease);
}
.modal-close {
  top: 12px;
  right: 12px;
}
.modal-actions {
  flex-wrap: wrap;
}
.field-preview input,
.field-preview select {
  background: var(--input);
}
.action-choice.btn {
  border-radius: 14px;
}
.floating-bar {
  left: calc(50% + var(--sidebar-width) / 2);
  transform: translateX(-50%);
  right: auto;
  bottom: 22px;
  max-width: calc(100vw - var(--sidebar-width) - 80px);
  border-color: rgba(170, 197, 243, 0.22);
  border-radius: 18px;
  background: rgba(25, 36, 54, 0.9);
  box-shadow: var(--shadow);
  gap: 24px;
}
.fab-wrap {
  right: 28px;
  bottom: 26px;
}
.fab {
  border-color: rgba(170, 210, 255, 0.4);
  background: linear-gradient(145deg, #9acbff, #79b8ff);
  color: #081525;
  border-radius: 18px;
  box-shadow: var(--glow);
}
.fab-menu {
  background: rgba(22, 31, 48, 0.94);
  border-color: var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.fab-menu .btn {
  border-radius: 12px;
}
.toast {
  left: calc(50% + var(--sidebar-width) / 2);
  max-width: min(640px, calc(100vw - var(--sidebar-width) - 60px));
  background: rgba(24, 37, 55, 0.96);
  border-color: rgba(170, 197, 243, 0.24);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: glass-enter 250ms var(--ease);
}
.toast .btn {
  min-height: 36px;
  width: 36px;
  height: 36px;
}
.view-enter {
  animation: glass-enter 300ms var(--ease);
}
.glass-leaving {
  pointer-events: none;
  animation: glass-exit 160ms var(--ease) forwards !important;
}
.mobile-menu-toggle,
.mobile-menu-backdrop,
.mobile-rail-close {
  display: none;
}
.boot-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 228px 1fr;
  gap: 16px;
  padding: 16px;
}
.boot-rail {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  padding: 24px;
}
.boot-main {
  padding: 24px;
}
.skeleton {
  border-radius: 12px;
  background: rgba(157, 188, 240, 0.1);
  animation: glass-pulse 1.1s ease-in-out infinite alternate;
}
.boot-rail .skeleton {
  height: 44px;
  margin-bottom: 20px;
}
.boot-heading {
  height: 46px;
  width: min(340px, 70%);
  margin-bottom: 26px;
}
.boot-card {
  height: 112px;
}
.boot-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.boot-board .skeleton {
  height: 290px;
}
@keyframes glass-enter {
  from {
    opacity: 0;
    translate: 0 7px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes glass-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes glass-modal-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(5px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
@keyframes glass-drawer-in {
  from {
    opacity: 0;
    translate: 16px 0;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes glass-exit {
  to {
    opacity: 0;
    translate: 0 4px;
  }
}
@keyframes glass-pulse {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}
@media (hover: hover) {
  .metric-card,
  .manager-stats > button,
  .integration-card {
    transition:
      transform var(--duration) var(--ease),
      border-color var(--duration) var(--ease);
  }
  .metric-card:hover,
  .manager-stats > button:hover,
  .integration-card:hover {
    transform: translateY(-2px);
    border-color: rgba(121, 184, 255, 0.32);
  }
}
@media (min-width: 1500px) {
  .main-content:not(.settings-main) {
    padding: 36px 16px 120px;
  }
  .settings-content {
    padding: 12px 24px 120px;
  }
}
@media (max-width: 1280px) {
  :root {
    --sidebar-width: 200px;
  }
  html[data-sidebar='collapsed'] {
    --sidebar-width: 80px;
  }
  .app-header {
    gap: 10px;
    padding: 0 16px;
  }
  .header-brand span,
  .user-switch > span {
    display: none;
  }
  .settings-layout {
    grid-template-columns: 196px minmax(0, 1fr);
    gap: 16px;
  }
  .settings-nav > .btn {
    font-size: 11px;
    padding: 10px;
  }
  .board {
    grid-template-columns: repeat(var(--columns), 230px);
  }
  .card-layout {
    grid-template-columns: minmax(260px, 0.85fr) minmax(300px, 1.15fr);
    gap: 20px;
  }
}
@media (max-width: 1000px) {
  :root {
    --sidebar-width: 80px;
  }
  .rail-brand-copy,
  .rail-caption,
  .rail-profile-copy,
  .app-rail nav .btn span {
    display: none;
  }
  .rail-brand {
    justify-content: center;
    padding: 0;
  }
  .app-rail nav {
    margin-top: 30px;
  }
  .app-rail nav .btn {
    justify-content: center;
    padding: 12px;
  }
  .rail-foot {
    flex-direction: column;
    padding-left: 0;
    padding-right: 0;
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-nav {
    display: flex;
    gap: 5px;
    padding: 10px;
    height: auto;
    position: static;
    max-height: none;
    overflow: auto;
  }
  .settings-nav h2,
  .settings-note {
    display: none;
  }
  .settings-nav > .btn {
    width: auto;
    flex-shrink: 0;
    white-space: nowrap;
    margin: 0;
  }
  .settings-nav > .btn.active {
    box-shadow: none;
  }
  .settings-content {
    padding: 12px 4px 120px;
  }
  .card-layout {
    grid-template-columns: 1fr;
  }
  .floating-bar > span {
    display: none;
  }
}
@media (max-width: 760px) {
  :root,
  html[data-sidebar='collapsed'] {
    --sidebar-width: 0px;
  }
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
    gap: 0;
  }
  .app-rail {
    position: fixed;
    inset: 12px auto 12px 12px;
    top: 12px;
    width: 252px;
    height: calc(100dvh - 24px);
    z-index: 42;
    flex-direction: column;
    overflow: auto;
    padding: 22px 12px 14px;
    border: 1px solid var(--line);
    transform: translateX(-280px);
    visibility: hidden;
    transition:
      transform 280ms var(--ease),
      visibility 280ms;
  }
  html[data-mobile-menu='open'] .app-rail {
    transform: translateX(0);
    visibility: visible;
  }
  .rail-brand-copy,
  html[data-sidebar='collapsed'] .rail-brand-copy,
  .rail-caption,
  html[data-sidebar='collapsed'] .rail-caption,
  .rail-profile-copy,
  html[data-sidebar='collapsed'] .rail-profile-copy,
  .app-rail nav .btn span,
  html[data-sidebar='collapsed'] .app-rail nav .btn span {
    display: block;
  }
  .rail-brand,
  html[data-sidebar='collapsed'] .rail-brand {
    padding: 0 8px;
    justify-content: flex-start;
  }
  .app-rail nav,
  html[data-sidebar='collapsed'] .app-rail nav {
    display: grid;
    width: 100%;
    margin-top: 0;
    gap: 5px;
  }
  .app-rail nav .btn,
  html[data-sidebar='collapsed'] .app-rail nav .btn {
    justify-content: flex-start;
    padding: 12px 14px;
    font-size: 13px;
  }
  .rail-foot,
  html[data-sidebar='collapsed'] .rail-foot {
    display: flex;
    flex-direction: row;
    padding: 18px 8px 0;
  }
  .sidebar-toggle {
    display: none;
  }
  .mobile-rail-close {
    display: grid;
    margin-left: auto;
  }
  .mobile-menu-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }
  html[data-mobile-menu='open'] .mobile-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 12, 0.65);
    backdrop-filter: blur(4px);
    z-index: 41;
    animation: glass-fade-in 200ms var(--ease);
  }
  .app-header {
    height: auto;
    min-height: 64px;
    padding: 10px 12px;
    position: sticky;
    top: 12px;
    gap: 8px;
    flex-wrap: wrap;
    border-radius: 18px;
  }
  .header-brand {
    font-size: 12px;
  }
  .app-header > .avatar,
  .app-header > .pill.demo {
    display: none;
  }
  .cabinet-switch {
    margin-left: 0;
    order: 5;
    width: 100%;
  }
  .cabinet-switch .btn {
    flex: 1;
    min-height: 38px;
    font-size: 11px;
  }
  .user-switch select {
    max-width: 108px;
    min-height: 40px;
    padding: 8px;
    font-size: 12px;
  }
  .entity-nav {
    padding: 6px 0 12px;
    gap: 4px;
  }
  .entity-nav .btn {
    font-size: 12px;
    padding: 9px 12px;
  }
  .main-content,
  .canvas-main {
    padding: 24px 0 115px;
  }
  .main-content.settings-main {
    padding: 20px 0 0;
  }
  .settings-content {
    padding: 10px 0 115px;
  }
  .metric-grid {
    gap: 8px;
    margin-bottom: 24px;
  }
  .metric-card {
    padding: 15px 12px;
    grid-template-columns: 1fr;
    gap: 0;
  }
  .metric-card > svg {
    display: none;
  }
  .metric-card strong {
    font-size: 20px;
    margin-top: 10px;
  }
  .metric-card span,
  .metric-card small {
    font-size: 10px;
  }
  .page-heading {
    gap: 14px;
  }
  .page-heading > .actions {
    width: 100%;
    justify-content: flex-start;
  }
  .search {
    min-width: 0;
    width: 100%;
  }
  .list-toolbar > .actions {
    width: 100%;
  }
  .list-toolbar select {
    max-width: 100%;
  }
  .list-toolbar > .actions > select {
    width: 100%;
  }
  .board {
    grid-template-columns: repeat(var(--columns), 250px);
  }
  .record-panel {
    padding: 20px;
  }
  .integration-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
  .floating-bar {
    left: 12px;
    right: 80px;
    bottom: 16px;
    transform: none;
    max-width: none;
    padding: 10px;
    justify-content: center;
  }
  .floating-bar .actions {
    width: 100%;
    justify-content: center;
  }
  .floating-bar .btn {
    width: 100%;
  }
  .fab-wrap {
    right: 16px;
    bottom: 19px;
  }
  .fab {
    width: 52px;
    height: 52px;
  }
  .toast {
    left: 12px;
    right: 12px;
    bottom: 86px;
    max-width: none;
    transform: none;
  }
  .drawer {
    inset: 8px;
    width: auto;
    max-width: none;
    border-radius: 20px;
  }
  .drawer > header {
    padding: 22px 20px;
  }
  .modal {
    width: calc(100vw - 24px);
    padding: 28px 20px;
  }
  .manager-home-grid,
  .cabinet-cards {
    grid-template-columns: 1fr;
  }
  .boot-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .boot-rail {
    display: none;
  }
  .boot-main {
    padding: 12px;
  }
}
@media (max-width: 420px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .metric-card {
    grid-template-columns: 1fr auto;
    padding: 18px;
  }
  .metric-card > svg {
    display: block;
  }
  .metric-card strong {
    font-size: 26px;
    margin: 8px 0;
  }
  .metric-card span,
  .metric-card small {
    font-size: 11px;
  }
  .manager-stats {
    grid-template-columns: 1fr;
  }
  .quote-bottom {
    display: block;
  }
  .quote-summary {
    min-width: 0;
    margin-top: 20px;
  }
  .header-brand {
    font-size: 10px;
  }
  .boot-board {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
.modal.glass-leaving::backdrop {
  animation: glass-exit 160ms var(--ease) forwards;
}
.table-sort.btn {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 12px;
  justify-content: flex-start;
  gap: 10px;
}
.table-sort.btn:hover {
  color: var(--blue);
}
.sort-indicator {
  color: var(--muted);
  font-size: 12px;
}
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 4px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}
.table-pagination .actions > span {
  padding: 0 8px;
}
.table-pagination .btn {
  font-size: 12px;
}

/* Preferences and compact working views. */
:root[data-theme='gray'] {
  --bg: #242629;
  --rail: #2c2f33;
  --surface: #32363b;
  --surface2: #3d4248;
  --input: #292c30;
  --line: #50565e;
  --text: #f0f2f5;
  --muted: #c0c6ce;
}
:root[data-theme='white'] {
  color-scheme: light;
  --bg: #f2f4f7;
  --rail: #ffffff;
  --surface: #ffffff;
  --surface2: #e9eef5;
  --input: #ffffff;
  --line: #ccd4e0;
  --text: #172438;
  --muted: #526176;
  --blue: #155bc0;
  --accent: #155bc0;
  --green: #16734d;
  --amber: #885b10;
  --red: #b82440;
  --shadow: 0 5px 20px #23334d12;
}
:root[data-theme='gray'] body,
:root[data-theme='white'] body {
  background: var(--bg);
}
:root[data-theme='gray']
  :is(
    .board-column,
    .record-tile,
    .section,
    .settings-nav,
    .record-panel,
    .record-history,
    .task-card,
    .event,
    .table-wrap,
    .modal,
    .drawer,
    .integration-card,
    .metric-card
  ),
:root[data-theme='white']
  :is(
    .board-column,
    .record-tile,
    .section,
    .settings-nav,
    .record-panel,
    .record-history,
    .task-card,
    .event,
    .table-wrap,
    .modal,
    .drawer,
    .integration-card,
    .metric-card
  ) {
  background: var(--surface);
  border-color: var(--line);
}
:root[data-theme='white']
  :is(
    .btn,
    .segment .btn.active,
    .entity-tabs .btn.active,
    .tile-footer,
    .record-tile strong,
    .readonly-value,
    .table-wrap th,
    .pill,
    .settings-nav > .btn,
    .linked-record,
    .event-head strong
  ) {
  color: var(--text);
}
:root[data-theme='white']
  :is(
    .app-header,
    .entity-nav,
    .tabs,
    .floating-bar,
    .drawer > header,
    .drawer > footer,
    .modal > header,
    .rail-foot,
    .table-wrap thead
  ) {
  background: var(--surface);
}
:root[data-theme='white'] .btn.primary {
  background: var(--accent);
  color: white;
}
:root[data-theme='white'] :is(input::placeholder, textarea::placeholder) {
  color: var(--muted);
}
:root[data-theme='white'] :is(.link, .settings-nav > .btn.active) {
  color: var(--accent);
}
.board {
  gap: 10px;
  grid-template-columns: repeat(var(--columns), minmax(190px, 1fr));
  height: clamp(280px, calc(100dvh - 330px), 900px);
  padding-bottom: 8px;
  align-items: stretch;
}
.board-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 10px 8px;
  border-radius: 12px;
}
.board-column > header,
.column-total,
.column-add {
  flex-shrink: 0;
}
.column-total {
  margin: 6px 3px 8px;
}
.stage-cards {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 2px 3px;
  scrollbar-gutter: stable;
}
.record-tile {
  padding: 10px;
  margin-bottom: 7px;
  border-radius: 10px;
}
.record-tile h3 {
  font-size: 13px;
  margin-bottom: 6px;
}
.record-tile p {
  margin: 5px 0 8px;
}
.record-tile:hover {
  transform: none;
}
.page-heading {
  margin-bottom: 16px;
}
.page-heading h1 {
  font-size: 24px;
}
.event {
  padding: 10px 0;
}
.event-head {
  gap: 8px;
}
.event-head strong {
  font-size: 13px;
}
.event-symbol {
  width: 28px;
  height: 28px;
}
.event-details {
  margin-top: 5px;
}
.event-details > summary {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.event-note {
  border-left: 3px solid var(--blue);
  padding-left: 8px;
}
.task-card {
  padding: 12px;
  gap: 10px;
  margin-bottom: 8px;
}
.task-card h3 {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.task-card p {
  font-size: 12px;
}
.task-week-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.task-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(170px, 1fr));
  gap: 10px;
  overflow-x: auto;
}
.task-day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}
.task-day > h3 {
  margin: 0 0 12px;
  font-size: 14px;
}
.task-day > h3 small {
  display: block;
  font-weight: normal;
  color: var(--muted);
  margin-top: 4px;
}
.task-calendar .task-card {
  flex-wrap: wrap;
}
.task-list {
  display: grid;
  gap: 10px;
}
.task-other {
  margin-top: 16px;
}
.task-other > summary {
  cursor: pointer;
  padding: 12px 0;
}
.audit-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.audit-filters .actions {
  grid-column: 1 / -1;
}
@media (max-width: 800px) {
  .audit-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .board {
    height: clamp(280px, calc(100dvh - 300px), 700px);
  }
}
@media (max-width: 480px) {
  .audit-filters {
    grid-template-columns: 1fr;
  }
  .task-week-nav .btn {
    font-size: 11px;
  }
}
.theme-switch select {
  max-width: 108px;
  min-height: 40px;
  padding: 8px;
  font-size: 12px;
}
:root[data-theme='white']
  :is(
    .rail-brand-copy,
    .rail-profile-copy,
    .app-rail nav .btn.active,
    .header-brand,
    .entity-nav .btn,
    .segment .btn,
    .tabs .btn,
    .settings-note,
    .form-group h3,
    .trace-row strong,
    .task-day h3,
    .event-head time,
    .tile-footer span
  ) {
  color: var(--text);
}
:root[data-theme='white']
  :is(
    .record-field,
    .quote-summary,
    .quote-item,
    .automation-block,
    .bot-node,
    .bot-toolbar,
    .pipeline-stage,
    .catalog-card,
    .settings-form section,
    .empty,
    .readonly-value,
    .task-day,
    .chat-bubble
  ) {
  background: var(--surface);
  border-color: var(--line);
}
:root[data-theme='gray'] :is(.app-header, .entity-nav, .floating-bar) {
  background: var(--rail);
}
:root[data-theme='white'] :is(.record-tile:hover, .btn:hover, .table-wrap tr:hover) {
  background: var(--surface2);
}

/* Shared surfaces make all application screens follow the user's palette. */
:root:is([data-theme='gray'], [data-theme='white'])
  :is(
    .segment,
    .entity-tabs,
    .table-wrap,
    .pipeline-card,
    .bot-card,
    .api-playground,
    .api-playground pre,
    .data-cards section,
    .quote-main,
    .quote-catalog,
    .manager-home-grid > section,
    .cabinet-cards > article,
    .manager-stats > button,
    .pipeline-sheet,
    .bot-workspace,
    .sheet-header,
    .sheet-corner,
    .sheet-row-number,
    .sheet-cell .automation-block,
    .flow-node,
    .node-editor,
    .drawer,
    .modal,
    .field-preview,
    .queue-row,
    .fab-menu,
    .toast,
    details,
    .note-composer,
    .bot-reply
  ) {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}
:root[data-theme='white']
  :is(
    .entity-nav .btn.active,
    .stage-ribbon .btn,
    .stage-ribbon .btn.active,
    .sheet-header .btn,
    .sheet-header > span,
    .flow-node h3,
    .flow-node p,
    .node-editor h3,
    .api-playground pre,
    .task-card strong,
    .quote-main strong,
    .catalog-card strong,
    .manager-stats strong,
    .manager-deal b,
    .fab-menu .btn,
    .toast,
    .drawer header,
    th
  ) {
  color: var(--text);
}
:root[data-theme='white'] :is(.info, .success-info) {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--line);
}
:root[data-theme='white'] :is(.sheet-cell:hover, .empty-cell:hover, .manager-deal:hover) {
  background: var(--surface2);
}
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-page form {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  padding: 28px;
  display: grid;
  gap: 16px;
}
.login-page h1 {
  font-size: 26px;
}
#login-error {
  color: var(--red);
  min-height: 20px;
}
.access-target {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0;
}
.access-matrix {
  max-height: 65dvh;
  overflow: auto;
  margin-bottom: 20px;
}
.access-matrix thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}
.access-matrix input {
  min-height: 0;
  width: 18px;
  height: 18px;
}
.access-matrix td:not(:first-child),
.access-matrix th:not(:first-child) {
  text-align: center;
}
.access-matrix td:first-child {
  min-width: 240px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 16px 0;
  padding: 16px;
}
fieldset legend {
  padding: 0 8px;
}
fieldset .check {
  margin: 8px 0;
}
.database-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.preview-banner {
  background: var(--surface2);
  border: 1px solid var(--amber);
  margin: 8px 24px;
  padding: 10px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.sync-bar {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.sync-error {
  color: var(--red);
}
[data-sync-recovery][hidden] {
  display: none;
}
.event-details .trace-row strong {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow: auto;
}
.pipeline-toolbar {
  padding: 8px 0;
}
.sheet-header {
  padding: 10px 12px;
}
.sheet-cell {
  min-height: 92px;
}
.settings-layout {
  align-items: start;
}
.settings-content {
  min-width: 0;
  overflow: visible;
}
@media (max-width: 600px) {
  .access-target {
    grid-template-columns: 1fr;
  }
  .preview-banner {
    margin: 8px 12px;
  }
  .sync-bar {
    padding: 4px 12px;
  }
  .btn-logout {
    padding: 8px;
    font-size: 11px;
  }
  .login-page form {
    padding: 20px;
  }
}
.metric-card {
  padding: 14px 16px;
}
.metric-grid {
  margin-bottom: 14px;
  gap: 10px;
}
.metric-card strong {
  font-size: 28px;
}
.board {
  height: clamp(240px, calc(100dvh - 410px), 900px);
}
.column-more {
  width: 100%;
  font-size: 12px;
  margin-bottom: 8px;
}
@media (max-width: 800px) {
  .board {
    height: clamp(240px, calc(100dvh - 360px), 650px);
  }
}

/* Long CRM values must stay inside their cards at every viewport width. */
body {
  overflow-wrap: anywhere;
}
:where(
  .app-main,
  .main-content,
  .settings-content,
  .record-panel,
  .timeline,
  .board-column,
  .stage-cards,
  .task-day,
  .table-wrap,
  .quote-main,
  .quote-catalog,
  .manager-home-grid > section,
  .cabinet-cards > article,
  .bot-card,
  .integration-card,
  .api-playground,
  .node-editor,
  .drawer,
  .modal
) {
  min-width: 0;
}
:where(
    .page-heading,
    .section-heading,
    .event-head,
    .task-row,
    .task-card,
    .bot-card,
    .catalog-items article,
    .manager-deal,
    .note-composer > div,
    .condition-result,
    .webhook-row,
    .queue-row,
    .tile-footer
  )
  > :where(div, span, strong, p) {
  min-width: 0;
}
:where(.control, input, select, textarea) {
  min-width: 0;
  max-width: 100%;
}
:where(
  h1,
  h2,
  h3,
  p,
  small,
  summary,
  .readonly-value,
  .metadata,
  .linked-record,
  .chat-bubble,
  .block-title,
  .block-condition,
  .sheet-header,
  .notification-item,
  .permission-summary,
  .trace-row
) {
  overflow-wrap: anywhere;
}
.btn {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.btn svg,
.avatar,
.catalog-icon,
.event-symbol,
.task-check {
  flex-shrink: 0;
}
.btn.link,
.linked-record {
  text-align: left;
}
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
th,
td {
  overflow-wrap: anywhere;
}
td .link {
  max-width: 100%;
}
.page-heading,
.section-heading,
.actions,
.tasks-head,
.note-composer > div,
.quote-bottom,
.quote-summary > div {
  flex-wrap: wrap;
}
.page-heading > div:first-child,
.section-heading > div:first-child {
  flex: 1 1 180px;
}
.task-card > div,
.task-row > div,
.bot-card > div:nth-child(2),
.catalog-items article > div:nth-child(2),
.manager-deal > span {
  flex: 1 1 0;
  min-width: 0;
}
.task-card > .pill {
  flex-shrink: 0;
}
.tile-footer > span:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.board-column > header > span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.board-column > header > small {
  flex-shrink: 0;
}
.manager-home-grid,
.cabinet-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.quote-summary {
  min-width: 0;
  flex: 1 1 240px;
  max-width: 100%;
}
.quote-summary > div > strong,
.manager-deal > b {
  min-width: 0;
  overflow-wrap: anywhere;
}
.quote-summary > div > strong {
  text-align: right;
}
.manager-deal {
  gap: 12px;
}
.app-header {
  height: auto;
  min-height: 72px;
  padding-top: 10px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}
.header-brand {
  min-width: 0;
  max-width: 240px;
  overflow-wrap: anywhere;
}
.user-switch,
.theme-switch {
  min-width: 0;
  max-width: 100%;
}
.floating-bar {
  max-width: calc(100vw - var(--sidebar-width) - 48px);
  flex-wrap: wrap;
  gap: 12px;
}
.flow-node :where(h3, p, .node-summary),
.automation-block :where(.block-title, .block-condition) {
  min-width: 0;
  overflow-wrap: anywhere;
}
.api-playground pre {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.trace-row {
  grid-template-columns: minmax(0, 120px) minmax(0, 1fr);
}
@media (max-width: 800px) {
  .manager-home-grid,
  .cabinet-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 600px) {
  .floating-bar {
    max-width: calc(100vw - 24px);
  }
  .trace-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
  .task-card,
  .bot-card,
  .manager-deal {
    flex-wrap: wrap;
  }
  .task-card > div,
  .bot-card > div:nth-child(2),
  .manager-deal > span {
    flex-basis: 65%;
  }
}

/* Compact CRM cards and record lists. */
.record-panel { padding: 18px; }
.record-panel .form-group { margin-bottom: 20px; }
.record-panel .form-group h3 {
  margin-bottom: 12px;
  padding-bottom: 10px;
  font-size: 13px;
  color: var(--text);
}
.record-panel .record-field .control { margin-bottom: 12px; gap: 5px; }
.record-panel .control > span { font-size: 12px; }
.record-panel :is(input:not([type='checkbox']):not([type='radio']), select, .readonly-value) {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 7px;
}
.record-panel textarea { min-height: 64px; padding: 8px 10px; font-size: 13px; border-radius: 7px; }
.card-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.card-tools .btn { min-height: 34px; padding: 7px 11px; font-size: 12px; border-radius: 8px; }
.card-add { position: relative; }
.card-add-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  display: grid; gap: 4px; min-width: 180px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); backdrop-filter: blur(24px);
}
.card-add-menu .btn { justify-content: flex-start; }
.theme-switch { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; }
.theme-switch .btn { min-height: 32px; width: 32px; height: 32px; padding: 0; font-size: 22px; border-radius: 7px; }
.theme-switch .btn.active { color: var(--blue); background: var(--surface2); border-color: var(--blue); }
.modal fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 14px 0; padding: 12px; }
.modal legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
.template-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.template-row strong { flex: 1; }
#record-list .table-wrap { border-radius: 10px; }
#record-list table { font-size: 13px; }
#record-list :is(th, td) { padding: 10px 14px; border-bottom: 1px solid var(--line); }
#record-list th { font-size: 11px; letter-spacing: .02em; background: var(--surface2); }
#record-list th .btn { min-height: 28px; padding: 3px 0; font-size: inherit; }
#record-list td .link { font-weight: 600; font-size: 13px; }
#record-list td small { font-size: 10px; margin-top: 3px; color: var(--muted); }
#record-list tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface2) 35%, transparent); }
#record-list tbody tr:hover { background: var(--surface2); }
@media (max-width: 640px) {
  .card-tools { gap: 6px; }
  .record-panel { padding: 12px; }
  .theme-switch .btn { width: 28px; min-height: 28px; height: 28px; }
}
[data-record-draft-status] { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; }
[data-record-draft-status]:empty { display: none; }
.template-row > div { flex: 1; min-width: 0; }
.template-row small { display: block; color: var(--muted); margin-top: 4px; }
.empty-field-group .btn { font-size: 12px; }

/* User selection and common settings navigation. */
.user-switch { position: relative; display: block; }
.user-switch > summary {
  display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none;
  min-height: 44px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 11px; background: var(--input); color: var(--text);
}
.user-switch > summary::-webkit-details-marker { display: none; }
.user-switch > summary > svg { width: 15px; height: 15px; transform: rotate(90deg); color: var(--muted); }
.user-switch[open] > summary { border-color: var(--blue); }
.user-switch[open] > summary > svg { transform: rotate(-90deg); }
.user-switch-copy { display: grid; gap: 3px; min-width: 0; text-align: left; }
.user-switch-copy strong { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.user-switch-copy small { font-size: 10px; color: var(--muted); }
.user-switch-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  display: grid; gap: 4px; min-width: 240px; max-width: calc(100vw - 32px);
  max-height: min(420px, 65vh); overflow-y: auto; padding: 8px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--surface);
  backdrop-filter: blur(24px); box-shadow: var(--shadow);
}
.user-switch-menu .btn { display: flex; justify-content: flex-start; gap: 10px; min-height: 48px; padding: 8px 10px; }
.user-switch-menu .user-switch-copy { flex: 1; }
.user-switch-menu .btn.active { background: var(--surface2); border-color: var(--blue); }
.rail-settings { color: var(--muted); width: 36px; min-width: 36px; height: 36px; border-radius: 10px; }
.rail-settings:hover { color: var(--blue); }
.rail-settings svg { width: 21px; height: 21px; }
.personal-appearance .theme-switch { width: fit-content; margin: 12px 0 20px; }
@media (max-width: 640px) {
  .user-switch > summary { gap: 5px; padding: 5px 7px; }
  .user-switch > summary .user-switch-copy { max-width: 90px; }
  .user-switch-menu { min-width: 220px; }
}

/* Bounded CRM columns keep rounded bottoms while cards scroll independently. */
.board {
  height: clamp(260px, calc(100dvh - 390px), 720px);
  max-height: 720px;
  grid-auto-rows: minmax(0, 1fr);
  align-items: stretch;
}
.board-column {
  height: 100%; max-height: 100%; min-height: 0;
  box-sizing: border-box; overflow: hidden; border-radius: 16px;
  padding-bottom: 10px;
}
.board-column .stage-cards {
  flex: 1 1 0; min-height: 0; max-height: 100%;
  overflow-y: auto; overflow-x: hidden; border-radius: 9px;
}
.board-column .column-add { margin-top: 8px; border-radius: 9px; }
.notification-options { display: grid; gap: 12px; }
.notification-settings .check {
  display: flex; align-items: center; gap: 14px; margin: 0;
  padding: 8px 0; font-size: 13px; line-height: 1.5;
}
.notification-settings .check input { flex: 0 0 16px; width: 16px; height: 16px; min-height: 16px; margin: 0; }
.notification-settings .check span { padding-left: 0; }
.notification-settings .actions .btn { min-height: 32px; padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.app-header:has(.user-switch[open]) { z-index: 70; }
@media (max-width: 800px) {
  .board { height: clamp(260px, calc(100dvh - 360px), 620px); max-height: 620px; }
}
.floating-bar button[form='notifications-form'] { min-height: 34px; padding: 7px 12px; font-size: 12px; border-radius: 9px; }
.user-switch-trigger {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  min-height: 44px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 11px; background: var(--input); color: var(--text);
}
.user-switch-trigger > svg { width: 15px; height: 15px; transform: rotate(90deg); color: var(--muted); }
.user-switch.open .user-switch-trigger { border-color: var(--blue); }
.user-switch.open .user-switch-trigger > svg { transform: rotate(-90deg); }
.app-header:has(.user-switch.open) { z-index: 70; }
.board { min-height: 0; }
@media (max-width: 640px) {
  .user-switch-trigger { gap: 5px; padding: 5px 7px; }
  .user-switch-trigger .user-switch-copy { max-width: 90px; }
}
