:root {
  --bg: #f2efe7;
  --panel: rgba(255, 250, 241, 0.82);
  --panel-strong: #fffaf1;
  --ink: #1a1d20;
  --muted: #6f6257;
  --accent: #b44a1f;
  --accent-dark: #7d3010;
  --border: rgba(31, 26, 23, 0.12);
  --shadow: 0 24px 60px rgba(60, 39, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(180, 74, 31, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(62, 97, 71, 0.12), transparent 24%),
    linear-gradient(135deg, #f2efe7, #ece4d6 48%, #e8dcc8);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

button,
a,
.ghost-link,
.text-link {
  font-family: "SFMono-Regular", Menlo, monospace;
}

input,
select,
textarea {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
}

input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.72);
}

select {
  padding-right: 40px;
}

button,
.ghost-link {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 1rem;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff7f0;
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease;
}

button:hover,
.ghost-link:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.75;
  cursor: wait;
}

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

.text-link {
  color: var(--accent-dark);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--accent-dark);
  margin-bottom: 12px;
}

.lede,
.muted {
  color: var(--muted);
}

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

.stack-tight {
  display: grid;
  gap: 6px;
}

label {
  display: grid;
  gap: 8px;
}

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

.grid-phone {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
}

.phone-code-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  padding: 0 14px;
}

.phone-code-shell input {
  border: 0;
  background: transparent;
  padding-left: 0;
}

.hidden {
  display: none;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card,
.sidebar,
.main-panel,
.dashboard-card,
.hero-panel,
.topbar {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(1100px, 100%);
  padding: 28px;
  border-radius: 28px;
}

.auth-card-wide {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
}

.auth-copy,
.auth-form-panel {
  border-radius: 24px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.32);
}

.auth-copy {
  display: grid;
  align-content: start;
  gap: 16px;
}

.auth-copy h1,
.auth-copy .lede {
  margin: 0;
}

.auth-logo-shell {
  display: grid;
  place-items: center;
  height: 180px;
  margin-top: 8px;
}

.auth-logo {
  max-width: 100%;
  max-height: 132px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.auth-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
}

.error-banner,
.success-banner {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.error-banner {
  background: rgba(180, 74, 31, 0.12);
  border: 1px solid rgba(180, 74, 31, 0.2);
}

.success-banner {
  background: rgba(54, 119, 88, 0.12);
  border: 1px solid rgba(54, 119, 88, 0.2);
}

.dashboard-body {
  padding-top: 74px;
}

.chat-page-body {
  height: 100vh;
  overflow: hidden;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
}

.topbar-brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.user-badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
}

.workspace-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  padding: 0;
  height: calc(100vh - 74px);
}

.admin-shell {
  display: grid;
  gap: 24px;
  padding: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-radius: 0;
  align-self: stretch;
  position: relative;
  top: 0;
  margin: 0;
  border-left: 0;
  border-bottom: 0;
  min-height: calc(100vh - 74px);
  overflow: hidden;
}

.sidebar section {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.panel-title {
  margin-bottom: 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.thread-list,
.messages {
  display: grid;
  gap: 12px;
}

.thread-list {
  margin-top: 0;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
}

.thread-button {
  width: 100%;
  text-align: left;
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  padding: 10px 12px;
}

.main-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  min-height: calc(100vh - 74px);
  height: calc(100vh - 74px);
  padding: 24px;
  border-radius: 0;
  margin: 0;
  border-right: 0;
  border-bottom: 0;
  overflow: hidden;
}

.hero-panel,
.dashboard-card {
  border-radius: 24px;
  padding: 20px;
}

.messages {
  align-content: start;
  overflow: auto;
  padding-right: 4px;
  min-height: 0;
  padding-bottom: 8px;
}

.message {
  max-width: min(860px, 100%);
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
}

.message.user {
  justify-self: end;
  background: rgba(180, 74, 31, 0.12);
}

.message-meta {
  margin-bottom: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-body {
  line-height: 1.5;
}

.citations {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

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

.row-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.approval-card {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.settings-group {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.38);
}

.settings-group h3 {
  margin: 0 0 8px;
}

.spaced-top {
  margin-top: 20px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 247, 240, 0.35);
  border-top-color: #fff7f0;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

.spinner.hidden {
  display: none;
}

.reveal {
  animation: rise 360ms ease;
}

.reveal-left {
  animation: slide 420ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .auth-card-wide,
  .workspace-shell,
  .dashboard-grid,
  .grid-two,
  .grid-phone {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    margin: 0;
  }

  .dashboard-body {
    padding-top: 0;
  }

  .chat-page-body {
    height: auto;
    overflow: auto;
  }

  .workspace-shell,
  .main-panel {
    height: auto;
  }

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