:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #14181f;
  --muted: #667085;
  --line: #d8dde6;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warning: #b54708;
  --success: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 0.75rem 1rem;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  background: #98a2b3;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

button.ghost:disabled {
  background: #f2f4f7;
  color: #98a2b3;
}

.shell {
  min-height: 100vh;
  padding: 2rem;
}

.shell.compact {
  display: grid;
  place-items: center;
}

.auth-view {
  display: grid;
  gap: 1.5rem;
  margin: 8vh auto 0;
  max-width: 430px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 1rem;
}

.mark {
  align-items: center;
  background: var(--text);
  border-radius: 8px;
  color: white;
  display: inline-flex;
  font-weight: 700;
  height: 44px;
  justify-content: center;
  width: 44px;
}

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

h1 {
  font-size: 1.7rem;
}

h2 {
  font-size: 0.95rem;
}

h3 {
  font-size: 0.88rem;
}

.brand p,
.message,
.conversation footer {
  color: var(--muted);
}

.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0.6rem 0.7rem;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid #ccfbf1;
}

.message {
  min-height: 1.25rem;
}

.compact-message {
  font-size: 0.84rem;
  min-height: 1rem;
}

.password-control {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

.password-control input {
  min-width: 0;
}

.icon-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  min-width: 76px;
}

.icon-button:hover {
  background: #f2f4f7;
}

.strength {
  background: #eef2f6;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.strength-bar {
  background: var(--danger);
  display: block;
  height: 100%;
  transition: width 160ms ease, background 160ms ease;
  width: 0;
}

.strength-bar[data-level="medium"] {
  background: var(--warning);
}

.strength-bar[data-level="strong"] {
  background: var(--success);
}

.policy-list {
  color: var(--muted);
  display: grid;
  font-size: 0.84rem;
  gap: 0.4rem;
  line-height: 1.35;
  list-style: none;
  margin: -0.2rem 0 0;
  padding: 0;
}

.policy-list li {
  align-items: start;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: 1rem minmax(0, 1fr);
}

.policy-list li::before {
  color: #98a2b3;
  content: "○";
  font-weight: 700;
}

.policy-list li.passed {
  color: var(--success);
}

.policy-list li.passed::before {
  content: "✓";
}

.policy-list li.failed {
  color: var(--danger);
}

.policy-list li.failed::before {
  content: "×";
}

.hidden {
  display: none;
}

.app-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 4rem);
}

.app-menu {
  background: #101828;
  border-radius: 8px 0 0 8px;
  color: white;
  display: grid;
  gap: 1.25rem;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 1rem;
}

.menu-brand {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.menu-brand .mark {
  background: white;
  color: #101828;
}

.menu-brand p {
  color: #cbd5e1;
  font-size: 0.8rem;
}

.menu-nav {
  align-content: start;
  display: grid;
  gap: 0.45rem;
}

.menu-item {
  background: transparent;
  border-radius: 6px;
  color: #d0d5dd;
  padding: 0.7rem 0.75rem;
  text-align: left;
}

.menu-item:hover,
.menu-item.active {
  background: #1d2939;
  color: white;
}

.menu-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.menu-item:disabled {
  background: transparent;
  color: #667085;
}

.app-content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  min-width: 0;
  padding: 1.5rem;
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin: -1.5rem -1.5rem 1.5rem;
  padding: 1rem 1.5rem;
}

#sessionSummary,
.metric p,
.signal p,
.customer p,
.event p,
.empty-state {
  color: var(--muted);
  line-height: 1.35;
}

.actions {
  display: flex;
  gap: 0.75rem;
}

.banner {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 8px;
  color: var(--danger);
  font-weight: 700;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

.dashboard-grid,
.operations-grid {
  display: grid;
  gap: 1rem;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  margin-bottom: 1rem;
}

.operations-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.25rem;
}

.channel-panel,
.summary-panel,
.panel,
.inbox-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 1rem;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.status-pill,
.muted-pill {
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  white-space: nowrap;
}

.muted-pill {
  background: #f2f4f7;
  color: var(--muted);
}

.status-pill.ok,
.signal-dot.ok {
  background: #ecfdf3;
  color: var(--success);
}

.status-pill.attention,
.signal-dot.attention {
  background: #fffaeb;
  color: var(--warning);
}

.status-pill.danger,
.signal-dot.danger {
  background: #fef3f2;
  color: var(--danger);
}

.status-pill.neutral,
.signal-dot.neutral {
  background: #eef2f6;
  color: var(--muted);
}

.channel-facts {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.channel-facts div {
  border-left: 2px solid #d0d5dd;
  min-width: 0;
  padding-left: 0.75rem;
}

.channel-facts dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.channel-facts dd {
  font-size: 0.86rem;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
}

.metric-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 86px;
  padding: 0.75rem;
}

.metric span {
  display: block;
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.metric.attention span {
  color: var(--warning);
}

.signal-list,
.customer-list,
.event-list {
  display: grid;
  gap: 0.7rem;
}

.signal,
.customer,
.event {
  align-items: start;
  display: grid;
  gap: 0.7rem;
}

.signal {
  grid-template-columns: auto minmax(0, 1fr);
}

.signal-dot {
  border-radius: 999px;
  display: inline-block;
  height: 0.7rem;
  margin-top: 0.25rem;
  width: 0.7rem;
}

.customer,
.event {
  grid-template-columns: minmax(0, 1fr) auto;
}

.customer span,
.event time {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.inbox-section {
  padding-bottom: 1.25rem;
}

.conversation-console {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr) minmax(260px, 320px);
  min-height: 680px;
  overflow: hidden;
}

.catalog-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  margin-bottom: 1rem;
}

.catalog-uploader,
.catalog-rules,
.catalog-table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 1rem;
}

.catalog-defaults {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}

.sync-steps {
  display: grid;
  gap: 0.75rem;
}

.sync-steps article {
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
}

.sync-steps p {
  color: var(--muted);
  line-height: 1.35;
}

.catalog-table-wrap {
  overflow: auto;
}

.catalog-table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

.catalog-table th,
.catalog-table td {
  border-bottom: 1px solid #eef2f6;
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

.catalog-table th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.catalog-table td p {
  color: var(--muted);
  line-height: 1.35;
  margin-top: 0.25rem;
}

.catalog-table code {
  background: #f2f4f7;
  border-radius: 4px;
  font-size: 0.78rem;
  padding: 0.15rem 0.25rem;
}

.thread-pane,
.context-pane {
  background: #fbfcfe;
  min-width: 0;
}

.thread-pane {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.thread-pane-head {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 1rem;
}

.thread-head-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.compact-input {
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 36px;
  min-width: 150px;
  padding: 0.45rem 0.6rem;
}

.compact-button {
  min-height: 36px;
  padding: 0.45rem 0.7rem;
}

.thread-summary {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0.75rem 1rem;
}

.thread-summary span {
  background: white;
  border: 1px solid #e4e7ec;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: 0.75rem;
  justify-content: space-between;
  padding: 0.35rem 0.45rem;
}

.thread-summary strong {
  color: var(--text);
}

.thread-list {
  display: grid;
  gap: 0;
  overflow: auto;
}

.board,
.lane,
.lane-list {
  display: contents;
}

.conversation {
  background: transparent;
  border: 0;
  border-bottom: 1px solid #edf0f4;
  border-radius: 0;
  color: var(--text);
  display: grid;
  gap: 0.45rem;
  min-height: 92px;
  padding: 0.85rem 1rem;
  text-align: left;
  width: 100%;
}

.conversation:hover,
.conversation:focus-visible,
.conversation.selected {
  background: #eef7f5;
  outline: none;
}

.conversation.selected {
  box-shadow: inset 4px 0 0 var(--accent);
}

.detail-actions {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}

.detail-actions button {
  min-height: 42px;
  padding: 0.55rem 0.65rem;
}

.compact-head {
  margin-bottom: 0.7rem;
}

.chat-pane {
  background:
    linear-gradient(rgba(238, 244, 241, 0.94), rgba(238, 244, 241, 0.94)),
    repeating-linear-gradient(45deg, rgba(15, 118, 110, 0.07) 0 1px, transparent 1px 24px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
}

.chat-head {
  align-items: center;
  background: #f7f9fb;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.8rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 72px;
  padding: 0.8rem 1rem;
}

.avatar {
  align-items: center;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #1d4ed8;
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.chat-head h2,
.chat-head p {
  overflow-wrap: anywhere;
}

.chat-head p {
  color: var(--muted);
  font-size: 0.83rem;
}

.chat-security-strip {
  align-items: center;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #9a3412;
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  padding: 0.55rem 1rem;
  text-align: center;
}

.chat-security-strip span {
  font-size: 0.8rem;
}

.message-list {
  display: grid;
  gap: 0.65rem;
}

.chat-timeline {
  align-content: end;
  overflow: auto;
  padding: 1rem clamp(1rem, 4vw, 4rem);
}

.message-item {
  border: 1px solid rgba(16, 24, 40, 0.06);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  display: grid;
  gap: 0.45rem;
  max-width: min(78%, 620px);
  padding: 0.65rem 0.75rem;
}

.message-item.inbound {
  background: white;
  justify-self: start;
}

.message-item.outbound {
  background: #d9fdd3;
  justify-self: end;
}

.message-meta,
.detail-event {
  align-items: center;
  display: flex;
  gap: 0.65rem;
  justify-content: space-between;
}

.message-item span,
.message-item time,
.detail-event time {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.message-item p,
.detail-event p {
  color: #303846;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.detail-event {
  align-items: start;
  border-bottom: 1px solid #eef2f6;
  padding-bottom: 0.6rem;
}

.composer {
  align-items: center;
  background: #f0f2f5;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.65rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 0.75rem 1rem;
}

.composer input {
  background: white;
  border: 1px solid #e4e7ec;
  border-radius: 999px;
  min-height: 42px;
  padding: 0.6rem 1rem;
}

.icon-lite {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 1.25rem;
  height: 42px;
  justify-content: center;
  padding: 0;
  width: 42px;
}

.context-pane {
  border-left: 1px solid var(--line);
  display: grid;
  gap: 1rem;
  grid-auto-rows: max-content;
  overflow: auto;
  padding: 1rem;
}

.context-block {
  background: white;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  padding: 0.85rem;
}

.context-facts {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.context-facts div {
  border-bottom: 1px solid #eef2f6;
  padding-bottom: 0.65rem;
}

.context-facts div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.context-facts dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.context-facts dd {
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-activity {
  display: grid;
  gap: 0.65rem;
}

.chat-pane.empty .chat-timeline {
  align-content: center;
  justify-items: center;
}

.conversation-head {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.conversation-head span {
  background: #eef6f5;
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 0.74rem;
  padding: 0.2rem 0.5rem;
}

.conversation p {
  color: #303846;
  line-height: 1.35;
}

.conversation footer {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

@media (max-width: 1180px) {
  .operations-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .conversation-console {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }

  .context-pane {
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .app-menu {
    border-radius: 8px 8px 0 0;
  }

  .app-content {
    border-left: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
  }

  .menu-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

  .conversation-console {
    grid-template-columns: 1fr;
    min-height: auto;
  }

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

  .thread-pane {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    max-height: 360px;
  }

  .chat-pane {
    min-height: 560px;
  }

  .context-pane {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 1rem;
  }

  .app-content {
    padding: 1rem;
  }

  .topbar {
    align-items: stretch;
    display: grid;
    gap: 1rem;
    margin: -1rem -1rem 1rem;
    padding: 1rem;
  }

  .menu-nav {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-grid,
  .operations-grid,
  .channel-facts,
  .metric-grid,
  .catalog-defaults {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chat-head,
  .detail-event {
    display: grid;
  }

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

  .composer {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .composer #sendReplyButton {
    grid-column: 1 / -1;
  }

  .message-item {
    max-width: 100%;
  }
}
