:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --border: #E4E7EC;
  --ink: #101828;
  --ink-soft: #475467;
  --ink-faint: #98A2B3;
  --accent: #4F46E5;
  --accent-soft: #EEF2FF;
  --green: #12B76A;
  --green-soft: #ECFDF3;
  --yellow: #B54708;
  --yellow-soft: #FFFAEB;
  --red: #F04438;
  --red-soft: #FEF3F2;
  --blue: #2E90FA;
  --blue-soft: #EFF8FF;
  --orange: #EF6820;
  --orange-soft: #FEF6EE;
  --gray-soft: #F2F4F7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 13.5px; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #101828 0%, #1D2939 100%);
}
.login-card {
  width: 360px;
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.login-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.login-subtitle { color: var(--ink-faint); font-size: 13px; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.btn-primary {
  width: 100%; padding: 11px; border-radius: 8px; border: none; background: var(--accent);
  color: #fff; font-weight: 600; font-size: 13.5px; transition: background .15s;
}
.btn-primary:hover { background: #4338CA; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.login-error { color: var(--red); font-size: 12.5px; margin-top: 12px; min-height: 16px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #101828; color: #D0D5DD;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto;
}
.sidebar-brand { padding: 20px 20px 16px; font-weight: 700; font-size: 15px; color: #fff; display: flex; align-items: center; gap: 8px; }
.sidebar-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.nav-group { margin-top: 14px; }
.nav-group-label { padding: 0 20px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; color: #667085; text-transform: uppercase; margin-bottom: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 20px; font-size: 13px; color: #D0D5DD;
  cursor: pointer; border-left: 3px solid transparent;
}
.nav-item i { width: 16px; text-align: center; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-item.active { background: rgba(79,70,229,.18); border-left-color: var(--accent); color: #fff; }
.nav-item .nav-count { margin-left: auto; background: rgba(255,255,255,.1); border-radius: 999px; padding: 1px 7px; font-size: 10.5px; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-admin { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.topbar-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--ink-soft); }
.icon-btn:hover { background: var(--gray-soft); }

.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.content-header h1 { font-size: 19px; margin: 0; }
.content-header .sub { color: var(--ink-faint); font-size: 12.5px; margin-top: 3px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 12px; box-shadow: var(--shadow); }
.kpi-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.kpi-body { min-width: 0; }
.kpi-label { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-change { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }
.kpi-change.flat { color: var(--ink-faint); font-weight: 500; }

/* ---------- Cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.panel-header h2 { font-size: 14px; margin: 0; }
.panel-body { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.data-table th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-faint); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr.clickable { cursor: pointer; }
table.data-table tr.clickable:hover { background: var(--gray-soft); }
.cell-user { display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; overflow: hidden; flex-shrink: 0; }
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.cell-user-name { font-weight: 600; }
.cell-user-sub { font-size: 11.5px; color: var(--ink-faint); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 5px; }
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); display: inline-block; margin-right: 5px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-gray { background: var(--gray-soft); color: var(--ink-soft); }

/* ---------- Filters / toolbar ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.toolbar input, .toolbar select {
  padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); font-size: 13px;
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.toolbar input[type="search"] { min-width: 220px; }

/* ---------- Buttons ---------- */
.btn { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--ink); }
.btn:hover { background: var(--gray-soft); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-danger { border-color: transparent; background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #FEE4E2; }
.btn-success { border-color: transparent; background: var(--green-soft); color: var(--green); }
.btn-success:hover { background: #D1FADF; }
.btn-accent { border-color: transparent; background: var(--accent); color: #fff; }
.btn-accent:hover { background: #4338CA; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 8px; padding: 12px 18px; font-size: 12.5px; color: var(--ink-soft); }
.pagination .spacer { flex: 1; }

/* ---------- Pills / tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Empty / loading / error ---------- */
.state-box { text-align: center; padding: 48px 20px; color: var(--ink-faint); }
.state-box i { font-size: 26px; margin-bottom: 10px; display: block; }
.state-box.error { color: var(--red); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Detail drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 92vw; background: var(--bg); z-index: 41; overflow-y: auto; box-shadow: -8px 0 30px rgba(0,0,0,.15); }
.drawer-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; }
.drawer-body { padding: 20px; }
.detail-section { margin-bottom: 18px; }
.detail-section h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); margin: 0 0 8px; }
.detail-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--ink-soft); }
.detail-row .v { font-weight: 600; }

/* ---------- Toasts ---------- */
#toastHost { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: all .2s; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }

/* ---------- Chart canvas wrapper ---------- */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.small { height: 200px; }

/* ---------- Misc ---------- */
.muted { color: var(--ink-faint); }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0 !important; }
.data-quality-note { background: var(--yellow-soft); color: var(--yellow); border-radius: 8px; padding: 9px 13px; font-size: 12px; margin-bottom: 14px; }

/* ---------- Message reports with the reported message ---------- */
.mr-list { padding: 4px 16px 16px; }
.mr-item { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 16px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.mr-item:last-child { border-bottom: none; }
.mr-msg { background: var(--gray-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.mr-msg.removed { opacity: .6; }
.mr-msg.missing { color: var(--ink-faint); }
.mr-msg-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; margin-bottom: 6px; }
.mr-msg-head a { font-weight: 600; cursor: pointer; color: var(--accent); }
.mr-media { max-width: 220px; max-height: 160px; border-radius: 8px; display: block; margin: 4px 0; }
.mr-msg audio { width: 100%; max-width: 280px; margin: 4px 0; }
.mr-text { white-space: pre-wrap; word-break: break-word; }
.mr-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 150px; }
@media (max-width: 900px) { .mr-item { grid-template-columns: 1fr; } .mr-actions { flex-direction: row; flex-wrap: wrap; } }

/* account actions in the user drawer */
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.acct-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.btn:disabled { opacity: .5; cursor: default; }
/* verification review */
.vr-card { padding: 18px; border-bottom: 1px solid var(--border); }
.vr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.vr-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .vr-grid { grid-template-columns: 1fr; } }
.vr-label { font-size: 11.5px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.vr-last4 { color: var(--ink); font-size: 13px; letter-spacing: .1em; }
.vr-video, .vr-card-img { width: 100%; max-height: 300px; border-radius: 10px; background: #000; object-fit: contain; display: block; }
.vr-card-img { background: var(--gray-soft); }
.vr-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vr-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.vr-missing { padding: 26px 10px; border-radius: 10px; background: var(--gray-soft); color: var(--ink-soft); font-size: 12.5px; text-align: center; }
.vr-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 16px; margin: 14px 0; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 12.5px; }
.vr-checks label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.vr-actions { display: flex; flex-direction: column; gap: 8px; }
.vr-actions > .btn-success { align-self: flex-start; padding: 9px 16px; }
.vr-reject { display: flex; gap: 8px; }
.vr-reject input { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); font: inherit; font-size: 12.5px; }
.vr-presets { display: flex; flex-wrap: wrap; gap: 6px; }
/* feature switches as cards, grouped by area */
.feat-area { margin-bottom: 22px; }
.feat-area h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.feat-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); transition: opacity .15s, border-color .15s; }
.feat-card.off { background: var(--gray-soft); border-style: dashed; }
.feat-card.off .feat-ic { background: var(--gray-soft); color: var(--ink-faint); }
.feat-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.feat-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.feat-card b { font-size: 14px; }
.feat-desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; flex: 1; }
.feat-state { margin-top: 4px; }
.feat-switch { position: relative; width: 42px; height: 24px; border-radius: 99px; border: none; background: #D0D5DD; cursor: pointer; padding: 0; transition: background .2s; }
.feat-switch i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .2s; }
.feat-switch.on { background: var(--green); }
.feat-switch.on i { left: 21px; }
.feat-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* admin two-step sign-in (core.js adminMfaPrompt) */
.mfa-overlay{position:fixed; inset:0; z-index:10000; background:rgba(15,10,30,.55); display:flex; align-items:center; justify-content:center; padding:16px;}
.mfa-card{background:#fff; color:#1f1633; width:min(400px,100%); border-radius:16px; padding:24px; box-shadow:0 20px 60px rgba(0,0,0,.3); display:flex; flex-direction:column; gap:10px; max-height:92vh; overflow:auto;}
.mfa-card h2{margin:0; font-size:20px;} .mfa-card p, .mfa-card ol{margin:0; font-size:14px; line-height:1.45; color:#4b4363;} .mfa-card ol{padding-left:20px;}
.mfa-icon{width:48px; height:48px; border-radius:14px; display:flex; align-items:center; justify-content:center; background:#F3E8FF; color:#7C3AED; font-size:22px;}
.mfa-qr{align-self:center; padding:8px; background:#fff; border:1px solid #eee; border-radius:12px;} .mfa-qr img, .mfa-qr canvas{display:block;}
.mfa-small{font-size:12.5px !important;} .mfa-small code{font-size:14px; letter-spacing:.06em; background:#F5F3FF; padding:3px 6px; border-radius:6px; word-break:break-all;}
#mfaCode{font-size:24px; letter-spacing:.3em; text-align:center; padding:10px; border:2px solid #DDD6FE; border-radius:12px;}
.mfa-err{color:#DC2626; font-size:13px; min-height:16px;}
.mfa-card .btn{width:100%; padding:11px 14px; border-radius:10px; font-size:14px; font-weight:600; cursor:pointer; border:1px solid #DDD6FE; background:#fff; color:#4C1D95;}
.mfa-card .btn-primary{background:#4F46E5; border-color:#4F46E5; color:#fff;} .mfa-card .btn-primary:hover{background:#4338CA;} .mfa-card .btn-primary:disabled{opacity:.6;}


/* The verified tick — the same seal as the app (webapp styles.css .vbadge). */
:root { --verified-a:#FF3D8B; --verified-b:#7C3AED; }
.vbadge { display:inline-block; position:relative; width:1.05em; height:1.05em; margin-left:.22em; vertical-align:-.16em;
  background:linear-gradient(135deg, var(--verified-a), var(--verified-b));
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8.4'/%3E%3Ccircle cx='20' cy='12' r='3.4'/%3E%3Ccircle cx='17.66' cy='17.66' r='3.4'/%3E%3Ccircle cx='12' cy='20' r='3.4'/%3E%3Ccircle cx='6.34' cy='17.66' r='3.4'/%3E%3Ccircle cx='4' cy='12' r='3.4'/%3E%3Ccircle cx='6.34' cy='6.34' r='3.4'/%3E%3Ccircle cx='12' cy='4' r='3.4'/%3E%3Ccircle cx='17.66' cy='6.34' r='3.4'/%3E%3C/svg%3E") center/contain no-repeat; mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8.4'/%3E%3Ccircle cx='20' cy='12' r='3.4'/%3E%3Ccircle cx='17.66' cy='17.66' r='3.4'/%3E%3Ccircle cx='12' cy='20' r='3.4'/%3E%3Ccircle cx='6.34' cy='17.66' r='3.4'/%3E%3Ccircle cx='4' cy='12' r='3.4'/%3E%3Ccircle cx='6.34' cy='6.34' r='3.4'/%3E%3Ccircle cx='12' cy='4' r='3.4'/%3E%3Ccircle cx='17.66' cy='6.34' r='3.4'/%3E%3C/svg%3E") center/contain no-repeat; }
.vbadge::after { content:''; position:absolute; inset:0; background:#fff;
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.6 12.4l2.9 2.9 5.9-6.1' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.6 12.4l2.9 2.9 5.9-6.1' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }
