:root {
  --sidebar-width: 200px;
  --header-height: 3.25rem;
  --header-offset: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  --hdr-icon-bg: #f1f5f9;
  --hdr-icon-border: transparent;
  --hdr-fg-muted: #475569;
}

.bg-brand { background-color: var(--brand-primary, #3C50E0); }
.text-brand { color: var(--brand-primary); }
.shadow-brand\/30 { --tw-shadow-color: color-mix(in srgb, var(--brand-primary) 30%, transparent); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: 0.5rem;
  padding: 0.38rem 0.6rem;
  color: #94a3b8;
  font-weight: 600;
  line-height: 1.22;
  transition: 0.15s ease;
}
.nav-link > i {
  width: 1.1rem;
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: color 0.15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--brand-primary, #3C50E0); color: #fff; }
.nav-link.active > i { color: #fff !important; }

/* Warna ikon per menu */
.nav-link[data-nav="dashboard"] > i { color: #60a5fa; }
.nav-link[data-nav="devices"] > i { color: #34d399; }
.nav-link[data-nav="contacts"] > i { color: #fbbf24; }
.nav-link[data-nav="groups"] > i { color: #a78bfa; }
.nav-link[data-nav="messages"] > i { color: #2dd4bf; }
.nav-link[data-nav="blast"] > i { color: #f97316; }
.nav-link[data-nav="leads"] > i { color: #22c55e; }
.nav-link[data-nav="subscription"] > i { color: #eab308; }
.nav-link[data-nav="usage"] > i { color: #38bdf8; }
.nav-link[data-nav="docs"] > i { color: #67e8f9; }
.nav-link[data-nav="api_tokens"] > i { color: #fb923c; }
.nav-link[data-nav="users"] > i { color: #38bdf8; }
.nav-link[data-nav="tenants"] > i { color: #c084fc; }
.nav-link[data-nav="settings"] > i { color: #94a3b8; }
.nav-link[data-nav="branding"] > i { color: #f472b6; }
.nav-link[data-nav="fail2ban"] > i { color: #fb7185; }

body.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
}

.app-sidebar {
  position: fixed;
  top: var(--header-offset);
  right: auto;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  background: #1C2434;
  color: #cbd5e1;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  height: auto;
  max-height: none;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-overflow-scrolling: touch;
}
html.sidebar-open .app-sidebar {
  transform: translateX(0);
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.18);
}
@media (min-width: 1024px) {
  html:not(.sidebar-closed) .app-sidebar {
    transform: translateX(0);
    box-shadow: none;
  }
}
.app-shell {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  flex-direction: column;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-left: 0;
  transition: padding-left 0.22s ease;
}
@media (min-width: 1024px) {
  html:not(.sidebar-closed) .app-shell {
    padding-left: var(--sidebar-width);
  }
}
.app-sidebar-backdrop {
  display: none;
  position: fixed;
  top: var(--header-offset);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.48);
  touch-action: manipulation;
}
.app-sidebar-backdrop[hidden] {
  display: none !important;
}
@media (max-width: 1023px) {
  html.sidebar-open .app-sidebar-backdrop:not([hidden]) {
    display: block;
  }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.sidebar-nav {
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  padding-top: 0.55rem;
  padding-bottom: 0.25rem;
  min-height: 0;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.nav-section {
  margin: 0.55rem 0 0.18rem;
  padding: 0 0.6rem;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}
.nav-section:first-child {
  margin-top: 0.1rem;
}

/* Anti-flash: if HTML somehow includes elevated links before role is known, keep them hidden */
body:not(.nav-ready) #sidebar-nav a[href="/tenants"],
body:not(.nav-ready) #sidebar-nav a[href="/settings"],
body:not(.nav-ready) #sidebar-nav a[href="/landing"],
body:not(.nav-ready) #sidebar-nav a[href="/branding"],
body:not(.nav-ready) #sidebar-nav a[href="/fail2ban"],
body:not(.nav-ready) #sidebar-nav a[href="/users"],
body:not(.nav-ready) #sidebar-nav .nav-section[data-section] {
  display: none !important;
}
body:not(.is-paid) #sidebar-nav a[data-paid="1"] {
  display: none !important;
}

.card {
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.input {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #0f172a;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.input:hover:not(:disabled):not(:focus) {
  border-color: #94a3b8;
  background: #eef2f7;
}
.input:focus {
  border-color: var(--brand-primary, #3C50E0);
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}
.input:disabled,
.input[readonly] {
  background: #e2e8f0;
  color: #64748b;
  cursor: not-allowed;
}
select.input {
  cursor: pointer;
}
textarea.input {
  resize: vertical;
  min-height: 4.5rem;
}

.label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #1e293b;
  line-height: 1.25rem;
  min-height: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dlg-body .grid {
  align-items: end;
}

/* Auto-reply: keep Prioritas / Cooldown / Status inputs on one baseline */
.dlg-body .grid.ar-meta-row {
  align-items: start;
}
.ar-active-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0 0.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
}

.rl-box {
  margin: 0.15rem 0 0;
  padding: 0.75rem 0.85rem 0.95rem;
  border: 1px dashed #cbd5e1;
  border-radius: 0.85rem;
  background: #f8fafc;
}
.rl-box legend {
  padding: 0 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
}
.rl-hint {
  margin: 0 0 0.7rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #64748b;
}
.cell-limits {
  font-size: 0.75rem;
  color: #475569;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cell-limits strong {
  color: #0f172a;
  font-weight: 650;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  background: var(--brand-primary);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: 0.15s ease;
  border: none;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn-ghost:hover:not(:disabled) { background: #f8fafc; }
.btn-ghost:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; table-layout: auto; }
.table th {
  text-align: left;
  padding: 0.7rem 0.65rem;
  color: #64748b;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.table td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr.table-row-link { cursor: pointer; }
.table tbody tr.table-row-link:hover .table-row-title { color: var(--brand-primary, #3C50E0); }
.table-row-anchor {
  display: block;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.table-row-title {
  display: block;
  font-weight: 650;
  color: #0f172a;
}
.table-row-preview {
  display: block;
  margin-top: 0.15rem;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 400;
  color: #64748b;
}

.table .col-actions,
.table th.col-actions {
  text-align: right;
  width: 1%;
  white-space: nowrap;
  padding-right: 0.75rem;
}
.table td.col-actions .crud-actions {
  justify-content: flex-end;
  width: 100%;
}
.table .col-status { width: 7.5rem; white-space: nowrap; }
.table .col-limits { width: 1%; white-space: nowrap; }
.table .col-narrow { width: 1%; white-space: nowrap; }
.table .col-phone {
  width: 11rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge-wa {
  background: #dcfce7;
  color: #14532d;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.badge-wa i {
  color: #16a34a;
  font-size: 0.85em;
}
.badge-device {
  background: #eef2ff;
  color: #3730a3;
  font-weight: 700;
  max-width: 18rem;
}
.badge-device i {
  color: #4f46e5;
  font-size: 0.8em;
}
#page-header:empty {
  display: none;
}
.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.rl-device-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.table .col-time { width: 9.5rem; white-space: nowrap; color: #94a3b8; font-size: 0.8rem; }
.table .col-num,
.table th.col-num { width: 4.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-primary {
  font-weight: 600;
  color: #1e293b;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table .cell-muted {
  color: #94a3b8;
  font-size: 0.8rem;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crud-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  align-items: center;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #ffe4e6; color: #9f1239; }
.badge-muted { background: #f1f5f9; color: #475569; }

/* Badge / tombol CRUD seragam */
.badge-crud,
.btn-crud {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.22rem 0.58rem;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn-crud:hover { filter: brightness(0.97); transform: translateY(-1px); }
.btn-crud:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.badge-crud-create, .btn-crud.badge-crud-create {
  background: var(--brand-primary, #3C50E0);
  color: #fff;
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 72%, #0f172a);
}
.badge-crud-send, .btn-crud.badge-crud-send {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 12%, white);
  color: var(--brand-primary, #3C50E0);
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 28%, white);
}
.badge-crud-read, .btn-crud.badge-crud-read { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.badge-crud-update, .btn-crud.badge-crud-update { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-crud-delete, .btn-crud.badge-crud-delete { background: #ffe4e6; color: #9f1239; border-color: #fecdd3; }
.badge-crud-connect, .btn-crud.badge-crud-connect { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-crud-disconnect, .btn-crud.badge-crud-disconnect { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.badge-crud-logout, .btn-crud.badge-crud-logout { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.badge-crud-settings, .btn-crud.badge-crud-settings { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }

span.badge-crud.badge-crud-create {
  padding: 0.32rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 999px;
  background: var(--brand-primary, #3C50E0);
  color: #fff;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 0.4rem 0.95rem;
  cursor: pointer;
  box-shadow: 0 6px 12px color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, transparent);
}
.btn-add:hover:not(:disabled) { filter: brightness(1.08); }
.btn-add:active:not(:disabled) { transform: translateY(1px); }
.btn-add i { font-size: 0.85rem; }
.btn-crud.btn-add {
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.95rem;
  gap: 0.45rem;
}

.rl-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
}
.badge-rl {
  border: 0;
  cursor: pointer;
  background: #e0f2fe;
  color: #0c4a6e;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  gap: 0.35rem;
}
.badge-rl:hover { filter: brightness(0.97); }
.badge-rl i { font-size: 0.75em; opacity: 0.85; }

.toast {
  pointer-events: auto;
  border-radius: 0.75rem;
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  box-shadow: 0 10px 30px rgba(15,23,42,0.2);
  display: flex;
  align-items: center;
  max-width: min(22rem, calc(100vw - 2rem));
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
dialog.dlg-confirm { width: min(calc(100vw - 2rem), 26rem); z-index: 70; }

/* Native <dialog> panels — keep browser [open] display, center reliably */
dialog.dlg-panel {
  width: min(calc(100vw - 2rem), 36rem);
  max-height: min(90vh, 720px);
  padding: 0;
  border: none;
  border-radius: 1rem;
  background: #fff;
  color: inherit;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}
dialog.dlg-panel[open] {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
dialog.dlg-panel::backdrop {
  background: rgba(15, 23, 42, 0.5);
}
.dlg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.dlg-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.dlg-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem 1.15rem;
  border-top: 1px solid #f1f5f9;
  background: #fff;
  flex-shrink: 0;
}
.dlg-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 1;
}
.dlg-x:hover { background: #f8fafc; color: #0f172a; }

/* Prevent stacked/open dialogs from looking glued together */
dialog.dlg-panel + dialog.dlg-panel[open] {
  z-index: 60;
}

/* Branding drag-drop upload */
.upload-zone {
  position: relative;
  display: flex;
  min-height: 10rem;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  padding: 1rem;
  text-align: center;
  transition: 0.15s ease;
}
.upload-zone:hover,
.upload-zone.is-dragover {
  border-color: var(--brand-primary, #3C50E0);
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 6%, white);
}
.upload-zone.has-file {
  border-style: solid;
  border-color: #e2e8f0;
  background: #fff;
  padding: 0.5rem;
}
.upload-preview {
  display: flex;
  height: 100%;
  width: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0.75rem;
}
.upload-preview img {
  max-height: 8.5rem;
  max-width: 100%;
  object-fit: contain;
}
.upload-zone[data-kind="login_bg"] .upload-preview img {
  max-height: 9rem;
  width: 100%;
  object-fit: cover;
}
.upload-clear {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #9f1239;
  cursor: pointer;
  z-index: 2;
}
.upload-clear:hover { background: #ffe4e6; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Settings tabs layout */
.settings-layout {
  display: grid;
  gap: 1rem;
}
@media (min-width: 900px) {
  .settings-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
    align-items: start;
  }
}
.settings-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
@media (min-width: 900px) {
  .settings-tabs {
    flex-direction: column;
    overflow: visible;
    position: sticky;
    top: 1rem;
  }
}
.settings-tab {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
  text-align: left;
}
.settings-tab i { width: 1.1rem; text-align: center; color: #94a3b8; }
.settings-tab-label { flex: 1; min-width: 0; }
.settings-tab-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}
.settings-tab:hover { border-color: #cbd5e1; background: #f8fafc; }
.settings-tab.active {
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 35%, white);
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 10%, white);
  color: #0f172a;
}
.settings-tab.active i { color: var(--brand-primary, #3C50E0); }
.settings-tab.active .settings-tab-count {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 18%, white);
  color: var(--brand-primary, #3C50E0);
}
.settings-panel { min-height: 24rem; }
.settings-row {
  display: block;
  border: 1px solid #e2e8f0;
  border-radius: 0.9rem;
  padding: 0.9rem 1rem;
  background: #fff;
}
.settings-row.is-readonly { background: #f8fafc; }
.settings-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}
.settings-switch input { width: 1.05rem; height: 1.05rem; }

/* WhatsApp-style chat shell — fill the visible viewport so iPad/Android can scroll inner panes */
body[data-page="messages"],
body.page-messages {
  height: 100%;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
}
body[data-page="messages"] .app-shell,
body.page-messages .app-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow: hidden;
}
body[data-page="messages"] .app-header,
body.page-messages .app-header {
  flex-shrink: 0;
}
body[data-page="messages"] main,
body.page-messages main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 0.55rem 0.85rem max(0.55rem, env(safe-area-inset-bottom, 0px));
  font-size: 14px;
}
@media (min-width: 1024px) {
  body[data-page="messages"] main,
  body.page-messages main {
    padding: 0.6rem 1rem max(0.85rem, env(safe-area-inset-bottom, 0px));
  }
}
body[data-page="messages"] #page-header,
body.page-messages #page-header {
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}
body[data-page="messages"] #page-header .page-toolbar {
  margin-bottom: 0;
  justify-content: flex-start;
}

.chat-shell {
  display: grid;
  grid-template-columns: minmax(240px, 22vw) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  padding: 0;
  overflow: hidden;
}
@media (min-width: 1400px) {
  .chat-shell {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  }
}
@media (max-width: 1024px) {
  .chat-shell {
    grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  }
}
@media (max-width: 900px) {
  .chat-shell {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    grid-template-rows: none;
  }
  .chat-sidebar {
    flex: 0 1 40%;
    min-height: 11rem;
    max-height: 42%;
    border-right: 0;
    border-bottom: 1px solid #e2e8f0;
  }
  .chat-main {
    flex: 1 1 auto;
    min-height: 0;
  }
  html.theme-dark .chat-sidebar {
    border-bottom-color: #1e293b;
  }
}
.chat-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e2e8f0;
  background: #fff;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.chat-sidebar-head {
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.chat-field-label {
  display: block;
  margin-bottom: 0.12rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}
.chat-sidebar-actions {
  display: grid;
  gap: 0.3rem;
}
.chat-field { min-width: 0; }
.chat-shell .input {
  padding: 0.28rem 0.55rem;
  font-size: 0.8125rem;
  line-height: 1.3;
  border-radius: 0.5rem;
  min-height: 1.8rem;
  height: 1.8rem;
}
.chat-search-wrap {
  position: relative;
}
.chat-search-wrap .input {
  padding-left: 1.7rem;
}
.chat-search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.7rem;
  pointer-events: none;
}
.chat-list-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem 0.45rem;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  flex-shrink: 0;
}
.chat-list-toolbar .chat-search-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.chat-header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  min-width: 0;
}
.chat-header-tools .chat-new-row {
  width: min(22rem, 100%);
}
.chat-header-tools .input {
  padding: 0.28rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.3;
  border-radius: 999px;
  min-height: 2.15rem;
  height: 2.15rem;
  background: #d7e0ea;
  border-color: #94a3b8;
  color: #0f172a;
}
.chat-header-tools .input::placeholder {
  color: #64748b;
}
.chat-header-tools .input:hover:not(:disabled):not(:focus) {
  background: #c9d5e2;
  border-color: #64748b;
}
.chat-header-tools .input:focus {
  background: #fff;
}
.chat-header-tools .chat-new-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  width: auto;
  min-width: max-content;
  height: 1.8rem;
  padding: 0 0.7rem;
  border-radius: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: visible;
}
@media (max-width: 640px) {
  .chat-header-tools {
    width: 100%;
  }
  .chat-header-tools .chat-new-row {
    width: 100%;
  }
  .chat-header-tools .chat-new-btn span {
    display: none;
  }
  .chat-header-tools .chat-new-btn {
    width: 1.8rem;
    min-width: 1.8rem;
    padding: 0;
  }
}
.chat-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  background: #f1f5f9;
  border-radius: 0.65rem;
  padding: 0.2rem;
}
.chat-tab {
  border: 0;
  background: transparent;
  border-radius: 0.4rem;
  padding: 0.26rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
}
.chat-tab.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
.chat-list {
  flex: 1 1 0;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.chat-list-empty {
  padding: 1.5rem 0.85rem;
  text-align: center;
  color: #94a3b8;
  font-size: 0.8125rem;
}
.chat-item {
  display: flex;
  width: 100%;
  gap: 0.55rem;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-bottom: 1px solid #f8fafc;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.chat-item:hover { background: #f8fafc; }
.chat-item.active { background: color-mix(in srgb, var(--brand-primary, #3C50E0) 10%, white); }
.chat-avatar {
  display: inline-flex;
  height: 2.1rem;
  width: 2.1rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
  font-size: 0.8rem;
}
.chat-avatar.is-group {
  background: #dbeafe;
  color: #1d4ed8;
}
.chat-chip {
  flex-shrink: 0;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #1d4ed8;
  background: #dbeafe;
  border-radius: 999px;
  padding: 0.05rem 0.32rem;
  line-height: 1.25;
}
.chat-item .font-semibold {
  font-size: 0.85rem;
  line-height: 1.25;
}
.chat-item .text-xs {
  font-size: 0.75rem;
  line-height: 1.3;
}
.chat-item .text-\[10px\] {
  font-size: 0.65rem;
}
.chat-bubble-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 0.12rem;
  line-height: 1.2;
  word-break: break-word;
}
.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #f8fafc;
}
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  text-align: center;
}
.chat-empty .text-5xl { font-size: 2.25rem; }
.chat-empty .text-lg { font-size: 1.05rem; }
.chat-empty .text-sm { font-size: 0.8125rem; }
.chat-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.chat-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
#chat-title {
  font-size: 0.92rem;
  line-height: 1.25;
}
#chat-subtitle {
  font-size: 0.75rem;
}
.chat-thread-head .badge {
  font-size: 0.68rem;
  padding: 0.12rem 0.4rem;
}
.chat-thread {
  flex: 1 1 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background:
    radial-gradient(circle at 20% 20%, rgba(15, 23, 42, 0.03), transparent 40%),
    #eef2f7;
}
.chat-thread-empty {
  margin: auto;
  color: #94a3b8;
  font-size: 0.8125rem;
}
.chat-bubble {
  max-width: min(72%, 36rem);
  border-radius: 0.7rem;
  padding: 0.4rem 0.6rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.chat-bubble.out {
  align-self: flex-end;
  background: #dcf8c6;
  border-bottom-right-radius: 0.25rem;
}
.chat-bubble.in {
  align-self: flex-start;
  background: #fff;
  border-bottom-left-radius: 0.25rem;
}
.chat-bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
  color: #0f172a;
  font-size: 0.875rem;
  line-height: 1.4;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", Satoshi, "Nunito Sans", system-ui, sans-serif;
}
.chat-bubble-meta {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.18rem;
  font-size: 0.65rem;
  color: #64748b;
}
.chat-bubble-error {
  margin-top: 0.3rem;
  padding-top: 0.28rem;
  border-top: 1px solid rgba(225, 29, 72, 0.18);
  color: #be123c;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.35;
}
.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}
.chat-status-label { opacity: 0.9; }
.chat-ticks {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  line-height: 1;
}
.chat-ticks.sent { color: #64748b; }
.chat-ticks.delivered { color: #64748b; }
.chat-ticks.read { color: #53bdeb; }
.chat-ticks.failed { color: #e11d48; }
.chat-new-row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
}
.chat-new-row .input { flex: 1 1 auto; min-width: 0; }
.chat-new-row .btn-primary:not(.chat-new-btn) {
  padding: 0;
  width: 1.8rem;
  min-width: 1.8rem;
  height: 1.8rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
}
.chat-header-tools .chat-new-row .input {
  min-height: 2.15rem;
  height: 2.15rem;
  background: #d7e0ea;
  border-color: #94a3b8;
}
.chat-header-tools .chat-new-row .chat-new-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: max-content;
  height: 2.15rem;
  padding: 0 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 6px 12px color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, transparent);
}
.chat-compose-wrap {
  position: relative;
  flex-shrink: 0;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.25rem 0.6rem 0.4rem;
}
.chat-compose-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.05rem;
  align-items: center;
  margin-bottom: 0.25rem;
}
.chat-tool-btn {
  width: 1.7rem;
  height: 1.7rem;
  border: none;
  border-radius: 0.4rem;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}
.chat-tool-btn:hover,
.chat-tool-btn:focus-visible {
  background: #f1f5f9;
  color: #0f172a;
  outline: none;
}
.chat-compose {
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
  padding: 0;
  border: 0;
  background: transparent;
}
.chat-compose-input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.emoji-panel {
  position: absolute;
  bottom: calc(100% + 0.35rem);
  left: 0.85rem;
  z-index: 30;
  width: min(22rem, calc(100% - 1.7rem));
  max-height: 13.5rem;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.2rem;
  padding: 0.55rem;
  border-radius: 0.9rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 16px 36px -14px rgba(15, 23, 42, 0.35);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}
.emoji-panel.hidden { display: none; }
.emoji-btn {
  border: none;
  background: transparent;
  border-radius: 0.45rem;
  font-size: 1.35rem;
  line-height: 1.35;
  cursor: pointer;
  padding: 0.2rem;
  min-height: 2rem;
  font-family: inherit;
}
.emoji-btn:hover { background: #f1f5f9; }
.chat-attach-preview {
  padding: 0.55rem 0.85rem 0;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.chat-attach-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}
.chat-attach-thumb {
  width: 3rem;
  height: 3rem;
  object-fit: cover;
  border-radius: 0.45rem;
}
.chat-attach-icon { font-size: 1.4rem; color: #64748b; }
.chat-media-img {
  display: block;
  max-width: min(100%, 18rem);
  max-height: 16rem;
  border-radius: 0.55rem;
  margin-bottom: 0.25rem;
}
.chat-media-video {
  display: block;
  max-width: min(100%, 18rem);
  border-radius: 0.55rem;
}
.chat-media-audio { width: min(100%, 16rem); }
.chat-media-caption { margin-top: 0.25rem; }
.chat-doc, .chat-loc {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.55rem;
  background: rgba(15, 23, 42, 0.04);
  color: inherit;
  text-decoration: none;
}
.chat-doc i, .chat-loc i { color: #0ea5e9; font-size: 1.15rem; }
.chat-doc:hover, .chat-loc:hover { background: rgba(15, 23, 42, 0.07); }
.chat-compose .input {
  resize: none;
  height: auto;
  min-height: 1.8rem;
  max-height: 6.5rem;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
  line-height: 1.3;
  font-size: 0.875rem;
}
.chat-compose #btn-chat-send {
  width: 1.8rem;
  min-width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border-radius: 0.5rem;
  font-size: 0.75rem;
}

/* —— Login page —— */
.login-page {
  --login-overlay: 0.55;
  --login-panel-bg: rgba(255, 255, 255, 0.78);
  --login-panel-border: rgba(255, 255, 255, 0.55);
  margin: 0;
  min-height: 100%;
  background: #0f172a;
}

.login-shell {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 12% 10%, color-mix(in srgb, var(--brand-primary) 45%, transparent), transparent 60%),
    radial-gradient(900px 500px at 88% 85%, color-mix(in srgb, var(--brand-secondary) 40%, transparent), transparent 55%),
    linear-gradient(145deg, #0b1220 0%, #1e293b 48%, #0f172a 100%);
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
}

.login-has-bg .login-bg {
  background-color: #0f172a;
  background-repeat: no-repeat;
}

.login-bg-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      160deg,
      rgba(15, 23, 42, calc(var(--login-overlay) + 0.12)) 0%,
      rgba(15, 23, 42, var(--login-overlay)) 45%,
      rgba(15, 23, 42, calc(var(--login-overlay) + 0.18)) 100%
    );
  backdrop-filter: blur(2px);
}

.login-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
  padding: 2rem 1.75rem 1.5rem;
  border-radius: 1.35rem;
  border: 1px solid var(--login-panel-border);
  background: var(--login-panel-bg);
  box-shadow:
    0 25px 50px -12px rgba(15, 23, 42, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  animation: login-rise 0.55s ease-out both;
}
.login-theme-bar {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.25rem;
  height: 4.25rem;
  margin-bottom: 0.9rem;
  border-radius: 1rem;
  background: var(--brand-primary);
  color: #fff;
  font-size: 1.75rem;
  box-shadow: 0 12px 24px color-mix(in srgb, var(--brand-primary) 35%, transparent);
}

.login-logo-img {
  display: block;
  height: 4.25rem;
  max-width: 12.5rem;
  margin: 0 auto 0.9rem;
  object-fit: contain;
}

.login-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.login-subtitle {
  margin: 0.4rem 0 0;
  font-size: 0.875rem;
  color: #64748b;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #1e293b;
}

.login-input-wrap {
  position: relative;
}

.login-input-wrap > i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.85rem;
  pointer-events: none;
}

.login-input {
  padding-left: 2.45rem !important;
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

.login-input:focus {
  background: #fff !important;
}

.login-error {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem;
  background: rgba(255, 241, 242, 0.92);
  border: 1px solid #fecdd3;
  color: #be123c;
  font-size: 0.8125rem;
}

.login-submit {
  width: 100%;
  justify-content: center;
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
  font-size: 0.9375rem;
  box-shadow: 0 10px 20px color-mix(in srgb, var(--brand-primary) 28%, transparent);
}

.login-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.login-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.85rem 0 0.35rem;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.login-or::before,
.login-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}
.btn-google-login {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid #dadce0;
  background: #fff;
  color: #1f2937;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.btn-google-login i { color: #ea4335; font-size: 1.05rem; }
.btn-google-login .google-logo {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  display: block;
}
.btn-google-login:hover { background: #f8fafc; border-color: #c4c7cc; }
html.theme-dark .btn-google-login {
  background: #fff;
  color: #111827;
}

.login-idle-lock {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
}
.login-idle-lock.hidden,
.login-idle-lock[hidden] {
  display: none !important;
}
.login-idle-card {
  width: 100%;
  max-width: 22rem;
  padding: 1.75rem 1.5rem 1.4rem;
  border-radius: 1.2rem;
  background: #fff;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.45);
}
.login-idle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.85rem;
  border-radius: 999px;
  background: #fee2e2;
  color: #be123c;
  font-size: 1.15rem;
}
.login-idle-card h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}
.login-idle-card p {
  margin: 0.55rem 0 1.15rem;
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.45;
}

.login-foot {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  min-height: 1rem;
}

@media (max-width: 420px) {
  .login-panel {
    padding: 1.5rem 1.15rem 1.25rem;
    border-radius: 1.15rem;
  }
}

/* —— QR pairing dialog —— */
dialog.dlg-qr-panel {
  width: min(calc(100vw - 2rem), 28rem);
  max-height: min(92vh, 820px);
}
.qr-dlg-head {
  align-items: center;
}
.qr-dlg-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}
.qr-dlg-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.qr-dlg-title i { color: var(--brand-primary, #3C50E0); }
.qr-status-badge .badge { font-size: 0.72rem; }
.qr-dlg-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.qr-steps {
  margin: 0;
  padding: 0.75rem 0.9rem 0.75rem 1.6rem;
  border-radius: 0.85rem;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  color: #64748b;
  font-size: 0.78rem;
  line-height: 1.45;
}
.qr-steps li + li { margin-top: 0.2rem; }
.qr-steps strong { color: #334155; font-weight: 600; }
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 1rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
}
.qr-box canvas,
.qr-box img {
  border-radius: 0.5rem;
  background: #fff;
}
.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.qr-actions .btn-primary,
.qr-actions .btn-ghost {
  flex: 1 1 9rem;
  justify-content: center;
}
.qr-panel {
  border-radius: 0.9rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.85rem 0.95rem;
}
.qr-panel-head h4 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 650;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.qr-panel-head p {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: #94a3b8;
}
.qr-pin-row,
.qr-share-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
  align-items: stretch;
}
.qr-pin-row .input,
.qr-share-row .input {
  flex: 1 1 auto;
  min-width: 0;
}
.qr-pin-row .btn-primary,
.qr-share-row .btn-primary {
  flex-shrink: 0;
  white-space: nowrap;
}
.qr-pin-result {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}
.qr-pin-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #047857;
}
.qr-pin-code {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #064e3b;
  font-variant-numeric: tabular-nums;
}
.btn-sm {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

/* —— Public /pair page —— */
.pair-page {
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--brand-primary, #3C50E0) 18%, transparent), transparent),
    linear-gradient(160deg, #f8fafc 0%, #eef2ff 45%, #f1f5f9 100%);
}
.pair-shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}
.pair-card {
  width: min(100%, 26rem);
  background: #fff;
  border-radius: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 40px -18px rgba(15, 23, 42, 0.28);
  padding: 1.35rem 1.25rem 1.5rem;
}
.pair-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.pair-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
}
.pair-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--brand-primary, #25D366) 14%, white);
  color: #16a34a;
  font-size: 1.35rem;
  flex-shrink: 0;
}
.pair-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}
.pair-sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 12rem;
}
.pair-steps {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem 0.7rem 1.5rem;
  border-radius: 0.85rem;
  background: #f8fafc;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.45;
}
.pair-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  border-radius: 1rem;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px solid #e2e8f0;
  padding: 1rem;
}
.pair-pin-wrap {
  margin-top: 1rem;
  text-align: center;
  padding: 0.75rem;
  border-radius: 0.85rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}
.pair-pin-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #047857;
}
.pair-pin-code {
  margin: 0.35rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #064e3b;
  font-variant-numeric: tabular-nums;
}
.pair-meta {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
}
.pair-error {
  margin: 0.65rem 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: #be123c;
}

.docs-layout {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-toc { position: static; }
}
.docs-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem;
}
.docs-switch-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #475569;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.docs-switch-item:hover { background: #f1f5f9; color: #0f172a; }
.docs-switch-item.is-active {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 12%, white);
  color: var(--brand-primary, #3C50E0);
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 28%, white);
}
.docs-switch-item i { opacity: 0.9; }
.docs-toc {
  position: sticky;
  top: 3.75rem;
  padding: 1rem;
  display: grid;
  gap: 0.2rem;
}
.docs-toc-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}
.docs-toc a {
  border-radius: 0.5rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
}
.docs-toc a:hover { background: #f1f5f9; color: #0f172a; }
.docs-section h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 0.65rem;
}
.docs-section p { font-size: 0.9rem; color: #475569; margin: 0.4rem 0; }
.docs-list {
  margin: 0.5rem 0 0.5rem 1.1rem;
  font-size: 0.9rem;
  color: #334155;
}
.docs-list li { margin: 0.25rem 0; }
.docs-note {
  margin-top: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.7rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.82rem;
  color: #64748b;
}
.docs-table {
  width: 100%;
  margin-top: 0.7rem;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.docs-table th, .docs-table td {
  text-align: left;
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
.docs-table th { color: #64748b; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.docs-code {
  position: relative;
  margin-top: 0.7rem;
  padding: 0.85rem 2.4rem 0.85rem 0.9rem;
  border-radius: 0.75rem;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
}
.docs-code code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
.docs-copy {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.85rem;
  height: 1.85rem;
  border: 0;
  border-radius: 0.45rem;
  background: rgba(255,255,255,0.08);
  color: #cbd5e1;
  cursor: pointer;
}
.docs-copy:hover { background: rgba(255,255,255,0.16); color: #fff; }
.docs-section code:not(.docs-code code) {
  font-size: 0.78rem;
  background: #f1f5f9;
  padding: 0.1rem 0.3rem;
  border-radius: 0.3rem;
}

/* —— App header + hamburger (full-width bar, same as admv2) —— */
.app-header {
  --hdr-bg: linear-gradient(180deg, #243044 0%, #1c2434 52%, #161d2b 100%);
  --hdr-fg: rgba(255, 255, 255, 0.95);
  --hdr-fg-muted: rgba(255, 255, 255, 0.78);
  --hdr-icon-bg: rgba(255, 255, 255, 0.1);
  --hdr-icon-hover: rgba(255, 255, 255, 0.16);
  --hdr-icon-border: rgba(255, 255, 255, 0.22);
  position: relative;
  z-index: 90;
  width: 100%;
  flex-shrink: 0;
  overflow: visible;
  background: var(--hdr-bg);
  border-bottom: 0;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
  padding: 0;
  padding-top: env(safe-area-inset-top, 0px);
}
.app-header-inner {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--header-height);
  background: transparent;
}
.app-header-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.75rem 0.45rem max(0.65rem, env(safe-area-inset-left, 0px));
}
.app-header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}
.app-header-logo img {
  height: 1.85rem;
  width: auto;
  max-width: 12rem;
  object-fit: contain;
}
.app-header-logo img.hidden {
  display: none;
}
.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  flex-shrink: 0;
  border: 1px solid var(--hdr-icon-border);
  border-radius: 0.4rem;
  background: var(--hdr-icon-bg);
  color: var(--hdr-fg);
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn-sidebar-toggle:hover,
.btn-sidebar-toggle:focus-visible {
  background: var(--hdr-icon-hover);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 10, 30, 0.32);
}
.btn-sidebar-toggle:active {
  transform: scale(0.96);
}
.app-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
  padding: 0.45rem max(0.85rem, env(safe-area-inset-right, 0px)) 0.45rem 0.35rem;
  position: relative;
  z-index: 90;
}
.hdr-theme-bar,
.hdr-lang-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.12rem;
  border-radius: 999px;
  background: var(--hdr-icon-bg);
  border: 1px solid var(--hdr-icon-border);
  flex-shrink: 0;
}
.hdr-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hdr-fg-muted);
  font-size: 0.78rem;
  cursor: pointer;
}
html:not(.theme-dark) .hdr-theme-btn[data-theme="light"],
html.theme-dark .hdr-theme-btn[data-theme="dark"] {
  background: var(--brand-primary, #3C50E0);
  color: #fff;
}
.hdr-user-menu {
  position: relative;
  z-index: 40;
}
.hdr-user-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  border: 1px solid var(--hdr-icon-border);
  border-radius: 0.4rem;
  background: var(--hdr-icon-bg);
  color: var(--hdr-fg);
  font-size: 1.1rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.15s;
}
.hdr-user-btn:hover,
.hdr-user-menu.is-open .hdr-user-btn {
  background: var(--hdr-icon-hover);
  color: #fff;
}
.hdr-user-panel {
  display: none;
  position: fixed;
  top: auto;
  right: auto;
  z-index: 200;
  width: 16.5rem;
  padding: 0.55rem 0.65rem 0.55rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.95rem;
  background: #fff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14);
  pointer-events: auto;
}
.hdr-user-menu.is-open .hdr-user-panel {
  display: block;
}
.hdr-user-meta {
  padding: 0.15rem 0.45rem 0.7rem;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 0.4rem;
}
.hdr-user-name {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr-user-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.hdr-badge {
  display: inline-flex;
  align-items: center;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  padding: 0.08rem 0.4rem;
  font-size: 0.62rem;
  font-weight: 650;
  line-height: 1.2;
  border: 1px solid transparent;
}
.hdr-badge[hidden] { display: none; }
.hdr-badge-role {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.hdr-badge-id {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hdr-lang {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  padding: 0.15rem 0.45rem 0.55rem;
  border-bottom: 1px solid #f1f5f9;
}
.hdr-lang-label {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
}
.hdr-lang-switch {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.12rem;
  border-radius: 999px;
  background: #f1f5f9;
}
.hdr-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hdr-fg-muted);
  padding: 0.28rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  text-decoration: none;
}
.hdr-lang-btn .hdr-flag {
  font-size: 0.95rem;
  line-height: 1;
}
html[lang="en"] .hdr-lang-btn[data-lang="en"],
html:not([lang="en"]) .hdr-lang-btn[data-lang="id"] {
  background: var(--brand-primary, #3C50E0);
  color: #fff;
}
.hdr-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: #1e293b;
  padding: 0.55rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.hdr-menu-item i {
  width: 1rem;
  text-align: center;
  color: #2563eb;
}
.hdr-menu-item:hover { background: #eff6ff; }
.hdr-menu-item-danger { color: #be123c; }
.hdr-menu-item-danger i { color: #e11d48; }
.hdr-menu-item-danger:hover { background: #fff1f2; }
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

@media (max-width: 1023px) {
  html.sidebar-open {
    overflow: hidden;
  }
  .nav-link {
    min-height: 2.75rem;
    padding: 0.6rem 0.7rem;
  }
  .input, select.input, textarea.input {
    font-size: 16px; /* prevent Android/iOS auto-zoom */
  }
  .app-main {
    padding: 0.85rem;
  }
  .table {
    font-size: 0.8125rem;
  }
  dialog.dlg-panel {
    width: min(calc(100vw - 1rem), 36rem);
    max-height: min(92dvh, 720px);
  }
}

@media (min-width: 1024px) {
  .app-header-bar {
    padding-left: 1rem;
  }
  .app-header-actions {
    padding-right: 1.25rem;
  }
  .app-main {
    padding: 1.5rem;
  }
}

@media (max-width: 639px) {
  .hdr-lang-btn span:not(.hdr-flag) { display: none; }
  .hdr-lang-btn { padding: 0.28rem 0.4rem; }
}

.page-search {
  position: relative;
  display: flex;
  align-items: center;
}
.page-search-icon {
  position: absolute;
  left: 0.9rem;
  color: #94a3b8;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 1;
}
.page-search-input {
  width: 100%;
  padding-left: 2.5rem !important;
  padding-right: 2.5rem !important;
  min-height: 2.75rem;
}
.page-search-clear {
  position: absolute;
  right: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}
.page-search-clear:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.filter-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
  overflow-x: auto;
}
.filter-row-device {
  flex: 0 1 16.5rem;
  min-width: 12rem;
  max-width: 20rem;
}
.filter-row-search {
  flex: 1 1 auto;
  min-width: 12rem;
}
.filter-row-device .input,
.filter-row .btn-ghost,
.filter-row .btn-primary {
  min-height: 2.75rem;
  white-space: nowrap;
}
.filter-row .btn-ghost,
.filter-row .btn-primary {
  flex: 0 0 auto;
}

/* —— Dark / light theme —— */
html { color-scheme: light; }
html.theme-dark { color-scheme: dark; }

html[lang="en"] .docs-lang[data-docs-lang="id"],
html:not([lang="en"]) .docs-lang[data-docs-lang="en"] {
  display: none !important;
}

html.theme-dark body {
  background: #0b1220 !important;
  color: #cbd5e1 !important;
}
html.theme-dark .app-sidebar {
  background: #070b14;
  color: #c5d0de;
  border-right: 1px solid #111827;
  box-shadow: none;
}
html.theme-dark .nav-section { color: #8b9aaf; }
html.theme-dark .nav-link { color: #c5d0de; }
html.theme-dark .nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}
html.theme-dark .nav-link > i {
  filter: saturate(0.7) brightness(0.88);
}
html.theme-dark .nav-link.active > i {
  filter: none;
  color: #fff !important;
}
html.theme-dark #brand-footer { color: #8b9aaf; }
html.theme-dark .app-header {
  --hdr-bg: linear-gradient(180deg, #2c3a50 0%, #1e293b 48%, #152033 100%);
  --hdr-icon-bg: rgba(255, 255, 255, 0.08);
  --hdr-icon-hover: rgba(255, 255, 255, 0.14);
  --hdr-icon-border: rgba(148, 163, 184, 0.28);
  background: var(--hdr-bg);
  box-shadow: inset 0 -1px 0 rgba(148, 163, 184, 0.22);
}
html.theme-dark .hdr-user-panel {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}
html.theme-dark .hdr-user-meta { border-bottom-color: #334155; }
html.theme-dark .hdr-user-name { color: #f1f5f9; }
html.theme-dark .hdr-menu-item { color: #e2e8f0; }
html.theme-dark .hdr-menu-item:hover { background: #0f172a; }
html.theme-dark .hdr-menu-item-danger { color: #fb7185; }
html.theme-dark .hdr-menu-item-danger:hover { background: rgba(225, 29, 72, 0.12); }
html.theme-dark .hdr-user-menu.is-open .hdr-user-btn {
  background: var(--hdr-icon-hover);
  color: #fff;
}

html.theme-dark .card {
  background: #111827;
  border-color: #1e293b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
html.theme-dark .input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
html.theme-dark .input:hover:not(:disabled):not(:focus) {
  border-color: #475569;
  background: #1e293b;
}
html.theme-dark .input:focus {
  background: #0f172a;
  border-color: var(--brand-primary, #3C50E0);
}
html.theme-dark .input:disabled,
html.theme-dark .input[readonly] {
  background: #1e293b;
  color: #94a3b8;
}
html.theme-dark .label { color: #e2e8f0; }
html.theme-dark .btn-ghost {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}
html.theme-dark .btn-ghost:hover:not(:disabled) { background: #0f172a; }
html.theme-dark .table th,
html.theme-dark .table td { border-bottom-color: #1e293b; color: #cbd5e1; }
html.theme-dark .table th { color: #94a3b8; }
html.theme-dark .table tbody tr:hover { background: #1e293b; }
html.theme-dark .table .cell-primary { color: #f1f5f9; }
html.theme-dark .table .cell-muted,
html.theme-dark .table .col-time { color: #64748b; }
html.theme-dark .badge-muted { background: #1e293b; color: #94a3b8; }
html.theme-dark .badge-ok { background: #14532d; color: #bbf7d0; }
html.theme-dark .badge-warn { background: #78350f; color: #fde68a; }
html.theme-dark .badge-err { background: #7f1d1d; color: #fecaca; }
html.theme-dark .badge-crud-read, html.theme-dark .btn-crud.badge-crud-read {
  background: #1e293b; color: #cbd5e1; border-color: #334155;
}

html.theme-dark dialog.dlg-panel {
  background: #111827;
  color: #e2e8f0;
}
html.theme-dark .dlg-head,
html.theme-dark .dlg-foot { border-color: #1e293b; }
html.theme-dark .dlg-foot { background: #111827; }
html.theme-dark .dlg-x {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}
html.theme-dark .dlg-x:hover { background: #0f172a; color: #fff; }
html.theme-dark .rl-box {
  background: #0f172a;
  border-color: #334155;
}
html.theme-dark .rl-box legend,
html.theme-dark .cell-limits strong { color: #f1f5f9; }

html.theme-dark .docs-toc a { color: #94a3b8; }
html.theme-dark .docs-toc a:hover { background: #1e293b; color: #f1f5f9; }
html.theme-dark .docs-switch-item { color: #94a3b8; }
html.theme-dark .docs-switch-item:hover { background: #1e293b; color: #f1f5f9; }
html.theme-dark .docs-switch-item.is-active {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, #0f172a);
  color: #c7d2fe;
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 40%, #1e293b);
}
html.theme-dark .docs-section h2 { color: #f8fafc; }
html.theme-dark .docs-section p,
html.theme-dark .docs-list { color: #94a3b8; }
html.theme-dark .docs-note {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}
html.theme-dark .docs-table th,
html.theme-dark .docs-table td { border-bottom-color: #1e293b; color: #cbd5e1; }
html.theme-dark .docs-section code:not(.docs-code code) {
  background: #1e293b;
  color: #e2e8f0;
}

html.theme-dark .chat-shell.card {
  background: #0f172a;
  border-color: #1e293b;
  overflow: hidden;
}
html.theme-dark .chat-sidebar,
html.theme-dark .chat-list,
html.theme-dark .chat-list-toolbar {
  background: #111827;
}
html.theme-dark .chat-main,
html.theme-dark .chat-empty,
html.theme-dark .chat-active,
html.theme-dark .chat-thread-head,
html.theme-dark .chat-compose-wrap { background: #0f172a; }
html.theme-dark .chat-sidebar,
html.theme-dark .chat-sidebar-head,
html.theme-dark .chat-list-toolbar,
html.theme-dark .chat-thread-head,
html.theme-dark .chat-compose-wrap,
html.theme-dark .chat-attach-preview { border-color: #1e293b; }
html.theme-dark .chat-item { border-bottom-color: #1e293b; }
html.theme-dark .chat-item:hover { background: #1e293b; }
html.theme-dark .chat-item.active {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, #0f172a);
}
html.theme-dark .chat-item .font-semibold { color: #f1f5f9; }
html.theme-dark .chat-item .text-xs,
html.theme-dark .chat-item .text-\[10px\] { color: #64748b; }
html.theme-dark .chat-avatar { background: #1e293b; color: #94a3b8; }
html.theme-dark .chat-avatar.is-group,
html.theme-dark .chat-chip {
  background: #1e3a5f;
  color: #93c5fd;
}
html.theme-dark .chat-bubble.in { background: #1e293b; }
html.theme-dark .chat-bubble.out { background: #14532d; }
html.theme-dark .chat-bubble-body { color: #e2e8f0; }
html.theme-dark .chat-bubble-sender { color: #93c5fd; }
html.theme-dark .chat-tabs { background: #0b1220; }
html.theme-dark .chat-tab { color: #94a3b8; }
html.theme-dark .chat-tab.active {
  background: #1e293b;
  color: #f1f5f9;
  box-shadow: none;
}
html.theme-dark .chat-tool-btn { color: #94a3b8; }
html.theme-dark .chat-tool-btn:hover,
html.theme-dark .chat-tool-btn:focus-visible {
  background: #1e293b;
  color: #f1f5f9;
}
html.theme-dark .chat-thread {
  background: #0b1220 !important;
}
html.theme-dark .chat-header-tools .input {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
html.theme-dark .chat-header-tools .input::placeholder { color: #64748b; }
html.theme-dark .chat-header-tools .input:hover:not(:disabled):not(:focus) {
  background: #1e293b !important;
  border-color: #475569 !important;
}
html.theme-dark .emoji-panel {
  background: #111827;
  border-color: #334155;
}
html.theme-dark .emoji-btn:hover { background: #1e293b; }
html.theme-dark .chat-attach-preview,
html.theme-dark .chat-attach-card {
  background: #111827;
  border-color: #1e293b;
}
html.theme-dark #chat-body,
html.theme-dark .chat-compose .input {
  background: #0b1220;
  border-color: #334155;
  color: #e2e8f0;
}
html.theme-dark .text-slate-300 { color: #475569 !important; }
html.theme-dark body[data-page="messages"] .app-main {
  background: #0b1220;
}
html.theme-dark .settings-tab {
  background: #111827;
  border-color: #1e293b;
  color: #cbd5e1;
}
html.theme-dark .settings-tab i { color: #64748b; }
html.theme-dark .settings-tab:hover {
  background: #1e293b;
  border-color: #334155;
}
html.theme-dark .settings-tab.active {
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 45%, #1e293b);
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 18%, #0f172a);
  color: #f1f5f9;
}
html.theme-dark .settings-tab.active i { color: #fff; }
html.theme-dark .settings-tab-count {
  background: #0f172a;
  color: #94a3b8;
}
html.theme-dark .settings-tab.active .settings-tab-count {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 28%, #0f172a);
  color: #fff;
}
html.theme-dark .settings-panel { background: #111827; }
html.theme-dark .settings-row {
  background: #0f172a;
  border-color: #1e293b;
}
html.theme-dark .settings-row.is-readonly { background: #111827; }
html.theme-dark .settings-switch { color: #cbd5e1; }
html.theme-dark .cell-muted { color: #64748b; }
html.theme-dark .upload-zone {
  background: #0f172a;
  border-color: #334155;
}
html.theme-dark .upload-zone:hover,
html.theme-dark .upload-zone.is-dragover {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 14%, #0f172a);
}
html.theme-dark .upload-zone.has-file {
  background: #111827;
  border-color: #1e293b;
}
html.theme-dark .page-search-clear:hover { background: #1e293b; color: #fff; }

html.theme-dark .text-slate-800,
html.theme-dark .text-slate-700 { color: #e2e8f0 !important; }
html.theme-dark .text-slate-600 { color: #94a3b8 !important; }
html.theme-dark .text-slate-500 { color: #94a3b8 !important; }
html.theme-dark .text-slate-400 { color: #64748b !important; }
html.theme-dark .bg-slate-50,
html.theme-dark .bg-slate-100 { background-color: #1e293b !important; }
html.theme-dark .border-slate-200,
html.theme-dark .border-slate-300 { border-color: #334155 !important; }
html.theme-dark .bg-white { background-color: #111827 !important; }
html.theme-dark .bg-amber-50 { background-color: rgba(245, 158, 11, 0.12) !important; }
html.theme-dark .border-amber-200 { border-color: rgba(245, 158, 11, 0.35) !important; }
html.theme-dark .text-amber-800 { color: #fbbf24 !important; }
html.theme-dark .bg-emerald-50 { background-color: rgba(16, 185, 129, 0.12) !important; }
html.theme-dark .text-emerald-700,
html.theme-dark .text-emerald-900 { color: #6ee7b7 !important; }
html.theme-dark .login-page {
  --login-panel-bg: rgba(15, 23, 42, 0.92);
  --login-panel-border: rgba(148, 163, 184, 0.22);
  --login-overlay: 0.62;
}
html.theme-dark .login-panel {
  color: #e2e8f0;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}
html.theme-dark .login-title,
html.theme-dark .login-field label,
html.theme-dark .login-idle-card h2 {
  color: #f8fafc !important;
}
html.theme-dark .login-subtitle,
html.theme-dark .login-foot,
html.theme-dark .login-idle-card p {
  color: #94a3b8 !important;
}
html.theme-dark .login-input-wrap > i { color: #94a3b8; }
html.theme-dark .login-input {
  background: #0b1220 !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}
html.theme-dark .login-input::placeholder { color: #64748b; }
html.theme-dark .login-input:focus {
  background: #020617 !important;
  border-color: var(--brand-primary, #3C50E0) !important;
}
html.theme-dark .login-error {
  background: rgba(127, 29, 29, 0.45);
  border-color: #7f1d1d;
  color: #fecaca;
}
html.theme-dark .login-theme-bar,
html.theme-dark .login-page .hdr-theme-bar {
  background: #0b1220;
}
html.theme-dark .login-page .hdr-theme-btn { color: #cbd5e1; }
html.theme-dark .login-idle-card {
  background: #111827;
  color: #e2e8f0;
  border: 1px solid #1e293b;
}

.kpi-limit-value {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.15;
  color: #0f172a;
  letter-spacing: -0.02em;
}
.kpi-trial {
  border-color: color-mix(in srgb, #f59e0b 28%, #e2e8f0);
  background:
    linear-gradient(135deg, color-mix(in srgb, #f59e0b 8%, #fff), #fff 42%),
    #fff;
}
.kpi-trial:hover {
  border-color: color-mix(in srgb, #f59e0b 45%, #cbd5e1);
}
html.theme-dark .kpi-trial {
  background:
    linear-gradient(135deg, color-mix(in srgb, #f59e0b 14%, #111827), #111827 48%),
    #111827;
  border-color: color-mix(in srgb, #f59e0b 28%, #1e293b);
}
.kpi-limit-sep {
  margin: 0 0.2rem;
  color: #94a3b8;
  font-weight: 600;
}
.kpi-limit-cap {
  color: #64748b;
  font-size: 1.05rem;
  font-weight: 650;
}
.kpi-limit-bar {
  height: 0.4rem;
  margin-top: 0.85rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}
.kpi-limit-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-primary, #3C50E0);
}
.kpi-limit-bar.is-warn > span { background: #d97706; }
.kpi-limit-bar.is-err > span { background: #e11d48; }
.kpi-limit-meta {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
}
.kpi-limit-mini {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 6.5rem;
  font-size: 0.75rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: #334155;
}
.kpi-limit-mini .kpi-limit-bar {
  margin-top: 0;
  height: 0.28rem;
}

html.theme-dark .kpi-limit-value { color: #f1f5f9; }
html.theme-dark .kpi-limit-sep,
html.theme-dark .kpi-limit-cap,
html.theme-dark .kpi-limit-meta { color: #94a3b8; }
html.theme-dark .kpi-limit-bar { background: #1e293b; }
html.theme-dark .kpi-limit-mini { color: #cbd5e1; }

.polygon-search {
  display: flex;
  gap: 0.5rem;
}
.polygon-map-wrap,
.gmap-inline-wrap {
  position: relative;
  width: 100%;
  height: 22rem;
  min-height: 22rem;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}
#polygon-picker-map,
.leads-result-map {
  width: 100%;
  height: 100%;
  min-height: 22rem;
}
.leads-result-map {
  height: 18rem;
  min-height: 18rem;
  border-radius: 0.75rem;
  overflow: hidden;
}
.polygon-dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-top: 1px solid #e2e8f0;
}
html.theme-dark .polygon-dialog-footer { border-color: #1e293b; }
.polygon-node {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}






/* ===== Subscription page ===== */
.sub-page { display: grid; gap: 1.25rem; }
.sub-paywall {
  display: flex; gap: 1rem; align-items: flex-start;
  border-radius: 1.1rem; padding: 1rem 1.15rem;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 1px solid #fdba74; color: #7c2d12;
}
.sub-paywall-icon {
  width: 2.4rem; height: 2.4rem; border-radius: .85rem; flex: none;
  display: grid; place-items: center; background: #ea580c; color: #fff;
}
.sub-paywall strong { display: block; margin-bottom: .2rem; }
.sub-paywall p { margin: 0; font-size: .9rem; line-height: 1.55; }

.sub-hero {
  position: relative; overflow: hidden;
  border-radius: 1.35rem; padding: 1.45rem 1.5rem;
  background:
    radial-gradient(700px 220px at 100% -20%, color-mix(in srgb, var(--brand-primary, #3C50E0) 28%, transparent), transparent 60%),
    linear-gradient(145deg, #0f172a, #1e293b);
  color: #e2e8f0;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
}
.sub-hero.is-trial {
  background:
    radial-gradient(700px 220px at 100% -20%, color-mix(in srgb, var(--brand-secondary, #80CAEE) 35%, transparent), transparent 60%),
    linear-gradient(145deg, #0b1220, #1e3a5f);
}
.sub-hero.is-empty {
  background:
    radial-gradient(700px 220px at 100% -20%, rgba(100, 116, 139, .28), transparent 60%),
    linear-gradient(145deg, #1e293b, #0f172a);
}
.sub-hero-inner {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.4fr .8fr; gap: 1.4rem; align-items: start;
}
.sub-kicker {
  margin: 0 0 .45rem; font-size: .7rem; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase; color: #93c5fd;
}
.sub-hero.is-trial .sub-kicker { color: #7dd3fc; }
.sub-hero.is-trial .badge-warn {
  background: rgba(125, 211, 252, .22);
  color: #e0f2fe;
  border: 1px solid rgba(125, 211, 252, .4);
}
.sub-hero h2 {
  margin: 0 0 .45rem; font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 800; letter-spacing: -.02em; color: #fff;
  display: flex; flex-wrap: wrap; align-items: center; gap: .55rem;
}
.sub-hero-lead { margin: 0 0 1.1rem; color: #cbd5e1; font-size: .92rem; line-height: 1.55; }
.sub-hero.is-trial .sub-hero-lead { color: #e0f2fe; }

.sub-usage { max-width: 28rem; }
.sub-usage-top {
  display: flex; justify-content: space-between; gap: .75rem;
  font-size: .82rem; margin-bottom: .4rem; color: #e2e8f0;
}
.sub-usage-bar {
  height: .55rem; border-radius: 999px; background: rgba(255,255,255,.14); overflow: hidden;
}
.sub-usage-bar span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-primary, #3C50E0), var(--brand-secondary, #80CAEE));
  transition: width .4s ease;
}
.sub-hero.is-trial .sub-usage-bar span {
  background: linear-gradient(90deg, #38bdf8, #80CAEE);
}
.sub-usage-meta {
  display: flex; justify-content: space-between; margin-top: .4rem;
  font-size: .75rem; color: #cbd5e1;
}
.sub-hero-side { display: grid; gap: .65rem; }
.sub-stat {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14);
  border-radius: .9rem; padding: .7rem .85rem;
}
.sub-stat span { display: block; font-size: .72rem; color: #cbd5e1; margin-bottom: .15rem; }
.sub-stat strong { color: #fff; font-size: .95rem; }

.sub-section {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 1.25rem;
  padding: 1.25rem 1.3rem 1.35rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.sub-section-head { margin-bottom: 1.1rem; }
.sub-section-head h2 {
  margin: 0 0 .25rem; font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; color: #0f172a;
}
.sub-section-head p { margin: 0; color: #64748b; font-size: .9rem; }

.sub-periods {
  display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem;
}
.sub-period {
  border: 1px solid #e2e8f0; background: #fff; color: #334155;
  border-radius: 999px; padding: .45rem .95rem; font-size: .86rem; font-weight: 700;
  cursor: pointer; transition: all .15s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.sub-period:hover { border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 40%, #e2e8f0); }
.sub-period.is-active {
  background: var(--brand-primary, #3C50E0); color: #fff; border-color: transparent;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--brand-primary, #3C50E0) 25%, transparent);
}

.sub-plans {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: stretch;
}
.sub-plan {
  position: relative;
  display: flex; flex-direction: column; gap: .45rem;
  border: 1px solid #e2e8f0; border-radius: 1.2rem; padding: 1.25rem 1.15rem 1.2rem;
  background: linear-gradient(180deg, #fff, #f8fafc);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  cursor: pointer;
}
.sub-plan.is-hot {
  border: 2px solid transparent;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(145deg, var(--brand-primary, #3C50E0), var(--brand-secondary, #80CAEE)) border-box;
  box-shadow: 0 18px 36px color-mix(in srgb, var(--brand-primary, #3C50E0) 16%, transparent);
}
.sub-plan.is-selected {
  border-color: var(--brand-primary, #3C50E0);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary, #3C50E0) 18%, transparent);
}
.sub-plan.is-current { outline: 2px dashed color-mix(in srgb, #16a34a 45%, white); outline-offset: 2px; }
.sub-plan-tag, .sub-plan-current {
  position: absolute; top: .75rem; right: .75rem; left: auto; transform: none;
  font-size: .65rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  border-radius: 999px; padding: .22rem .65rem; white-space: nowrap; color: #fff;
  z-index: 1; max-width: calc(100% - 1.5rem); overflow: hidden; text-overflow: ellipsis;
}
.sub-plan-tag {
  background: linear-gradient(135deg, var(--brand-primary, #3C50E0), color-mix(in srgb, var(--brand-primary, #3C50E0) 55%, var(--brand-secondary, #80CAEE)));
  box-shadow: 0 8px 16px color-mix(in srgb, var(--brand-primary, #3C50E0) 35%, transparent);
}
.sub-plan-current { background: #16a34a; top: auto; bottom: .75rem; right: .75rem; }
.sub-plan h3 { margin: .15rem 0 0; padding-right: 6.5rem; font-size: 1.05rem; font-weight: 800; color: #0f172a; }
@media (hover: hover) and (pointer: fine) {
  .sub-plan:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px rgba(15, 23, 42, .08);
    border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 35%, #e2e8f0);
  }
  .sub-plan.is-hot { transform: translateY(-4px); }
}
.sub-price-wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .55rem; }
.sub-price {
  font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; color: #0f172a;
}
.sub-price span { font-size: .78rem; font-weight: 650; color: #64748b; margin-left: .15rem; }
.sub-price-was { font-size: .82rem; color: #94a3b8; text-decoration: line-through; font-weight: 600; }
.sub-save {
  display: inline-flex; align-items: center;
  background: #ecfdf5; color: #047857; border-radius: 999px;
  font-size: .72rem; font-weight: 800; padding: .15rem .5rem;
}
.sub-eff { margin: 0; font-size: .78rem; color: #64748b; font-weight: 600; }
.sub-plan-desc { margin: 0; color: #64748b; font-size: .86rem; line-height: 1.5; min-height: 2.6em; }
.sub-plan ul {
  list-style: none; margin: .35rem 0 .85rem; padding: 0;
  display: grid; gap: .4rem; color: #475569; font-size: .86rem;
}
.sub-plan ul li { display: flex; gap: .45rem; align-items: baseline; }
.sub-plan ul li::before {
  content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900;
  font-size: .7rem; color: #16a34a;
}
.sub-plan-cta {
  margin-top: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  width: 100%; padding: .72rem 1rem; border-radius: .85rem; border: none; cursor: pointer;
  font-weight: 800; font-size: .9rem;
  color: var(--brand-primary, #3C50E0);
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 8%, white);
  border: 1.5px solid color-mix(in srgb, var(--brand-primary, #3C50E0) 30%, white);
  transition: filter .15s ease, transform .15s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.sub-plan.is-hot .sub-plan-cta {
  background: linear-gradient(135deg, var(--brand-primary, #3C50E0), color-mix(in srgb, var(--brand-primary, #3C50E0) 55%, var(--brand-secondary, #80CAEE)));
  color: #fff; border-color: transparent;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--brand-primary, #3C50E0) 35%, transparent);
}
@media (hover: hover) and (pointer: fine) {
  .sub-plan-cta:hover { filter: brightness(1.03); transform: translateY(-1px); }
}

.sub-methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.sub-methods-loading { color: #64748b; font-size: .9rem; grid-column: 1 / -1; }
.sub-method {
  display: flex; align-items: center; gap: .85rem; text-align: left;
  border: 1px solid #e2e8f0; border-radius: 1rem; padding: .85rem 1rem;
  background: #fff; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
  .sub-method:hover {
    border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 40%, #e2e8f0);
    box-shadow: 0 10px 22px rgba(15, 23, 42, .06);
    transform: translateY(-1px);
  }
}
.sub-method:disabled { opacity: .6; cursor: wait; }
.sub-method-icon {
  width: 3.1rem; height: 2.2rem; border-radius: .65rem; flex: none;
  display: grid; place-items: center;
  background: #f8fafc; border: 1px solid #e2e8f0;
  color: var(--brand-primary, #3C50E0);
  overflow: hidden; padding: .2rem .3rem;
}
.sub-method-icon img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.sub-method-icon i { font-size: .95rem; }
.sub-method-body { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.sub-method-body strong { color: #0f172a; font-size: .92rem; }
.sub-method-body small { color: #64748b; font-size: .78rem; }
.sub-method-go { color: #94a3b8; font-size: .8rem; }

.sub-history { border: none; box-shadow: none; padding: 0; background: transparent; }
.sub-history .badge-pay-pending {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 14%, white);
  color: var(--brand-primary, #3C50E0);
  border: 1px solid color-mix(in srgb, var(--brand-primary, #3C50E0) 28%, white);
}
.sub-history .badge-pay-paid {
  background: #dcfce7; color: #166534; border: 1px solid #bbf7d0;
}
.sub-history .badge-pay-failed {
  background: #ffe4e6; color: #9f1239; border: 1px solid #fecdd3;
}
.sub-history .badge-pay-muted {
  background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0;
}
.sub-history td.col-actions {
  text-align: right;
  width: 1%;
  white-space: nowrap;
}
.sub-pay-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: 999px; padding: .42rem .95rem;
  font-size: .82rem; font-weight: 700; text-decoration: none; white-space: nowrap;
  color: #fff;
  background: var(--brand-primary, #3C50E0);
  border: 1px solid color-mix(in srgb, var(--brand-primary, #3C50E0) 80%, #0f172a);
  box-shadow: 0 8px 16px color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, transparent);
  transition: filter .15s ease, transform .15s ease;
}
.sub-pay-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  color: #fff;
}
.sub-pay-btn i { font-size: .85em; }
.sub-history-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: .4rem; }
.sub-cancel-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border-radius: 999px; padding: .42rem .85rem;
  font-size: .82rem; font-weight: 700; white-space: nowrap; cursor: pointer;
  color: #64748b; background: #fff;
  border: 1px solid #e2e8f0;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.sub-cancel-btn:hover {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}
.sub-cancel-btn:disabled { opacity: .55; cursor: wait; }
.sub-cancel-btn i { font-size: .85em; }

@media (max-width: 1100px) {
  .sub-plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sub-plan.is-hot { transform: none; }
}
@media (max-width: 760px) {
  .sub-hero-inner, .sub-plans, .sub-methods { grid-template-columns: 1fr; }
  .sub-hero, .sub-section { padding: 1.1rem; }
  .sub-page { gap: 1rem; min-width: 0; }
  .sub-paywall { flex-direction: column; gap: .75rem; }
  .sub-usage-top,
  .sub-usage-meta {
    flex-wrap: wrap;
    row-gap: .25rem;
  }
  .sub-usage-top strong { word-break: break-word; }
  .sub-hero-side {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
  }
  .sub-stat { padding: .55rem .6rem; }
  .sub-stat strong { font-size: .82rem; }
  .sub-periods {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
  }
  .sub-period {
    min-height: 2.75rem;
    width: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .sub-plan {
    padding: 1.15rem 1rem 1.05rem;
    transform: none !important;
  }
  .sub-plan-tag,
  .sub-plan-current {
    top: .65rem;
    right: .65rem;
    left: auto;
    bottom: auto;
    transform: none;
  }
  .sub-plan-current { top: auto; bottom: .65rem; }
  .sub-plan h3 { padding-right: 6rem; font-size: 1rem; }
  .sub-plan-desc { min-height: 0; }
  .sub-plan-cta {
    min-height: 2.85rem;
    touch-action: manipulation;
  }
  .sub-method {
    min-height: 3.35rem;
    padding: .9rem .95rem;
    touch-action: manipulation;
    transform: none !important;
  }
  .sub-method-body strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sub-history {
    margin: 0 -.15rem;
  }
  .sub-history .table {
    display: block;
    width: 100%;
  }
  .sub-history thead { display: none; }
  .sub-history tbody { display: grid; gap: .65rem; }
  .sub-history tr {
    display: grid;
    gap: .35rem;
    padding: .85rem .9rem;
    border: 1px solid #e2e8f0;
    border-radius: .95rem;
    background: #fff;
  }
  .sub-history td {
    display: block;
    width: auto !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: normal;
  }
  .sub-history td.font-mono {
    font-size: .72rem;
    word-break: break-all;
    color: #64748b;
  }
  .sub-history td.col-status { order: -1; }
  .sub-history td.col-actions {
    text-align: left;
    margin-top: .35rem;
  }
  .sub-history-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: .45rem;
    justify-content: stretch;
  }
  .sub-pay-btn,
  .sub-cancel-btn {
    justify-content: center;
    min-height: 2.6rem;
    width: 100%;
    touch-action: manipulation;
  }
  .sub-history-actions .sub-pay-btn:only-child,
  .sub-history-actions .sub-cancel-btn:only-child {
    grid-column: 1 / -1;
  }
}
@media (max-width: 420px) {
  .sub-hero-side { grid-template-columns: 1fr; }
  .sub-periods { grid-template-columns: 1fr 1fr; }
  .sub-plan h3 { padding-right: 0; margin-top: 1.5rem; }
  .sub-plan-tag { left: .65rem; right: auto; }
}
@media (hover: none), (pointer: coarse) {
  .sub-plan:hover,
  .sub-plan.is-hot,
  .sub-method:hover,
  .sub-plan-cta:hover {
    transform: none;
  }
}
html.theme-dark .sub-history tr {
  background: #111827;
  border-color: #1e293b;
}
.sub-methods-error {
  grid-column: 1 / -1;
  border: 1px solid #fecdd3; background: #fff1f2; color: #9f1239;
  border-radius: 1rem; padding: 1rem 1.1rem;
}
.sub-methods-error strong { display: block; margin-bottom: .35rem; }
.sub-methods-error p { margin: 0; font-size: .9rem; line-height: 1.5; }

.blast-type-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: .5rem;
}
.blast-type-toggle button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid #e2e8f0; background: #f8fafc; color: #475569;
  border-radius: .75rem; padding: .65rem .8rem; font-size: .85rem; font-weight: 700;
  cursor: pointer; transition: .15s ease;
}
.blast-type-toggle button:hover { border-color: #cbd5e1; background: #fff; }
.blast-type-toggle button.is-active {
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 45%, #e2e8f0);
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 10%, white);
  color: var(--brand-primary, #3C50E0);
}
.blast-upload { min-height: 8.5rem; }
.blast-upload.has-file { min-height: 11rem; }
.blast-upload .upload-preview {
  display: flex !important;
  min-height: 9rem;
  width: 100%;
}
.blast-upload .upload-preview.hidden { display: none !important; }
.blast-upload .upload-clear {
  position: absolute; top: .55rem; right: .55rem;
  width: 1.75rem; height: 1.75rem; border-radius: 999px;
  border: 0; background: rgba(15, 23, 42, .72); color: #fff;
  font-size: 1.1rem; line-height: 1; cursor: pointer; z-index: 2;
}
.blast-upload .upload-preview img {
  display: block;
  max-height: 10rem;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.blast-job-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .5rem;
}
.blast-job-all {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .82rem; font-weight: 600; color: #475569; cursor: pointer;
}
.blast-job-list {
  max-height: 11.5rem; overflow: auto;
  border: 1px solid #e2e8f0; border-radius: .85rem; background: #f8fafc;
  padding: .35rem;
}
.blast-job-item {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .5rem .6rem; border-radius: .65rem; cursor: pointer;
}
.blast-job-item:hover { background: #fff; }
.blast-job-item input { margin-top: .15rem; }
.blast-job-item span { display: grid; gap: .1rem; min-width: 0; }
.blast-job-item strong { font-size: .86rem; color: #0f172a; }
.blast-job-item small { font-size: .75rem; color: #64748b; }

.blast-template-row {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch;
}
.blast-template-row .input { flex: 1 1 12rem; min-width: 0; }
.blast-template-row .btn-ghost {
  white-space: nowrap;
}
.blast-save-panel {
  margin-top: .55rem;
  padding: .75rem;
  border: 1px solid #e2e8f0;
  border-radius: .85rem;
  background: #f8fafc;
  display: grid;
  gap: .55rem;
}
.blast-save-panel.hidden { display: none; }
.blast-save-actions {
  display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
}

/* —— Dark mode: subscription + blast + pairing extras —— */
html.theme-dark .sub-paywall {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.16), rgba(251, 146, 60, 0.1));
  border-color: rgba(251, 146, 60, 0.4);
  color: #fdba74;
}
html.theme-dark .sub-paywall strong { color: #ffedd5; }
html.theme-dark .sub-paywall p { color: #fdba74; }

html.theme-dark .sub-section {
  background: #111827;
  border-color: #1e293b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
html.theme-dark .sub-section-head h2 { color: #f1f5f9; }
html.theme-dark .sub-section-head p { color: #94a3b8; }

html.theme-dark .sub-period {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}
html.theme-dark .sub-period:hover {
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 45%, #334155);
  background: #1e293b;
}
html.theme-dark .sub-period.is-active {
  background: var(--brand-primary, #3C50E0);
  color: #fff;
  border-color: transparent;
}

html.theme-dark .sub-plan {
  background: linear-gradient(180deg, #1e293b, #111827);
  border-color: #334155;
}
html.theme-dark .sub-plan:hover {
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 40%, #334155);
}
html.theme-dark .sub-plan.is-hot {
  background:
    linear-gradient(#1e293b, #1e293b) padding-box,
    linear-gradient(145deg, var(--brand-primary, #3C50E0), var(--brand-secondary, #80CAEE)) border-box;
  box-shadow: 0 18px 36px color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, transparent);
}
html.theme-dark .sub-plan.is-selected {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary, #3C50E0) 28%, transparent);
}
html.theme-dark .sub-plan.is-current {
  outline-color: color-mix(in srgb, #22c55e 55%, transparent);
}
html.theme-dark .sub-plan h3,
html.theme-dark .sub-price { color: #f8fafc; }
html.theme-dark .sub-price span,
html.theme-dark .sub-eff,
html.theme-dark .sub-plan-desc { color: #94a3b8; }
html.theme-dark .sub-price-was { color: #64748b; }
html.theme-dark .sub-save {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}
html.theme-dark .sub-plan ul { color: #cbd5e1; }
html.theme-dark .sub-plan-cta {
  color: #bfdbfe;
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 18%, #0f172a);
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 40%, #334155);
}
html.theme-dark .sub-plan.is-hot .sub-plan-cta {
  color: #fff;
  border-color: transparent;
}

html.theme-dark .sub-methods-loading { color: #94a3b8; }
html.theme-dark .sub-method {
  background: #0f172a;
  border-color: #334155;
}
html.theme-dark .sub-method:hover {
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 45%, #334155);
  background: #1e293b;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
}
html.theme-dark .sub-method-icon {
  background: #111827;
  border-color: #334155;
}
html.theme-dark .sub-method-body strong { color: #f1f5f9; }
html.theme-dark .sub-method-body small,
html.theme-dark .sub-method-go { color: #94a3b8; }
html.theme-dark .sub-methods-error {
  background: rgba(127, 29, 29, 0.28);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

html.theme-dark .sub-history .badge-pay-pending {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, #0f172a);
  color: #bfdbfe;
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 40%, #334155);
}
html.theme-dark .sub-history .badge-pay-paid {
  background: #14532d; color: #bbf7d0; border-color: #166534;
}
html.theme-dark .sub-history .badge-pay-failed {
  background: #7f1d1d; color: #fecaca; border-color: #991b1b;
}
html.theme-dark .sub-history .badge-pay-muted {
  background: #1e293b; color: #94a3b8; border-color: #334155;
}
html.theme-dark .sub-cancel-btn {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}
html.theme-dark .sub-cancel-btn:hover {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.25);
}

html.theme-dark .blast-type-toggle button {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}
html.theme-dark .blast-type-toggle button:hover {
  background: #1e293b;
  border-color: #475569;
  color: #e2e8f0;
}
html.theme-dark .blast-type-toggle button.is-active {
  background: color-mix(in srgb, var(--brand-primary, #3C50E0) 18%, #0f172a);
  border-color: color-mix(in srgb, var(--brand-primary, #3C50E0) 45%, #334155);
  color: #bfdbfe;
}
html.theme-dark .blast-job-all { color: #94a3b8; }
html.theme-dark .blast-job-list {
  background: #0f172a;
  border-color: #334155;
}
html.theme-dark .blast-job-item:hover { background: #1e293b; }
html.theme-dark .blast-job-item strong { color: #f1f5f9; }
html.theme-dark .blast-job-item small { color: #94a3b8; }
html.theme-dark .blast-save-panel {
  background: #0f172a;
  border-color: #334155;
}

html.theme-dark .qr-dlg-title { color: #f1f5f9; }
html.theme-dark .qr-steps {
  background: #0f172a;
  border-color: #1e293b;
  color: #94a3b8;
}
html.theme-dark .qr-steps strong { color: #e2e8f0; }
html.theme-dark .qr-box {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  border-color: #1e293b;
}
html.theme-dark .polygon-map-wrap,
html.theme-dark .gmap-inline-wrap {
  background: #0f172a;
  border-color: #334155;
}
html.theme-dark .polygon-node {
  box-shadow: 0 0 0 2px #1e293b;
}

html.theme-dark .pair-page {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--brand-primary, #3C50E0) 22%, transparent), transparent),
    linear-gradient(160deg, #0b1220 0%, #111827 55%, #0f172a 100%);
}
html.theme-dark .pair-card {
  background: #111827;
  border-color: #1e293b;
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.55);
}
html.theme-dark .pair-logo {
  background: color-mix(in srgb, var(--brand-primary, #25D366) 22%, #0f172a);
  color: #4ade80;
}
html.theme-dark .pair-title { color: #f1f5f9; }
html.theme-dark .pair-sub,
html.theme-dark .pair-meta { color: #94a3b8; }
html.theme-dark .pair-steps {
  background: #0f172a;
  color: #94a3b8;
}
html.theme-dark .pair-qr-box {
  background: linear-gradient(180deg, #0f172a, #111827);
  border-color: #1e293b;
}
html.theme-dark .pair-pin-wrap {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
}
html.theme-dark .pair-pin-label { color: #6ee7b7; }
html.theme-dark .pair-pin-code { color: #a7f3d0; }
html.theme-dark .pair-error { color: #fb7185; }

