:root {
  --bg: #f6efe1;
  --bg-2: #f2dfc2;
  --ink: #16233b;
  --muted: #4c5e7e;
  --accent: #ea580c;
  --accent-2: #0f766e;
  --card: rgba(255, 255, 255, 0.82);
  --line: rgba(22, 35, 59, 0.14);
  --good: #116530;
  --bad: #a30f25;
  --shadow: 0 18px 50px rgba(22, 35, 59, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 18% 18%, #fff4df 0%, var(--bg) 42%, var(--bg-2) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Sora", "Trebuchet MS", sans-serif;
  letter-spacing: 0.01em;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(22, 35, 59, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 35, 59, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
  z-index: 0;
}

.bg-orb {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.34;
  z-index: 0;
}

.orb-a {
  background: #f97316;
  top: -130px;
  left: -80px;
}

.orb-b {
  background: #0f766e;
  right: -100px;
  bottom: -140px;
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1200px, 94vw);
  margin: 30px auto 60px;
  display: grid;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(9px);
}

.hero {
  display: grid;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--accent-2);
  font-weight: 700;
}

.hero h1 {
  font-size: clamp(30px, 5vw, 52px);
}

.hero-sub {
  margin: 0;
  color: var(--muted);
}

.session-pill {
  justify-self: start;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.grid-form.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#system-config-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow-x: auto;
}

.system-config-provider-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  min-width: 1200px;
}

.system-config-provider-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
  padding: 10px;
}

.system-config-provider-card h4 {
  margin-bottom: 8px;
}

.system-config-provider-row {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 1fr 1.4fr 0.7fr auto;
  gap: 10px;
  align-items: end;
}

.system-config-test-btn {
  min-width: 86px;
}

.system-config-policy-box {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
  font: inherit;
  color: var(--ink);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  font: inherit;
}

.btn.primary {
  background: linear-gradient(120deg, var(--accent), #ef4444);
  color: #fff;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  border-color: var(--line);
}

.btn.warn {
  background: #fff0f3;
  color: var(--bad);
  border-color: rgba(163, 15, 37, 0.2);
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.toolbar,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.tabs {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
}

.tab.active {
  background: linear-gradient(120deg, #0f766e, #0ea5a4);
  color: #fff;
  border-color: transparent;
}

.panel {
  display: grid;
  gap: 12px;
}

.panel h4 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px;
  font-size: 14px;
}

td.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.stat p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.output {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
  min-height: 100px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}

.test-chat-window {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.test-chat-msg {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.test-chat-user {
  justify-self: end;
  background: #16233b;
  color: #fff;
}

.test-chat-assistant {
  justify-self: start;
  background: #f8fafc;
  border: 1px solid var(--line);
}

#tenant-context-inline {
  margin-top: -6px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, 92vw);
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 5;
}

.reveal {
  animation: rise 450ms ease both;
}

.delay-1 {
  animation-delay: 120ms;
}

.delay-2 {
  animation-delay: 220ms;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 920px) {
  .grid-form,
  .grid-form.compact,
  .stats {
    grid-template-columns: 1fr;
  }

  #system-config-form {
    grid-template-columns: 1fr;
  }

  .system-config-provider-list {
    min-width: 0;
  }

  .system-config-provider-row {
    grid-template-columns: 1fr;
  }

  .layout {
    width: min(100%, 94vw);
  }
}
