:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.976 0.004 210);
  --surface-strong: oklch(0.946 0.008 210);
  --ink: oklch(0.22 0.028 240);
  --muted: oklch(0.45 0.026 232);
  --line: oklch(0.88 0.01 220);
  --primary: oklch(0.5 0.112 210);
  --primary-hover: oklch(0.44 0.118 210);
  --primary-soft: oklch(0.93 0.028 210);
  --accent: oklch(0.62 0.14 78);
  --danger: oklch(0.55 0.16 25);
  --success: oklch(0.5 0.13 150);
  --shadow: 0 8px 24px oklch(0.35 0.03 240 / 0.1);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(180deg, var(--surface) 0, var(--bg) 32%),
    var(--bg);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  max-width: 1240px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
}

.side-panel,
.chat-panel {
  border: 1px solid var(--line);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border-radius: 12px;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.05rem;
  line-height: 1.25;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.25;
}

.brand-block p,
.chat-header p,
.status-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.status-card,
.tenant-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.status-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
}

.status-dot.ok {
  background: var(--success);
}

.status-dot.error {
  background: var(--danger);
}

.tenant-card {
  display: grid;
  gap: 10px;
}

.tenant-card-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.tenant-card-head strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.module-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.module-pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-size: 0.78rem;
  font-weight: 800;
}

.module-pill.muted {
  background: var(--surface-strong);
  color: var(--muted);
}

.module-pill.warn {
  background: oklch(0.93 0.052 78);
  color: oklch(0.34 0.08 78);
}

.module-pill.off {
  background: oklch(0.95 0.012 25);
  color: var(--danger);
}

.login-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
}

input {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 52px;
  max-height: 160px;
  resize: vertical;
  padding: 11px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button,
.docs-link {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 800;
  transition:
    background-color 170ms ease,
    border-color 170ms ease,
    transform 170ms ease;
}

button:active,
.docs-link:active {
  transform: translateY(1px);
}

.login-form button,
.composer button {
  background: var(--primary);
  color: white;
}

.login-form button:hover,
.composer button:hover {
  background: var(--primary-hover);
}

.quick-list {
  display: grid;
  gap: 8px;
}

.quick-list p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.quick-list button,
.docs-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.quick-list button {
  justify-content: flex-start;
}

.quick-list button:hover,
.docs-link:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 12px;
}

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

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 18px 20px;
  background: var(--surface);
}

.message {
  max-width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg);
  line-height: 1.48;
}

.message.user {
  align-self: flex-end;
  border-color: var(--primary);
  background: var(--primary-soft);
}

.message.assistant {
  align-self: flex-start;
}

.message.error {
  border-color: var(--danger);
}

.warning-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.table-wrap {
  max-width: 100%;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--surface-strong);
  font-size: 0.78rem;
  color: var(--muted);
}

tr:last-child td {
  border-bottom: 0;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 840px) {
  .shell {
    padding: 12px;
  }

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

  .chat-panel {
    min-height: 70vh;
  }

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

  .chat-header {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
