:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #eff2f1; --border: #dfe4e2;
  --text: #17201c; --muted: #5f6b66; --accent: #1f7a5a; --wa: #1faa59; --wa-hover: #188f4a;
  --wa-soft: #e2f5ea; --warn: #9a5b00; --warn-soft: #fff3dc; --danger: #b42318; --danger-soft: #fdecea;
  --focus: #2f6fed; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101412; --surface: #181d1b; --surface-2: #212825; --border: #2c3531;
    --text: #e7ece9; --muted: #98a59f; --accent: #3fb68b; --wa: #25c265; --wa-hover: #3ad179;
    --wa-soft: #16362a; --warn: #f5b546; --warn-soft: #3a2d12; --danger: #f97066; --danger-soft: #3b1d1b;
    --focus: #6b9bff; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 32px 16px 48px; }
code { background: var(--surface-2); padding: 0 4px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); font-weight: 400; }

/* header */
header { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px; background: var(--wa);
  display: grid; place-items: center; flex-shrink: 0;
}
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: 14px; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}

/* upload */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  border: 2px dashed var(--border); border-radius: 10px; padding: 26px 16px; cursor: pointer;
  background: var(--surface-2); color: var(--muted); transition: border-color .15s, background .15s;
}
.drop span:first-of-type { color: var(--text); }
.drop strong { color: var(--wa); }
.drop:hover, .drop.over { border-color: var(--wa); background: var(--wa-soft); }
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.hint { font-size: 13px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.files:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px;
}
.msg-label { display: block; font-weight: 600; font-size: 14px; margin: 18px 0 6px; }
textarea, .search {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px;
}
textarea { resize: vertical; }
textarea:focus, .search:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: transparent; }
.alert {
  display: none; margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid currentColor;
}
.alert.show { display: block; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat.good .v { color: var(--wa); }
.stat.warn .v { color: var(--warn); }

/* duplicate / invalid details */
.dupes {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px;
  background: var(--warn-soft);
}
.dupes summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.dupes ul { margin: 10px 0 2px; padding-left: 20px; font-size: 14px; max-height: 220px; overflow: auto; }
.dupes li { margin: 3px 0; }
.dupes .num { font-family: Consolas, "Cascadia Mono", monospace; }

/* toolbar + buttons */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 12px; }
.search { flex: 1; min-width: 200px; width: auto; }
button {
  font: inherit; border-radius: 9px; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 8px 14px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
button:hover { background: var(--surface-2); }
button:focus-visible, .wa:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* contact list */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.item {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.idx { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.who { min-width: 0; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name.none { color: var(--muted); font-weight: 400; font-style: italic; }
.phone { font-family: Consolas, "Cascadia Mono", monospace; color: var(--muted); font-size: 14px; }
.opened {
  display: none; margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--wa);
  font-family: "Segoe UI", system-ui, sans-serif;
}
.item.done .opened { display: inline; }
.item.done .name { opacity: .75; }
.wa {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 99px;
  background: var(--wa); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  white-space: nowrap;
}
.wa:hover { background: var(--wa-hover); }
.empty { text-align: center; color: var(--muted); padding: 20px; margin: 0; }
footer { color: var(--muted); font-size: 13px; text-align: center; margin-top: 24px; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { flex-basis: 100%; }
  .toolbar button { flex: 1; justify-content: center; }
  .card { padding: 16px; }
  .item { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; padding: 10px; }
  .wa .label { display: none; }
  .wa { padding: 9px; }
}
