:root {
  --bg: #f5efe2;
  --bg-soft: #efe5d3;
  --card: rgba(255, 252, 245, 0.85);
  --line: rgba(31, 77, 61, 0.12);
  --text: #163128;
  --muted: #677a70;
  --accent: #1f4d3d;
  --accent-strong: #14362c;
  --accent-warm: #c86d3a;
  --bubble-client: #fff9ef;
  --bubble-seller: #d7eadf;
  --shadow: 0 24px 60px rgba(40, 50, 45, 0.12);
  --radius: 24px;
  --radius-sm: 16px;
  --font-ui: "Segoe UI Variable", "Aptos", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(200, 109, 58, 0.12), transparent 32%),
    radial-gradient(circle at bottom right, rgba(31, 77, 61, 0.14), transparent 28%),
    linear-gradient(180deg, #fbf5e9 0%, var(--bg) 100%);
}

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

.app-shell {
  width: min(1600px, calc(100vw - 24px));
  margin: 16px auto;
}

.topbar,
.banner,
.panel {
  backdrop-filter: blur(18px);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(31, 77, 61, 0.98), rgba(29, 57, 48, 0.96)),
    var(--card);
  color: #f9f4eb;
}

.topbar h1,
.assistant-header h2,
.thread-meta h2,
.login-card h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.72;
}

.topbar-actions,
.assistant-actions,
.badge-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.banner {
  margin-top: 16px;
  padding: 18px 22px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.accounts-panel {
  margin-top: 16px;
  min-height: auto;
}

.notifications-panel {
  margin-top: 16px;
  min-height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.notifications-panel h2 {
  margin: 0;
}

.notifications-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.accounts-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.account-status-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.device-flow-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.device-flow-box.hidden {
  display: none;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.6);
}

.account-card h3,
.account-card p {
  margin: 0;
}

.account-card p {
  color: var(--muted);
  margin-top: 8px;
}

.account-card .badge-row {
  margin-top: 12px;
}

.banner strong,
.badge-strong {
  color: var(--accent);
}

.layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: stretch;
}

.panel {
  border-radius: var(--radius);
  padding: 18px;
  min-height: 72vh;
}

.sidebar,
.assistant-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-tools {
  display: grid;
  gap: 12px;
}

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

.queue-tab {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.queue-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 77, 61, 0.24);
}

.queue-tab.active {
  background: linear-gradient(135deg, rgba(31, 77, 61, 0.96), rgba(29, 57, 48, 0.94));
  color: #f9f4eb;
  border-color: transparent;
  box-shadow: 0 16px 28px rgba(31, 77, 61, 0.18);
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
}

.field textarea {
  min-height: 260px;
  resize: vertical;
  line-height: 1.5;
}

.grow {
  flex: 1;
}

.thread-list {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 2px;
}

.thread-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.54);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.thread-card:hover,
.thread-card.active {
  transform: translateY(-1px);
  border-color: rgba(31, 77, 61, 0.3);
  background: rgba(255, 255, 255, 0.85);
}

.thread-card h3,
.thread-card p {
  margin: 0;
}

.thread-card p {
  color: var(--muted);
  margin-top: 8px;
}

.thread-meta {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.meta-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(31, 77, 61, 0.08);
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 600;
}

.conversation {
  display: grid;
  gap: 12px;
  padding-top: 18px;
}

.message-bubble {
  max-width: 78%;
  padding: 16px 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(37, 51, 42, 0.08);
}

.message-bubble.client {
  justify-self: start;
  background: var(--bubble-client);
  border-bottom-left-radius: 8px;
}

.message-bubble.seller {
  justify-self: end;
  background: var(--bubble-seller);
  border-bottom-right-radius: 8px;
}

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

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #f8f4ec;
}

.button-ghost {
  background: rgba(31, 77, 61, 0.08);
  color: var(--accent);
}

.button-wide {
  width: 100%;
}

.draft-meta,
.empty-state {
  color: var(--muted);
}

.status-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(20, 54, 44, 0.95);
  color: #f9f4eb;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.status-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.login-dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

.login-dialog::backdrop {
  background: rgba(12, 27, 22, 0.45);
  backdrop-filter: blur(10px);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  border-radius: 28px;
  background: #fffaf1;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .assistant-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw, calc(100vw - 12px));
    margin: 6px auto 20px;
  }

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

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions .button {
    width: 100%;
  }

  .banner {
    flex-direction: column;
    align-items: stretch;
  }

  .notifications-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .notifications-actions {
    width: 100%;
  }

  .notifications-actions .button {
    width: 100%;
  }

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

  .topbar,
  .banner {
    padding: 18px;
  }

  .panel {
    min-height: auto;
  }

  .message-bubble {
    max-width: 100%;
  }
}
