:root {
  --ink: #10231e;
  --deep: #122821;
  --moss: #28443b;
  --paper: #f6f4ef;
  --cream: #fffdf8;
  --panel: #ffffff;
  --lime: #b9ef55;
  --lime-soft: #f1fad8;
  --rust: #c66f43;
  --muted: #69756f;
  --line: #e4dfd4;
  --line-strong: #cbc2b2;
  --danger: #b75b49;
  --shadow: 0 10px 34px rgba(16, 35, 30, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, Manrope, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(246, 244, 239, 0.92);
  border-bottom: 1px solid rgba(228, 223, 212, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--lime);
  box-shadow: inset 0 0 0 1px rgba(7, 27, 21, 0.12);
}

.brand-mark::after {
  content: "М";
  color: var(--ink);
  font-size: 15px;
  font-weight: 560;
  line-height: 1;
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 560;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
}

.nav-links {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.72);
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 13px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 520;
}

.nav-links a.active {
  background: var(--ink);
  color: var(--cream);
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 14px;
  min-height: calc(100vh - 64px);
  padding: 14px;
}

.admin-shell {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
}

.call-surface {
  display: grid;
  grid-template-rows: auto auto auto minmax(320px, 1fr);
  gap: 12px;
  min-width: 0;
}

.topbar,
.agent-stage,
.transcript-panel,
.card {
  border: 1px solid rgba(225, 216, 199, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--rust);
  font-size: 11px;
  line-height: 1;
  font-weight: 560;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  font-weight: 560;
}

h1 {
  max-width: 720px;
  font-size: clamp(27px, 2.35vw, 36px);
  line-height: 1.16;
}

h2 {
  font-size: 20px;
  line-height: 1.18;
}

.status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid rgba(7, 27, 21, 0.14);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.72);
  font-weight: 520;
  text-decoration: none;
}

.status.live {
  background: var(--lime);
  color: var(--ink);
  border-color: var(--lime);
}

.agent-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 20px;
  min-height: 124px;
  background: var(--deep);
  color: var(--cream);
  box-shadow: 0 14px 46px rgba(7, 27, 21, 0.13);
}

.agent-orb {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(185, 239, 85, 0.1);
  border: 1px solid rgba(185, 239, 85, 0.25);
}

.agent-orb span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 10px rgba(185, 239, 85, 0.08);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.agent-orb.live span {
  transform: scale(1.22);
  opacity: 0.82;
}

.agent-name {
  margin: 0 0 7px;
  font-size: clamp(19px, 1.8vw, 24px);
  font-weight: 560;
  letter-spacing: 0;
}

.agent-state {
  margin: 0;
  color: rgba(255, 250, 240, 0.66);
  line-height: 1.45;
}

.call-controls {
  display: flex;
  gap: 10px;
}

.control {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 250, 240, 0.14);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.08);
  color: var(--cream);
  cursor: pointer;
  font-size: 18px;
  font-weight: 560;
}

.control.primary {
  background: var(--lime);
  color: var(--ink);
  border-color: var(--lime);
}

.control.danger {
  color: #ffb49b;
}

.control:hover:not(:disabled),
.quick-text button:hover,
.submit:hover:not(:disabled),
.slot-button:hover,
.admin-actions button:hover,
.admin-actions a:hover {
  transform: translateY(-1px);
}

.control:disabled,
.submit:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.quick-text {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-text button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 520;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.test-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(225, 216, 199, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.test-panel[hidden] {
  display: none;
}

.test-panel h2 {
  margin-bottom: 8px;
}

.test-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.test-scenarios {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.test-scenarios button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 520;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.test-scenarios button:hover {
  border-color: var(--line-strong);
  background: var(--cream);
  transform: translateY(-1px);
}

.transcript-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.messages {
  min-height: 0;
  max-height: calc(100vh - 440px);
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 84%;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.message.system {
  max-width: 100%;
  background: rgba(7, 27, 21, 0.055);
  color: var(--muted);
}

.message.agent {
  align-self: flex-start;
  background: var(--ink);
  color: var(--cream);
}

.message.user {
  align-self: flex-end;
  background: var(--lime);
  color: var(--ink);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.card {
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: 6px;
}

.admin-tabs button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 520;
}

.admin-tabs button.active {
  background: var(--ink);
  color: var(--cream);
}

.submit.compact {
  width: auto;
  min-width: 120px;
  margin-top: 0;
  padding: 10px 12px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar-search {
  min-width: min(100%, 320px);
  flex: 1 1 260px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  color: var(--ink);
  padding: 0 13px;
  font: inherit;
}

.toolbar-search:focus,
.lead-note-input:focus {
  outline: 2px solid rgba(183, 241, 86, 0.34);
  outline-offset: 1px;
}

.filter-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  color: var(--muted);
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 520;
}

.filter-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.pipeline-stage {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.76);
  color: var(--ink);
  padding: 11px;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 3px 0 0 rgba(7, 27, 21, 0.16);
}

.pipeline-stage.callback {
  box-shadow: inset 3px 0 0 #e8a33d;
}

.pipeline-stage.measure {
  box-shadow: inset 3px 0 0 #4b83df;
}

.pipeline-stage.won {
  box-shadow: inset 3px 0 0 #45a96b;
}

.pipeline-stage.lost {
  box-shadow: inset 3px 0 0 #b75b49;
}

.pipeline-stage.not_target {
  box-shadow: inset 3px 0 0 #8c918b;
}

.pipeline-stage.active {
  border-color: rgba(7, 27, 21, 0.34);
  background: rgba(183, 241, 86, 0.14);
}

.pipeline-stage span,
.pipeline-stage small,
.pipeline-stage em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-stage strong {
  font-size: 24px;
  font-weight: 620;
}

label {
  display: block;
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 520;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

input,
textarea,
select {
  display: block;
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(7, 27, 21, 0.45);
  background: #fffdf8;
  box-shadow: 0 0 0 4px rgba(200, 243, 109, 0.24);
}

.agent-profile-row {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.agents-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.owner-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.owner-summary div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: 10px;
}

.owner-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
}

.owner-summary strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
  line-height: 1;
  font-weight: 560;
}

.owner-attention {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.owner-attention:empty {
  display: none;
}

.owner-attention-head,
.owner-attention-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
  padding: 10px;
}

.owner-attention-head strong,
.owner-attention-empty strong {
  font-size: 14px;
  font-weight: 560;
}

.owner-attention-head span,
.owner-attention-empty span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.owner-attention-items {
  display: grid;
  gap: 8px;
}

.owner-attention-items article {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(183, 91, 73, 0.18);
  border-radius: 8px;
  background: #fffaf4;
  padding: 10px;
}

.owner-attention-items strong,
.owner-attention-items span {
  display: block;
}

.owner-attention-items strong {
  font-size: 14px;
  font-weight: 560;
}

.owner-attention-items span,
.owner-attention-items p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.owner-attention-items p {
  margin: 0;
}

.owner-attention-items a {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffdf8;
  padding: 8px 10px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 520;
}

.event-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.event-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: 10px;
}

.event-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
}

.event-summary strong {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 19px;
  line-height: 1;
  font-weight: 560;
}

.event-timeline {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.event-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.62);
  padding: 11px;
}

.event-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.event-item.booking .event-dot,
.event-item.slot_created .event-dot,
.event-item.slot_updated .event-dot {
  background: var(--lime);
}

.event-item.quality_review .event-dot,
.event-item.telegram_error .event-dot {
  background: var(--danger);
}

.event-item.billing_updated .event-dot,
.event-item.lead_status .event-dot {
  background: #d7a332;
}

.event-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.event-head strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 560;
}

.event-head time,
.event-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
}

.event-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.agent-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.7);
  padding: 13px;
}

.agent-card.active {
  border-color: rgba(7, 27, 21, 0.22);
  background: #fffdf8;
  box-shadow: inset 3px 0 0 var(--lime);
}

.agent-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.agent-card-top strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 560;
}

.agent-card-top small,
.agent-card-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.agent-card-meta {
  display: grid;
  gap: 3px;
  margin-top: 10px;
}

.agent-readiness {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(228, 223, 212, 0.78);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.68);
  padding: 10px;
}

.agent-readiness-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.agent-readiness-head strong {
  color: var(--danger);
  font-size: 12px;
  font-weight: 560;
}

.agent-readiness-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-readiness-pills span {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 250, 240, 0.8);
  color: var(--muted);
  padding: 5px 7px;
  font-size: 11px;
  font-weight: 520;
}

.agent-readiness-pills span.ready {
  background: var(--lime-soft);
  color: var(--ink);
  border-color: rgba(7, 27, 21, 0.14);
}

.agent-usage {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  border: 1px solid rgba(228, 223, 212, 0.76);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.62);
  padding: 10px;
}

.agent-usage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.agent-usage-head strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 560;
}

.agent-usage.warning .agent-usage-head strong {
  color: #996f16;
}

.agent-usage.exceeded .agent-usage-head strong {
  color: var(--danger);
}

.agent-usage-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(7, 27, 21, 0.08);
}

.agent-usage-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--lime);
}

.agent-usage.warning .agent-usage-bar i {
  background: #d7a332;
}

.agent-usage.exceeded .agent-usage-bar i {
  background: var(--danger);
}

.agent-economy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  border: 1px solid rgba(228, 223, 212, 0.72);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.58);
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 520;
}

.agent-economy strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 560;
}

.agent-economy.warning strong {
  color: #996f16;
}

.agent-economy.danger strong {
  color: var(--danger);
}

.agent-card-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.agent-card-stats div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.7);
  padding: 8px;
}

.agent-card-stats strong {
  display: block;
  font-size: 18px;
  line-height: 1;
  font-weight: 560;
}

.agent-card-stats small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
}

.telephony-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  gap: 12px;
  margin-top: 14px;
}

.telephony-summary,
.telephony-help {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.7);
  padding: 13px;
}

.telephony-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.telephony-summary div {
  min-width: 0;
}

.telephony-summary small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
}

.telephony-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 520;
  overflow-wrap: anywhere;
}

.telephony-help strong {
  display: block;
  font-size: 14px;
}

.telephony-help p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.launch-checklist {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.launch-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.76);
  padding: 12px;
}

.launch-score strong {
  font-size: 22px;
  font-weight: 560;
}

.launch-score span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.launch-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.launch-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  padding: 10px;
}

.launch-item span {
  width: fit-content;
  border-radius: 6px;
  background: #fff6df;
  color: #936223;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 560;
}

.launch-item.ready span {
  background: var(--lime-soft);
  color: var(--ink);
}

.launch-item strong {
  font-size: 14px;
  font-weight: 560;
}

.launch-item small {
  color: var(--muted);
  line-height: 1.35;
}

.inline-action {
  display: inline-flex;
  margin-top: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 560;
  text-decoration: none;
}

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.scenario-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.scenario-guide div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.68);
  padding: 10px;
}

.scenario-guide span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  grid-row: span 2;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--cream);
  font-size: 12px;
  font-weight: 620;
}

.scenario-guide strong {
  min-width: 0;
  font-size: 14px;
  font-weight: 620;
}

.scenario-guide small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.industry-profile-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr);
  gap: 14px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  padding: 14px;
}

.industry-profile-panel h3 {
  margin: 3px 0 6px;
  font-size: 18px;
  font-weight: 560;
}

.industry-profile-controls {
  display: grid;
  gap: 10px;
}

.industry-profile-controls .submit {
  margin-top: 0;
}

.industry-template-summary {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.industry-template-summary strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 560;
}

.lead-field-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 3px;
}

.lead-field-pills em {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--ink);
  padding: 6px 8px;
  font-style: normal;
  font-size: 12px;
  font-weight: 520;
}

.lead-detail-list {
  display: grid;
  gap: 7px;
}

.lead-detail-list div {
  display: grid;
  grid-template-columns: minmax(110px, 0.44fr) minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.78);
  padding: 8px 10px;
}

.lead-detail-list span {
  color: var(--muted);
  font-size: 12px;
}

.lead-detail-list strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 540;
  overflow-wrap: anywhere;
}

.quality-panel {
  border: 1px solid rgba(7, 27, 21, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  padding: 13px;
}

.quality-panel.needs_review,
.quality-panel.bad_lead {
  border-color: rgba(232, 163, 61, 0.34);
  background: rgba(232, 163, 61, 0.09);
}

.quality-panel.scenario_issue,
.quality-panel.technical_issue {
  border-color: rgba(183, 91, 73, 0.34);
  background: rgba(183, 91, 73, 0.08);
}

.quality-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.quality-score strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 620;
}

.quality-score span,
.quality-panel small {
  color: var(--muted);
  font-size: 12px;
}

.quality-panel p {
  margin: 0 0 7px;
}

.quality-delivery {
  margin-top: 10px;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12px;
}

.quality-delivery.success {
  background: rgba(69, 169, 107, 0.11);
  color: #286a43;
}

.quality-delivery.danger {
  background: rgba(183, 91, 73, 0.1);
  color: #873c2f;
}

.quality-delivery.muted {
  background: rgba(7, 27, 21, 0.06);
  color: var(--muted);
}

.training-suggestion {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  border-top: 1px solid rgba(7, 27, 21, 0.1);
  padding-top: 10px;
}

.training-suggestion span {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.training-suggestion button {
  border: 1px solid rgba(7, 27, 21, 0.14);
  border-radius: 8px;
  background: var(--ink);
  color: #fffdf6;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 620;
  cursor: pointer;
}

.training-suggestion button:disabled {
  background: rgba(7, 27, 21, 0.08);
  color: var(--muted);
  cursor: default;
}

.training-history {
  margin-top: 18px;
}

.compact-head {
  margin-bottom: 10px;
}

.training-history-empty,
.training-history-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: 12px;
}

.training-history-empty,
.training-history-list {
  display: grid;
  gap: 8px;
}

.training-history-empty span,
.training-history-list span,
.training-history-list small {
  color: var(--muted);
  font-size: 12px;
}

.training-history-list article {
  display: grid;
  gap: 5px;
}

.training-history-list strong {
  font-size: 13px;
  font-weight: 560;
}

.scenario-test-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.scenario-test-presets button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  color: var(--ink);
  padding: 8px 11px;
  cursor: pointer;
  font: inherit;
  font-weight: 520;
}

.scenario-test-result {
  display: grid;
  gap: 6px;
  min-height: 92px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--muted);
  padding: 13px;
  line-height: 1.5;
}

.scenario-test-result span {
  color: var(--muted);
  font-size: 12px;
}

.scenario-test-result strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 560;
  overflow-wrap: anywhere;
}

.submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--cream);
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 560;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

a.submit {
  text-decoration: none;
}

.submit.secondary {
  background: rgba(255, 250, 240, 0.82);
  color: var(--ink);
  border: 1px solid var(--line);
}

.submit.secondary:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #fffdf8;
}

.note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.slots,
.calls-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.slot-button,
.call-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.76);
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
}

.slot-button {
  cursor: pointer;
  font-weight: 520;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.slot-button.selected {
  background: var(--lime-soft);
  border-color: rgba(7, 27, 21, 0.24);
  box-shadow: inset 4px 0 0 var(--lime);
}

.call-item strong {
  display: block;
  margin-bottom: 5px;
  overflow-wrap: anywhere;
}

.call-item small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.calls-board {
  gap: 10px;
}

.lead-card {
  padding: 13px;
}

.lead-card.callback {
  box-shadow: inset 3px 0 0 #e8a33d;
}

.lead-card.measure {
  box-shadow: inset 3px 0 0 #4b83df;
}

.lead-card.won {
  box-shadow: inset 3px 0 0 #45a96b;
}

.lead-card.lost {
  box-shadow: inset 3px 0 0 #b75b49;
}

.lead-card.not_target {
  box-shadow: inset 3px 0 0 #8c918b;
}

.lead-card.handled {
  opacity: 0.82;
}

.lead-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lead-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.lead-next-action {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  padding: 10px;
}

.lead-next-action span,
.lead-lines span {
  color: var(--muted);
  font-size: 11px;
}

.lead-next-action strong {
  font-size: 14px;
  font-weight: 560;
}

.lead-lines {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(120px, 0.8fr) minmax(100px, 0.5fr) minmax(0, 1.5fr);
  gap: 8px;
  margin-top: 10px;
}

.lead-lines div {
  min-width: 0;
  border: 1px solid rgba(228, 223, 212, 0.75);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.52);
  padding: 8px;
}

.lead-actions {
  margin-top: 10px;
}

.badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--cream);
  color: var(--muted);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 520;
}

.badge.success {
  background: var(--lime-soft);
  color: var(--ink);
  border-color: rgba(7, 27, 21, 0.16);
}

.badge.danger {
  background: #fff0ec;
  color: var(--danger);
  border-color: rgba(183, 91, 73, 0.24);
}

.badge.warning {
  background: #fff6df;
  color: #936223;
  border-color: rgba(232, 163, 61, 0.28);
}

.badge.info {
  background: #eef5ff;
  color: #3262a8;
  border-color: rgba(75, 131, 223, 0.24);
}

.badge.lost {
  background: #fff0ec;
  color: var(--danger);
  border-color: rgba(183, 91, 73, 0.24);
}

.badge.muted {
  color: var(--muted);
}

details {
  margin-top: 10px;
}

summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 560;
}

.lead-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.lead-detail-grid h3 {
  margin: 0 0 7px;
  font-size: 14px;
}

.lead-detail-grid p,
.lead-detail-grid pre {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--muted);
  padding: 10px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lead-detail-grid pre {
  max-height: 280px;
  overflow: auto;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
}

.lead-note-input {
  width: 100%;
  resize: vertical;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  padding: 10px;
  font: inherit;
  line-height: 1.48;
}

.lead-crm-fields {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.lead-crm-fields label {
  margin-top: 0;
  color: var(--muted);
  font-size: 12px;
}

.lead-crm-fields input {
  margin-top: 5px;
  height: 38px;
  font-size: 14px;
}

.danger-text {
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.76);
  padding: 12px;
}

.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1;
  font-weight: 560;
}

.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 520;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.admin-actions button,
.admin-actions a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink);
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 520;
  font-size: 13px;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.client-mode .admin-shell {
  grid-template-columns: minmax(0, 1180px);
  justify-content: center;
}

.client-mode .admin-main {
  gap: 14px;
}

.client-mode .side {
  display: none;
}

.client-mode .topbar {
  align-items: center;
  background: #fffdf8;
}

.client-mode .topbar h1 {
  max-width: 760px;
}

.client-mode .card {
  box-shadow: none;
}

.client-overview {
  background: #fffdf8;
}

.client-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.client-metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.7);
  padding: 13px;
}

.client-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.client-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
  font-weight: 560;
}

.client-mode .admin-toolbar {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.client-mode .lead-next-action,
.client-mode .lead-lines div,
.client-mode .slot-button,
.client-mode .call-item {
  background: #fffdf8;
}

.client-mode .knowledge-grid,
.client-mode .admin-grid {
  gap: 12px;
}

.muted-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .shell,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .lead-detail-grid {
    grid-template-columns: 1fr;
  }

  .pipeline-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .messages {
    max-height: none;
    min-height: 320px;
  }

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

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

  .scenario-guide {
    grid-template-columns: 1fr;
  }

  .industry-profile-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-nav {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
  }

  .nav-links {
    width: 100%;
  }

  .nav-links a {
    flex: 1;
  }

  .shell {
    padding: 10px;
  }

  .topbar,
  .agent-stage {
    display: grid;
    grid-template-columns: 1fr;
  }

  .agent-stage {
    min-height: 0;
  }

  .call-controls {
    width: 100%;
  }

  .control {
    flex: 1;
    width: auto;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-tabs button {
    flex: 1 1 calc(50% - 6px);
  }

  .pipeline-board {
    grid-template-columns: 1fr;
  }

  .agent-profile-row {
    grid-template-columns: 1fr;
  }

  .agents-board {
    grid-template-columns: 1fr;
  }

  .owner-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .owner-attention-items article {
    grid-template-columns: 1fr;
  }

  .telephony-grid,
  .telephony-summary {
    grid-template-columns: 1fr;
  }

  .test-panel,
  .test-scenarios {
    grid-template-columns: 1fr;
  }

  .launch-score {
    align-items: flex-start;
    flex-direction: column;
  }

  .launch-score span {
    text-align: left;
  }

  .launch-items {
    grid-template-columns: 1fr;
  }

  .client-metrics {
    grid-template-columns: 1fr;
  }

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

  .owner-attention-head,
  .owner-attention-empty {
    align-items: flex-start;
    flex-direction: column;
  }

  .knowledge-grid {
    grid-template-columns: 1fr;
  }
}
