:root {
  --ink: #0b1220;
  --muted: #5b6578;
  --line: #d7deea;
  --bg: #f4f7fb;
  --card: #fff;
  --blue: #175197;
  --yellow: #f5c518;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.hidden { display: none !important; }
.crm-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 420px at 10% -10%, #dbe8ff 0%, transparent 60%),
    radial-gradient(700px 360px at 110% 10%, #fff3b0 0%, transparent 55%),
    var(--bg);
}
.card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  padding: 1.8rem;
  box-shadow: 0 20px 50px rgba(15, 30, 60, 0.08);
}
.eyebrow { margin: 0 0 .4rem; color: var(--blue); font-weight: 800; letter-spacing: .08em; font-size: .75rem; }
h1 { margin: 0 0 .6rem; letter-spacing: -.03em; }
.lead, .muted { color: var(--muted); line-height: 1.5; }
.google {
  margin-top: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  width: 100%;
  padding: .85rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.err { color: #991b1b; background: #fef2f2; padding: .7rem .8rem; border-radius: .8rem; }
.top, .who, .actions, .chat-shell { display: flex; }
.top {
  justify-content: space-between;
  align-items: flex-end;
  padding: 1.2rem 1.4rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.who { gap: .8rem; align-items: center; color: var(--muted); }
.who a { color: var(--blue); font-weight: 700; }
.qr-box {
  margin: 1rem 1.4rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid #f0d56a;
  background: #fff8d6;
  border-radius: 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.qr-box img { width: 180px; height: 180px; background: #fff; border-radius: .6rem; }
.chat-shell { height: calc(100vh - 92px); }
.chat-shell aside {
  width: min(320px, 38vw);
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
}
.chat-shell aside input, .thread textarea {
  border: 1px solid var(--line);
  border-radius: .8rem;
  padding: .7rem .8rem;
  font: inherit;
  width: 100%;
}
.chat-shell aside input { margin: .8rem; width: calc(100% - 1.6rem); }
.list { overflow: auto; }
.list button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: .85rem 1rem;
  cursor: pointer;
  font: inherit;
}
.list button.active { background: #eef4ff; }
.thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#thread-head { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); font-weight: 800; background: #fff; }
.messages { flex: 1; overflow: auto; padding: 1rem; display: flex; flex-direction: column; gap: .55rem; }
.bubble { max-width: 78%; padding: .7rem .85rem; border-radius: 1rem; line-height: 1.4; white-space: pre-wrap; }
.bubble.me { margin-left: auto; background: var(--blue); color: #fff; }
.bubble.them { background: #fff; border: 1px solid var(--line); }
#composer { padding: .8rem; background: #fff; border-top: 1px solid var(--line); }
.actions { justify-content: flex-end; gap: .6rem; margin-top: .6rem; }
button, .actions button {
  border: 0;
  border-radius: 999px;
  padding: .7rem 1rem;
  font-weight: 800;
  cursor: pointer;
}
#ai-btn { background: var(--yellow); color: var(--ink); }
#composer button[type=submit] { background: var(--blue); color: #fff; }
@media (max-width: 800px) {
  .chat-shell { flex-direction: column; height: auto; min-height: 70vh; }
  .chat-shell aside { width: 100%; max-height: 34vh; }
}
.edit-wrap { max-width: 980px; margin: 0 auto; padding: 1.2rem 1.4rem 2.4rem; }
.edit-wrap .lead { margin: 0 0 1rem; }
.ok { color: #166534; background: #ecfdf3; padding: .7rem .8rem; border-radius: .8rem; }
.grid-head, .grid-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr 1.4fr auto;
  gap: .5rem;
  align-items: center;
  margin-bottom: .45rem;
}
.grid-head { font-size: .75rem; font-weight: 800; color: var(--muted); }
.grid-row input[type=text], .grid-row input:not([type=checkbox]) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .7rem;
  padding: .55rem .7rem;
  font: inherit;
}
.save {
  margin-top: 1rem;
  background: var(--blue);
  color: #fff;
}
@media (max-width: 720px) {
  .grid-head { display: none; }
  .grid-row { grid-template-columns: 4.5rem 1fr; }
  .grid-row input[name=reply], .grid-row label { grid-column: 1 / -1; }
}
