:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --panel: #fffaf0;
  --panel-soft: #f4ead7;
  --line: #dfd0b7;
  --text: #241a12;
  --muted: #706151;
  --brand: #9d1f18;
  --brand-strong: #76150f;
  --green: #14785f;
  --coral: #b9442e;
  --amber: #c99a3d;
  --night: #11100e;
  --shadow: 0 18px 48px rgba(36, 26, 18, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(201, 154, 61, 0.16), transparent 28%),
    linear-gradient(180deg, #f7f0e4 0%, #efe3d0 46%, #f9f4eb 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.sidebar {
  background:
    radial-gradient(circle at 26% 6%, rgba(201, 154, 61, 0.16), transparent 24%),
    linear-gradient(180deg, #141210 0%, #191511 52%, #21160f 100%);
  color: #f9fafb;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 88px;
  background:
    linear-gradient(90deg, transparent, rgba(201, 154, 61, 0.3), transparent),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent);
  opacity: 0.65;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f4d98e 0%, #c99a3d 100%);
  color: #1b120b;
  box-shadow: 0 0 0 1px rgba(255, 231, 174, 0.22), 0 12px 28px rgba(201, 154, 61, 0.22);
  font-weight: 900;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 0 12px;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: #d8c6a6;
  font-size: 13px;
  position: relative;
  z-index: 1;
}

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: rgba(255, 250, 235, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 4;
}

.main {
  padding: 28px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  color: #8e251d;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.18;
}

.subtle {
  color: var(--muted);
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(73, 38, 12, 0.08);
}

.agent-card {
  min-height: 198px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  position: relative;
  overflow: hidden;
}

.agent-card::before {
  content: "";
  position: absolute;
  inset: 0;
  height: 4px;
  background: linear-gradient(90deg, #241a12, #c99a3d);
}

.agent-card:hover {
  transform: translateY(-2px);
  border-color: rgba(201, 154, 61, 0.44);
  box-shadow: var(--shadow);
}

.agent-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #241a12, #9d1f18);
  font-weight: 900;
}

.agent-card:nth-child(2n) .agent-icon {
  background: linear-gradient(135deg, #241a12, #c99a3d);
}

.agent-card:nth-child(3n) .agent-icon {
  background: linear-gradient(135deg, #241a12, #14785f);
}

.agent-card h3 {
  font-size: 18px;
}

.agent-card p {
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
}

.btn {
  height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  background: linear-gradient(135deg, #241a12, #9d1f18);
  color: #fff;
  font-weight: 650;
  box-shadow: 0 8px 18px rgba(36, 26, 18, 0.16);
}

.btn:hover {
  background: linear-gradient(135deg, #1b120b, var(--brand-strong));
}

.btn.secondary {
  background: #efe3c7;
  color: #3b2a19;
  box-shadow: none;
}

.btn.ghost {
  background: rgba(255, 250, 240, 0.72);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.danger {
  background: #fff1f0;
  color: #b42318;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 14%, rgba(201, 154, 61, 0.14), transparent 24%),
    linear-gradient(180deg, #11100e 0%, #1c1712 52%, #eee2ce 52%, #f7f1e7 100%);
}

.entry-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(201, 154, 61, 0.14), transparent 24%),
    linear-gradient(180deg, #11100e 0%, #1a1714 45%, #eee2ce 45%, #f7f1e7 100%);
}

.entry {
  width: min(980px, 100%);
  display: grid;
  gap: 24px;
}

.entry > .brand {
  color: #f7ead0;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

.entry h1 {
  font-size: 34px;
  color: #f7ead0;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.entry > div .subtle {
  color: #d8c6a6;
}

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

.entry-card {
  padding: 22px;
  display: grid;
  gap: 14px;
  background: rgba(255, 250, 240, 0.96);
}

.entry-card p {
  color: var(--muted);
  line-height: 1.7;
}

.login {
  width: min(960px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: 1.06fr 0.94fr;
  background: #fffaf0;
  border: 1px solid rgba(201, 154, 61, 0.32);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.login-visual {
  background:
    radial-gradient(circle at 26% 18%, rgba(201, 154, 61, 0.16), transparent 28%),
    linear-gradient(180deg, #11100e 0%, #1b1612 52%, #2a1a10 100%);
  color: #fff;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-visual h1 {
  font-size: 36px;
  max-width: 420px;
}

.login-visual p {
  color: #d8c6a6;
  margin-top: 14px;
  line-height: 1.7;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.metric {
  border: 1px solid rgba(201, 154, 61, 0.28);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.metric strong {
  display: block;
  font-size: 22px;
}

.login-form {
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

label {
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(157, 31, 24, 0.12);
}

.notice {
  border-radius: 8px;
  padding: 12px;
  background: #f4ead7;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.6;
}

.error {
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #ffd3ce;
  border-radius: 8px;
  padding: 10px 12px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  height: calc(100vh - 120px);
}

.conversation-list {
  padding: 14px;
  overflow: auto;
}

.conversation-list button {
  width: 100%;
  min-height: 44px;
  text-align: left;
  background: transparent;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
}

.conversation-list button.active,
.conversation-list button:hover {
  background: #f0e3c9;
}

.conversation-list .back-workbench {
  background: #fffaf0;
  border: 1px solid var(--line);
  text-align: center;
}

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

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

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.messages {
  padding: 22px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  background:
    linear-gradient(rgba(255, 250, 240, 0.94), rgba(247, 241, 231, 0.98)),
    radial-gradient(circle at 84% 12%, rgba(201, 154, 61, 0.1), transparent 28%);
}

.empty-guide {
  max-width: 740px;
  margin: 54px auto;
  padding: 24px;
  border: 1px dashed #bda579;
  border-radius: 8px;
  background: #f8efe0;
}

.empty-guide h2 {
  margin-bottom: 10px;
}

.msg {
  display: grid;
  gap: 6px;
  max-width: 820px;
}

.msg.user {
  justify-self: end;
}

.bubble {
  white-space: pre-wrap;
  line-height: 1.72;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
}

.user .bubble {
  background: linear-gradient(135deg, #241a12, #9d1f18);
  color: #fff;
  border-color: #9d1f18;
}

.msg-tools {
  display: flex;
  justify-content: flex-end;
}

.copy {
  height: 28px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}

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

.composer textarea {
  min-height: 52px;
  max-height: 160px;
}

.table-wrap {
  overflow: auto;
}

.section-toolbar {
  min-width: 720px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8efe0;
}

.section-toolbar .subtle {
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fffaf0;
}

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 13px;
  color: var(--muted);
  background: #f4ead7;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  padding: 16px;
}

.kpi strong {
  display: block;
  font-size: 26px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.form-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.model-config-form {
  min-width: 720px;
  padding: 16px;
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: #f8efe0;
}

.length-control {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(3, auto);
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check-row input {
  width: 16px;
  height: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  background: #efe3c7;
  color: #3b2a19;
  font-weight: 700;
}

.pill.green {
  background: #e5f0ea;
  color: #14785f;
}

.pill.red {
  background: #fff1f0;
  color: #b42318;
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.loading::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 0.9s infinite ease-in-out;
}

/* Premium black-gold theme override */
:root {
  --bg: #080604;
  --panel: #100d08;
  --panel-soft: #171107;
  --line: #6f5520;
  --text: #f4d88a;
  --muted: #b99645;
  --brand: #d6ad56;
  --brand-strong: #f2d184;
  --green: #d6ad56;
  --coral: #d6ad56;
  --amber: #d6ad56;
  --night: #080604;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.42);
}

body {
  background:
    radial-gradient(circle at 18% 10%, rgba(214, 173, 86, 0.14), transparent 26%),
    radial-gradient(circle at 86% 6%, rgba(214, 173, 86, 0.08), transparent 24%),
    linear-gradient(180deg, #080604 0%, #0d0a06 52%, #080604 100%);
  color: var(--text);
}

.sidebar,
.login-visual {
  background:
    radial-gradient(circle at 30% 8%, rgba(214, 173, 86, 0.16), transparent 28%),
    linear-gradient(180deg, #070503 0%, #0f0b06 58%, #080604 100%);
  color: #f4d88a;
}

.sidebar::before {
  background:
    linear-gradient(90deg, transparent, rgba(214, 173, 86, 0.34), transparent),
    linear-gradient(180deg, rgba(214, 173, 86, 0.1), transparent);
  opacity: 0.78;
}

.brand,
.entry > .brand {
  color: #f4d88a;
  text-shadow: 0 0 20px rgba(214, 173, 86, 0.24);
}

.brand-mark,
.agent-icon {
  background: linear-gradient(135deg, #f4d88a 0%, #d6ad56 52%, #8a6a2a 100%);
  color: #080604;
  box-shadow: 0 0 0 1px rgba(244, 216, 138, 0.36), 0 14px 30px rgba(214, 173, 86, 0.22);
}

.agent-card:nth-child(2n) .agent-icon,
.agent-card:nth-child(3n) .agent-icon {
  background: linear-gradient(135deg, #f4d88a 0%, #d6ad56 52%, #8a6a2a 100%);
}

.sidebar-footer,
.login-visual p,
.entry > div .subtle,
.subtle,
.copy,
.loading {
  color: #b99645;
}

.topbar,
.card,
.login,
.entry-card,
.chat-panel,
.conversation-list,
.composer,
.section-toolbar,
.model-config-form,
table,
input,
textarea,
select,
.bubble,
.empty-guide,
.notice {
  background: rgba(16, 13, 8, 0.94);
  border-color: rgba(214, 173, 86, 0.38);
  color: #f4d88a;
}

.topbar {
  box-shadow: 0 1px 0 rgba(214, 173, 86, 0.18);
}

.main {
  background:
    radial-gradient(circle at 82% 12%, rgba(214, 173, 86, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(8, 6, 4, 0.2), rgba(8, 6, 4, 0.72));
}

.page-head h1,
.entry h1,
.login-visual h1,
.chat-head h2,
.empty-guide h2,
h1,
h2,
h3,
label {
  color: #f4d88a;
}

.eyebrow {
  color: #d6ad56;
}

.agent-card::before {
  background: linear-gradient(90deg, transparent, #d6ad56, transparent);
}

.agent-card:hover {
  border-color: rgba(244, 216, 138, 0.62);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(214, 173, 86, 0.2);
}

.btn,
.btn.secondary,
.btn.danger {
  background: linear-gradient(135deg, #f4d88a 0%, #d6ad56 54%, #8a6a2a 100%);
  color: #080604;
  box-shadow: 0 12px 26px rgba(214, 173, 86, 0.22);
}

.btn:hover,
.btn.secondary:hover,
.btn.danger:hover {
  background: linear-gradient(135deg, #ffe9a6 0%, #d6ad56 62%, #7a5b1f 100%);
}

.btn.ghost,
.conversation-list .back-workbench {
  background: rgba(8, 6, 4, 0.72);
  color: #f4d88a;
  border-color: rgba(214, 173, 86, 0.46);
}

.login-wrap,
.entry-wrap {
  background:
    radial-gradient(circle at 20% 12%, rgba(214, 173, 86, 0.16), transparent 26%),
    radial-gradient(circle at 82% 14%, rgba(214, 173, 86, 0.1), transparent 24%),
    linear-gradient(180deg, #080604 0%, #100d08 56%, #080604 100%);
}

.metric {
  background: rgba(8, 6, 4, 0.52);
  border-color: rgba(214, 173, 86, 0.42);
  color: #f4d88a;
}

input::placeholder,
textarea::placeholder {
  color: #8a6a2a;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #f4d88a;
  box-shadow: 0 0 0 3px rgba(214, 173, 86, 0.18);
}

.conversation-list button {
  color: #f4d88a;
}

.conversation-list button.active,
.conversation-list button:hover {
  background: rgba(214, 173, 86, 0.14);
}

.messages {
  background:
    radial-gradient(circle at 84% 12%, rgba(214, 173, 86, 0.08), transparent 28%),
    linear-gradient(180deg, #0b0805 0%, #100d08 100%);
}

.empty-guide {
  border-style: solid;
}

.user .bubble {
  background: linear-gradient(135deg, #f4d88a 0%, #d6ad56 58%, #8a6a2a 100%);
  color: #080604;
  border-color: rgba(244, 216, 138, 0.72);
}

th {
  background: #171107;
  color: #d6ad56;
}

td {
  color: #f4d88a;
}

.pill,
.pill.green,
.pill.red {
  background: rgba(214, 173, 86, 0.14);
  color: #f4d88a;
  border: 1px solid rgba(214, 173, 86, 0.34);
}

.error {
  background: rgba(214, 173, 86, 0.12);
  color: #f4d88a;
  border-color: rgba(214, 173, 86, 0.44);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.6);
    opacity: 0.55;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

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

  .sidebar {
    position: static;
    min-height: auto;
  }

  .nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .chat-layout,
  .split,
  .login,
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .chat-layout {
    height: auto;
  }

  .conversation-list {
    max-height: 220px;
  }

  .admin-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .topbar,
  .main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page-head,
  .chat-head,
  .composer {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .section-toolbar {
    min-width: 0;
    align-items: stretch;
    flex-direction: column;
  }

  .model-config-form {
    min-width: 0;
  }

  .length-control {
    grid-template-columns: 1fr;
  }

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

  .login-visual,
  .login-form {
    padding: 24px;
  }

  .metric-row,
  .admin-grid,
  .row {
    grid-template-columns: 1fr;
  }
}
