:root {
  color-scheme: light;
  --primary: #2f8fed;
  --primary-dark: #1f78ce;
  --primary-soft: #e9f3ff;
  --ink: #17211b;
  --muted: #69756e;
  --faint: #96a099;
  --paper: #f5f5f0;
  --surface: #ffffff;
  --surface-soft: #fafaf7;
  --line: #dde1dc;
  --line-strong: #cbd1ca;
  --accent: #2f8fed;
  --accent-dark: #1f78ce;
  --accent-soft: #e9f3ff;
  --warning: #9a5b16;
  --warning-soft: #fff1d9;
  --danger: #a63831;
  --danger-soft: #fce9e7;
  --shadow: 0 18px 50px rgba(27, 40, 32, .09);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
.hidden { display: none !important; }

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: white;
  font-weight: 800;
  letter-spacing: -.04em;
  box-shadow: 0 8px 20px rgba(23, 33, 27, .17);
}

.brand-lockup { display: inline-flex; align-items: center; gap: 12px; }
.brand-lockup b, .brand-lockup small { display: block; }
.brand-lockup b { font-size: 18px; letter-spacing: -.02em; }
.brand-lockup small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-lockup.compact .brand-mark { width: 38px; height: 38px; border-radius: 12px; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr);
}

.auth-story {
  padding: clamp(34px, 6vw, 84px);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 84% 18%, rgba(255, 255, 255, .18), transparent 28%),
    linear-gradient(145deg, #174f3d, #0f3025 66%, #10251d);
  color: white;
}
.auth-story .brand-mark { background: white; color: var(--accent-dark); }
.auth-story .brand-lockup small { color: rgba(255, 255, 255, .66); }
.auth-copy { margin: auto 0; max-width: 620px; }
.auth-copy h1 { margin: 14px 0 22px; font-size: clamp(42px, 5vw, 74px); line-height: .98; letter-spacing: -.055em; }
.auth-copy p { max-width: 530px; color: rgba(255, 255, 255, .72); font-size: 18px; line-height: 1.55; }
.auth-footnote { margin: 0; color: rgba(255, 255, 255, .55); font-size: 13px; }

.auth-card-wrap { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(100%, 430px); background: var(--surface); padding: 38px; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 9px 0 8px; font-size: 30px; letter-spacing: -.035em; }
.auth-card .field { margin-top: 18px; }
.blocked-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.blocked-card { text-align: center; }
.blocked-actions { margin-top: 24px; display: flex; justify-content: center; gap: 10px; }
.invite-identity { margin: 22px 0 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.invite-identity span, .invite-identity b { display: block; }
.invite-identity b { margin-top: 5px; color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.workspace-card { padding: 16px; border-radius: 14px; background: var(--surface-soft); border: 1px solid var(--line); }
.workspace-card strong, .workspace-card span { display: block; }
.workspace-card strong { margin: 7px 0 3px; font-size: 14px; }
.workspace-card .muted { font-size: 12px; }
.sidebar-section { display: grid; gap: 9px; }
.section-label { min-height: 26px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.account-card { margin-top: auto; display: flex; align-items: center; gap: 11px; padding-top: 18px; border-top: 1px solid var(--line); min-width: 0; }
.account-card div { min-width: 0; }
.account-card strong { display: block; max-width: 176px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.account-avatar { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; }
.role-badge { display: inline-block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.workspace-main { min-width: 0; padding: 34px clamp(24px, 4vw, 62px) 64px; }
.workspace-header { max-width: 1280px; margin: 0 auto 28px; display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.workspace-header h1 { margin: 6px 0 0; font-size: clamp(28px, 3vw, 42px); letter-spacing: -.045em; }
.status-line { min-height: 20px; margin: 0; color: var(--muted); font-size: 13px; }
.status-line.error { color: var(--danger); }

.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.muted { color: var(--muted); line-height: 1.5; }
.form-error { min-height: 19px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.admin-view, .agent-view { max-width: 1280px; margin: 0 auto; }
.organization-admin-grid { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(460px, 1.28fr); gap: 18px; align-items: start; }
.organization-catalog { display: grid; gap: 18px; }
.organization-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.organization-list button { width: 100%; padding: 13px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--ink); text-align: left; cursor: pointer; }
.organization-list button.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(23, 107, 79, .08); }
.organization-list strong, .organization-list small { min-width: 0; overflow-wrap: anywhere; }
.organization-list small { color: var(--muted); }
.organization-list .organization-state { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.organization-form { display: grid; gap: 13px; }
.organization-form h3 { margin: 0; }
.limit-editor { display: grid; gap: 8px; }
.limit-editor:empty::after { content: "Добавьте хотя бы один лимит"; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 11px; color: var(--muted); font-size: 12px; text-align: center; }
.limit-row { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(90px, .7fr) minmax(90px, .65fr) 34px; gap: 7px; align-items: end; }
.limit-row .field > span { font-size: 10px; }
.remove-limit { min-height: 40px; border: 0; border-radius: 10px; background: var(--danger-soft); color: var(--danger); cursor: pointer; }
.onboarding-card { max-width: 760px; padding: clamp(28px, 5vw, 54px); border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.onboarding-card h2 { margin: 10px 0 12px; font-size: 34px; letter-spacing: -.04em; }
.organization-detail-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.organization-detail-heading .lifecycle-badge.active { color: var(--accent-dark); background: var(--accent-soft); }
.organization-detail-heading .lifecycle-badge.stopped { color: var(--warning); background: var(--warning-soft); }
.organization-detail-heading .btn { flex: none; }
.owner-admission { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.inline-form { margin-top: 24px; display: flex; align-items: end; gap: 12px; }
.grow { flex: 1; }
.invite-result { margin-top: 20px; padding: 16px; display: flex; align-items: end; gap: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.invite-result .field { flex: 1; }

.empty-state { min-height: 60vh; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-state h2 { margin: 14px 0 7px; font-size: 30px; letter-spacing: -.04em; }
.empty-state p { max-width: 480px; color: var(--muted); line-height: 1.55; }
.empty-glyph { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 20px; background: var(--accent-soft); color: var(--accent); font-size: 27px; }

.agent-workspace { display: grid; gap: 18px; }
.hero-card { padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: var(--ink); color: white; border-radius: var(--radius); }
.hero-card .eyebrow { color: #8bd0b5; }
.hero-card h2 { margin: 4px 0 0; font-size: 26px; letter-spacing: -.035em; }
.hero-card .muted { margin: 7px 0 0; color: rgba(255, 255, 255, .62); font-size: 13px; }
.agent-heading { display: flex; align-items: center; gap: 10px; }
.agent-heading h2 { overflow-wrap: anywhere; }
.lifecycle-badge { padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lifecycle-badge.active { color: #b8efd9; background: rgba(89, 195, 151, .16); }
.lifecycle-badge.stopped { color: #ffd9a6; background: rgba(246, 171, 70, .16); }
.hero-card .btn { border-color: rgba(255, 255, 255, .26); background: rgba(255, 255, 255, .08); color: white; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 18px; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 6px 24px rgba(27, 40, 32, .045); }
.panel-heading { margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading h3 { margin: 5px 0 0; font-size: 18px; letter-spacing: -.02em; }
.editor-panel { display: grid; gap: 15px; }
.field-row { display: flex; gap: 12px; }
.api-key-control { display: flex; align-items: end; gap: 12px; }
.api-key-control .field { flex: 1; min-width: 0; }
.api-key-control .btn { flex: 0 0 auto; margin-bottom: 3px; }
.field { display: grid; gap: 7px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.field small { color: var(--faint); font-weight: 500; }
.read-only-hint { padding: 5px 8px; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.panel-actions { display: flex; justify-content: flex-end; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 107, 79, .10); }
input:disabled, select:disabled, textarea:disabled, input[readonly], textarea[readonly] { background: #f1f2ee; color: #59635d; }

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { border-color: #aeb7af; background: var(--surface-soft); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.subtle { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); }
.btn.quiet { min-height: 34px; padding: 6px 10px; background: transparent; border-color: transparent; color: var(--muted); }
.btn.wide { width: 100%; }
.icon-action { width: 28px; height: 28px; border: 0; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 20px; cursor: pointer; }

.preview-panel { min-height: 520px; display: flex; flex-direction: column; }
.preview-log { flex: 1; min-height: 340px; max-height: 540px; overflow: auto; padding: 8px 2px 16px; display: flex; flex-direction: column; gap: 8px; }
.preview-message { max-width: 86%; padding: 10px 12px; border-radius: 13px; white-space: pre-wrap; line-height: 1.45; font-size: 13px; }
.preview-message.user { align-self: end; background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.preview-message.agent { align-self: start; background: var(--paper); border-bottom-left-radius: 4px; }
.preview-message.pending { color: var(--muted); font-style: italic; }
.composer { display: flex; gap: 8px; }
.send-button { width: 42px; flex: none; border: 0; border-radius: 12px; background: var(--accent); color: white; font-size: 20px; cursor: pointer; }
.send-button:disabled { opacity: .45; }
.offline-note { padding: 11px 12px; border-radius: 11px; background: var(--warning-soft); color: var(--warning); font-size: 12px; line-height: 1.45; }

.owner-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.compact-panel { min-height: 190px; }
.copy-row { display: flex; gap: 8px; }
.safe-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.safe-item { padding: 11px 12px; border-radius: 11px; background: var(--surface-soft); border: 1px solid var(--line); }
.safe-item strong, .safe-item span { display: block; }
.safe-item strong { font-size: 13px; }
.safe-item span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.channel-state { display: inline-flex !important; width: fit-content; margin-bottom: 5px; padding: 3px 7px; border-radius: 999px; font-size: 9px !important; font-weight: 800; text-transform: uppercase; }
.channel-state.running { background: var(--accent-soft); color: var(--accent); }
.channel-state.stopped { background: #eceeea; color: var(--muted); }
.channel-state.error { background: var(--danger-soft); color: var(--danger); }
.channel-state.ready { background: var(--accent-soft); color: var(--accent); }
.channel-state.degraded { background: var(--warning-soft); color: var(--warning); }
.channel-state.not_ready { background: var(--danger-soft); color: var(--danger); }
.channel-facts { display: flex !important; flex-wrap: wrap; gap: 6px; margin: 7px 0; }
.channel-fact { display: inline-flex !important; width: fit-content; margin: 0 !important; padding: 3px 7px; border-radius: 999px; background: #eceeea; color: var(--muted) !important; font-size: 9px !important; font-weight: 750; }
.channel-fact.verified { background: var(--accent-soft); color: var(--accent) !important; }
.channel-fact.replacement_required,
.channel-fact.missing { background: var(--warning-soft); color: var(--warning) !important; }
.channel-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

dialog { width: min(92vw, 500px); padding: 0; border: 0; border-radius: 20px; background: transparent; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(12, 21, 16, .45); backdrop-filter: blur(3px); }
.dialog-card { padding: 26px; display: grid; gap: 16px; background: var(--surface); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.dialog-heading h2 { margin: 6px 0 0; letter-spacing: -.035em; }
.close-button { border: 0; background: transparent; color: var(--muted); font-size: 25px; cursor: pointer; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 13px 16px; border-radius: 12px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 13px; z-index: 20; }
.toast.error { background: var(--danger); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .content-grid, .owner-tools, .organization-admin-grid { grid-template-columns: 1fr; }
  .preview-panel { min-height: 440px; }
}

@media (max-width: 760px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-story { min-height: 38vh; padding: 28px; }
  .auth-copy { margin: 60px 0 40px; }
  .auth-copy h1 { font-size: 42px; }
  .auth-footnote { display: none; }
  .auth-card-wrap { padding: 22px; }
  .auth-card { padding: 28px; }
  .app-shell { display: block; }
  .sidebar { position: relative; width: auto; height: auto; padding: 18px; gap: 14px; }
  .workspace-card { display: none; }
  .account-card { margin-top: 0; }
  .workspace-main { padding: 24px 16px 48px; }
  .workspace-header { align-items: start; }
  .field-row, .api-key-control, .inline-form, .invite-result, .copy-row, .blocked-actions { flex-direction: column; align-items: stretch; }
  .limit-row { grid-template-columns: 1fr 1fr; }
  .limit-row .remove-limit { grid-column: 1 / -1; }
  .api-key-control .btn { margin-bottom: 0; }
  .hero-card { align-items: start; flex-direction: column; }
  .hero-card .btn { width: 100%; }
}

/* D2.1: original blogger product shell, with D1/D2 state mounted locally. */
body {
  background: #f4f7fb;
  color: #17233a;
}

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

.shell .sidebar {
  position: sticky;
  top: 0;
  z-index: 12;
  height: 100vh;
  padding: 20px 16px;
  gap: 16px;
  background: #fff;
  border-right: 1px solid #dce4ef;
}

.shell .brand-mark,
.auth-story .brand-mark {
  border-radius: 11px;
  background: linear-gradient(145deg, var(--primary), #1476a8);
  box-shadow: 0 8px 20px rgba(47, 143, 237, .24);
}

.brand-lockup b { color: #18243a; }
.brand-lockup small { color: #8793a5; }
.mainnav { display: grid; gap: 4px; margin-top: 5px; }
.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #5d6a7d;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: #f3f7fc; color: #25344c; }
.nav-item.on { background: var(--primary-soft); color: var(--primary-dark); }

.workspace-card {
  padding: 13px;
  border-color: #dce4ef;
  border-radius: 10px;
  background: #f7f9fc;
}
.sidebar-section select { border-color: #d6dfeb; background: #fff; }
.account-card { margin-top: 0; padding-top: 0; border-top: 0; }
.account-avatar,
.avatar-btn {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}
.avatar-btn { width: 38px; height: 38px; flex: none; cursor: pointer; }
.account-avatar { background: var(--primary-soft); color: var(--primary-dark); }

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid #dce4ef;
  backdrop-filter: blur(14px);
}
.topbar-title { min-width: 0; }
.topbar h1 {
  margin: 0;
  overflow: hidden;
  color: #1d2a40;
  font-size: 18px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-line {
  max-width: min(44vw, 580px);
  min-height: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.burger {
  display: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: #f0f5fb;
  color: #516076;
  font-size: 18px;
  cursor: pointer;
}

.acc-panel {
  position: fixed;
  top: 72px;
  right: 18px;
  z-index: 42;
  width: min(340px, calc(100vw - 32px));
  padding: 18px;
  display: grid;
  gap: 12px;
  border: 1px solid #d8e1ed;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(34, 58, 90, .18);
}
.acc-panel .account-card { padding-bottom: 13px; border-bottom: 1px solid #e4e9f0; }
.acc-panel .account-card strong {
  max-width: 230px;
  overflow-wrap: anywhere;
  white-space: normal;
}
.acc-row {
  min-width: 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  color: #7b8798;
  font-size: 12px;
}
.acc-row b {
  min-width: 0;
  color: #26344a;
  text-align: right;
  overflow-wrap: anywhere;
}

.agent-view { max-width: none; margin: 0; }
.agent-workspace { display: block; }
.product-view,
.board {
  min-width: 0;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: start;
}
.board > .hero-card { grid-column: 1 / -1; }
.content-grid,
.owner-tools { display: contents; }
.board .panel,
.board .col,
.page .col {
  min-width: 0;
  border: 1px solid #dce4ef;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(42, 64, 91, .04);
}
.instruction-col { grid-column: 1; grid-row: 2 / span 4; }
.instruction-col .api-key-control { align-items: stretch; flex-direction: column; }
.instruction-col .api-key-control .btn { align-self: start; margin-bottom: 0; }
.knowledge-panel { grid-column: 2; grid-row: 2 / span 4; }
.knowledge-carrier-field input[type="file"] {
  padding: 10px;
  border: 1px dashed var(--line);
  background: var(--surface-soft);
}
.knowledge-carrier-field.hidden {
  display: none;
}
.channel-col { grid-column: 3; grid-row: 2 / span 2; }
.channels-panel { grid-column: 3; grid-row: 4; }
.share-panel { grid-column: 3; grid-row: 5; }
.col-head {
  margin: -22px -22px 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid #e1e7ef;
  color: #27354b;
  font-size: 14px;
  font-weight: 750;
}
.num {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
}
.hero-card {
  padding: 15px 18px;
  border-radius: 11px;
  background: linear-gradient(112deg, #24344d, #1c2b41);
}
.hero-card .eyebrow { color: #8dc7ff; }
.hero-card h2 { font-size: 20px; }
.panel-heading { min-width: 0; }
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.field-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.prompt-actions { display: inline-flex; align-items: center; gap: 6px; }
.btn-accent { border-color: #b8dcff; background: #eaf5ff; color: #1569b4; }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.editor-panel textarea { min-height: 360px; }
.preview-panel { min-height: 490px; }
.preview-log {
  background:
    linear-gradient(rgba(241, 246, 252, .88), rgba(241, 246, 252, .88)),
    radial-gradient(circle at 20% 20%, #dce8f4 1px, transparent 1px);
  background-size: auto, 20px 20px;
  border-radius: 10px;
  padding: 14px;
}
.preview-message.user { background: var(--primary); }
.send-button { background: var(--primary); }
.drop-zone {
  width: 100%;
  margin-top: 14px;
  padding: 17px;
  display: grid;
  justify-items: center;
  gap: 4px;
  border: 1px dashed #a9bfd8;
  border-radius: 10px;
  background: #f7fbff;
  color: #4c6179;
  cursor: pointer;
}
.drop-plus { color: var(--primary); font-size: 24px; line-height: 1; }
.drop-sub { color: #8a98aa; font-size: 11px; }
.safe-item,
.safe-item strong,
.safe-item span { min-width: 0; overflow-wrap: anywhere; }

.page { padding: 20px; }
.page-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(360px, 1.28fr); gap: 14px; }
.page .col { overflow: hidden; }
.page .col-head { margin: 0; }
.col-body { min-width: 0; padding: 20px; }
.hint { color: #7f8b9d; font-size: 12px; line-height: 1.55; }
.conversation-list button { width: 100%; text-align: left; }
.external-case-panel { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.external-case-panel h3 { margin: 0 0 10px; font-size: 13px; }
.external-case-list { margin-bottom: 10px; }
.external-case-button { width: 100%; text-align: left; border: 1px solid #f0cf9e; background: #fff8ed; cursor: pointer; }
.external-case-button .external-case-action { color: var(--primary); font-weight: 750; }
.conversation-log { min-height: 440px; max-height: calc(100vh - 190px); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat-card { min-height: 150px; padding: 28px; display: grid; place-content: center; text-align: center; }
.stat-card strong { color: var(--primary-dark); font-size: 42px; }
.stat-card span { margin-top: 6px; color: #788597; }
.narrow-card { max-width: 620px; margin: 0 auto; }
.manager-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.manager-event-list { margin-top: 16px; }
.manager-outcome-list {
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  list-style: none;
}
.manager-outcome-list li {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 8px;
  background: #fff;
}
.manager-outcome-list span,
.manager-outcome-list small {
  overflow-wrap: anywhere;
}
.manager-outcome-list small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.admin-overlay {
  position: fixed;
  inset: 78px 24px 24px max(272px, 24px);
  z-index: 35;
  max-width: none;
  margin: 0;
  padding: 22px;
  overflow: auto;
  border: 1px solid #d8e1ed;
  border-radius: 16px;
  background: #f4f7fb;
  box-shadow: 0 22px 70px rgba(29, 52, 80, .22);
}
.admin-overlay-head {
  margin-bottom: 18px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}
.admin-overlay-head h2 { margin: 5px 0 0; }
.admin-overlay .organization-admin-grid { max-width: 1180px; }

.editor-dialog { width: min(96vw, 1040px); }
.editor-card { min-height: min(86vh, 800px); grid-template-rows: auto 1fr auto; }
.editor-card textarea { min-height: 55vh; }

.auth-screen {
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(20, 36, 58, .93) 0 31%, rgba(244, 247, 251, .92) 31%),
    repeating-linear-gradient(90deg, transparent 0 32%, rgba(47, 143, 237, .08) 32% 53%, transparent 53% 75%);
}
.auth-story {
  background:
    radial-gradient(circle at 80% 15%, rgba(47, 143, 237, .28), transparent 32%),
    linear-gradient(145deg, #243b5a, #16263b 68%, #122033);
}
.auth-story .brand-lockup b { color: #fff; }
.auth-story .brand-mark { color: #fff; }
.auth-card { border-color: #d9e3ef; border-radius: 14px; }
.blocked-screen {
  background:
    linear-gradient(rgba(244, 247, 251, .88), rgba(244, 247, 251, .88)),
    linear-gradient(90deg, #243b5a 0 248px, #f4f7fb 248px);
}

input,
select,
textarea {
  max-width: 100%;
  border-color: #cfd9e6;
  border-radius: 8px;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 143, 237, .12);
}
.btn { border-radius: 8px; }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.subtle { background: var(--primary-soft); color: var(--primary-dark); }
.icon-action { background: var(--primary-soft); color: var(--primary-dark); }

@media (max-width: 1120px) {
  .shell { grid-template-columns: 218px minmax(0, 1fr); }
  .product-view,
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .instruction-col { grid-column: 1; grid-row: 2 / span 4; }
  .knowledge-panel { grid-column: 2; grid-row: 2 / span 2; }
  .channel-col { grid-column: 2; grid-row: 4 / span 2; }
  .channels-panel,
  .share-panel { grid-column: 1 / -1; grid-row: auto; }
  .admin-overlay { left: 238px; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .shell .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    height: 100dvh;
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: 18px 0 55px rgba(26, 45, 70, .22);
  }
  .shell .sidebar.open { transform: translateX(0); }
  .burger { display: grid; place-items: center; }
  .topbar { padding: 9px 12px; }
  .topbar h1 { font-size: 15px; }
  .status-line { display: none; }
  .product-view,
  .board {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
  .instruction-col,
  .knowledge-panel,
  .channel-col,
  .channels-panel,
  .share-panel {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
  .board > .hero-card { grid-column: 1; }
  .board .panel { padding: 18px; }
  .col-head { margin: -18px -18px 16px; }
  .field-label-row { align-items: start; flex-direction: column; }
  .prompt-actions { width: 100%; }
  .prompt-actions .btn { flex: 1; }
  .editor-panel textarea { min-height: 280px; }
  .preview-panel { min-height: 440px; }
  .page { padding: 12px; }
  .page-grid,
  .stat-grid,
  .manager-settings-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-overlay { inset: 68px 10px 10px; padding: 14px; }
  .admin-overlay .organization-admin-grid { grid-template-columns: minmax(0, 1fr); }
  .acc-panel { top: 62px; right: 10px; }
  .auth-screen { grid-template-columns: 1fr; }
  .auth-story { min-height: 34vh; }
  .auth-copy { margin: 42px 0 28px; }
  .auth-copy h1 { font-size: clamp(34px, 10vw, 46px); }
  .auth-card-wrap { margin-top: -28px; z-index: 2; }
  .auth-card { padding: 24px; }
  .copy-row,
  .inline-form,
  .invite-result {
    min-width: 0;
  }
  .copy-row > *,
  .inline-form > *,
  .invite-result > * {
    min-width: 0;
    max-width: 100%;
  }
  dialog { width: min(94vw, 500px); max-height: calc(100dvh - 24px); overflow: auto; }
  .dialog-card { padding: 20px; }
  .channel-actions { align-items: stretch; }
  .channel-actions .btn { flex: 1 1 118px; }
}

.auth-screen {
  position: relative;
  display: block;
  min-height: 100vh;
  overflow: hidden;
  background: #f4f7fb;
}
.auth-story { display: none; }
.auth-product-backdrop {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: #f4f7fb;
}
.auth-preview-sidebar {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: #fff;
  border-right: 1px solid #dce4ef;
}
.auth-preview-nav { display: grid; gap: 5px; }
.auth-preview-nav span {
  padding: 10px 12px;
  border-radius: 9px;
  color: #67758a;
  font-size: 14px;
  font-weight: 650;
}
.auth-preview-nav .on { background: var(--primary-soft); color: var(--primary-dark); }
.auth-preview-select {
  display: grid;
  gap: 8px;
  color: #738197;
  font-size: 13px;
}
.auth-preview-select small {
  color: #7a8798;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.auth-preview-select span {
  padding: 11px 12px;
  border: 1px solid #d5deea;
  border-radius: 8px;
  background: #fff;
}
.auth-preview-main { min-width: 0; }
.auth-preview-topbar {
  min-height: 64px;
  padding: 21px 24px;
  border-bottom: 1px solid #dce4ef;
  background: #fff;
  color: #243248;
  font-weight: 750;
}
.auth-preview-board {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.auth-preview-board span {
  min-height: calc(100vh - 104px);
  padding: 15px;
  border: 1px solid #dce4ef;
  border-radius: 11px;
  background: #fff;
  color: #45546a;
  font-size: 13px;
  font-weight: 750;
}
.auth-preview-board b {
  width: 24px;
  height: 24px;
  margin-right: 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
}
.auth-card-wrap {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: 32px 32px 32px 280px;
  display: grid;
  place-items: center;
  background: rgba(231, 237, 246, .54);
  backdrop-filter: blur(2px);
}
.auth-card { box-shadow: 0 22px 70px rgba(32, 55, 86, .22); }

@media (max-width: 760px) {
  .auth-screen { display: block; }
  .auth-product-backdrop { grid-template-columns: 1fr; }
  .auth-preview-sidebar { display: none; }
  .auth-preview-board { grid-template-columns: 1fr; }
  .auth-preview-board span { min-height: 28vh; }
  .auth-preview-board span:nth-child(n + 2) { display: none; }
  .auth-card-wrap {
    min-height: 100vh;
    margin-top: 0;
    padding: 18px;
    background: rgba(231, 237, 246, .68);
  }
}
