:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --text: #1b2420;
  --muted: #5f6b66;
  --line: #dde3df;
  --accent: #128c5a;
  --accent-soft: #e3f4ec;
  --danger: #c0392b;
  --warn: #9a6200;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #18201c;
    --text: #e6ece9;
    --muted: #93a19a;
    --line: #2a3530;
    --accent: #2fbf7f;
    --accent-soft: #1b3328;
    --danger: #ff6b5b;
    --warn: #e3a64a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
h2 + h2, .card h2:not(:first-child) { margin-top: 1.5rem; }
code { background: var(--accent-soft); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); }
.error { color: var(--danger); min-height: 1.2em; margin: .5rem 0; font-size: .9rem; }

label { display: block; margin-bottom: .9rem; font-weight: 500; }
input, select, textarea {
  width: 100%;
  margin-top: .3rem;
  padding: .65rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=radio] { width: auto; margin: 0; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { width: 100%; padding: .9rem; font-size: 1rem; }
.btn:disabled { opacity: .55; cursor: progress; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }

.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); padding: 2rem; border-radius: var(--radius); border: 1px solid var(--line); }
.auth-card .brand { font-size: 1.6rem; }
.auth-card .btn { width: 100%; }

.tabs { display: flex; gap: .25rem; background: var(--bg); padding: .25rem; border-radius: 10px; margin-bottom: 1rem; }
.tab { flex: 1; border: 0; background: none; padding: .45rem .9rem; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .tabs { margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.pill { font-size: .8rem; font-weight: 600; padding: .2rem .6rem; border-radius: 99px; background: var(--bg); color: var(--muted); }
.pill.on { background: var(--accent-soft); color: var(--accent); }

.view, .connect { max-width: 1100px; margin: 1.25rem auto; padding: 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.step { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .85rem; }

/* Connect */
.connect { display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; align-items: center; }
.connect.card { max-width: none; padding: 1.4rem; margin: 1.25rem max(16px, calc((100% - 1068px) / 2)); }
.qr-box { width: 240px; height: 240px; border: 1px dashed var(--line); border-radius: 12px; display: grid; place-items: center; background: #fff; text-align: center; padding: .5rem; }
.qr-box img { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 640px) { .connect { grid-template-columns: 1fr; } .qr-box { margin: 0 auto; } }

/* Upload */
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 1rem; text-align: center; margin-bottom: .9rem; transition: .15s; }
.drop p { margin: 0; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

.seg { display: flex; gap: 1.25rem; margin-bottom: .6rem; }
.seg label { display: flex; align-items: center; gap: .4rem; margin: 0; }
#dest-group { display: grid; gap: .4rem; }

.modes { display: grid; gap: .6rem; }
.mode { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem; border: 1px solid var(--line); border-radius: 12px; margin: 0; font-weight: 400; cursor: pointer; }
.mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode input { margin-top: .3rem; }
.tag { font-style: normal; font-size: .72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; margin-left: .3rem; }

/* Pré-visualização estilo WhatsApp */
.preview { margin: 1.25rem 0 .5rem; display: grid; gap: .5rem; max-height: 340px; overflow: auto; padding: .75rem; border-radius: 12px; background: var(--bg); }
.preview:empty { display: none; }
.bubble { background: var(--surface); border-radius: 10px; padding: .6rem .8rem; font-size: .88rem; max-width: 90%; box-shadow: 0 1px 1px rgb(0 0 0 / .06); }
.bubble b { display: block; margin-bottom: .3rem; }
.bubble .opt { display: flex; align-items: center; gap: .45rem; padding: .15rem 0; }
.bubble .opt::before { content: ""; width: .95rem; height: .95rem; border: 2px solid var(--muted); border-radius: 50%; flex: none; }
.bubble.more { text-align: center; color: var(--muted); max-width: none; background: none; box-shadow: none; }

/* Listas */
.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.list-card { text-align: left; cursor: pointer; font: inherit; color: inherit; }
.list-card:hover { border-color: var(--accent); }
.list-card h3 { margin: 0 0 .2rem; font-size: 1rem; }
.list-card .row { display: flex; justify-content: space-between; align-items: baseline; margin-top: .6rem; font-size: .85rem; }
.status { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.status.error { color: var(--danger); }
.status.sending, .status.queued { color: var(--warn); }
.status.done { color: var(--accent); }
.empty { grid-column: 1 / -1; text-align: center; padding: 3rem 1rem; }

.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: .6rem; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

dialog { width: min(560px, calc(100vw - 32px)); max-height: 85vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.4rem; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.detail-head { display: flex; justify-content: space-between; gap: 1rem; }
.detail-head h2 { margin-bottom: .2rem; }
.items { margin: 1rem 0; }
.items h4 { margin: 1rem 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.item { display: flex; gap: .6rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.item .check { width: 1.2rem; height: 1.2rem; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; font-size: .75rem; flex: none; }
.item.done .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.item.done .t { text-decoration: line-through; color: var(--muted); }
.detail-actions { display: flex; justify-content: space-between; gap: .5rem; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .7rem 1.1rem; border-radius: 10px; font-weight: 600; z-index: 20; max-width: calc(100vw - 32px); }
