:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef3f6;
  --line: #d9e1e7;
  --text: #17202a;
  --muted: #647381;
  --brand: #1d6b62;
  --brand-2: #214d73;
  --danger: #b33a3a;
  --warn: #9b6b11;
  --ok: #287245;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 440px) 1fr;
}

.login-panel {
  background: var(--panel);
  padding: 40px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-visual {
  background: linear-gradient(135deg, #173d4b, #1d6b62 55%, #d4c27a);
  color: white;
  padding: 42px;
  display: flex;
  align-items: end;
}

.login-visual h1 {
  font-size: 44px;
  line-height: 1;
  max-width: 720px;
  margin: 0;
}

.field {
  display: grid;
  gap: 6px;
  margin: 14px 0;
}

.field input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.sidebar {
  background: #17202a;
  color: #e8eef2;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  padding: 8px;
}

.tenant-card {
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 10px;
  color: #c8d2da;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dce5eb;
  border-color: transparent;
}

.nav button.active,
.nav button:hover {
  background: rgba(255,255,255,.1);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}

.content {
  padding: 18px;
  overflow: auto;
}

.grid {
  display: grid;
  gap: 14px;
}

.metrics {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.metric,
.panel,
.conversation-row,
.message,
.pipeline-column,
.kb-row,
.user-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 26px;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(360px, 1fr) 280px;
  gap: 14px;
  min-height: 650px;
}

.panel {
  overflow: hidden;
  min-width: 0;
}

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

.list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.conversation-row {
  text-align: left;
  padding: 10px;
  display: grid;
  gap: 5px;
}

.conversation-row.active {
  border-color: var(--brand);
  background: #f0faf7;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: var(--panel-2);
  color: var(--text);
}

.badge.ok { background: #e5f4eb; color: var(--ok); }
.badge.warn { background: #fff4d8; color: var(--warn); }
.badge.danger { background: #f9e6e6; color: var(--danger); }

.thread {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 460px;
  background: #f9fbfc;
}

.message {
  max-width: 78%;
  padding: 10px;
}

.message.outbound {
  align-self: flex-end;
  border-color: #bddbd1;
}

.composer {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.pipeline-column {
  min-height: 280px;
  padding: 10px;
}

.kb-row,
.user-row {
  padding: 12px;
  display: grid;
  gap: 5px;
}

.qr {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  display: inline-block;
  background: white;
  color: #111;
  border: 1px solid var(--line);
  padding: 12px;
  line-height: 1;
}

.error {
  color: var(--danger);
  margin-top: 10px;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .nav {
    grid-template-columns: repeat(4, 1fr);
  }
  .workspace,
  .section-grid {
    grid-template-columns: 1fr;
  }
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .login {
    grid-template-columns: 1fr;
  }
  .login-visual {
    display: none;
  }
}
