:root {
  --bg: #eef3fb;
  --card: #ffffff;
  --text: #0e1524;
  --muted: #4d5e7d;
  --line: #d8e1f2;
  --primary: #0a7b75;
  --primary-2: #085e5a;
  --accent: #153a73;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, #f8fbff 0%, rgba(248, 251, 255, 0) 42%),
    radial-gradient(circle at 95% 8%, #d8fff5 0%, rgba(216, 255, 245, 0) 30%),
    linear-gradient(160deg, #e8effb 0%, #eef3fb 55%, #f7fafe 100%);
}

.page { width: 100%; min-height: 100vh; }

.hidden { display: none !important; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  width: 100vw;
  margin-left: calc(50% - 50vw);
}

.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 8%, #2f5fa6 0%, rgba(47, 95, 166, 0) 40%),
    radial-gradient(circle at 92% 14%, #169c97 0%, rgba(22, 156, 151, 0) 34%),
    radial-gradient(circle at 72% 88%, #f49a62 0%, rgba(244, 154, 98, 0) 36%),
    linear-gradient(140deg, #0f1f42 0%, #142a57 45%, #12315e 100%);
}

.orb {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(2px);
  opacity: 0.45;
  animation: float 14s ease-in-out infinite;
}

.orb-a {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle at 30% 30%, #6ea7ff 0%, #4f8df0 70%, transparent 100%);
  top: -80px;
  left: -60px;
}

.orb-b {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle at 30% 30%, #68f5dd 0%, #45d5be 70%, transparent 100%);
  right: -40px;
  top: 50px;
  animation-delay: 2s;
}

.orb-c {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle at 30% 30%, #ffc18f 0%, #f0a469 70%, transparent 100%);
  bottom: -90px;
  left: 40%;
  animation-delay: 4s;
}

.auth-shell {
  width: 100%;
  max-width: 1040px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  position: relative;
  z-index: 2;
  padding: 20px;
}

.auth-hero {
  border-radius: 26px;
  padding: 34px;
  background: linear-gradient(150deg, rgba(9, 27, 62, 0.55) 0%, rgba(20, 52, 102, 0.5) 100%);
  border: 1px solid rgba(144, 185, 255, 0.35);
  box-shadow: 0 16px 42px rgba(2, 8, 25, 0.35);
  backdrop-filter: blur(8px);
}

.auth-kicker {
  margin: 0 0 16px;
  font-size: 12px;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: #b6cdf8;
}

.auth-hero h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.08;
  color: #f7fbff;
}

.auth-copy {
  margin-top: 16px;
  max-width: 500px;
  color: #d6e3ff;
  font-size: 16px;
}

.auth-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(35, 63, 102, 0.14);
  backdrop-filter: blur(10px);
}

.auth-card h2 { margin: 0; font-size: 30px; }
.auth-card p { margin: 8px 0 16px; color: var(--muted); }

.app-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  background: linear-gradient(140deg, #0f2852 0%, #1a3a78 48%, #135e76 100%);
  color: #eff5ff;
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 18px 30px rgba(14, 26, 52, 0.16);
}

.topbar-main h1 { margin: 2px 0 0; font-size: 32px; font-weight: 700; }
.topbar-main p { margin: 8px 0 0; color: #d7e7ff; }
.top-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: #a9c3ef;
  font-weight: 700;
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.badge {
  border: 1px solid rgba(188, 212, 255, 0.45);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  padding: 9px 14px;
  color: #ebf4ff;
  font-size: 14px;
}

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

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 12px 28px rgba(23, 33, 52, 0.08);
}

.card h2 { margin: 0; font-size: 18px; }
.card p { margin: 8px 0 12px; color: var(--muted); font-size: 14px; }

input, textarea, button { font: inherit; }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  margin-bottom: 8px;
}

textarea { resize: vertical; min-height: 120px; }

button {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover { background: var(--primary-2); }

.btn-light { background: #eef4ff; color: #1f3f7d; }
.btn-light:hover { background: #dfeaff; }

.row { display: flex; gap: 8px; margin-top: 10px; }

.chat-card { display: flex; flex-direction: column; }

.chat-window {
  border: 1px solid var(--line);
  border-radius: 12px;
  height: 270px;
  overflow-y: auto;
  padding: 10px;
  background: #fcfdff;
}

.chat-msg { margin: 8px 0; padding: 8px 10px; border-radius: 10px; max-width: 92%; white-space: pre-wrap; }
.chat-msg.user { background: #eaf1ff; margin-left: auto; }
.chat-msg.bot { background: #f2f5fa; }

.chat-controls { display: flex; gap: 8px; margin-top: 10px; }

.wa-status {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--muted);
  margin-bottom: 10px;
}

.qr-wrap {
  margin-top: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

#waQrImage {
  max-width: 320px;
  width: 100%;
  display: none;
  image-rendering: pixelated;
}

.ingest-history-wrap {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.ingest-history-wrap h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #1c325a;
}

.ingest-history {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.ingest-empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  background: #fafcff;
}

.ingest-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fbfdff;
}

.ingest-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #3e5d91;
  margin-bottom: 6px;
}

.ingest-item p {
  margin: 0 0 8px;
  color: #1d2b44;
  font-size: 13px;
  line-height: 1.45;
}

.ingest-use-btn {
  padding: 8px 10px;
  font-size: 13px;
}

small { display: block; margin-top: 10px; color: var(--muted); }
#loginStatus { min-height: 20px; color: #b42318; font-weight: 600; }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 24px; }
  .auth-hero h1 { font-size: 32px; }
  .grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@keyframes float {
  0% { transform: translateY(0px) translateX(0px); }
  50% { transform: translateY(-16px) translateX(8px); }
  100% { transform: translateY(0px) translateX(0px); }
}
