:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-strong: #fdfaf4;
  --line: #d9e0e3;
  --text: #162126;
  --muted: #5f6f77;
  --blue: #246b93;
  --blue-strong: #155477;
  --green: #2c7a4b;
  --amber: #a96810;
  --red: #b94444;
  --shadow: 0 18px 50px rgba(29, 45, 53, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

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

.chat-surface,
.insights-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chat-surface {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 36px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

.topbar p,
.muted-section p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.suggestions {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.suggestions button {
  min-height: 34px;
  white-space: nowrap;
  border: 1px solid #c7d7de;
  border-radius: 8px;
  background: #f7fbfc;
  color: var(--blue-strong);
  cursor: pointer;
  padding: 0 12px;
}

.messages {
  overflow-y: auto;
  padding: 20px;
}

.message {
  display: flex;
  margin-bottom: 14px;
}

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

.bubble {
  max-width: min(760px, 88%);
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant .bubble {
  background: #eef5f1;
  border: 1px solid #c9ddd1;
}

.message.user .bubble {
  background: var(--blue);
  color: #fff;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}

.composer input {
  min-height: 44px;
  width: 100%;
  border: 1px solid #cbd6da;
  border-radius: 8px;
  padding: 0 13px;
  outline: none;
}

.composer input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 147, 0.14);
}

.composer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  padding: 0 16px;
}

.composer button:disabled,
.suggestions button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.insights-panel {
  align-self: stretch;
  overflow-y: auto;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.metric-strip div {
  padding: 17px 14px;
  border-right: 1px solid var(--line);
}

.metric-strip div:last-child {
  border-right: 0;
}

.metric-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.metric-strip strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
  line-height: 1;
}

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-section h2 {
  margin-bottom: 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #31444c;
}

.quick-facts {
  display: grid;
  gap: 11px;
  margin: 0;
}

.quick-facts div {
  display: grid;
  gap: 4px;
}

.quick-facts dt {
  color: var(--muted);
  font-size: 12px;
}

.quick-facts dd {
  margin: 0;
  line-height: 1.35;
}

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

.alert-list li {
  border-left: 4px solid var(--amber);
  background: #fff8ed;
  border-radius: 6px;
  padding: 10px 11px;
  line-height: 1.35;
}

.alert-list li.good {
  border-left-color: var(--green);
  background: #eff8f2;
}

.alert-list li.critical {
  border-left-color: var(--red);
  background: #fff0f0;
}

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

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

  .chat-surface {
    min-height: 68vh;
  }

  .insights-panel {
    align-self: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .topbar,
  .messages,
  .composer,
  .suggestions {
    padding-left: 12px;
    padding-right: 12px;
  }

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

  .composer button {
    width: 100%;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .metric-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-strip div:last-child {
    border-bottom: 0;
  }
}
