:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --text: #18202b;
  --muted: #697586;
  --line: #d9e1ea;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b42318;
  --warning: #a15c07;
  --radius: 8px;
  font-family: Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary,
#simulateBtn,
#igSuggestBtn,
#approveTicketBtn,
#saveKnowledgeBtn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 10px;
}

textarea {
  resize: vertical;
  line-height: 1.8;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1440px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
}

.topbar p,
.panelHead span,
.metric span {
  color: var(--muted);
  font-size: 13px;
}

.auth {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 72px;
  gap: 8px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(360px, 1fr) minmax(320px, 420px);
  gap: 12px;
  min-height: calc(100vh - 150px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
}

.panelHead {
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  gap: 12px;
}

.list,
.messages,
.tabPanel {
  padding: 12px;
}

.queueItem,
.conversationItem,
.message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
}

.queueItem {
  cursor: pointer;
}

.queueItem strong,
.conversationItem strong {
  display: block;
  margin-bottom: 6px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.risk-human {
  border-color: #f3b4ad;
  background: #fff7f6;
}

.risk-approval {
  border-color: #f4d18f;
  background: #fffaf0;
}

.message {
  white-space: pre-wrap;
  line-height: 1.8;
}

.message.user {
  border-right: 4px solid var(--accent-2);
}

.message.assistant {
  border-right: 4px solid var(--accent);
}

.message.admin {
  border-right: 4px solid var(--warning);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

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

.tab.active {
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 700;
}

.tabPanel {
  display: none;
}

.tabPanel.active {
  display: block;
}

pre {
  min-height: 120px;
  white-space: pre-wrap;
  direction: ltr;
  text-align: left;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 10px;
  overflow: auto;
}

.knowledgeActions,
.dialogActions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

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

dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

#ticketMeta {
  margin: 8px 0 12px;
  color: var(--muted);
}

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

  .panel {
    min-height: 280px;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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