:root {
  --ink: #333; --soft: #555; --muted: #888; --page: #f1f1f1; --paper: #fff; --line: #ddd;
  --gold: #cfac5d; --gold-dark: #ad8b3e; --green: #2e7d32; --red: #c62828; --amber: #9a5b00;
  --wa: #e7ddd3; --bubble: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.45 Lato, system-ui, sans-serif; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 22px 0 10px; color: var(--gold-dark); text-transform: uppercase; letter-spacing: .04em; }
h2:first-child { margin-top: 0; }
[hidden] { display: none !important; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  background: var(--paper); padding: 0 20px; height: 56px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.brand { font-size: 20px; color: var(--gold); }
.who { display: flex; gap: 14px; align-items: center; color: var(--soft); font-size: 14px; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.center { text-align: center; }
.card { background: var(--paper); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1); padding: 20px; }
.narrow { max-width: 380px; margin: 40px auto; text-align: left; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--soft); }
input, select { font: inherit; color: var(--ink); padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
button { font: inherit; cursor: pointer; border-radius: 8px; padding: 10px 16px; border: 0; }
button:disabled { opacity: .5; cursor: default; }
.gold { background: var(--gold); color: #fff; font-weight: 700; }
.gold:hover:not(:disabled) { background: var(--gold-dark); }
.gold.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 18px; }
.line { background: #fff; border: 1px solid var(--ink); color: var(--ink); white-space: nowrap; }
.link { background: none; color: var(--gold-dark); font-weight: 700; padding: 6px 0; }
.back { margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); font-weight: 700; }
.warn { color: var(--amber); }
.note { background: #f6f1e4; border-radius: 8px; padding: 10px 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row input[type=search] { max-width: 280px; }
.lbl { font-size: 13px; color: var(--soft); margin-right: 4px; }
.pill { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 14px; color: var(--ink); cursor: pointer; }
.pill input { width: auto; margin: 0; accent-color: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ev { background: var(--paper); border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.12); cursor: pointer; text-align: left; padding: 0; }
.ev .img { height: 130px; background: var(--line) center/cover; }
.ev .txt { padding: 10px 12px; }
.ev b { display: block; }
.ev span { font-size: 13px; color: var(--muted); }
.cover { height: 150px; border-radius: 8px; background: #555 center/cover; position: relative; overflow: hidden; margin-bottom: 14px; }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 30%, rgba(0,0,0,.65)); }
.cover h1 { position: absolute; left: 18px; bottom: 6px; color: #fff; z-index: 1; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: #fff; color: var(--soft); }
.tabs button.on { background: var(--gold); color: #fff; font-weight: 700; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 12px; }
.choice { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; color: var(--ink); font-size: 14px; }
.choice input { display: none; }
.choice:has(input:checked) { border: 2px solid var(--gold); background: #fffaf0; }
.choice small { display: block; color: var(--muted); font-size: 12px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields .wide { grid-column: 1 / -1; }
#inviteWrap, label + label { margin-top: 10px; }
.phone { position: sticky; top: 72px; background: var(--wa); border-radius: 16px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.phone-head { font-weight: 700; margin-bottom: 10px; }
.bubble { background: var(--bubble); border-radius: 10px; padding: 6px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.bubble img { width: 100%; border-radius: 8px; display: block; }
.bubble .text { padding: 8px 6px 4px; }
.bubble .foot { color: var(--muted); font-size: 12px; padding: 0 6px 6px; }
.bubble .btn { border-top: 1px solid #eee; text-align: center; color: #1e88e5; padding: 9px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: #fff; border-radius: 8px; padding: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.stat b { display: block; font-size: 24px; }
.camp { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: #fff; border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tag { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #eee; white-space: nowrap; }
.tag.sent, .tag.delivered, .tag.read, .tag.done { background: #e6f4e5; color: var(--green); }
.tag.failed, .tag.cancelled { background: #fde7e7; color: var(--red); }
.tag.queued, .tag.sending, .tag.preparing { background: #fff0d2; color: var(--amber); }
.tablewrap { overflow-x: auto; background: #fff; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #eee; white-space: nowrap; }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; }
td.bad { color: var(--red); }
dialog { border: 0; border-radius: 12px; padding: 22px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .phone { position: static; }
  .fields { grid-template-columns: 1fr; }
}

/* ---- added: nav, sheet events, language columns, inbox ---- */
.topnav { display: flex; gap: 4px; margin-left: 18px; }
.topnav button { background: none; color: var(--soft); padding: 8px 12px; }
.topnav button.on { background: #f6f1e4; color: var(--gold-dark); font-weight: 700; }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--green); color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
.sec { margin-top: 26px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--soft); }
.langcols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.langcols.one { grid-template-columns: 1fr; }
.langcols .fields { grid-template-columns: 1fr; }
.langcols.one .fields { grid-template-columns: 1fr 1fr; }
.warnbox { background: #fff4dc; margin-top: 12px; }
code { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 13px; word-break: break-all; }
.coverpv img { max-height: 140px; border-radius: 8px; margin-top: 10px; }
.sheetbar { margin-bottom: 12px; }
.btnlink { display: inline-block; text-decoration: none; padding: 10px 16px; border-radius: 8px; font-size: 15px; }
.mini { padding: 4px 10px; font-size: 13px; background: #fff; border: 1px solid var(--line); }
.mini.on { background: var(--gold); color: #fff; border-color: var(--gold); }
.mini.yes { border-color: var(--green); color: var(--green); }
.mini.no { border-color: var(--red); color: var(--red); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fffaf0; }
.pad { padding: 12px; }
.nowrap { flex-wrap: nowrap; }
.pill.sm { padding: 4px 10px; font-size: 13px; }

.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - 100px); background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1); overflow: hidden; }
.ilist { border-right: 1px solid #eee; display: flex; flex-direction: column; min-height: 0; }
.ihead { padding: 10px; display: grid; gap: 8px; border-bottom: 1px solid #eee; }
.ihead select { width: auto; flex: 1; padding: 6px 8px; font-size: 13px; }
#chatList { overflow-y: auto; flex: 1; }
.chat { display: flex; gap: 10px; width: 100%; text-align: left; background: #fff; border-radius: 0; border-bottom: 1px solid #f2f2f2; padding: 10px 12px; }
.chat:hover { background: #fafafa; }
.chat.on { background: #f6f1e4; }
.chat .av { flex: none; width: 40px; height: 40px; border-radius: 50%; background: #f1e6cc; color: var(--gold-dark); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.chat .cmain { flex: 1; min-width: 0; display: grid; gap: 1px; }
.chat .cmain b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat .last { color: var(--soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat.unread .last { color: var(--ink); font-weight: 700; }
.chat small { font-size: 11.5px; color: var(--muted); }
.ithread { display: flex; flex-direction: column; min-height: 0; background: var(--wa); }
.ithread .empty { margin: auto; }
.thead { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid #eee; flex-wrap: wrap; }
.gbar { background: #fffaf0; border-bottom: 1px solid #eee; padding: 6px 14px; display: grid; gap: 4px; font-size: 13px; }
.gitem { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.gitem .pp { width: 74px; padding: 4px 6px; font-size: 13px; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.m { display: flex; }
.m.out { justify-content: flex-end; }
.mb { max-width: min(520px, 80%); background: #fff; border-radius: 10px; padding: 6px 8px; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.m.out .mb { background: #dcf8c6; }
.mb img, .mb video { max-width: 100%; border-radius: 8px; display: block; margin-bottom: 4px; }
.mb audio { max-width: 260px; }
.mt { white-space: pre-wrap; word-break: break-word; }
.mb .btn { border-top: 1px solid rgba(0,0,0,.08); text-align: center; color: #1e88e5; padding: 6px; font-weight: 700; font-size: 13px; }
.mtime { text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; }
.tname { font-size: 11px; color: var(--gold-dark); font-weight: 700; margin-bottom: 4px; }
.qrph { background: #f6f1e4; border-radius: 8px; padding: 18px; text-align: center; color: var(--gold-dark); font-weight: 700; margin-bottom: 4px; }
.blue { color: #34b7f1; }
.bad { color: var(--red); }
.media { background: #f1f1f1; padding: 8px 12px; margin-bottom: 4px; font-size: 13px; }
.reply { display: flex; gap: 8px; padding: 10px; background: #f0f0f0; }
.reply textarea { flex: 1; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: none; }
#replyNote { background: #f0f0f0; margin: 0; padding: 0 12px 8px; }
@media (max-width: 860px) {
  .langcols, .langcols.one .fields { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .ilist { max-height: 45vh; }
  .ithread { min-height: 70vh; }
  .topnav { margin-left: 6px; }
}

.tag.new { background: #fff3b0; color: #7a5b00; }
.ok { color: var(--green); font-weight: 700; }

/* Invita Admin menu + tools */
.topnav a { color: var(--soft); padding: 8px 12px; border-radius: 8px; text-decoration: none; font-size: 15px; }
.topnav a:hover, .topnav button:hover { background: #f6f1e4; }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.tool { display: flex; flex-direction: column; gap: 4px; }
.tool p { margin: 0; }
.tool .btnlink { margin-top: auto; align-self: flex-start; color: #fff; }
@media (max-width: 860px) {
  .bar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 6px; }
  .bar > .row { flex-wrap: wrap; }
  .topnav { margin-left: 0; overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  .topnav a, .topnav button { white-space: nowrap; padding: 6px 9px; font-size: 14px; }
}
