:root {
  color-scheme: light;
  --bg: #f5f2ed;
  --panel: #fffdf9;
  --line: #d9d2c8;
  --line-strong: #b9afa2;
  --ink: #1f2f2b;
  --muted: #6b655d;
  --soft: #ece6dc;
  --teal: #176b5d;
  --teal-dark: #0e4039;
  --coral: #c95f3d;
  --amber: #a86e16;
  --danger: #a53b32;
  --ok: #287458;
  --shadow: 0 18px 50px rgba(44, 38, 31, 0.13);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  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.55;
}

.auth-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-panel {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 28px;
}

.auth-panel h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

.auth-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tab,
.ghost,
.icon-button,
.primary,
.danger {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.tab {
  background: var(--soft);
  color: var(--ink);
}

.tab.active,
.primary {
  background: var(--teal);
  color: white;
}

.ghost,
.icon-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger {
  background: var(--danger);
  color: white;
}

.form {
  display: grid;
  gap: 14px;
}

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

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.12);
}

.message-line {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

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

.app-shell {
  height: 100%;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  background: #29251f;
  color: #f8f1e8;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand .user {
  margin-top: 8px;
  color: #cfc5b8;
  font-size: 13px;
}

.sidebar-scroll {
  overflow: auto;
  padding: 14px;
}

.side-section {
  margin-bottom: 18px;
}

.side-title {
  margin: 0 0 8px;
  color: #bdb2a5;
  font-size: 12px;
  text-transform: uppercase;
}

.agent-list,
.conversation-list {
  display: grid;
  gap: 8px;
}

.side-item {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  color: #f8f1e8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px;
}

.side-item.active {
  background: #f8f1e8;
  color: #1f2f2b;
}

.side-item small {
  display: block;
  margin-top: 4px;
  color: inherit;
  opacity: 0.72;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sidebar-footer .ghost {
  color: #f8f1e8;
  border-color: rgba(255, 255, 255, 0.2);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--panel);
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  min-width: 0;
}

.topbar-title h2 {
  margin: 0;
  font-size: 20px;
}

.topbar-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.empty {
  padding: 42px;
  color: var(--muted);
}

.messages {
  overflow: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble {
  max-width: min(820px, 92%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffaf2;
  white-space: pre-wrap;
  line-height: 1.55;
}

.bubble.user {
  align-self: flex-end;
  background: #e7f2ef;
  border-color: #bfd8d0;
}

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

.bubble.failed {
  border-color: #d29a93;
  background: #fff2f0;
}

.bubble .meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 14px 22px 18px;
  display: grid;
  gap: 10px;
  background: #fbf7f0;
}

.composer textarea {
  width: 100%;
  min-height: 92px;
  max-height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  outline: none;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.title-input {
  width: min(360px, 100%);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.admin-view,
.image-view {
  overflow: auto;
  padding: 22px;
}

.admin-layout {
  display: grid;
  gap: 18px;
}

.panel {
  background: #fffaf2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: white;
}

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

th {
  background: #f4eee5;
  color: var(--muted);
  font-weight: 650;
}

td input,
td select,
td textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
}

.checkboxes {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  overflow: hidden;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--soft);
}

.image-card .body {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  width: fit-content;
}

.pill.ok {
  background: #dcefe5;
  color: var(--ok);
}

.pill.bad {
  background: #f4d9d5;
  color: var(--danger);
}

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

  .sidebar {
    grid-template-rows: auto auto auto;
  }

  .sidebar-scroll {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    max-height: 300px;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
