:root {
  --bg: #eef2f0;
  --bg-2: #f7faf8;
  --ink: #14201a;
  --muted: #5c6b63;
  --line: #cfd8d2;
  --panel: rgba(255, 255, 255, 0.82);
  --accent: #0f766e;
  --accent-2: #c2410c;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --claimed: #1d4ed8;
  --shadow: 0 18px 50px rgba(20, 32, 26, 0.08);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

body {
  position: relative;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 8% -10%, #9fd9cf 0%, transparent 60%),
    radial-gradient(700px 380px at 100% 0%, #f0c2a4 0%, transparent 55%),
    linear-gradient(180deg, #e8efeb 0%, #f4f7f5 45%, #eef2f0 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(247, 250, 248, 0.75);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  background:
    linear-gradient(145deg, #0f766e, #134e4a);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15);
}

.brand-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar-actions {
  display: flex;
  gap: 0.6rem;
  align-items: end;
  flex-wrap: wrap;
}

.key-field {
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.key-field input,
.enqueue-form input,
.enqueue-form textarea,
.filters input,
.filters select {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  min-width: 0;
}

.key-field input { width: 16rem; }

.layout {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.25rem auto 3rem;
  display: grid;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1.5rem;
  align-items: start;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15,118,110,0.18), transparent 70%);
  pointer-events: none;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  max-width: 28ch;
  font-size: 1.05rem;
}

.enqueue-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.enqueue-form label,
.enqueue-form fieldset {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.enqueue-form .span-2 { grid-column: 1 / -1; }

.envio-toggle {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.envio-toggle legend {
  padding: 0 0.3rem;
  font-size: 0.8rem;
}

.radio {
  display: inline-flex !important;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink);
  font-size: 0.95rem;
}

.form-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover { filter: brightness(1.08); }

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

.btn.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn.danger {
  background: #fff;
  color: var(--bad);
  border: 1px solid #fecaca;
}

.feedback {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.feedback.ok { color: var(--ok); }
.feedback.err { color: var(--bad); }

.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
}

.stat {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.75);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
  box-shadow: var(--shadow);
}

.stat:hover, .stat.active {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 118, 110, 0.15);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 500;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

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

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.auto {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.device-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.device-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f3f6f4;
}

td.msg {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.mono, .mono { font-family: var(--mono); font-size: 0.8rem; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem !important;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--mono);
}

.pill.muted { background: #e5ebe7; color: var(--muted); }
.pill.queued { background: #ecfdf5; color: var(--ok); }
.pill.claimed { background: #eff6ff; color: var(--claimed); }
.pill.sent { background: #f0fdf4; color: var(--ok); }
.pill.failed { background: #fef2f2; color: var(--bad); }
.pill.cancelled { background: #fff7ed; color: var(--warn); }

.row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.jobs-meta { margin: 0.7rem 0 0; font-size: 0.85rem; }

.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 1.25rem;
}

.login-form {
  display: grid;
  gap: 0.85rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-form input {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
}

.inbox-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 0.75rem;
  min-height: 360px;
}

.inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: auto;
  max-height: 420px;
}

.inbox-list li {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.inbox-list li:hover,
.inbox-list li.active {
  background: #f0f7f4;
}

.inbox-list .phone {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.inbox-list .preview {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.2rem;
}

.chat-pane {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 360px;
}

.chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.chat-messages {
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 320px;
}

.bubble {
  max-width: 80%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.35;
}

.bubble.in {
  align-self: flex-start;
  background: #eef2f0;
}

.bubble.out {
  align-self: flex-end;
  background: #ccfbf1;
}

.bubble .meta {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
}

.reply-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
}

.reply-form input {
  flex: 1;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .topbar { flex-direction: column; align-items: stretch; }
  .key-field input { width: 100%; }
  .inbox-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .enqueue-form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
