:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --soft: #eef2f8;
  --softer: #f8fafc;
  --ink: #0f1f38;
  --ink-2: #354761;
  --muted: #6b7a94;
  --faint: #a6b0c2;
  --line: #e3e8f0;
  --line-strong: #c8d2e2;
  --brand: #1e5aa8;
  --brand-strong: #164a8f;
  --brand-bg: #e6eff9;
  --brand-tint: #f0f6fc;
  --dark: #0f1f38;
  --dark-panel: #1a2d4a;
  --dark-muted: #8ea1bd;
  --urgent: #c0392b;
  --urgent-bg: #fdeeec;
  --success: #217a4e;
  --success-bg: #e6f2ec;
  --warning: #9a6100;
  --warning-bg: #fff5df;
  --highlight: #ffe082;
}

* { box-sizing: border-box; }

html,
body { margin: 0; min-height: 100%; }

body {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px;
}

button,
input,
textarea { font: inherit; letter-spacing: 0; }

button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(30, 90, 168, .35);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(15, 31, 56, .035) 1px, transparent 1px),
    linear-gradient(rgba(15, 31, 56, .035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

.login-shell {
  width: min(400px, 100%);
  padding: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(15, 31, 56, .1);
}

.login-brand,
.brand-logo {
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.login-brand { width: 40px; height: 40px; margin-bottom: 22px; border-radius: 6px; }
.login-shell h1 { margin: 6px 0 8px; font-size: 26px; }
.login-copy { margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; color: var(--ink-2); font-weight: 600; }
.login-form input {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}
.login-form button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.login-form button:hover { background: var(--brand-strong); }
.form-error { min-height: 18px; margin: -4px 0 -6px; color: var(--urgent); font-size: 12px; }

.app { min-height: 100vh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 270px minmax(360px, 1fr) auto;
  align-items: center;
  height: 48px;
  padding: 0 20px;
  background: var(--dark);
  color: #fff;
}

.brand-group { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 28px; height: 28px; border-radius: 5px; font-size: 11px; }
.brand-group > div:last-child { display: grid; gap: 1px; }
.brand-group strong { font-size: 13px; }
.brand-group span { color: var(--dark-muted); font-size: 11px; }

.module-tabs { display: flex; align-items: center; gap: 2px; }
.module-tabs button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  padding: 0 14px;
  background: transparent;
  color: var(--dark-muted);
  font-size: 12px;
}
.module-tabs button.active { background: rgba(255,255,255,.09); color: #fff; }
.module-tabs button:disabled { cursor: default; opacity: .65; }

.header-meta { display: flex; align-items: center; gap: 14px; color: var(--dark-muted); white-space: nowrap; }
.archive-state { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.archive-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.archive-state.healthy i { background: #4ade80; }
.archive-state.error i { background: #ff7a6b; }
.license-state { border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 3px 8px; color: var(--dark-muted); font-size: 10px; }
.license-state.license-trial { border-color: rgba(255,224,130,.35); color: #ffe7a8; }
.license-state.license-active { border-color: rgba(74,222,128,.35); color: #8df0b0; }
.license-state.license-expired,
.license-state.license-suspended,
.license-state.license-cancelled { border-color: rgba(255,122,107,.35); background: rgba(192,57,43,.15); color: #ffb5ad; }
.today-summary { border: 0; border-radius: 4px; padding: 5px 7px; background: rgba(255,255,255,.07); color: var(--dark-muted); font-size: 11px; }
.today-summary:hover { background: rgba(255,255,255,.12); color: #fff; }
.today-summary.has-urgent { background: rgba(214,61,50,.2); color: #ffb5ad; }
.user-badge { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; }
.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
}
.icon-button:hover { background: rgba(255,255,255,.09); }

.pipeline-band {
  position: sticky;
  top: 48px;
  z-index: 30;
  padding: 9px 20px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.pipeline-heading { display: flex; align-items: center; gap: 12px; min-height: 18px; margin-bottom: 7px; }
.pipeline-heading > span,
.kicker { margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.kicker.brand { color: var(--brand); }
.text-button { border: 0; padding: 0; background: transparent; color: var(--brand); font-size: 11px; }
.pipeline { display: grid; grid-template-columns: repeat(8, minmax(92px, 1fr)); gap: 7px; }
.pipeline-card {
  min-width: 0;
  min-height: 53px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  transition: border-color .15s, background .15s, opacity .15s;
}
.pipeline.has-filter .pipeline-card:not(.active) { opacity: .42; }
.pipeline-card:hover { border-color: var(--line-strong); }
.pipeline-card.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.pipeline-card span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.pipeline-card span i { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--status-color, var(--brand)); }
.pipeline-card.active span { color: rgba(255,255,255,.8); }
.pipeline-card.active span i { background: #fff; }
.pipeline-card strong { display: block; margin-top: 2px; font-size: 22px; line-height: 1; }

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

.queue-pane {
  position: sticky;
  top: 143px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 143px);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.queue-head { padding: 13px 14px 11px; border-bottom: 1px solid var(--line); }
.queue-head > div { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.queue-head strong { font-size: 13px; }
.queue-head span { color: var(--muted); font-size: 11px; }
.queue-agent-filter { width: 100%; height: 32px; margin-top: 8px; border: 1px solid var(--line); border-radius: 5px; padding: 0 28px 0 10px; background: #fff; color: var(--ink-2); font-size: 11px; }
.search-field { position: relative; display: block; }
.search-field > span { position: absolute; top: 50%; left: 10px; transform: translateY(-50%); color: var(--faint); }
.search-field input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 10px 0 29px;
  background: var(--softer);
  color: var(--ink);
}
.queue-list { flex: 1; overflow: auto; }
.queue-empty { padding: 36px 18px; color: var(--faint); text-align: center; line-height: 1.6; }

.lead-row {
  position: relative;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf0f5;
  padding: 11px 13px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.lead-row:hover { background: var(--softer); }
.lead-row.active { background: var(--brand-bg); }
.lead-row.linked-wecom { border: 1px solid #b8d5f2; border-left: 3px solid #4b91d1; background: #f3f8fe; }
.lead-row.linked-wecom:hover { background: #edf6ff; }
.lead-row.linked-wecom.active { border-color: #75aae0; background: #e7f2ff; }
.lead-row.active::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: var(--brand); }
.lead-row.urgent::after { content: ""; position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--urgent); }
.lead-row-main { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 9px; }
.avatar { display: grid; place-items: center; border-radius: 7px; background: var(--avatar-bg, #dce7f4); color: var(--brand-strong); font-weight: 700; }
.lead-row .avatar { width: 34px; height: 34px; }
.lead-copy { min-width: 0; }
.lead-name-line { display: flex; align-items: center; gap: 6px; }
.lead-name-line strong { min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.lead-name-line time { margin-left: auto; color: var(--faint); font-size: 10px; }
.lead-row.urgent .lead-name-line time { margin-right: 14px; }
.lead-subtitle { overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.badge-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.badge,
.channel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}
.channel-badge { border: 1px solid #ccdaeb; background: #eef4fb; color: var(--brand); }
.linked-badge { border: 1px solid #9fc8ed; background: #dceeff; color: #145e9f; }
.agent-badge { border: 1px solid #d7dce5; background: #f5f6f8; color: #586579; font-weight: 600; }
.platform-finished-badge { border: 1px solid #cbd4df; background: #eef1f5; color: #667386; }
.unread { min-width: 18px; border-radius: 9px; padding: 1px 5px; background: var(--urgent); color: #fff; text-align: center; }
.task-preview {
  margin: 8px 0 0 43px;
  overflow: hidden;
  border-left: 2px solid var(--brand);
  border-radius: 0 4px 4px 0;
  padding: 5px 7px;
  background: var(--softer);
  color: var(--ink-2);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lead-row.urgent .task-preview { border-left-color: var(--urgent); background: var(--urgent-bg); }
.lead-row.today-priority { box-shadow: inset 3px 0 0 #1f6ecb; }
.lead-row.today-priority:not(.active):not(.linked-wecom) { background: #f8fbff; }
.today-badge { border: 1px solid #9fc8ed; background: #e4f1ff; color: #145e9f; }
.task-preview b { margin-right: 6px; color: var(--brand-strong); font-size: 9px; }

.main-panel { min-width: 0; overflow: hidden; background: var(--bg); }
.empty-state { display: grid; min-height: 60vh; place-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 18px; }

.lead-header {
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 84px;
  padding: 16px 30px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.lead-header .avatar { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 9px; font-size: 16px; }
.lead-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.lead-heading { min-width: 0; flex: 1; }
.lead-heading-top { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.lead-heading h1 { margin: 0; font-size: 18px; }
.lead-heading p { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.link-code { border-radius: 3px; padding: 3px 7px; background: var(--soft); color: var(--muted); font: 11px ui-monospace, monospace; }
.intent-badge { border: 1px solid #c7d7eb; border-radius: 12px; padding: 3px 8px; background: var(--brand-tint); color: var(--brand); font-size: 11px; font-weight: 700; }
.primary-button,
.secondary-button,
.chip-button {
  min-height: 34px;
  border-radius: 5px;
  padding: 0 12px;
  font-weight: 600;
}
.primary-button { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-strong); }
.secondary-button { border: 1px solid var(--line-strong); background: #fff; color: var(--ink-2); }
.secondary-button:hover { border-color: #aebdd2; background: var(--softer); }

.main-content { width: min(1024px, 100%); margin: 0 auto; padding: 22px 30px 60px; }
.copilot-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid rgba(30,90,168,.2);
  border-radius: 8px;
  padding: 17px;
  background: linear-gradient(135deg, #f0f6fc 0%, #e6eff9 100%);
}
.copilot-card::after { content: ""; position: absolute; top: -65px; right: -35px; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, rgba(30,90,168,.16), transparent 68%); }
.copilot-title { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.copilot-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 5px; background: var(--brand); color: #fff; font-size: 17px; }
.copilot-title div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.copilot-title strong { color: var(--brand-strong); font-size: 11px; text-transform: uppercase; }
.copilot-title span { color: var(--muted); font-size: 11px; }
.insight-list { display: grid; gap: 7px; margin-left: 40px; }
.insight-row { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; color: var(--ink-2); line-height: 1.55; }
.insight-row b { border: 1px solid rgba(30,90,168,.14); border-radius: 3px; padding: 2px 5px; background: rgba(255,255,255,.76); color: var(--brand-strong); font-size: 10px; text-align: center; }
.copilot-profile { margin: 14px 0 0 40px; border-top: 1px solid rgba(30,90,168,.16); padding-top: 13px; }
.compact-profile { gap: 8px; }
.compact-profile .profile-stat { border: 1px solid rgba(30,90,168,.1); background: rgba(255,255,255,.64); }

.actions-section { margin-bottom: 24px; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-title-row h2 { margin: 4px 0 0; font-size: 20px; }
.section-title-row h2 span { margin-left: 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
.section-title-row h2 em { color: var(--urgent); font-style: normal; }
.task-list { display: grid; gap: 12px; }
.task-empty { padding: 28px; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); background: var(--panel); text-align: center; }
.task-card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.task-card.urgent { border-color: #f5c9c2; box-shadow: 0 0 0 3px #fbeeee; }
.task-card.completed { opacity: .66; }
.task-summary { display: grid; grid-template-columns: 22px minmax(0,1fr); gap: 11px; padding: 13px 15px; }
.task-check { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; color: #fff; }
.task-check.done { border-color: var(--success); background: var(--success); }
.task-check input { position: absolute; opacity: 0; pointer-events: none; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 5px; }
.priority-badge { border-radius: 3px; padding: 2px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.priority-urgent { background: var(--urgent); color: #fff; }
.priority-high { background: var(--brand); color: #fff; }
.priority-medium { background: var(--soft); color: var(--ink-2); }
.priority-low { background: var(--softer); color: var(--muted); }
.task-type,
.task-due { color: var(--muted); font-size: 12px; }
.task-card.urgent .task-due { color: var(--urgent); font-weight: 600; }
.task-title { margin: 0; color: var(--ink); font-size: 15px; font-weight: 600; }
.task-card.completed .task-title { text-decoration: line-through; }
.task-reason { margin: 8px 0 0; border-left: 2px solid var(--brand); padding: 7px 9px; background: var(--brand-bg); color: var(--ink-2); font-size: 12px; line-height: 1.5; }
.task-reason b { margin-right: 6px; color: var(--brand-strong); font-size: 10px; }

.draft-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 0 15px;
  background: #fff;
  color: var(--ink-2);
  text-align: left;
}
.draft-toggle strong { color: var(--brand); }
.draft-toggle .channel-badge { margin-left: auto; }
.chevron { color: var(--faint); transition: transform .15s; }
.draft-toggle.open .chevron { transform: rotate(180deg); }
.draft-editor { padding: 14px 15px 15px; border-top: 1px dashed var(--line-strong); }
.draft-caption { display: flex; align-items: center; gap: 5px; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.draft-caption b { color: var(--brand); }
.draft-caption span:last-child { margin-left: auto; color: var(--faint); font-family: ui-monospace, monospace; }
.model-state { border-radius: 3px; padding: 2px 5px; font-size: 9px; font-style: normal; font-weight: 700; }
.model-state.online { border: 1px solid #a8dfc9; background: #e7f8f1; color: #087a4d; }
.model-state.fallback { border: 1px solid #d7dee8; background: #f2f4f7; color: #6f7c90; }
.draft-editor textarea { width: 100%; min-height: 100px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 6px; padding: 10px 11px; color: var(--ink); line-height: 1.7; }
.draft-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; }
.draft-actions > div { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-button { min-height: 30px; border: 1px solid var(--line); border-radius: 15px; padding: 0 9px; background: var(--softer); color: var(--ink-2); font-size: 11px; }
.chip-button:hover { border-color: #b9c7d9; background: var(--soft); }
.button-success { border-color: var(--success) !important; background: var(--success) !important; color: #fff !important; }

.content-card { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: var(--panel); }
.content-card-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.content-card-head h3 { margin: 3px 0 0; font-size: 15px; }
.mini-messages { display: grid; gap: 10px; padding: 12px; border-radius: 6px; background: var(--softer); }
.mini-message { display: flex; gap: 8px; align-items: flex-end; }
.mini-message.agent { flex-direction: row-reverse; }
.mini-message.bot { flex-direction: row-reverse; }
.mini-message .avatar { width: 32px; height: 27px; flex: 0 0 auto; border-radius: 6px; font-size: 9px; }
.message-copy { max-width: 76%; }
.message-meta { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; color: var(--faint); font-size: 10px; }
.agent .message-meta { justify-content: flex-end; }
.bot .message-meta { justify-content: flex-end; }
.message-bubble { border: 1px solid var(--line); border-radius: 9px 9px 9px 3px; padding: 8px 10px; background: #fff; color: var(--ink-2); font-size: 12px; line-height: 1.55; }
.agent .message-bubble { border-color: var(--brand); border-radius: 9px 9px 3px 9px; background: var(--brand); color: #fff; }
.bot .message-bubble { border-color: #9dcbd0; border-radius: 9px 9px 3px 9px; background: #edf9fa; color: #245d63; }
.mini-message.bot .avatar { background: #d9f0f2; color: #176b73; }
.mini-message.unknown .avatar { background: #edf0f4; color: #6b778b; }
.mini-message.unknown .message-bubble { border-style: dashed; background: #f8f9fb; color: #5d687a; }
.mini-message.system .avatar { background: #e9eef5; color: #50627b; }
.party-badge { border-radius: 3px; padding: 2px 5px; background: #edf2f8; color: #52647d; font-style: normal; font-weight: 700; }
.party-agent { background: #e3efff; color: var(--brand-strong); }
.party-customer { background: #eef3f7; color: #3f5875; }
.party-bot { background: #dff3f5; color: #176b73; }
.party-unknown { background: #f0f1f3; color: #737d8b; }

.profile-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.profile-stat { min-width: 0; border-radius: 6px; padding: 10px; background: var(--softer); }
.profile-stat span { display: block; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.profile-stat strong { display: block; overflow: hidden; margin-top: 4px; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-stat strong.intent { color: var(--brand); }
.persona-block { margin-top: 13px; }
.persona-block > span { color: var(--muted); font-size: 11px; font-weight: 600; }
.persona-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.persona-tags i { border-radius: 12px; padding: 4px 8px; background: var(--brand-bg); color: var(--brand-strong); font-size: 11px; font-style: normal; }
.ctrip-tags-block { margin-top: 13px; }
.ctrip-tags-block > span { color: var(--muted); font-size: 11px; font-weight: 600; }
.ctrip-source-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ctrip-source-tags i { display: inline-flex; overflow: hidden; border: 1px solid rgba(30,90,168,.16); border-radius: 4px; background: #fff; color: var(--ink-2); font-size: 11px; font-style: normal; }
.ctrip-source-tags i b { padding: 4px 6px; background: var(--brand-bg); color: var(--brand-strong); font-weight: 700; }
.ctrip-source-tags i:not(:has(b)) { padding: 4px 7px; }
.ctrip-source-tags i b + * { padding: 4px 7px; }
.ctrip-source-tags i { padding-right: 7px; }
.ctrip-source-tags i b { margin-right: 7px; }

.secondary-view { min-height: calc(100vh - 48px); padding: 24px; background: var(--bg); }
.module-error-state { max-width: 720px; margin: 40px auto; padding: 36px; text-align: center; }
.module-error-state strong { display: block; color: var(--ink); font-size: 18px; }
.module-error-state p { margin: 10px 0 20px; color: var(--muted); }
.module-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 auto 20px; max-width: 1400px; }
.module-heading h1 { margin: 4px 0 5px; font-size: 24px; }
.module-heading p:last-child { margin: 0; color: var(--muted); line-height: 1.55; }
.module-heading-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.metric-grid { display: grid; max-width: 1400px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 auto 16px; }
.metric-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 15px 16px; background: var(--panel); }
.metric-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.metric-card strong { display: block; overflow: hidden; margin-top: 5px; color: var(--ink); font-size: 23px; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { display: block; overflow: hidden; margin-top: 4px; color: var(--faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.metric-card-button { width: 100%; appearance: none; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease; }
.metric-card-button:hover { border-color: var(--line-strong); background: var(--softer); }
.metric-card-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.metric-card-button.active { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.metric-card-button.active span,
.metric-card-button.active strong { color: var(--brand); }
.data-panel { max-width: 1400px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.settings-loading { padding: 48px 20px; color: var(--muted); text-align: center; }
.config-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 1400px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.config-stats > div { display: grid; gap: 4px; padding: 14px 16px; border-right: 1px solid var(--line); }
.config-stats > div:last-child { border-right: 0; }
.config-stats span { color: var(--muted); font-size: 11px; }
.config-stats strong { color: var(--ink); font-size: 22px; }
.config-heading { padding: 14px 16px; }
.config-actions { display: flex; gap: 8px; }
.template-list { display: grid; }
.template-row { padding: 15px 16px 17px; border-bottom: 1px solid var(--line); background: #fff; }
.template-row:last-child { border-bottom: 0; }
.template-row.disabled { background: #f7f8fa; opacity: .68; }
.template-row-head { display: grid; grid-template-columns: 34px minmax(240px, 1fr) auto auto; align-items: end; gap: 10px; margin-bottom: 13px; }
.template-row label { display: grid; gap: 5px; min-width: 0; }
.template-row label > span { color: var(--muted); font-size: 10px; font-weight: 700; }
.template-row input:not([type="checkbox"]),
.template-row select { width: 100%; min-height: 34px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 9px; background: #fff; color: var(--ink-2); }
.template-row input:disabled { background: var(--softer); color: var(--faint); }
.template-name input { border: 0 !important; border-bottom: 1px solid var(--line-strong) !important; border-radius: 0 !important; padding: 0 !important; color: var(--ink) !important; font-size: 15px; font-weight: 700; }
.template-order { align-self: center; color: var(--faint); font: 11px ui-monospace, monospace; }
.template-fields { display: grid; grid-template-columns: minmax(190px, 1.5fr) repeat(5, minmax(120px, 1fr)); gap: 11px; }
.template-fields .field-wide { grid-column: span 2; }
.config-toggle { position: relative; align-self: center; width: 30px; height: 18px; }
.config-toggle input { position: absolute; opacity: 0; }
.config-toggle span { position: absolute; inset: 0; border-radius: 9px; background: #c7d0dd; cursor: pointer; transition: background .15s; }
.config-toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15,31,56,.2); transition: transform .15s; }
.config-toggle input:checked + span { background: var(--brand); }
.config-toggle input:checked + span::after { transform: translateX(12px); }
.danger-text { color: var(--urgent) !important; }
.performance-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; max-width: 1400px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fff; }
.performance-toolbar > div { display: grid; gap: 3px; }
.performance-toolbar span { color: var(--muted); font-size: 10px; font-weight: 700; }
.performance-toolbar strong { color: var(--ink); font-size: 13px; }
.performance-toolbar label { display: grid; grid-template-columns: auto minmax(170px, 230px); align-items: center; gap: 8px; }
.performance-toolbar select { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 28px 0 10px; background: #fff; color: var(--ink-2); }
.today-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; max-width: 1400px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fff; }
.today-toolbar > div { display: grid; gap: 3px; }
.today-toolbar span { color: var(--muted); font-size: 10px; font-weight: 700; }
.today-toolbar strong { color: var(--ink); font-size: 13px; }
.today-toolbar .today-toolbar-context { display: flex; align-items: center; gap: 28px; }
.today-business-date,
.today-sync-status,
.today-review-status { display: grid; gap: 3px; }
.today-sync-status,
.today-review-status { min-width: 220px; border-left: 1px solid var(--line); padding-left: 20px; }
.today-sync-status > span,
.today-review-status > span { display: flex; align-items: center; gap: 6px; }
.today-sync-status > span i,
.today-review-status > span i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px #e9f7f0; }
.today-review-status > span i { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-bg); }
.today-review-status.running > span i { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
.today-sync-status small,
.today-review-status small { color: var(--faint); font-size: 10px; }
.today-toolbar-actions { display: flex !important; align-items: center; gap: 10px !important; }
.today-toolbar label { display: grid; grid-template-columns: auto minmax(180px, 250px); align-items: center; gap: 8px; }
.today-toolbar select { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 28px 0 10px; background: #fff; color: var(--ink-2); }
.today-metrics,
.performance-metrics,
.reports-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.today-section .panel-heading { align-items: end; }
.today-section .panel-heading span,
.today-overview-panel .panel-heading span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.today-section .panel-heading > strong { color: var(--brand); font-size: 24px; }
.today-critical { border-top: 3px solid var(--urgent); }
.today-sales { border-top: 3px solid var(--brand); }
.today-nurture { border-top: 3px solid #d6a64a; }
.today-standard { border-top: 3px solid #6e8aab; }
.today-task-list { display: grid; }
.today-task-row { display: grid; grid-template-columns: 28px minmax(300px, 1.6fr) minmax(180px, .75fr) auto; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #edf0f5; }
.today-task-row:last-child { border-bottom: 0; }
.today-task-row:hover { background: #fbfcfe; }
.today-task-row.today-priority-urgent { box-shadow: inset 3px 0 0 var(--urgent); background: #fffafa; }
.today-task-row.today-priority-high { box-shadow: inset 3px 0 0 var(--brand); background: #fff; }
.today-task-row.today-priority-medium { box-shadow: inset 3px 0 0 #d6a64a; background: #fff; }
.today-task-row.today-priority-low { box-shadow: inset 3px 0 0 #9aa8ba; background: #fff; }
.today-task-check { display: grid; width: 22px; height: 22px; place-items: center; }
.today-task-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.today-task-main { min-width: 0; }
.today-task-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.today-task-meta b { margin-left: auto; color: var(--warning); font-weight: 700; }
.today-task-main h3 { margin: 6px 0 4px; color: var(--ink); font-size: 14px; }
.today-task-main p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.today-task-lead { display: grid; min-width: 0; gap: 3px; padding-left: 12px; border-left: 1px solid var(--line); }
.today-task-lead strong,
.today-task-lead span,
.today-task-lead small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-task-lead strong { color: var(--ink); font-size: 12px; }
.today-task-lead span { color: var(--muted); font-size: 10px; }
.today-task-lead small { color: var(--faint); font-size: 10px; }
.today-task-actions { display: flex; align-items: center; gap: 7px; }
.opportunity-score { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 7px; border-top: 1px solid var(--line); padding-top: 7px; }
.opportunity-score > b { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid #b9cfea; border-radius: 6px; background: var(--brand-tint); color: var(--brand); font-size: 16px; }
.opportunity-score > span { display: grid; min-width: 0; gap: 1px; }
.opportunity-score > span > strong { color: var(--ink-2); font-size: 10px; }
.opportunity-score > span > small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.opportunity-score > span > em { overflow: hidden; color: var(--brand); font-size: 10px; font-style: normal; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.today-overview-list { display: grid; }
.today-overview-list > button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; border: 0; border-bottom: 1px solid #edf0f5; padding: 11px 16px; background: #fff; color: var(--ink-2); text-align: left; }
.today-overview-list > button:last-child { border-bottom: 0; }
.today-overview-list > button:hover { background: var(--softer); }
.today-overview-list > button span { display: grid; min-width: 0; gap: 3px; }
.today-overview-list > button strong,
.today-overview-list > button small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-overview-list > button strong { color: var(--ink); font-size: 12px; }
.today-overview-list > button small { color: var(--muted); font-size: 10px; }
.today-overview-list > button > b { color: var(--brand); font-size: 10px; }
.today-empty { display: grid; min-height: 180px; place-content: center; gap: 6px; color: var(--muted); text-align: center; }
.today-empty strong { color: var(--ink); font-size: 16px; }
.today-empty.compact { min-height: 90px; }
.performance-table { min-width: 1080px; }
.progress-summary { color: var(--ink-2); font-size: 11px; white-space: nowrap; }
.quality-pill { display: inline-flex; align-items: baseline; gap: 5px; min-width: 74px; border-radius: 4px; padding: 5px 7px; font-size: 10px; font-weight: 700; }
.quality-pill b { font-size: 15px; }
.quality-excellent { background: #e6f7ef; color: #08794f; }
.quality-good { background: #eaf3ff; color: #1768b1; }
.quality-fair { background: #fff5dc; color: #946000; }
.quality-attention { background: var(--urgent-bg); color: var(--urgent); }
.opportunity-table { min-width: 1040px; }
.data-toolbar { display: flex; align-items: center; gap: 9px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.wide-search { width: min(420px, 100%); }
.data-toolbar select { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 28px 0 10px; background: #fff; color: var(--ink-2); }
.table-wrap { overflow: auto; }
.crm-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.crm-table th { height: 38px; padding: 0 13px; border-bottom: 1px solid var(--line); background: var(--softer); color: var(--muted); font-size: 10px; text-align: left; text-transform: uppercase; white-space: nowrap; }
.crm-table td { max-width: 300px; padding: 11px 13px; border-bottom: 1px solid #edf0f5; color: var(--ink-2); vertical-align: middle; }
.crm-table tr:last-child td { border-bottom: 0; }
.crm-table td > strong { display: block; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.crm-table td > small { display: block; margin-top: 3px; color: var(--faint); font: 10px ui-monospace, monospace; }
.crm-table code { color: var(--brand-strong); font-size: 11px; }
.table-empty { padding: 34px !important; color: var(--faint) !important; text-align: center; }
.score-value { color: var(--brand) !important; font-size: 15px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 3px 0 0; font-size: 16px; }
.split-panels { display: grid; max-width: 1400px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 auto; }
.split-panels .data-panel { width: 100%; }
.status-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; padding: 8px 16px 16px; }
.status-list div { min-width: 0; padding: 10px 0; border-bottom: 1px solid #edf0f5; }
.status-list div:nth-child(odd) { padding-right: 14px; }
.status-list dt { color: var(--muted); font-size: 10px; }
.status-list dd { overflow: hidden; margin: 4px 0 0; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.error-text { color: var(--urgent) !important; }
.health-pill { display: inline-flex; align-items: center; min-height: 23px; border-radius: 12px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
.health-pill.healthy { background: var(--success-bg); color: var(--success); }
.health-pill.pending { background: var(--warning-bg); color: var(--warning); }
.health-pill.error { background: var(--urgent-bg); color: var(--urgent); }
.link-coverage { display: grid; place-items: center; min-height: 230px; padding: 28px; text-align: center; }
.link-coverage > strong { color: var(--brand); font-size: 42px; }
.link-coverage > span { margin-top: 5px; color: var(--muted); }
.link-coverage > div { width: min(360px, 100%); height: 8px; margin-top: 22px; overflow: hidden; border-radius: 4px; background: var(--soft); }
.link-coverage > div i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.bar-chart { display: grid; gap: 12px; padding: 18px; }
.bar-row { display: grid; grid-template-columns: 86px minmax(0, 1fr) 28px; align-items: center; gap: 10px; }
.bar-row > span { color: var(--muted); font-size: 11px; }
.bar-row > div { height: 9px; overflow: hidden; border-radius: 5px; background: var(--soft); }
.bar-row > div i { display: block; height: 100%; border-radius: 5px; }
.bar-row strong { color: var(--ink-2); text-align: right; }
.channel-report { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 18px; }
.channel-report > div { border-radius: 6px; padding: 12px; background: var(--softer); }
.channel-report span { display: block; color: var(--muted); font-size: 10px; }
.channel-report strong { display: block; margin-top: 4px; color: var(--brand); font-size: 22px; }
.channel-report p { grid-column: 1 / -1; margin: 6px 0 0; color: var(--muted); line-height: 1.6; }
.system-hidden { margin: 2px 0 0; color: var(--faint); font-size: 10px; }

.drawer-overlay { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: flex-end; }
.drawer-backdrop { position: absolute; inset: 0; border: 0; background: rgba(15,15,20,.4); backdrop-filter: blur(2px); animation: fade-in .15s ease-out; }
.chat-drawer { position: relative; z-index: 1; display: flex; width: min(480px, 100vw); flex-direction: column; height: 100%; background: var(--panel); box-shadow: -8px 0 32px rgba(0,0,0,.12); animation: slide-in .2s ease-out; }
.drawer-header { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer-title-line { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.drawer-title-line h3 { margin: 3px 0 0; font-size: 16px; }
.drawer-controls { display: grid; gap: 8px; margin-top: 12px; }
.drawer-tabs { display: flex; gap: 4px; }
.drawer-tabs button { min-height: 29px; border: 1px solid transparent; border-radius: 4px; padding: 0 9px; background: transparent; color: var(--muted); font-size: 11px; }
.drawer-tabs button.active { border-color: #c7d7eb; background: var(--brand-bg); color: var(--brand); }
.drawer-messages { flex: 1; overflow: auto; padding: 16px 20px; background: var(--bg); }
.drawer-messages .mini-message { margin-bottom: 13px; }
.system-snippet { max-width: 100%; border: 1px solid var(--line); border-radius: 5px; background: var(--softer); color: var(--muted); }
.system-snippet summary { padding: 9px 11px; cursor: pointer; font-size: 11px; font-weight: 700; }
.system-snippet pre { overflow: auto; max-height: 180px; margin: 0; border-top: 1px solid var(--line); padding: 10px 11px; color: var(--faint); font: 10px/1.55 ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; }
mark { border-radius: 2px; padding: 0 2px; background: var(--highlight); color: var(--ink); }

.toast { position: fixed; z-index: 120; right: 22px; bottom: 22px; max-width: min(380px, calc(100vw - 44px)); transform: translateY(12px); border-radius: 6px; padding: 10px 13px; background: var(--dark); color: #fff; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; box-shadow: 0 8px 24px rgba(15,31,56,.2); }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--urgent); }

.badge[class*="status-"] { border: 1px solid transparent; }
.status-DORMANT { border-color: #dfe4eb !important; background: #f1f3f6; color: #7b8799; }
.status-SHALLOW { border-color: #cbddec !important; background: #edf5fb; color: #527fa8; }
.status-HIGH_INTENT { border-color: #9bcdf8 !important; background: #dceeff; color: #096cc8; }
.status-QUOTED { border-color: #0867d5 !important; background: #0867d5; color: #fff; box-shadow: 0 1px 3px rgba(8,103,213,.18); }
.status-ORDERED { border-color: #0da86b !important; background: #0da86b; color: #fff; box-shadow: 0 1px 3px rgba(13,168,107,.18); }
.status-REPEAT { border-color: #008f87 !important; background: #008f87; color: #fff; box-shadow: 0 1px 3px rgba(0,143,135,.18); }
.status-POST_SALE { border-color: #b7dcd9 !important; background: #e5f5f3; color: #287c77; }
.status-COMPLAINT { border-color: #edb5af !important; background: var(--urgent-bg); color: var(--urgent); }
.status-row-DORMANT .task-preview { border-left-color: #a7b1c0; }
.status-row-SHALLOW .task-preview { border-left-color: #7ca6cf; }
.status-row-HIGH_INTENT .task-preview { border-left-color: #2684e8; background: #edf6ff; }
.status-row-QUOTED .task-preview { border-left-color: #0867d5; background: #eaf3ff; }
.status-row-ORDERED .task-preview { border-left-color: #0da86b; background: #e8f8f1; }
.status-row-REPEAT .task-preview { border-left-color: #00a39b; background: #e7f8f6; }

.access-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.access-grid { display: grid; max-width: 1400px; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr); gap: 16px; margin: 0 auto 16px; }
.access-grid .data-panel { width: 100%; margin: 0; }
.access-create-form { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr 1fr auto; align-items: end; gap: 10px; border-bottom: 1px solid var(--line); padding: 14px 16px; background: var(--softer); }
.access-create-form label,
.license-admin-panel form label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.access-create-form input,
.access-create-form select,
.license-admin-panel input,
.license-admin-panel select { width: 100%; min-height: 36px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 9px; background: #fff; color: var(--ink); }
.access-table td:first-child strong,
.access-table td:first-child small { display: block; }
.crm-table.access-table { min-width: 680px; }
.access-table td:first-child small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.badge.access-active { background: var(--success-bg); color: var(--success); }
.badge.access-disabled { background: var(--soft); color: var(--muted); }
.row-actions { display: flex; gap: 10px; white-space: nowrap; }
.text-button.danger { color: var(--urgent); }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.access-device-list { display: grid; }
.access-device-list > div { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 13px 16px; }
.access-device-list > div:last-child { border-bottom: 0; }
.access-device-list span:nth-child(2) { display: grid; min-width: 0; gap: 2px; }
.access-device-list strong,
.access-device-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.access-device-list small { color: var(--muted); font-size: 10px; }
.device-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 5px; background: var(--brand-bg); color: var(--brand); font-size: 9px; font-weight: 800; }
.access-empty { display: block !important; padding: 28px !important; color: var(--muted); text-align: center; }
.license-admin-panel form { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)) auto; align-items: end; gap: 12px; padding: 16px; }
.vendor-only { border-radius: 999px; padding: 4px 8px; background: var(--brand-bg); color: var(--brand); font-size: 10px; }
.license-blocked-panel { display: grid; max-width: 1400px; gap: 5px; margin: 0 auto 16px; border: 1px solid #f2c4bf; border-left: 4px solid var(--urgent); border-radius: 6px; padding: 15px 16px; background: var(--urgent-bg); color: var(--ink-2); }
.license-blocked-panel strong { color: var(--urgent); font-size: 15px; }

@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 1100px) {
  .app-header { grid-template-columns: 235px 1fr auto; }
  .today-summary { display: none; }
  .pipeline { overflow-x: auto; grid-template-columns: repeat(8, 112px); }
  .workspace { grid-template-columns: 275px minmax(0, 1fr); }
  .main-content { padding-inline: 22px; }
  .template-fields { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .today-metrics,
  .performance-metrics,
  .reports-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .today-task-row { grid-template-columns: 28px minmax(280px, 1fr) auto; }
  .today-task-lead { grid-column: 2; grid-row: 2; padding-left: 0; border-left: 0; }
  .access-grid { grid-template-columns: 1fr; }
  .access-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .access-create-form button { justify-self: start; }
  .license-admin-panel form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-header { grid-template-columns: 1fr auto; height: auto; min-height: 48px; padding-block: 8px; }
  .module-tabs { grid-column: 1 / -1; order: 3; overflow-x: auto; padding-top: 6px; }
  .pipeline-band { position: static; }
  .workspace { grid-template-columns: 1fr; }
  .queue-pane { position: static; height: 320px; border-right: 0; border-bottom: 1px solid var(--line); }
  .lead-header { padding-inline: 18px; }
  .main-content { padding: 18px 16px 48px; }
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid,
  .split-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .config-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .config-stats > div:nth-child(2) { border-right: 0; }
  .config-stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .secondary-view { padding: 18px 14px; }
  .performance-toolbar { align-items: stretch; flex-direction: column; }
  .performance-toolbar label { grid-template-columns: 1fr; }
  .today-toolbar { align-items: stretch; flex-direction: column; }
  .today-toolbar .today-toolbar-context { align-items: flex-start; flex-direction: column; gap: 12px; }
  .today-sync-status,
  .today-review-status { width: 100%; min-width: 0; border-top: 1px solid var(--line); border-left: 0; padding-top: 10px; padding-left: 0; }
  .today-toolbar-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .today-toolbar label { grid-template-columns: 1fr; }
  .today-task-row { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .access-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .app-header { padding-inline: 12px; }
  .archive-state { display: none; }
  .license-state { display: none; }
  .pipeline-band { padding-inline: 12px; }
  .lead-header { align-items: flex-start; flex-wrap: wrap; }
  .lead-header-actions { width: 100%; margin-left: 0; }
  .lead-header-actions > button { flex: 1; }
  .today-task-actions { grid-column: 2; justify-self: start; flex-wrap: wrap; }
  .main-content { padding-inline: 10px; }
  .insight-list { margin-left: 0; }
  .copilot-profile { margin-left: 0; }
  .draft-actions { align-items: stretch; flex-direction: column; }
  .draft-actions > div:last-child { justify-content: flex-end; }
  .profile-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid,
  .split-panels { grid-template-columns: 1fr; }
  .module-heading { align-items: flex-start; flex-direction: column; }
  .config-heading { align-items: stretch; }
  .config-actions { justify-content: flex-end; }
  .template-row-head { grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; }
  .template-row-head .danger-text { grid-column: 2 / -1; justify-self: end; }
  .template-fields { grid-template-columns: 1fr; }
  .template-fields .field-wide { grid-column: auto; }
  .data-toolbar { align-items: stretch; flex-direction: column; }
  .wide-search { width: 100%; }
  .channel-report { grid-template-columns: 1fr; }
  .channel-report p { grid-column: 1; }
  .today-metrics,
  .performance-metrics,
  .reports-metrics { grid-template-columns: 1fr; }
  .today-task-row { grid-template-columns: 24px minmax(0, 1fr); }
  .today-task-row > button { grid-column: 2; justify-self: start; }
  .status-list { grid-template-columns: 1fr; }
  .login-shell { padding: 24px; }
  .access-create-form,
  .license-admin-panel form { grid-template-columns: 1fr; }
  .access-metrics { grid-template-columns: 1fr; }
}
