/* Tap Admin: the look of the onboarding website ("tap"), dark by default, light on request. */

@font-face { font-family: "Plus Jakarta Sans"; font-weight: 400; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 500; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 600; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 700; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 600; font-display: swap; src: url(fonts/outfit-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 700; font-display: swap; src: url(fonts/outfit-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 800; font-display: swap; src: url(fonts/outfit-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 600; font-display: swap; src: url(fonts/jetbrains-mono-latin-600-normal.woff2) format("woff2"); }

:root {
  color-scheme: dark;
  --red: #EF233C;
  --red-hover: #D90429;
  --red-soft: rgba(239, 35, 60, .12);
  --red-line: rgba(239, 35, 60, .35);
  --bg: #0A0C10;
  --side: #0E111A;
  --panel: #11141D;
  --panel-2: #161B26;
  --field: #0A0C10;
  --line: #1F2636;
  --line-strong: #2C3548;
  --ink: #F3F4F6;
  --ink-2: #D1D5DB;
  --muted: #8B93A7;
  --ok: #34D399; --ok-bg: rgba(16, 185, 129, .12); --ok-line: rgba(16, 185, 129, .3);
  --warn: #FBBF24; --warn-bg: rgba(245, 158, 11, .12); --warn-line: rgba(245, 158, 11, .3);
  --bad: #F87171; --bad-bg: rgba(239, 68, 68, .12); --bad-line: rgba(239, 68, 68, .3);
  --info: #22D3EE; --info-bg: rgba(6, 182, 212, .12); --info-line: rgba(6, 182, 212, .3);
  --neutral-bg: rgba(148, 163, 184, .12); --neutral-line: rgba(148, 163, 184, .25);
  /* chat (WhatsApp-like) */
  --chat-bg: #0B141A;
  --bubble-in: #1F2C34;
  --bubble-out: #005C4B;
  --bubble-ink: #E9EDEF;
  --bubble-meta: rgba(233, 237, 239, .6);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px;
  --radius-sm: 12px;
  --sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  --display: "Outfit", var(--sans);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
html.light {
  color-scheme: light;
  --bg: #F8F9FA;
  --side: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #F3F4F6;
  --field: #F9FAFB;
  --line: #E5E7EB;
  --line-strong: #CBD5E1;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --ok: #047857; --ok-bg: #ECFDF5; --ok-line: #A7F3D0;
  --warn: #B45309; --warn-bg: #FFFBEB; --warn-line: #FDE68A;
  --bad: #B91C1C; --bad-bg: #FEF2F2; --bad-line: #FECACA;
  --info: #0E7490; --info-bg: #ECFEFF; --info-line: #A5F3FC;
  --neutral-bg: #F1F5F9; --neutral-line: #E2E8F0;
  --chat-bg: #EFEAE2;
  --bubble-in: #FFFFFF;
  --bubble-out: #D9FDD3;
  --bubble-ink: #111B21;
  --bubble-meta: rgba(17, 27, 33, .55);
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; }
::selection { background: var(--red-soft); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .28); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, .5); }
.boot { padding: 48px; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.icon { width: 16px; height: 16px; flex: none; }

/* ------------------------------------------------------------------ frame */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; padding: 2px 8px 18px; }
.brand .logo { height: 24px; width: auto; }
.brand .tap { font: 800 11px/1 var(--display); letter-spacing: .04em; color: var(--red); background: var(--red-soft); border: 1px solid var(--red-line); padding: 4px 6px; border-radius: 6px; }
.brand .brand-sub { font: 600 15px/1 var(--display); color: var(--ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--muted); padding: 8px 10px; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-weight: 500; border: 1px solid transparent; }
.nav a:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--red-soft); color: var(--red); border-color: var(--red-line); font-weight: 600; }
.nav a .badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font: 700 11px/20px var(--mono); text-align: center; }
.sidebar .spacer { flex: 1; min-height: 12px; }
.row .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; border-top: 1px solid var(--line); }
.who .avatar { width: 32px; height: 32px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--red-line); color: var(--ink); display: grid; place-items: center; font: 700 11px var(--display); flex: none; }
.who .who-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.who strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono-label { font: 500 10px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.who .mono-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); cursor: pointer; flex: none; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

.main { padding: 0 28px 48px; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 0 14px; margin-bottom: 8px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; }

/* ------------------------------------------------------------------ building blocks */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 16px 0; }
.panel h2 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.panel h3 { margin: 16px 0 8px; font: 600 10px/1.4 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.right { text-align: right; }

.card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--panel-2); cursor: pointer; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--red-line); transform: translateY(-1px); }
.card .title { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.card ul { margin: 6px 0 0; padding-left: 16px; color: var(--bad); font-size: 12px; }
.card .big { margin-top: 8px; font: 700 26px/1.1 var(--mono); }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 600 10px/1.4 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font: 600 10px/1.6 var(--mono); text-transform: uppercase; letter-spacing: .04em; background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); white-space: nowrap; }
.pill.healthy, .pill.connected, .pill.subscribed, .pill.completed, .pill.caught_up, .pill.internally_reconciled, .pill.resolved, .pill.stored, .pill.AVAILABLE, .pill.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.pill.degraded, .pill.partial, .pill.backlogged, .pill.unverified, .pill.warning, .pill.receiving, .pill.processing, .pill.pending, .pill.repairing, .pill.LIMITED, .pill.held, .pill.unknown { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.pill.unhealthy, .pill.unreachable, .pill.down, .pill.disconnected, .pill.unsubscribed, .pill.failed, .pill.unavailable, .pill.issues_found, .pill.critical, .pill.open, .pill.BLOCKED { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.pill.info, .pill.acknowledged, .pill.not_requested, .pill.external_verification_unknown { background: var(--neutral-bg); color: var(--muted); border-color: var(--neutral-line); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--ink); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 13px; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 6px 18px rgba(239, 35, 60, .2); }
.btn.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); background: var(--bad-bg); }
.btn.danger:hover { border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; padding: 11px 14px; font-family: var(--display); font-size: 14px; }

form.stack { display: grid; gap: 12px; max-width: 560px; }
label { display: grid; gap: 5px; font: 500 11px/1.4 var(--mono); color: var(--muted); }
label.inline { display: flex; align-items: center; gap: 8px; font: 500 13px var(--sans); color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=search], input[type=number], select, textarea {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px; background: var(--field); color: var(--ink); width: 100%; font: 400 14px var(--sans); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.row > input, .row > select { width: auto; min-width: 200px; flex: 1 1 200px; }
input[type=checkbox] { accent-color: var(--red); width: 16px; height: 16px; }
textarea { min-height: 120px; font-family: var(--mono); font-size: 12px; }

.notice { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); margin: 12px 0; font-size: 13px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.notice.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.notice a { color: inherit; text-decoration: underline; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 420px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: var(--shadow); z-index: 40; font: 500 12px/1.5 var(--mono); }
.toast.bad { border-color: var(--bad-line); color: var(--bad); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); font: 500 11px/1.9 var(--mono); }
.kv dd { margin: 0; }
.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: var(--red); }
.p0 { width: 0; } .p10 { width: 10%; } .p20 { width: 20%; } .p30 { width: 30%; } .p40 { width: 40%; } .p50 { width: 50%; } .p60 { width: 60%; } .p70 { width: 70%; } .p80 { width: 80%; } .p90 { width: 90%; } .p100 { width: 100%; }
pre.json { background: var(--field); color: var(--ink-2); border: 1px solid var(--line); padding: 12px; border-radius: var(--radius-sm); overflow: auto; max-height: 360px; font: 12px/1.5 var(--mono); }
details summary { cursor: pointer; margin-top: 12px; color: var(--muted); }
.hints { margin: 10px 0 0; padding-left: 18px; }
.qr { background: #fff; padding: 12px; display: inline-block; border: 1px solid var(--line); border-radius: var(--radius); }
.qr img { display: block; width: 280px; height: 280px; image-rendering: pixelated; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--line-strong); vertical-align: middle; }

/* ------------------------------------------------------------------ sign-in */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(60% 50% at 50% 0%, rgba(239, 35, 60, .10), transparent 70%), var(--bg); }
.login { width: min(440px, 100%); background: var(--panel); border: 2px solid var(--line-strong); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.login-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.login-head .brand { padding: 0; }
.login-body { padding: 24px 26px 26px; }
.login-body h1 { margin: 0 0 4px; font-size: 20px; text-align: center; }
.login-body > p { text-align: center; margin: 0 0 18px; font-size: 13px; }
.login form.stack { max-width: none; }
.login-foot { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--field); }

/* ------------------------------------------------------------------ modal */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 30; overflow: auto; }
.modal { width: min(560px, 100%); border-radius: 22px; border-width: 2px; box-shadow: var(--shadow); }
.modal ul { padding-left: 18px; }

/* ------------------------------------------------------------------ conversations */
.conv-filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 12px; }
.conv-filters > * { flex: 1 1 200px; width: auto; }
.conv-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 0; height: calc(100vh - 150px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.conv-list { overflow-y: auto; border-right: 1px solid var(--line); }
.conv-list .item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; border-left: 3px solid transparent; }
.conv-list .item:hover { background: var(--panel-2); }
.conv-list .item.active { background: var(--panel-2); border-left-color: var(--red); }
.conv-list .item .name { font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-list .item .name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-list .item .when { font: 500 10px var(--mono); color: var(--muted); white-space: nowrap; }
.conv-list .item.fresh .when { color: var(--ok); }
.conv-list .item .preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.conv-list .item .preview .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; margin-left: auto; }
.conv-list .item .sub { font: 500 10px/1.6 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.conv-list .empty, .conv-list .more { padding: 16px; text-align: center; }
.conv-list .flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--ok-bg); } to { background: transparent; } }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); position: relative; }
.chat-empty { margin: auto; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.chat-head { padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.chat-head .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line-strong); display: grid; place-items: center; font: 700 13px var(--display); flex: none; }
.chat-head .who-text { min-width: 0; flex: 1; }
.chat-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.chat-head .live { display: inline-flex; align-items: center; gap: 6px; font: 600 10px var(--mono); text-transform: uppercase; color: var(--ok); }
.chat-head .live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.chat .banner { margin: 0; border-radius: 0; border-left: 0; border-right: 0; border-top: 0; font-size: 12px; }
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 6% 18px; display: flex; flex-direction: column; gap: 4px; }
.thread .loader { align-self: center; font: 500 11px var(--mono); color: var(--muted); padding: 6px 12px; }
.bubble { max-width: 70%; padding: 7px 10px 5px; border-radius: 10px; background: var(--bubble-in); color: var(--bubble-ink); box-shadow: 0 1px 1px rgba(0, 0, 0, .12); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); }
.bubble.unknown { align-self: center; background: var(--warn-bg); color: var(--ink); }
.bubble .meta { font-size: 11px; color: var(--bubble-meta); text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.bubble .quote { border-left: 3px solid var(--red); background: rgba(0, 0, 0, .12); padding: 3px 8px; margin-bottom: 4px; font-size: 12px; color: var(--bubble-meta); border-radius: 6px; }
.bubble.deleted { opacity: .7; font-style: italic; }
.bubble .att { display: block; font-size: 12px; margin-top: 4px; color: inherit; text-decoration: underline; }
.bubble.reaction { background: transparent; box-shadow: none; font-size: 12px; color: var(--muted); padding: 0 6px; }
.bubble.arrived { animation: arrive .35s ease-out; }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.day { align-self: center; font: 500 11px var(--mono); background: var(--panel); color: var(--muted); padding: 3px 12px; border-radius: 8px; margin: 8px 0; border: 1px solid var(--line); }
.unread-line { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--ok); font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: var(--ok); opacity: .6; }
.jump { position: absolute; right: 22px; bottom: 18px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--ok-line); background: var(--panel); color: var(--ok); font: 600 12px var(--mono); cursor: pointer; box-shadow: var(--shadow); }
.jump[hidden] { display: none; }
.att-block { display: flex; flex-direction: column; gap: 4px; margin: 2px 0 4px; white-space: normal; }
.bubble .media { display: block; max-width: min(320px, 100%); max-height: 360px; border-radius: 8px; background: #000; }
.bubble img.media { background: transparent; object-fit: contain; }
.bubble audio { max-width: 280px; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  .nav { flex-direction: row; overflow-x: auto; flex-wrap: nowrap; width: 100%; order: 3; }
  .nav a { white-space: nowrap; }
  .sidebar .spacer { display: none; }
  .who { border-top: 0; padding: 0; margin-left: auto; }
  .who .who-text { display: none; }
  .main { padding: 0 16px 40px; }
  .conv-layout { grid-template-columns: 1fr; height: auto; }
  .conv-list { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat { height: 75vh; }
  .bubble { max-width: 88%; }
}
