:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --text: #172033;
  --muted: #687386;
  --line: #e2e8f0;
  --blue: #1f6feb;
  --blue-strong: #1557c0;
  --green: #0f9f6e;
  --red: #d92d20;
  --amber: #b7791f;
  --shadow: 0 18px 45px rgba(21, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select {
  font: inherit;
}
button {
  border: 0;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: .55;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, .12);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 460px;
  background: #fff;
}
.login-visual {
  position: relative;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, .84), rgba(15, 23, 42, .35)),
    url("https://images.unsplash.com/photo-1516321318423-f06f85e504b3?auto=format&fit=crop&w=1600&q=80") center/cover;
}
.login-visual-overlay {
  height: 100%;
  padding: 56px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 24px;
  max-width: 760px;
}
.login-visual h1 {
  font-size: 48px;
  line-height: 1.08;
  margin: 0;
  font-weight: 760;
  letter-spacing: 0;
}
.login-visual p {
  max-width: 580px;
  color: rgba(255,255,255,.82);
  font-size: 18px;
  line-height: 1.7;
  margin: 0;
}
.hero-brand { position: absolute; top: 42px; left: 56px; color: #fff; }
.metric-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.metric-strip span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(12px);
}
.login-panel {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}
.login-panel h2 {
  margin: 0 0 8px;
  font-size: 32px;
}
.login-entry-list {
  display: grid;
  gap: 14px;
}
.login-entry-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-areas:
    "icon title"
    "icon desc";
  gap: 4px 12px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.login-entry-card:hover {
  border-color: rgba(31,111,235,.42);
  box-shadow: var(--shadow);
}
.login-entry-card strong {
  grid-area: title;
  font-size: 18px;
}
.login-entry-card small {
  grid-area: desc;
  color: var(--muted);
  line-height: 1.6;
}
.entry-icon {
  grid-area: icon;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue);
  font-weight: 800;
}
.login-entry-card.admin .entry-icon {
  background: #e8fbf7;
  color: #0f9f6e;
}
.back-link {
  width: fit-content;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.back-link:hover,
.login-switch a {
  color: var(--blue);
}
.login-switch {
  text-align: center;
  line-height: 1.6;
}
label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: #334155;
}
.demo-accounts {
  display: flex;
  gap: 10px;
}
.demo-accounts button {
  flex: 1;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}
.sidebar {
  background: #0f172a;
  color: #dce5f7;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2f80ed, #00b3a4);
  color: white;
  font-weight: 800;
}
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: #91a0ba; margin-top: 2px; }
.nav {
  display: grid;
  gap: 6px;
}
.nav a {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #aebbd1;
}
.nav a.active, .nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.nav-icon {
  width: 18px;
  text-align: center;
  color: #7dd3fc;
}
.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}
.user-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
}
.user-chip strong {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip small { color: #91a0ba; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #20304f;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}
.main {
  min-width: 0;
  background: var(--bg);
}
.page {
  padding: 32px;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}
.page-heading h1, .chat-header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}
.muted {
  color: var(--muted);
  margin: 0;
}
.toolbar { display: flex; gap: 10px; }
.primary, .secondary, .ghost, .danger {
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  border: 1px solid transparent;
}
.primary {
  background: var(--blue);
  color: #fff;
}
.primary:hover { background: var(--blue-strong); }
.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}
.ghost {
  background: transparent;
  color: #dce5f7;
  border-color: rgba(255,255,255,.16);
}
.danger {
  background: #fff1f0;
  color: var(--red);
  border-color: #ffccc7;
}
.large { min-height: 46px; font-size: 15px; }
.full { width: 100%; }
.mini {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #eef4ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  margin-right: 6px;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.agent-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.agent-card:hover {
  border-color: rgba(31,111,235,.35);
  box-shadow: var(--shadow);
}
.agent-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.agent-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue);
  font-weight: 800;
}
.agent-icon.large {
  width: 56px;
  height: 56px;
  margin: auto;
}
.agent-card h2 {
  margin: 0;
  font-size: 18px;
}
.agent-card p {
  min-height: 72px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  background: #eef2f7;
  color: #475569;
}
.status.active, .status.success { background: #e7f8f0; color: var(--green); }
.status.error, .status.disabled { background: #fff1f0; color: var(--red); }
.status.draft { background: #fff7e6; color: var(--amber); }

.chat-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
}
.conversation-panel {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.conversation-list {
  overflow: auto;
  display: grid;
  gap: 14px;
}
.conversation-section {
  display: grid;
  gap: 8px;
}
.conversation-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.conversation-section-title b {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: stretch;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #fff;
}
.conversation-row:hover, .conversation-row.active {
  background: #f3f7ff;
  border-color: #d6e5ff;
}
.conversation-row.archived {
  background: #f8fafc;
}
.conversation-row.archived:hover, .conversation-row.archived.active {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.conversation-item {
  min-width: 0;
  text-align: left;
  padding: 10px;
  border: 0;
  border-radius: 8px 0 0 8px;
  background: transparent;
  display: grid;
  gap: 4px;
}
.conversation-item strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.conversation-item small { color: var(--muted); }
.conversation-delete {
  width: 32px;
  min-height: 100%;
  border: 0;
  border-left: 1px solid transparent;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
}
.conversation-row:hover .conversation-delete {
  border-left-color: #d6e5ff;
  color: var(--red);
}
.conversation-delete:hover {
  background: #fff1f0;
}
.conversation-delete:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}
.conversation-archived-mark {
  width: 32px;
  min-height: 100%;
  border-left: 1px solid #e2e8f0;
  border-radius: 0 8px 8px 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.archive-notice {
  padding: 10px 12px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
}
.chat-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 24px 28px;
  gap: 14px;
}
.chat-main.with-materials {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.guide-box {
  background: #eef6ff;
  border: 1px solid #d8eaff;
  border-radius: 8px;
  padding: 12px 14px;
  color: #22436f;
  display: flex;
  gap: 10px;
  line-height: 1.6;
}
.guide-box strong { white-space: nowrap; }

.marketing-v6-panel {
  padding: 12px 14px;
  border: 1px solid #b8d7c8;
  border-radius: 12px;
  background: #f2fbf7;
}
.marketing-v6-panel summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.marketing-v6-panel summary > span { display: flex; align-items: center; gap: 8px; }
.marketing-v6-content { display: grid; gap: 9px; margin-top: 12px; }
.marketing-v6-panel.inactive { border-color: var(--line); background: #f7f7f7; }
.marketing-v6-panel.blocked { border-color: #efc2bd; background: #fff5f4; }
.marketing-v6-panel p { margin: 0; color: var(--muted); }
.marketing-v6-heading, .marketing-v6-heading > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.marketing-v6-heading > div { justify-content: flex-start; }
.marketing-v6-blockers, .marketing-v6-warnings { display: grid; gap: 5px; }
.marketing-v6-blockers span { color: #9d2e22; }
.marketing-v6-warnings span { color: #875b09; }
.marketing-project-select, .marketing-project-create { display: flex; align-items: center; gap: 8px; }
.marketing-project-select select, .marketing-project-create input { min-width: 180px; }
.marketing-project-create { grid-column: 2 / -1; }
.marketing-work-mode-options { margin-top: 10px; }
.moments-materials {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
  display: grid;
  gap: 12px;
}
.moments-materials-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}
.moments-materials-head h2 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 0;
}
.moments-material-create {
  display: grid;
  gap: 10px;
}
.moments-material-create-row,
.moments-material-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.moments-material-filters {
  grid-template-columns: minmax(180px, 1fr) 150px 170px 130px;
}
.moments-material-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}
.moments-material-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fbfdff;
}
.moments-material-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}
.moments-material-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.moments-material-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.proof {
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 750;
  background: #eef2f7;
  color: #475569;
  white-space: nowrap;
}
.proof.strong { background: #e8fbf7; color: #0f766e; }
.proof.medium { background: #fff7e6; color: #9a5b00; }
.moments-material-meta,
.moments-material-tags,
.moments-material-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.moments-material-meta span,
.moments-material-tags span {
  font-size: 12px;
  color: #475569;
  background: #eef2f7;
  border-radius: 999px;
  padding: 4px 8px;
}
.moments-material-actions button {
  padding: 7px 10px;
  font-size: 12px;
}
.moments-material-empty {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}
.deal-desk {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.deal-desk-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.deal-desk-head h2 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 0;
}
.deal-desk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.deal-desk-actions .secondary {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}
.deal-desk-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.deal-desk-card {
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
  min-width: 0;
}
.deal-desk-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
}
.deal-desk-card div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.deal-desk-card span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: #475569;
  font-size: 12px;
  line-height: 1.2;
}
.messages {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 6px;
}
.message {
  max-width: min(820px, 92%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(15, 23, 42, .04);
}
.message.user {
  align-self: flex-end;
  background: #1f6feb;
  color: #fff;
  border-color: #1f6feb;
}
.message.assistant { align-self: flex-start; }
.message-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.message.user .message-meta { color: rgba(255,255,255,.72); }
.message pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  font-family: inherit;
}
.copy-block {
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.copy-block + .copy-block,
.message pre + .copy-block,
.copy-block + pre {
  margin-top: 12px;
}
.copy-block-top {
  min-height: 36px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #475569;
  font-size: 13px;
  font-weight: 750;
}
.copy-block pre {
  padding: 12px;
}
.empty-chat {
  margin: auto;
  text-align: center;
  max-width: 460px;
  color: var(--muted);
}
.empty-chat h2 { margin-bottom: 8px; color: var(--text); }
.composer {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.composer textarea {
  border: 0;
  box-shadow: none;
  padding: 4px;
  min-height: 84px;
}
.image-composer {
  border-top: 1px solid var(--line);
  padding: 10px 0;
  display: grid;
  gap: 10px;
}
.image-composer-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.image-upload-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.image-upload-btn:hover {
  border-color: #bcd6ff;
  background: #eef6ff;
}
.image-upload-btn.disabled {
  cursor: not-allowed;
  opacity: .58;
}
.image-upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.image-upload-btn.disabled input {
  cursor: not-allowed;
}
.image-attachment-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.image-attachment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  background: #fff;
}
.image-attachment-card img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: #f1f5f9;
}
.image-attachment-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
.style-picker {
  border-top: 1px solid var(--line);
  padding: 10px 0 12px;
  display: grid;
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}
.deal-mode-picker {
  grid-template-columns: auto repeat(2, minmax(0, 1fr));
}
.sales-letter-system-module-picker {
  grid-template-columns: auto repeat(4, minmax(0, 1fr));
}
.sales-letter-system-module-picker .style-option {
  min-height: 70px;
}
.result-moments-framework-picker {
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  max-height: 280px;
  overflow: auto;
  align-items: stretch;
}
.result-moments-framework-picker .style-option {
  min-height: 64px;
}
.legacy-customer-case-picker {
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
}
.structure-fields {
  grid-column: 1 / -1;
}
.structure-field-list {
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
  color: #334155;
}
.structure-field-list strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}
.structure-field-list ol {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}
.style-picker-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  align-self: center;
  white-space: nowrap;
}
.style-option {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fff;
  min-width: 0;
}
.style-option:hover {
  border-color: #bcd6ff;
  background: #f8fbff;
}
.style-option input {
  width: 14px;
  height: 14px;
  margin: 3px 0 0;
  flex: 0 0 auto;
}
.style-option:has(input:checked) {
  border-color: var(--blue);
  background: #eef6ff;
}
.style-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.style-option strong {
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.style-option small {
  color: var(--muted);
  line-height: 1.35;
}
.composer-actions {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

@media (max-width: 760px) {
  .image-attachment-preview {
    grid-template-columns: 1fr;
  }
  .moments-materials-head,
  .moments-material-create-row {
    grid-template-columns: 1fr;
    display: grid;
  }
  .moments-material-filters {
    grid-template-columns: 1fr;
  }
  .moments-material-list {
    grid-template-columns: 1fr;
    max-height: none;
  }
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.tabs a {
  padding: 12px 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-weight: 700;
}
.tabs a.active {
  color: var(--blue);
  border-color: var(--blue);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat, .panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.stat {
  padding: 16px;
  display: grid;
  gap: 6px;
}
.stat span, .stat small { color: var(--muted); }
.stat strong { font-size: 28px; }
.panel {
  padding: 18px;
  min-width: 0;
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}
.two-col, .admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .7fr);
  gap: 16px;
}
.row-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  margin: 0;
}
.table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
.tr {
  display: grid;
  grid-template-columns: 1.4fr .7fr .5fr 1fr;
  gap: 12px;
  align-items: center;
  min-width: 720px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.tr:last-child { border-bottom: 0; }
.tr.head {
  background: var(--surface-soft);
  color: #475569;
  font-weight: 800;
  font-size: 12px;
}
.tr small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}
.model-table .tr {
  grid-template-columns: 1fr 1fr .75fr 1.35fr 1.2fr .5fr 1fr;
  min-width: 1180px;
}
.usage-table .tr {
  grid-template-columns: 1fr .6fr .7fr .7fr 2fr;
  min-width: 860px;
}
.stack-form {
  display: grid;
  gap: 14px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
summary {
  cursor: pointer;
  font-weight: 750;
}
details .form-row { margin-top: 12px; }
.switch {
  display: inline-flex;
}
.switch input { display: none; }
.switch i {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
}
.switch i::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform .16s ease;
}
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(16px); }
.inline-check {
  display: inline-flex;
  grid-template-columns: auto;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  font-weight: 600;
}
.inline-check input { width: auto; }
.empty-line {
  color: var(--muted);
  margin: 0;
  padding: 12px;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  background: #0f172a;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: all .18s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.error { background: var(--red); }

@media (max-width: 1260px) {
  .sales-letter-system-module-picker,
  .result-moments-framework-picker,
  .legacy-customer-case-picker {
    grid-template-columns: auto repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-visual { min-height: 360px; }
  .login-panel { padding: 32px; }
  .login-visual-overlay { padding: 32px; }
  .login-visual h1 { font-size: 34px; }
  .hero-brand { top: 28px; left: 32px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    padding: 12px;
  }
  .nav { display: flex; }
  .sidebar-footer { margin-left: auto; margin-top: 0; grid-template-columns: 1fr auto; align-items: center; }
  .user-chip small { display: none; }
  .chat-shell { height: auto; min-height: calc(100vh - 70px); grid-template-columns: 1fr; }
  .conversation-panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: 210px; }
  .chat-main { min-height: 760px; padding: 18px; }
  .deal-desk-head { flex-direction: column; }
  .deal-desk-actions { justify-content: flex-start; }
  .deal-desk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .style-picker, .deal-mode-picker, .sales-letter-system-module-picker, .result-moments-framework-picker, .legacy-customer-case-picker { grid-template-columns: 1fr; }
  .style-picker-label { align-self: auto; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page { padding: 18px; }
  .page-heading, .chat-header, .composer-actions { flex-direction: column; align-items: stretch; }
  .sidebar {
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: hidden;
  }
  .brand {
    flex: 0 0 auto;
  }
  .brand > span:not(.brand-mark), .brand small, .user-chip { display: none; }
  .brand-mark {
    width: 32px;
    height: 32px;
  }
  .nav {
    flex: 1 0 auto;
  }
  .nav a {
    min-height: 34px;
    padding: 8px 9px;
    white-space: nowrap;
  }
  .sidebar-footer {
    display: block;
    margin-left: 0;
  }
  .sidebar-footer .ghost {
    width: auto;
    min-height: 34px;
    padding: 8px 10px;
    white-space: nowrap;
  }
  .stat-grid, .form-row { grid-template-columns: 1fr; }
  .deal-desk-grid { grid-template-columns: 1fr; }
  .message { max-width: 100%; }
}
