:root {
  --navy: #2c4a69;
  --coral: #d26d60;
  --sand: #f5d583;
  --cream: #f7f0e0;
  --paper: #fdfaf3;
  --ink: #1e2f42;
  --line: rgba(44, 74, 105, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--navy);
  color: var(--cream);
  position: sticky;
  top: 0;
  z-index: 20;
}
.bar { flex-wrap: wrap; }
@media (max-width: 700px) {
  .bar { gap: 10px 14px; padding: 12px 16px; }
  .brand { flex: 1 1 100%; }
  .who { order: 2; }
  .counts { order: 3; margin-left: auto; }
}
.brand { display: flex; flex-direction: column; }
.mark { font-weight: 800; letter-spacing: .12em; font-size: 15px; }
.sub { font-size: 12px; opacity: .72; letter-spacing: .04em; }
.counts { margin-left: auto; font-size: 13px; opacity: .9; font-variant-numeric: tabular-nums; }

/* Who is at the keyboard — the shared send log names a person, not a browser. */
.who { display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: .8; }
.who input {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .25);
  color: var(--cream);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  width: 120px;
}
.who input::placeholder { color: rgba(247, 240, 224, .5); }
.who input:focus { outline: 2px solid var(--sand); outline-offset: 1px; }

/* ---------------------------------------------------------- message */
.msg {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.msg > summary {
  cursor: pointer;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  background: var(--cream);
}
.msg-hint { font-weight: 400; color: #7b8c9c; font-size: 13px; }
.msg-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
#template {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.55;
  resize: vertical;
  background: var(--paper);
  color: var(--ink);
}
#template:focus { outline: 2px solid rgba(210, 109, 96, .4); outline-offset: 1px; }
.msg-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.msg-foot .msg-hint { flex: 1 1 240px; }
.saved { font-size: 13px; color: #2f7d55; font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* ---------------------------------------------------------- dropzone */
.drop {
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--cream);
  padding: 34px 24px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--coral); background: #fff6ec; }
.drop-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: var(--navy); }
.drop-note { margin: 0 0 16px; font-size: 13px; color: #5a6b7d; }
.drop-opt { justify-content: center; margin-top: 14px; }
.drop-note code {
  background: rgba(44, 74, 105, .09);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.progress { margin-top: 18px; font-size: 13px; color: var(--navy); }
.progress .bar-fill {
  height: 6px;
  background: var(--coral);
  border-radius: 3px;
  width: 0;
  transition: width .25s;
  margin-bottom: 8px;
}

/* ---------------------------------------------------------- buttons */
.btn {
  appearance: none;
  border: 1px solid var(--navy);
  background: transparent;
  color: var(--navy);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: rgba(44, 74, 105, .07); }
.btn.primary { background: var(--navy); color: var(--cream); }
.btn.primary:hover { background: #21384f; }
.btn.ghost { border-color: var(--line); color: #5a6b7d; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* display:inline-block above would otherwise beat the UA rule for [hidden] */
.btn[hidden] { display: none; }

/* WhatsApp's own green, because the button has to be recognised at a glance. */
.btn.wa {
  background: #1fa855;
  border-color: #1fa855;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn.wa:hover { background: #18904a; border-color: #18904a; }
.btn.wa svg { flex: none; }

/* Already sent: still available, but it should not look like the default move. */
.btn.wa.again { background: #8a5d00; border-color: #8a5d00; }
.btn.wa.again:hover { background: #6f4b00; border-color: #6f4b00; }

/* Instagram's gradient, flattened to one workable colour. */
.btn.ig {
  background: #C13584;
  border-color: #C13584;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn.ig:hover { background: #a52c70; border-color: #a52c70; }
.btn.ig svg { flex: none; }

.btn.amber { background: #b8791a; border-color: #b8791a; color: #fff; }
.btn.amber:hover { background: #96620f; border-color: #96620f; }

.btn.link {
  border: 0;
  background: none;
  color: #7b8c9c;
  padding: 6px 4px;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn.link:hover { background: none; color: var(--navy); }

/* ---------------------------------------------------------- report */
.report {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.report h3 {
  margin: 0;
  padding: 12px 16px;
  font-size: 14px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
}
.report ul { margin: 0; padding: 10px 16px 14px 32px; font-size: 13px; }
.report li { margin: 4px 0; }
.report .bad { color: #a8372a; }
.report .warn { color: #9a6b18; }

.notice {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff6e2;
  border: 1px solid #e8cf99;
  color: #6b4e11;
  font-size: 14px;
  line-height: 1.55;
}

/* ---------------------------------------------------------- QA */
.qa {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.qa-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--cream);
  flex-wrap: wrap;
}
.qa-sum { font-size: 13.5px; color: #5a6b7d; font-variant-numeric: tabular-nums; }
.qa-sum b { color: var(--navy); }
.qa-sum .bad  { color: #a8372a; font-weight: 700; }
.qa-sum .warn { color: #8a5d00; font-weight: 700; }
.qa-sum .ok   { color: #2f7d55; font-weight: 700; }

#qaBody { max-height: 460px; overflow: auto; }
.qa-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  align-items: start;
}
.qa-row .who-id { font-variant-numeric: tabular-nums; color: #8496a6; font-size: 13px; }
.qa-row .who-id b { display: block; color: var(--navy); font-size: 14px; font-variant-numeric: normal; }
.qa-row ul { margin: 4px 0 0; padding-left: 18px; }
.qa-row li { margin: 2px 0; }
.qa-row li.bad  { color: #a8372a; }
.qa-row li.warn { color: #8a5d00; }
.qa-row li.todo { color: #5a6b7d; }
.qa-row li.info { color: #8496a6; }
.qa-row .payload {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  overflow-wrap: anywhere;
}
.qa-empty { padding: 22px 16px; color: #2f7d55; font-size: 14px; border-top: 1px solid var(--line); }
.qa-progress { padding: 12px 16px; font-size: 13.5px; color: var(--navy); border-top: 1px solid var(--line); }

/* ---------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 14px;
  flex-wrap: wrap;
}
#search {
  flex: 1 1 260px;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  background: #fff;
}
#search:focus { outline: 2px solid rgba(210, 109, 96, .4); outline-offset: 1px; }
#reasonFilter {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  max-width: 220px;
}
#reasonFilter:focus { outline: 2px solid rgba(210, 109, 96, .4); outline-offset: 1px; }
.chk { font-size: 13px; color: #5a6b7d; display: flex; align-items: center; gap: 6px; }
.spacer { flex: 1 1 auto; }

/* ---------------------------------------------------------- list */
.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card .thumb {
  aspect-ratio: 1856 / 2923;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .pending {
  font-size: 12px;
  color: #93a3b3;
  text-align: center;
  padding: 0 16px;
}
.card .meta { padding: 10px 12px; border-top: 1px solid var(--line); }
.card .name { font-weight: 700; color: var(--navy); }
.card .id { font-size: 12px; color: #8496a6; font-variant-numeric: tabular-nums; }
.card .tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(44, 74, 105, .09);
  color: var(--navy);
}
.tag.tickets { background: rgba(210, 109, 96, .16); color: #a8372a; }
.tag.missing { background: #fff0cd; color: #8a5d00; }
.tag.sent { background: #e2f0e7; color: #2f7d55; }
.tag.stale { background: #ffe0d6; color: #a8372a; font-weight: 600; }
.card.is-stale { border-color: #f0b8a8; }
.card.is-sent { border-color: #b9dcc8; }
.card.is-sent .thumb { opacity: .82; }
.card .actions {
  padding: 0 12px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.card .actions .btn { padding: 6px 12px; font-size: 13px; }
.empty { padding: 40px; text-align: center; color: #8496a6; }

/* ---------------------------------------------------------- lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(19, 30, 42, .88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  z-index: 50;
}
/* display:flex above would otherwise beat the UA rule for [hidden] */
.lightbox[hidden] { display: none; }
.lightbox img { max-height: 78vh; max-width: 100%; border-radius: 6px; }
.lightbox-bar { display: flex; align-items: center; gap: 16px; color: var(--cream); }
.lightbox .close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: var(--cream);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
.lightbox .btn.primary { background: var(--cream); color: var(--navy); border-color: var(--cream); }
