:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --primary: #128c5e; --primary-text: #fff; --ok: #128c5e; --ok-bg: #e3f5ec; --warn: #a65f00; --warn-bg: #fff1dc;
  --bad: #c0362c; --bad-bg: #fde7e5; --code-bg: #eef0f4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b2029; --text: #e6e9ef; --muted: #8b93a5; --line: #2a303b;
    --primary: #25b37a; --primary-text: #08140e; --ok: #46c98f; --ok-bg: #143326; --warn: #f0a445; --warn-bg: #3a2a12;
    --bad: #ff7468; --bad-bg: #3d1a17; --code-bg: #262c37;
  }
}
* { box-sizing: border-box; }
[v-cloak] { display: none; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1 { margin: 0 0 4px; font-size: 22px; }
h2 { font-size: 18px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.error { color: var(--bad); }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-size: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab { background: none; border: 0; padding: 7px 12px; border-radius: 6px; color: var(--muted); cursor: pointer; font: inherit; }
.tab.active { background: var(--bg); color: var(--text); font-weight: 600; }
.badge { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; margin-left: 6px; font-size: 11px; }
main { max-width: 1280px; margin: 0 auto; padding: 8px 20px 60px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.cards .card { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--muted); font-size: 12px; }
.stat span { display: block; font-size: 24px; font-weight: 700; color: var(--text); }
.stat.ok span { color: var(--ok); } .stat.warn span { color: var(--warn); } .stat.bad span { color: var(--bad); }

.row { display: flex; gap: 10px; align-items: end; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
label.check { flex-direction: row; align-items: center; color: var(--text); font-size: 14px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); min-width: 0; }
textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 12.5px; }

.btn { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 4px; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--code-bg); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.tiny { font-size: 11px; padding: 0 6px; margin: 2px 3px 0 0; }
.pair { margin-top: 4px; } .pair code { font-size: 15px; letter-spacing: 2px; font-weight: 700; }

.meter { height: 6px; background: var(--code-bg); border-radius: 3px; margin: 10px 0 4px; overflow: hidden; }
.meter div { height: 100%; background: var(--primary); }
.event { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.event:last-child { border-bottom: 0; }
.event .time { color: var(--muted); font-size: 12px; margin-right: 6px; }
.event.critical { color: var(--bad); }
.events-small { max-height: 240px; overflow-y: auto; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-card { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; margin: 0; }
.modal-card label input, .modal-card label select { width: 100%; }
.toast { position: fixed; right: 20px; bottom: 20px; padding: 12px 16px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); border: 1px solid var(--line); z-index: 20; max-width: 420px; cursor: pointer; }
.toast.bad { background: var(--bad-bg); color: var(--bad); } .toast.warn { background: var(--warn-bg); color: var(--warn); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 6px; }

@media (max-width: 640px) {
  main { padding: 8px 12px 40px; }
  .topbar { padding: 8px 12px; }
  .row { flex-wrap: wrap; }
}

.creds { border-color: var(--warn); background: var(--warn-bg); }
.kv td { border: 0; padding: 4px 10px 4px 0; }
.kv code { user-select: all; word-break: break-all; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; }
.checks .check { margin: 0; font-size: 13px; }
tr.revoked td { opacity: .55; }

.code-big { font-size: 20px; font-weight: 700; letter-spacing: 2px; padding: 2px 8px; }
textarea { font: inherit; width: 100%; }
.details { max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--code-bg); padding: 10px; border-radius: 6px; }

.row.tight { margin-top: 0; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn.passkey { margin-top: 8px; width: 100%; }
label.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.passkey-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.customer-row { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.modal-card.wide { max-width: 720px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 12px; }
.warn-note { background: var(--warn-bg); color: var(--warn); padding: 8px 10px; border-radius: 6px; }
.audit { margin-top: 12px; }
.search { min-width: 220px; }
.inbox { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 14px; align-items: start; }
.chat-list { padding: 6px; max-height: 72vh; overflow-y: auto; margin: 0; }
.chat-row { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px 10px; color: var(--text); cursor: pointer; font: inherit; }
.chat-row:hover { background: var(--bg); }
.chat-row.active { background: var(--code-bg); }
.chat-row .clip { max-width: 100%; }
.chat-pane { margin: 0; display: flex; flex-direction: column; min-height: 420px; gap: 8px; }
.thread { flex: 1; max-height: 52vh; min-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 6px 2px; }
.bubble { max-width: 78%; align-self: flex-start; background: var(--code-bg); padding: 6px 10px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--ok-bg); }
.tiny-text { font-size: 11px; margin-top: 2px; }
.summary { background: var(--code-bg); padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; }
.draft { border-top: 1px solid var(--line); padding-top: 8px; }
.row.reply { margin-top: 0; }
.row.reply textarea { font-family: inherit; font-size: 14px; }
.back-btn { display: none; margin-right: 4px; }
/* Phones: one pane at a time; the chat list hides while a chat is open. */
@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; }
  .chat-list { max-height: none; }
  .inbox.has-chat .chat-list { display: none; }
  .inbox:not(.has-chat) .chat-pane { display: none; }
  .back-btn { display: inline-flex; }
  .chat-pane { min-height: 0; padding: 10px; }
  .thread { max-height: 58vh; min-height: 200px; }
  .bubble { max-width: 90%; }
  .media { max-width: 100%; }
  .chat-pane .row-between { flex-wrap: wrap; gap: 6px; }
  .search { min-width: 0; width: 100%; }
  .label-input { width: 100%; }
  .row.reply { flex-wrap: nowrap; }
  .row.reply textarea { font-size: 16px; } /* stops iOS zooming into the box */
}

.media { display: block; max-width: 280px; max-height: 280px; border-radius: 6px; }
.bubble audio { display: block; max-width: 260px; }
.contact-card { border-top: 1px solid var(--line); padding-top: 8px; }
.label-input { width: 130px; padding: 3px 7px; font-size: 12px; }
.row.notes { margin-top: 6px; align-items: center; }
.row.notes textarea { font-family: inherit; font-size: 13px; }
.edit { border-top: 1px solid var(--line); padding: 8px 0; }
.checks.days { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.file-btn { cursor: pointer; margin: 0; flex-direction: row; color: var(--text); font-size: 12px; }
.consent { margin-top: 6px; }
.ab .card { margin: 0 0 8px; }

.timeline { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; max-height: 260px; overflow-y: auto; }
.timeline-row { padding: 3px 0; border-bottom: 1px solid var(--line); }
.meter.warn div { background: var(--warn); }
.meter.bad div { background: var(--bad); }

/* Opaque, so nothing behind it can be read. */
.lock-screen { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }

.banner-bad { border-left: 4px solid var(--bad); }
.banner-warn { border-left: 4px solid var(--warn, var(--bad)); }
.check-item { padding: 8px 0; border-top: 1px solid var(--line); }
.check-item:first-of-type { margin-top: 8px; }
.warn-text { color: var(--warn); }
.proxy-fit { margin: 8px 0; background: var(--bg); }
.proxy-fit p { margin: 4px 0; }

/* Row actions: one main button and a menu for the rest. */
.key-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
td.actions .key-actions .btn { margin-left: 0; }
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 200px; display: grid;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 4px; text-align: left; }
details.menu .menu-list button { font: inherit; font-size: 13px; text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px 10px; color: var(--text); cursor: pointer; white-space: nowrap; }
details.menu .menu-list button:hover, details.menu .menu-list button:focus-visible { background: var(--bg, rgba(0,0,0,.05)); }
details.menu .menu-list .danger-text { color: var(--bad, #c0392b); }
/* A table's scroll box would clip an open menu; let it out while one is open. */
.table-wrap:has(details.menu[open]) { overflow: visible; }
/* Pairing an SMS phone: two equal steps side by side, stacked on narrow screens. */
.pair-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 12px 0; }
.pair-step { border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; min-width: 0; }
.pair-step h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.pair-step p { margin: 0; max-width: 260px; }
.step-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: var(--primary-text); font-size: 13px; }
.pair-step .qr { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; box-sizing: content-box; }
.pair-code { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pair-code code { font-size: 20px; font-weight: 600; letter-spacing: 1px; padding: 6px 10px; white-space: nowrap; }
.pair-foot { text-align: center; margin: 0 0 8px; word-break: break-word; }
@media (max-width: 600px) { .pair-steps { grid-template-columns: 1fr; } }
