/* WhatsApp dashboard: a neutral look (it serves several businesses), one green for actions. */
:root {
  --bg: #f4f5f4; --panel: #ffffff; --line: #e3e6e4; --text: #1d2321; --muted: #66706c; --soft: #f0f2f1;
  --green: #127a5f; --green-soft: #e3f2ec; --mine: #dcf5e8; --theirs: #ffffff;
  --red: #b3261e; --red-soft: #fbe7e5; --amber: #8a5a00; --amber-soft: #fbf0d9; --blue: #1f6fd1;
  --radius: 10px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111513; --panel: #1a1f1d; --line: #2b3330; --text: #e8ecea; --muted: #9aa5a0; --soft: #222926;
    --green: #3fb68d; --green-soft: #183a2e; --mine: #1d3b30; --theirs: #222926;
    --red: #f2a19a; --red-soft: #3b1f1d; --amber: #e8c27a; --amber-soft: #3a2f17; --blue: #7fb2f0; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.logo { display: inline-block; width: 26px; height: 26px; border-radius: 7px; background: var(--green);
  -webkit-mask: none; position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 6px; border: 2.2px solid #fff; border-radius: 50% 50% 50% 12%; }
.logo.big { width: 48px; height: 48px; border-radius: 12px; }
.logo.big::after { inset: 11px; border-width: 3px; }

/* layout */
.app { display: flex; flex-direction: column; height: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; color: var(--text); text-decoration: none; border-radius: 8px; padding: 2px 6px 2px 2px; }
.brand:hover { background: var(--soft); }
.crumbs { display: flex; align-items: center; gap: 8px; padding: 10px 16px 0; max-width: 1100px; margin: 0 auto; width: 100%; font-size: 14px; flex-wrap: wrap; }
.crumbs a { color: var(--green); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .back { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 4px 10px; margin-right: 6px; color: var(--text); }
.crumbs .back:hover { border-color: var(--muted); text-decoration: none; }
.crumbs .sep { color: var(--muted); }
.crumbs .here { color: var(--muted); }
.tabs { display: flex; gap: 2px; align-items: center; padding: 8px 16px; max-width: 1100px; margin: 0 auto; width: 100%; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs .tabs-biz { font-weight: 650; margin-right: 10px; white-space: nowrap; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a:hover { background: var(--soft); color: var(--text); }
.tabs a.on { background: var(--green-soft); color: var(--green); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.link { border: 0; background: none; color: var(--green); cursor: pointer; padding: 4px; }
.view { flex: 1; min-height: 0; overflow: auto; }
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.page h2 { font-size: 20px; margin: 4px 0 4px; }
.page h3 { font-size: 16px; margin: 24px 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.danger { color: var(--red); }
.btn.wide { width: 100%; padding: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.input, .textarea { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; }
.textarea { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { margin: 0 0 12px; } .field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* cards and badges */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h4 { margin: 0 0 2px; font-size: 16px; }
.card .facts { margin: 10px 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.card .facts li { margin: 2px 0; } .card .facts b { color: var(--text); font-weight: 500; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  background: var(--soft); color: var(--muted); border: 1px solid transparent; vertical-align: middle; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.kind { background: var(--panel); color: var(--muted); border-color: var(--line); font-weight: 500; }
.bad-text { color: var(--red); }
.note { background: var(--soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 0 0 12px; }
.note.bad { background: var(--red-soft); color: var(--red); }
.note.good { background: var(--green-soft); color: var(--text); }

/* pages */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { margin: 0 0 4px; }
.page-head .lead { margin: 0; }
.page.narrow > * { max-width: 860px; }
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

/* numbers as rows: the whole row opens the number */
.rows { display: grid; gap: 8px; }
.num-row { display: grid; grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr) 20px; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; color: var(--text); text-decoration: none; }
.num-row:hover { border-color: var(--green); box-shadow: 0 1px 6px rgba(0,0,0,.05); }
.nr-name { display: flex; flex-direction: column; min-width: 0; }
.nr-name b, .nr-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-badges { display: flex; gap: 6px; }
.nr-today { font-size: 14px; text-align: right; }
.nr-go { color: var(--muted); font-size: 22px; text-align: right; }
.biz-block { margin: 0 0 26px; }
.biz-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.biz-head h3 { margin: 0 0 2px; font-size: 18px; }
.biz-head h3 a { color: var(--text); text-decoration: none; }
.biz-head h3 a:hover { color: var(--green); }

/* one number */
.banner { display: flex; gap: 14px; align-items: flex-start; border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; background: var(--soft); border: 1px solid var(--line); }
.banner .big { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px; background: var(--panel); color: var(--muted); flex: none; }
.banner .btn { margin-top: 10px; }
.banner.ok { background: var(--green-soft); border-color: transparent; }
.banner.ok .big { background: var(--green); color: #fff; }
.banner.warn { background: var(--amber-soft); border-color: transparent; }
.banner.warn .big { background: var(--amber); color: #fff; }
.banner.bad { background: var(--red-soft); border-color: transparent; }
.banner.bad .big { background: var(--red); color: #fff; }
.facts2 { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; font-size: 14.5px; }
.facts2 dt { color: var(--muted); }
.facts2 dd { margin: 0; }
.danger-zone { margin-top: 28px; padding: 14px 16px; border: 1px solid var(--red-soft); border-radius: var(--radius); }
.danger-zone h3 { margin: 0 0 4px; font-size: 15px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 8px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.choice input { margin-top: 4px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 8px; padding: 3px; margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.success { text-align: center; padding: 10px 0; }
.success .big { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; background: var(--green); color: #fff; font-size: 30px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* tables */
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 13px; background: var(--soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* chats */
.chats { display: grid; grid-template-columns: 340px 1fr; height: 100%; min-height: 0; }
.chat-list { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.chat-tools { padding: 10px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.chat-items { overflow-y: auto; flex: 1; }
.chat-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.chat-item:hover { background: var(--soft); } .chat-item.on { background: var(--green-soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--soft); color: var(--muted); display: grid; place-items: center; font-weight: 600; flex: none; }
.chat-main { min-width: 0; flex: 1; }
.chat-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { color: var(--muted); font-size: 12px; flex: none; }
.chat-prev { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; justify-content: space-between; gap: 6px; }
.unread { background: var(--green); color: #fff; border-radius: 10px; font-size: 12px; padding: 0 7px; font-weight: 600; flex: none; }
.convo { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.convo-head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.convo-head .back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 8px; padding: 2px 10px; margin: 8px 0; }
.msg { max-width: min(560px, 80%); padding: 7px 10px 5px; border-radius: 10px; background: var(--theirs); border: 1px solid var(--line); align-self: flex-start; overflow-wrap: anywhere; }
.msg.mine { background: var(--mine); align-self: flex-end; border-color: transparent; }
.msg .who { font-size: 12px; color: var(--green); font-weight: 600; margin-bottom: 2px; display: block; }
.msg .meta { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.msg .tick.read { color: var(--blue); }
.msg .text { white-space: pre-wrap; }
.msg img, .msg video { max-width: 100%; max-height: 320px; border-radius: 6px; display: block; margin-bottom: 4px; }
.msg audio { width: 260px; max-width: 100%; }
.msg .file { display: inline-block; padding: 6px 10px; background: var(--soft); border-radius: 6px; margin-bottom: 4px; color: var(--text); }
.msg .quote { border-left: 3px solid var(--green); background: var(--soft); padding: 3px 8px; border-radius: 4px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.msg.deleted .text { color: var(--muted); text-decoration: line-through; }
.msg .flag { font-size: 11.5px; color: var(--muted); font-style: italic; }
.msg .reacts { font-size: 14px; margin-top: 2px; }
.msg.call { align-self: center; background: var(--panel); font-size: 13px; color: var(--muted); }
.composer { display: flex; gap: 8px; padding: 10px; background: var(--panel); border-top: 1px solid var(--line); align-items: flex-end; position: relative; }
.composer textarea { flex: 1; border: 1px solid var(--line); border-radius: 18px; padding: 9px 14px; resize: none; max-height: 160px; min-height: 40px; background: var(--bg); }
.icon-btn { border: 0; background: var(--soft); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; flex: none; font-size: 18px; }
.icon-btn.send { background: var(--green); color: #fff; }
.qr-pop { position: absolute; bottom: 58px; left: 10px; right: 10px; max-height: 240px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.qr-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.qr-pop button:hover, .qr-pop button.on { background: var(--green-soft); }
.qr-pop small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-err { color: var(--red); font-size: 13px; padding: 0 14px 8px; background: var(--panel); }

/* linking */
.link-box { text-align: center; }
.qr { display: inline-block; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); line-height: 0; }
.qr svg { width: 260px; height: 260px; }
.pair-code { font: 600 34px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 4px; background: var(--soft); border-radius: 10px; padding: 14px; margin: 10px 0; }
.steps { text-align: left; margin: 14px auto 0; max-width: 380px; padding-left: 20px; }
.steps li { margin: 4px 0; }

/* sign-in, modal, toast */
.signin { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.signin .card { max-width: 380px; width: 100%; text-align: center; padding: 28px 24px; }
.signin h1 { font-size: 22px; margin: 12px 0 6px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-box { background: var(--panel); border-radius: 14px; padding: 22px; width: min(460px, 100%); max-height: 92vh; overflow-y: auto; position: relative; }
.modal-box h3 { margin: 0 0 12px; font-size: 18px; }
.modal-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }

@media (max-width: 760px) {
  .top { padding: 8px 12px; gap: 8px; }
  .num-row { grid-template-columns: minmax(0, 1fr) 20px; }
  .nr-badges { grid-column: 1; grid-row: 2; flex-wrap: wrap; }
  .nr-today { grid-column: 1; grid-row: 3; text-align: left; }
  .nr-go { grid-column: 2; grid-row: 1 / span 3; }
  .facts2 { grid-template-columns: 1fr; gap: 2px; }
  .facts2 dd { margin-bottom: 8px; }
  .who #who-name { display: none; }
  .chats { grid-template-columns: 1fr; }
  .chats.open .chat-list { display: none; }
  .chats:not(.open) .convo { display: none; }
  .convo-head .back { display: inline-block; }
  .msg { max-width: 88%; }
  .page { padding: 16px 16px 32px; }
}
