:root {
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f8;
  --surface-strong: #e8eef3;
  --text: #16212b;
  --muted: #607181;
  --subtle: #8a99a8;
  --border: #d9e2ea;
  --accent: #117c8a;
  --accent-strong: #0d6570;
  --accent-soft: #dff4f6;
  --amber: #b7791f;
  --amber-soft: #fff3d8;
  --danger: #a43b3b;
  --shadow: 0 18px 44px rgba(31, 45, 58, 0.12);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

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

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 390px;
  min-height: 100vh;
}

.sidebar,
.evidence-panel {
  background: var(--surface);
  border-color: var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-height: 100vh;
  overflow-y: auto;
  padding: 24px;
}

.sidebar {
  border-right: 1px solid var(--border);
}

.evidence-panel {
  border-left: 1px solid var(--border);
}

.brand-block {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: var(--radius);
  color: #ffffff;
  display: inline-flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.brand-mark svg,
.icon-button svg,
.send-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.brand-mark svg {
  height: 25px;
  width: 25px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.2;
}

h2 {
  font-size: 22px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.2;
}

.brand-block p,
.eyeline {
  color: var(--muted);
  font-size: 13px;
  font-weight: 520;
  line-height: 1.4;
  margin-top: 3px;
}

.sidebar-section,
.panel-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.section-heading {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 720;
  justify-content: space-between;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  padding: 0;
  width: 30px;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--text);
  outline: none;
}

.icon-button svg {
  height: 17px;
  width: 17px;
}

.ticket-list,
.evidence-list,
.knowledge-file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-button,
.evidence-item,
.knowledge-file-button {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  padding: 12px;
  text-align: left;
}

.ticket-button {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
}

.ticket-button:hover,
.ticket-button:focus-visible,
.ticket-button.is-selected,
.knowledge-file-button:hover,
.knowledge-file-button:focus-visible,
.knowledge-file-button.is-selected {
  background: var(--accent-soft);
  border-color: rgba(17, 124, 138, 0.38);
  outline: none;
}

.simulator-form,
.knowledge-block {
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.simulator-form label,
.admin-token-field,
.knowledge-filename-label,
.knowledge-editor-label {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 720;
  gap: 6px;
  line-height: 1.2;
  text-transform: uppercase;
}

input,
select {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  line-height: 1.45;
  outline: none;
  padding: 11px 12px;
  width: 100%;
}

input:focus,
select:focus {
  background: #ffffff;
  border-color: rgba(17, 124, 138, 0.6);
  box-shadow: 0 0 0 3px rgba(17, 124, 138, 0.13);
}

.helper-text,
.status-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.secondary-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 760;
  justify-content: center;
  min-height: 40px;
  padding: 0 12px;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: var(--accent-soft);
  border-color: rgba(17, 124, 138, 0.45);
  outline: none;
}

.secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

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

.knowledge-file-button {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.knowledge-file-button span {
  font-size: 13px;
  font-weight: 720;
}

.knowledge-file-button small {
  color: var(--muted);
  font-size: 11px;
}

.ticket-title {
  font-size: 14px;
  font-weight: 720;
  line-height: 1.35;
}

.ticket-meta,
.ticket-desc,
.evidence-source,
.runtime-list dt,
.runtime-list dd {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ticket-desc {
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

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

.topbar {
  align-items: center;
  background: rgba(247, 249, 251, 0.88);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 82px;
  padding: 22px 28px;
}

.runtime-chip,
.count-pill {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 650;
  gap: 8px;
  min-height: 32px;
  padding: 6px 12px;
}

.status-dot {
  background: #17a46f;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(23, 164, 111, 0.14);
  height: 8px;
  width: 8px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 28px;
}

.intro-panel,
.case-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(22, 33, 43, 0.04);
  max-width: 920px;
  padding: 18px;
}

.intro-panel {
  border-left: 4px solid var(--accent);
}

.intro-label,
.case-kicker,
.response-divider {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.intro-panel p {
  font-size: 16px;
  line-height: 1.55;
  margin-top: 8px;
}

.case-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.case-summary h3 {
  font-size: 20px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0;
}

.case-meta {
  display: grid;
  gap: 12px;
  margin: 0;
}

.case-meta div {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 6px;
  padding-top: 12px;
}

.case-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.case-meta dd {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.response-divider {
  margin-top: 4px;
}

.message-row {
  display: flex;
}

.message-row.user {
  justify-content: flex-end;
}

.message {
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(22, 33, 43, 0.04);
  max-width: min(760px, 86%);
  padding: 14px 16px;
}

.message.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
}

.message.user {
  background: var(--accent);
  color: #ffffff;
}

.message-label {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.2;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.message.user .message-label {
  color: rgba(255, 255, 255, 0.78);
}

.message p,
.message-body {
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message-body {
  font-family: var(--font);
  margin: 0;
}

.action-dock {
  background: rgba(247, 249, 251, 0.94);
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 14px 28px;
}

.action-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 760;
  justify-content: center;
  min-height: 46px;
  padding: 0 12px;
  text-align: center;
}

.action-button:hover,
.action-button:focus-visible {
  background: var(--accent-soft);
  border-color: rgba(17, 124, 138, 0.45);
  outline: none;
}

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

.composer {
  align-items: flex-end;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 18px 28px 22px;
}

textarea {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  line-height: 1.45;
  max-height: 160px;
  min-height: 54px;
  outline: none;
  padding: 14px 15px;
  resize: vertical;
  width: 100%;
}

.knowledge-editor-label textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  max-height: 360px;
  min-height: 230px;
}

textarea:focus {
  background: #ffffff;
  border-color: rgba(17, 124, 138, 0.6);
  box-shadow: 0 0 0 3px rgba(17, 124, 138, 0.13);
}

.send-button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 760;
  gap: 8px;
  min-height: 54px;
  padding: 0 18px;
}

.send-button:hover,
.send-button:focus-visible {
  background: var(--accent-strong);
  outline: none;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.send-button svg {
  height: 18px;
  width: 18px;
}

.evidence-item {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.evidence-source {
  color: var(--amber);
  font-weight: 760;
}

.evidence-item p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  background: var(--amber-soft);
  border: 1px solid rgba(183, 121, 31, 0.25);
  border-radius: var(--radius);
  color: #6e4d16;
  font-size: 13px;
  line-height: 1.45;
  padding: 12px;
}

.runtime-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}

.runtime-list div {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
}

.runtime-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.runtime-list dt {
  font-weight: 720;
  text-transform: uppercase;
}

.runtime-list dd {
  color: var(--text);
  font-weight: 650;
  margin: 0;
  text-align: right;
}

.sr-only {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

  .evidence-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  .sidebar,
  .evidence-panel {
    border: 0;
    padding: 18px;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
  }

  .ticket-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .ticket-button {
    min-width: 240px;
  }

  .topbar {
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
  }

  .chat-log {
    min-height: 380px;
    padding: 18px;
  }

  .message {
    max-width: 96%;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 14px 18px 18px;
  }

  .action-dock {
    grid-template-columns: 1fr;
    padding: 12px 18px;
  }

  .send-button {
    justify-content: center;
    width: 100%;
  }
}
