:root {
  color-scheme: light;
  --bg: #eef2f0;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --ink: #182027;
  --muted: #64717b;
  --line: #d9e1dc;
  --line-strong: #c6d1ca;
  --teal: #0f766e;
  --teal-soft: #dff5ef;
  --blue: #255b8d;
  --blue-soft: #e8f1fb;
  --coral: #b84b3f;
  --coral-soft: #fde8df;
  --green: #386a48;
  --green-soft: #e4f3e7;
  --shadow: 0 18px 44px rgba(24, 32, 39, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(238, 242, 240, 0.96)),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.22;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.25;
  letter-spacing: 0;
}

.crm-demo-shell {
  width: min(1460px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.crm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 6px 0 14px;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.crm-brand__logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-status,
.crm-tabs,
.case-metrics,
.action-bar,
.operator-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-status span,
.count-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.topbar-status span:first-child {
  color: #244c45;
  background: var(--teal-soft);
  border: 1px solid #a8d6ca;
}

.topbar-status span:last-child,
.status-pill {
  color: #6a312a;
  background: var(--coral-soft);
  border: 1px solid #eabdb5;
}

.safety-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  color: #29463e;
  background: var(--teal-soft);
  border: 1px solid #a9d7ca;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.crm-tabs {
  overflow-x: auto;
  margin-bottom: 12px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crm-tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 14px;
  color: #41505a;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.crm-tab:hover,
.crm-tab:focus-visible {
  color: #083c36;
  background: #f1faf7;
  outline: none;
}

.crm-tab--active {
  color: #083c36;
  background: var(--teal-soft);
  border-color: #a9d7ca;
}

.crm-workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: start;
}

.queue-panel,
.case-panel,
.context-panel,
.panel-card,
.workflow-panel,
.ai-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.queue-panel,
.case-panel,
.context-panel {
  min-height: 640px;
  box-shadow: var(--shadow);
}

.case-panel {
  min-width: 0;
}

.queue-panel,
.context-panel {
  padding: 14px;
}

.case-panel {
  padding: 18px;
}

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

.panel-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.count-pill {
  color: #1f4c33;
  background: var(--green-soft);
  border: 1px solid #b7d9bf;
}

.queue-list {
  display: grid;
  gap: 10px;
  max-height: 760px;
  margin: 14px 0;
  overflow: auto;
  padding-right: 4px;
}

.queue-item {
  display: grid;
  width: 100%;
  min-height: 122px;
  padding: 13px;
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.queue-item:hover,
.queue-item:focus-visible {
  border-color: #97cfc2;
  outline: none;
}

.queue-item--active {
  border-color: var(--teal);
  box-shadow: inset 3px 0 0 var(--teal);
}

.queue-item--reviewed {
  background: #f1f4f2;
  opacity: 0.76;
}

.queue-item__source {
  width: max-content;
  max-width: 100%;
  margin-bottom: 8px;
  padding: 4px 7px;
  color: #244c45;
  background: var(--teal-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.queue-item strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.28;
}

.queue-item small,
.queue-item__time,
.section-heading span,
.field-list dt,
.case-metrics small,
.ai-suggestions small,
.workflow-step small,
.calendar-event small,
.calendar-event span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.queue-item__time {
  margin-top: 4px;
}

.queue-item__status {
  width: max-content;
  max-width: 100%;
  margin-top: 10px;
  padding: 4px 7px;
  color: #1f4c45;
  background: #eef8f4;
  border: 1px solid #c3e4d9;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.queue-note {
  padding: 12px;
  background: #fff9f6;
  border: 1px solid #edc1b8;
  border-radius: 8px;
}

.queue-note p {
  margin-bottom: 0;
  color: #4e5b63;
  font-size: 13px;
  line-height: 1.45;
}

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

.case-metrics article,
.ai-suggestions article {
  min-height: 76px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.case-metrics strong,
.ai-suggestions strong {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.3;
}

.workflow-panel,
.ai-panel {
  margin-bottom: 12px;
  padding: 14px;
}

.ai-panel {
  background: #f5fbf8;
  border-color: #b8d9cf;
}

.ai-suggestions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.ai-suggestions article {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  min-height: 88px;
  padding: 10px;
  background: var(--surface-soft);
}

.ai-suggestions strong,
.ai-tag-list {
  display: flex;
  align-items: center;
  min-height: 42px;
  margin-top: 0;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow-wrap: anywhere;
}

.ai-tag-list {
  align-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.ai-tag-chip {
  max-width: 100%;
  padding: 5px 8px;
  color: #173f38;
  background: #eef8f4;
  border: 1px solid #c3e4d9;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.operator-panel {
  margin-bottom: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.operator-controls {
  align-items: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.control-field,
.tag-control {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control-field span,
.tag-control__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.control-field select {
  appearance: none;
  min-height: 42px;
  min-width: 0;
  width: 100%;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 50%, #1f2a32 50%) calc(100% - 18px) 18px / 7px 7px no-repeat,
    linear-gradient(135deg, #1f2a32 50%, transparent 50%) calc(100% - 13px) 18px / 7px 7px no-repeat,
    var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 8px 34px 8px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.tag-control {
  border: 1px solid var(--line);
}

.tag-control__list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 42px;
  align-content: center;
  align-items: center;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  color: #173f38;
  background: var(--surface);
  border: 1px solid #cce5dc;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.tag-chip span {
  overflow-wrap: anywhere;
}

.tag-chip input {
  accent-color: var(--teal);
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  min-height: 78px;
  padding: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workflow-step__dot {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  background: var(--line-strong);
  border-radius: 50%;
}

.workflow-step strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.25;
}

.workflow-step--complete .workflow-step__dot {
  background: var(--green);
}

.workflow-step--active {
  border-color: #a9d7ca;
  background: var(--teal-soft);
}

.workflow-step--active .workflow-step__dot {
  background: var(--teal);
}

.workflow-step--planned .workflow-step__dot {
  background: var(--blue);
}

.case-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
  gap: 12px;
}

.panel-card {
  padding: 14px;
}

.panel-card--wide {
  grid-column: 1 / -1;
}

.panel-card--accent {
  background: #fff9f6;
  border-color: #edc1b8;
}

.panel-card--evidence {
  background: #f5fbf8;
  border-color: #b8d9cf;
}

.messages {
  display: grid;
  gap: 10px;
}

.message {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: min(88%, 640px);
  padding: 11px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message--outgoing {
  justify-self: end;
  background: #eef5fb;
  border-color: #bed3e8;
}

.message__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.message p,
.reply-draft,
#purposeText,
.field-list dd {
  margin-bottom: 0;
  color: #25313a;
  font-size: 14px;
  line-height: 1.5;
}

.reply-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 2px 0 10px;
}

.reply-meta__chip {
  max-width: 100%;
  padding: 5px 8px;
  color: #1f4c45;
  background: #eef8f4;
  border: 1px solid #c3e4d9;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.field-list,
.access-list,
.evidence-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.field-list div,
.access-list div,
.evidence-list div {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.field-list div:last-child,
.access-list div:last-child,
.evidence-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.field-list dt,
.access-list dt,
.evidence-list dt {
  margin-bottom: 4px;
}

.field-list dd,
.access-list dd,
.evidence-list dd {
  margin-left: 0;
  font-weight: 800;
}

.access-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.access-list dd {
  color: var(--coral);
  font-size: 13px;
  text-align: right;
}

.evidence-list dd {
  color: #173f38;
  font-size: 14px;
}

.permission-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.permission-card {
  padding: 10px 11px;
  background: var(--surface);
  border: 1px solid #cce5dc;
  border-radius: 8px;
}

.permission-card strong,
.permission-card span {
  display: block;
}

.permission-card strong {
  margin-bottom: 5px;
  color: #173f38;
  font-size: 12px;
  line-height: 1.25;
}

.permission-card span {
  color: #4e5b63;
  font-size: 12px;
  line-height: 1.4;
}

.reply-draft {
  min-height: 86px;
  padding: 12px;
  background: var(--coral-soft);
  border: 1px solid #efc6bd;
  border-radius: 8px;
}

.reply-draft--refreshed {
  animation: reply-preview-refresh 1.35s ease;
}

@keyframes reply-preview-refresh {
  0% {
    background: #e7f7f2;
    border-color: #138174;
    box-shadow: 0 0 0 3px rgba(19, 129, 116, 0.16);
  }

  100% {
    background: var(--coral-soft);
    border-color: #efc6bd;
    box-shadow: none;
  }
}

.action-bar {
  flex-wrap: wrap;
  margin-top: 12px;
}

.action-bar button,
.secondary-action {
  min-height: 36px;
  padding: 8px 12px;
  color: #1f4c45;
  background: #eef8f4;
  border: 1px solid #a9d7ca;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.action-bar button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.action-bar button:hover,
.action-bar button:focus-visible,
.secondary-action:hover,
.secondary-action:focus-visible {
  background: var(--teal-soft);
  outline: none;
}

.demo-feedback {
  margin: 10px 0 0;
  color: #4e5b63;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

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

.calendar-day {
  min-height: 420px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calendar-day__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.calendar-day__head h3 {
  margin-bottom: 0;
  font-size: 13px;
}

.calendar-day__head span,
.calendar-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.calendar-day__events {
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.calendar-event {
  display: grid;
  width: 100%;
  gap: 3px;
  min-height: 76px;
  padding: 8px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.calendar-event:hover,
.calendar-event:focus-visible {
  border-color: #97cfc2;
  outline: none;
}

.calendar-event--active {
  border-color: var(--teal);
  box-shadow: inset 3px 0 0 var(--teal);
}

.calendar-event--reviewed {
  background: #f1f4f2;
  opacity: 0.75;
}

.calendar-event strong {
  font-size: 12px;
  line-height: 1.25;
}

.calendar-event__stage {
  width: max-content;
  max-width: 100%;
  padding: 2px 5px;
  color: #244c45;
  background: var(--teal-soft);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.calendar-focus {
  margin-top: 0;
}

.secondary-action {
  margin-top: 12px;
}

.context-panel {
  display: grid;
  gap: 12px;
}

.context-panel .panel-card {
  box-shadow: none;
}

.safeguard-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.safeguard-list li {
  padding: 10px 11px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #27343d;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 1180px) {
  .crm-workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .context-panel {
    grid-column: 1 / -1;
    min-height: auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .crm-topbar,
  .case-header,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-status {
    align-self: flex-start;
  }

  .crm-workspace,
  .case-metrics,
  .case-grid,
  .ai-suggestions,
  .operator-controls,
  .workflow-steps,
  .calendar-grid,
  .context-panel {
    grid-template-columns: 1fr;
  }

  .queue-panel,
  .case-panel,
  .context-panel {
    min-height: auto;
  }

  .message {
    width: 100%;
  }
}
