:root {
  --teal: #0f766e;
  --ink: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --soft: #f3f4f6;
  --sidebar: #1f2937;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #f8fafc;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* display:grid on .login-view/.shell overrides native [hidden] — force hide */
.login-view[hidden],
.shell[hidden],
[hidden] {
  display: none !important;
}

.login-card {
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.login-card h1 { margin: 0 0 6px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card label { display: block; font-size: 12px; font-weight: 650; margin-bottom: 6px; }
.login-card label.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 4px 0 12px;
}
.login-card label.remember input { width: auto; margin: 0; }
.forgot-wrap { margin-top: 14px; font-size: 13px; }
.forgot-wrap a { color: var(--teal); }
.login-card input {
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.login-card button, .actions button, .reply-form button, .brand button {
  border: 0;
  border-radius: 10px;
  background: var(--teal);
  color: #fff;
  padding: 10px 14px;
  font-weight: 650;
  cursor: pointer;
}
.error { color: #b91c1c; font-size: 13px; }

.shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  gap: 10px;
}
.brand-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #d1d5db;
  cursor: pointer;
  user-select: none;
}
.sound-toggle input { margin: 0; }
.brand button {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  padding: 6px 10px;
  font-size: 12px;
}

.conv-list { overflow: auto; flex: 1; }
.conv-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: #fff;
  padding: 14px 16px;
  cursor: pointer;
}
.conv-item.active, .conv-item:hover { background: rgba(255,255,255,.06); }
.conv-item.unread strong { color: #fff; font-weight: 700; }
.conv-item.unread { background: rgba(15, 118, 110, 0.18); }
.conv-item .badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: #f59e0b;
  color: #111827;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  text-align: center;
}
.conv-item .chip {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--teal);
  padding: 2px 6px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.conv-item strong { display: block; }
.conv-item span { color: #9ca3af; font-size: 12px; }

.thread { display: flex; flex-direction: column; min-width: 0; background: #fff; }
.thread-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.thread-header h2 { margin: 0; font-size: 18px; }
.thread-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; }
.actions .ghost { background: #fff; color: var(--ink); border: 1px solid var(--border); }

.messages {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.bubble.visitor { align-self: flex-start; background: #fff; border: 1px solid var(--border); }
.bubble.bot { align-self: flex-start; background: #ecfdf5; border: 1px solid #a7f3d0; }
.bubble.agent { align-self: flex-end; background: var(--teal); color: #fff; }
.bubble .meta { display: block; font-size: 11px; opacity: .7; margin-bottom: 4px; }

.reply-form {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.reply-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 14px;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { max-height: 40vh; }
}
