:root {
  /* Technio logo: Lime Green + Black */
  --brand: #B8F26D;
  --brand-dark: #4E7A3D;
  --brand-soft: #F3FCE6;
  --brand-text: #1A2E12;
  --ink: #000000;
  --bg: #F5F5F3;
  --sidebar: #FFFFFF;
  --card: #FFFFFF;
  --text: #111111;
  --muted: #6B6B6B;
  --border: #E6E6E3;
  --danger: #B42318;
  --danger-soft: #FEE4E2;
  --ok: #1F7A3A;
  --ok-soft: #E8F8EC;
  --warn: #9A6700;
  --warn-soft: #FEF7C3;
  --gray-soft: #F1F1EF;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-family: Inter, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}
a { color: #2563EB; text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 248px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px 18px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand-wrap {
  padding: 10px 8px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.sidebar .brand-sub {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  width: 100%;
}
.sidebar .brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar .brand span { color: var(--brand-dark); }
.nav-section {
  margin-bottom: 18px;
}
.nav-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #A3A3A3;
  padding: 0 10px 8px;
}
.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #404040;
  padding: 9px 10px;
  border-radius: 8px;
  margin-bottom: 2px;
  text-decoration: none;
  position: relative;
  font-weight: 500;
}
.sidebar a.nav-link svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  flex-shrink: 0;
}
.sidebar a.nav-link:hover {
  background: #FAFAF9;
  text-decoration: none;
}
.sidebar a.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-text);
}
.sidebar a.nav-link.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  padding: 8px 10px 12px;
  color: var(--muted);
  font-size: 0.8rem;
}
.sidebar-user strong {
  display: block;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}
.btn-signout {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  color: #404040;
}
.btn-signout:hover { background: #FAFAF9; }

.main {
  flex: 1;
  padding: 28px 32px 40px;
  min-width: 0;
}

.crumbs {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 10px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.page-desc {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
h1 { margin: 0 0 6px; font-size: 1.75rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-body { padding: 18px; }
.stat-value { font-size: 1.45rem; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em; }
.stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #111;
  color: #B8F26D !important;
  border: 1px solid #111;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none !important;
  white-space: nowrap;
  -webkit-text-fill-color: #B8F26D;
}
.btn:hover {
  background: #000;
  filter: none;
  color: #B8F26D !important;
  -webkit-text-fill-color: #B8F26D;
}
.btn-secondary, .btn-outline {
  background: #fff;
  color: #111 !important;
  -webkit-text-fill-color: #111;
  border: 1px solid var(--border);
}
.btn-secondary:hover, .btn-outline:hover {
  background: #FAFAF9;
  color: #111 !important;
  -webkit-text-fill-color: #111;
}
.btn-danger {
  background: #fff;
  color: var(--danger) !important;
  -webkit-text-fill-color: var(--danger);
  border: 1px solid #FECACA;
}
.btn-sm { padding: 6px 10px; font-size: 0.82rem; }
.btn-lime,
a.btn.btn-lime,
button.btn.btn-lime {
  background: #B8F26D !important;
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
  border-color: #B8F26D !important;
}
.btn-lime:hover,
a.btn.btn-lime:hover,
button.btn.btn-lime:hover {
  background: #c8f78a !important;
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}
th {
  color: #A3A3A3;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: #FBFBFA;
}
tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
.link-id { color: #2563EB; text-decoration: underline; text-underline-offset: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-paid, .badge-active, .badge-ok, .badge-captured { background: var(--ok-soft); color: var(--ok); }
.badge-failed, .badge-inactive, .badge-revoked { background: var(--danger-soft); color: var(--danger); }
.badge-pending, .badge-processing, .badge-proposed { background: var(--warn-soft); color: var(--warn); }
.badge-cancelled, .badge-expired, .badge-refunded, .badge-created { background: var(--gray-soft); color: #525252; }

.form-row { margin-bottom: 14px; }
label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #404040;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: #111;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(184, 242, 109, 0.55);
  border-color: var(--brand-dark);
}
input::placeholder,
textarea::placeholder {
  color: #9CA3AF;
  opacity: 1;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0 1000px #fff inset;
}
.help { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar .form-row { margin: 0; min-width: 160px; }
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 10px 2px;
}
.pagination-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.pagination-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.pagination-meta { font-size: 13px; }

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #ABEFC6; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #FECDCA; }
.alert-info { background: #F5F5F4; color: #44403C; border-color: var(--border); }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #000;
}
.auth-card {
  width: min(420px, 92vw);
  background: #0A0A0A;
  border: 1px solid #222;
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
  color: #fff;
}
.auth-card h1, .auth-card .brand-login { color: var(--brand); }
.auth-card .muted { color: #A3A3A3; }
.auth-card label { color: #D4D4D4; }
.auth-card input {
  background: #111;
  border-color: #333;
  color: #fff;
  -webkit-text-fill-color: #fff;
  caret-color: #fff;
}
.auth-card input::placeholder {
  color: #888;
}
.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:hover,
.auth-card input:-webkit-autofill:focus,
.auth-card input:-webkit-autofill:active {
  -webkit-text-fill-color: #fff !important;
  caret-color: #fff;
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0 1000px #111 inset;
}
.auth-card .btn,
.auth-card button.btn {
  background: var(--brand) !important;
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
  border-color: var(--brand) !important;
}
.auth-card .btn:hover,
.auth-card button.btn:hover {
  background: #c8f78a !important;
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
}
.secrets-box {
  background: #171717;
  color: #F5F5F4;
  border-radius: 10px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  word-break: break-all;
}
.code-box {
  background: #F5F5F4;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  overflow-x: auto;
}
.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  overflow: visible;
}
.secret-row .secret-value {
  flex: 1;
  min-width: 0;
  margin: 0;
  display: block;
  overflow-x: auto;
}
.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  display: block;
  overflow: visible;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}
.icon-btn .icon-eye-closed,
.icon-btn .icon-copied {
  display: none;
}
.secret-row.is-revealed .icon-btn .icon-eye-open { display: none; }
.secret-row.is-revealed .icon-btn .icon-eye-closed { display: block; }
.icon-btn.is-copied .icon-copy { display: none; }
.icon-btn.is-copied .icon-copied { display: block; }
.icon-btn:hover { background: var(--gray-soft); }
.icon-btn.is-copied { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.secret-row.is-revealed .secret-value { color: var(--ok); }
html[data-theme="dark"] .icon-btn {
  background: #1A1A1A;
  border-color: #333;
  color: #F5F5F4;
}
.check-list label { font-weight: 500; display: flex; gap: 8px; align-items: center; }
.method-config {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 12px 0 18px;
}
.method-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 10px;
  background: var(--card);
}
.method-group-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.option-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  line-height: 1.3;
}
.option-item span { flex: 1; text-align: left; }
.ms { position: relative; }
.ms-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.ms-caret { font-size: 0.7rem; color: var(--muted); }
.ms-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-menu[hidden] { display: none !important; }
.method-group[hidden] { display: none !important; }
.ms-menu .option-item {
  padding: 8px 10px;
  border-radius: 8px;
}
.ms-menu .option-item:hover { background: #F5F5F4; }
.method-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0 0 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.method-group.is-collapsed .option-list { display: none; }
.method-group.is-collapsed .ms-caret { transform: rotate(-90deg); }
html[data-theme="dark"] .ms-toggle,
body.theme-dark .ms-toggle,
html[data-theme="dark"] .ms-menu,
body.theme-dark .ms-menu {
  background: #141414;
  border-color: #333;
  color: #F5F5F4;
}
html[data-theme="dark"] .ms-menu .option-item:hover,
body.theme-dark .ms-menu .option-item:hover {
  background: #1F1F1F;
}
.method-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}
.hpp-page {
  min-height: 100vh;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}
.hpp-box {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--ink);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  font-weight: 700;
}

.sidebar .brand-logo {
  width: 100%;
  max-width: 168px;
  height: auto;
  max-height: 68px;
  display: block;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border-radius: 0;
  margin: 0 auto;
}
.brand-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  min-height: 64px;
  width: 100%;
}
.auth-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 8px 8px 20px;
  min-height: 96px;
}
.auth-logo {
  width: min(280px, 92%);
  height: auto;
  max-height: 88px;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border-radius: 0;
  margin: 0 auto;
  display: block;
}
.auth-form { margin-top: 8px; }
.auth-footer {
  text-align: center;
  margin-top: 18px;
  color: #6B6B6B;
  font-size: 0.9rem;
}
.btn-theme {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
}
.btn-theme:hover { background: var(--gray-soft); }
.theme-choice { display: grid; gap: 10px; }
.theme-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--card);
}
.theme-option.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.theme-option input { margin-top: 3px; }
.theme-option strong { display: block; color: var(--text); }
.theme-option small { color: var(--muted); font-size: 0.82rem; }

/* Merchant dark mode (default) */
html[data-theme="dark"] {
  --bg: #0A0A0A;
  --sidebar: #111111;
  --card: #161616;
  --text: #F5F5F4;
  --muted: #A3A3A3;
  --border: #2A2A2A;
  --ink: #FFFFFF;
  --brand-soft: rgba(184, 242, 109, 0.12);
  --brand-text: #D8F9A0;
  --gray-soft: #1A1A1A;
  --ok-soft: #14301c;
  --danger-soft: #3a1414;
  --warn-soft: #3a2e10;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .sidebar a.nav-link { color: #D4D4D4; }
html[data-theme="dark"] .sidebar a.nav-link:hover { background: #1A1A1A; }
html[data-theme="dark"] .sidebar a.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-text);
}
html[data-theme="dark"] .btn-signout,
html[data-theme="dark"] .btn-theme {
  background: #161616;
  border-color: #333;
  color: #E5E5E5;
}
html[data-theme="dark"] .btn-signout:hover,
html[data-theme="dark"] .btn-theme:hover { background: #1F1F1F; }
html[data-theme="dark"] .card,
html[data-theme="dark"] .method-card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] table {
  background: var(--card);
  color: var(--text);
}
html[data-theme="dark"] table th {
  background: #1A1A1A;
  color: #A3A3A3;
  border-color: var(--border);
}
html[data-theme="dark"] table td { border-color: var(--border); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #0F0F0F;
  border-color: #333;
  color: #fff;
  -webkit-text-fill-color: #fff;
  caret-color: #fff;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #8A8A8A;
}
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus,
html[data-theme="dark"] input:-webkit-autofill:active,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill {
  -webkit-text-fill-color: #fff !important;
  caret-color: #fff;
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0 1000px #0F0F0F inset;
}
html[data-theme="dark"] .btn,
html[data-theme="dark"] a.btn,
html[data-theme="dark"] button.btn,
body.theme-dark .btn,
body.theme-dark a.btn,
body.theme-dark button.btn {
  background: #111 !important;
  color: #B8F26D !important;
  -webkit-text-fill-color: #B8F26D !important;
  border-color: #333 !important;
}
html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] a.btn:hover,
body.theme-dark .btn:hover {
  background: #000 !important;
  color: #B8F26D !important;
  -webkit-text-fill-color: #B8F26D !important;
}
html[data-theme="dark"] .btn-lime,
html[data-theme="dark"] a.btn.btn-lime,
html[data-theme="dark"] button.btn.btn-lime,
body.theme-dark .btn-lime,
body.theme-dark a.btn.btn-lime {
  background: #B8F26D !important;
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
  border-color: #B8F26D !important;
}
html[data-theme="dark"] .btn-lime:hover,
html[data-theme="dark"] a.btn.btn-lime:hover,
body.theme-dark .btn-lime:hover {
  background: #c8f78a !important;
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
}
html[data-theme="dark"] .btn-outline,
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] a.btn.btn-outline,
body.theme-dark .btn-outline,
body.theme-dark .btn-secondary {
  background: transparent !important;
  color: #F5F5F4 !important;
  -webkit-text-fill-color: #F5F5F4 !important;
  border-color: #555 !important;
}
html[data-theme="dark"] .btn-outline:hover,
html[data-theme="dark"] .btn-secondary:hover,
body.theme-dark .btn-outline:hover {
  background: #1A1A1A !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}
html[data-theme="dark"] .btn-danger,
body.theme-dark .btn-danger {
  background: transparent !important;
  color: #ffb4b4 !important;
  -webkit-text-fill-color: #ffb4b4 !important;
  border-color: #5c2b2b !important;
}
html[data-theme="dark"] .auth-card .btn,
body.theme-dark .auth-card .btn {
  background: #B8F26D !important;
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
  border-color: #B8F26D !important;
}
html[data-theme="dark"] .page-header .btn,
body.theme-dark .page-header .btn {
  color: #B8F26D !important;
  -webkit-text-fill-color: #B8F26D !important;
}
html[data-theme="dark"] .page-header .btn-lime,
body.theme-dark .page-header .btn-lime {
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
}
html[data-theme="dark"] .page-header .btn-outline,
body.theme-dark .page-header .btn-outline {
  color: #F5F5F4 !important;
  -webkit-text-fill-color: #F5F5F4 !important;
}
html[data-theme="dark"] .code-box {
  background: #0F0F0F;
  border-color: #333;
  color: #E5E5E5;
}
html[data-theme="dark"] .alert-info {
  background: #1A1A1A;
  color: #D4D4D4;
  border-color: #333;
}
html[data-theme="dark"] a:not(.nav-link):not(.btn) { color: var(--brand); }
.hpp-logo {
  width: min(200px, 80%);
  height: auto;
  max-height: 48px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
}
.logo-preview-frame {
  background: transparent;
  border-radius: 12px;
  padding: 18px;
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px dashed var(--border);
}
.logo-preview-img {
  max-width: 100%;
  max-height: 120px;
  height: auto;
  object-fit: contain;
  background: transparent;
}
.admin-method-preview {
  width: 128px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
}
.admin-method-preview .method-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
}
.admin-method-preview .method-logo img {
  max-height: 40px;
  max-width: 108px;
  width: auto;
  object-fit: contain;
}
.feature-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.feature-toggle strong { display: block; }
.feature-toggle small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.82rem;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #D4D4D4;
  position: relative;
  display: inline-block;
  transition: background 0.15s ease;
}
.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 0.15s ease;
}
.toggle input:checked + .toggle-ui { background: #1F7A3A; }
.toggle input:checked + .toggle-ui::after { transform: translateX(20px); }
.toggle-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-width: 28px;
  color: var(--muted);
}
.toggle input:checked ~ .toggle-label { color: var(--ok); }
html[data-theme="dark"] .toggle-ui { background: #3A3A3A; }
html[data-theme="dark"] .toggle input:checked + .toggle-ui { background: #1F7A3A; }
.mobile-topbar,
.nav-close,
.nav-backdrop {
  display: none;
}
.nav-toggle {
  width: 44px;
  height: 44px;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.mobile-brand {
  display: flex;
  align-items: center;
  min-width: 0;
}
.mobile-brand img {
  height: 44px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
}
.nav-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 960px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header-actions { justify-content: flex-start; }
  .filter-bar .form-row { min-width: 100%; flex: 1 1 100%; }
  .main { padding: 16px 14px 32px; }
}

@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 40;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 64px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
  }
  .nav-toggle { display: flex; }
  .nav-close { display: grid; place-items: center; }
  body.nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.45);
  }
  .shell { display: block; min-height: auto; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.18);
  }
  .sidebar .brand-wrap { position: relative; padding-top: 18px; }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { transform: none; }
  .sidebar a.nav-link {
    min-height: 44px;
    padding: 12px 12px;
  }
  .sidebar a.nav-link.active::before { display: none; }
  .btn, .btn-sm {
    min-height: 40px;
  }
}

@media (max-width: 860px) {
  .page-header h1, h1 { font-size: 1.4rem; }
  .panel { overflow: visible; }
  .shell table thead { display: none; }
  .shell table,
  .shell table tbody,
  .shell table tr,
  .shell table td {
    display: block;
    width: 100%;
  }
  .shell table tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .shell table tr:last-child { border-bottom: none; }
  .shell table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 7px 0;
    border-bottom: none;
    text-align: right;
    white-space: normal;
    word-break: break-word;
    font-size: 0.92rem;
  }
  .shell table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 34%;
    max-width: 38%;
  }
  .shell table td[colspan] {
    display: block;
    text-align: left;
  }
  .shell table td[colspan]::before { content: none; }
  .mono, .link-id { overflow-wrap: anywhere; word-break: break-all; }
  .card, .panel { padding-left: 14px; padding-right: 14px; }
  .panel { padding: 0; }

  /* Signups: compact cards, not label/value stacks. */
  .shell table.leads-overview thead { display: none; }
  .shell table.leads-overview,
  .shell table.leads-overview tbody {
    display: block;
    width: 100%;
  }
  .shell table.leads-overview tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "id when status"
      "contact contact contact"
      "company company company"
      "services services services";
    gap: 2px 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    align-items: start;
  }
  .shell table.leads-overview td {
    display: block;
    width: auto;
    padding: 0;
    border-bottom: none;
    text-align: left;
    justify-content: unset;
    align-items: unset;
    gap: 0;
    white-space: normal;
    word-break: break-word;
  }
  .shell table.leads-overview td::before {
    content: none !important;
    display: none !important;
  }
  .shell table.leads-overview .leads-id { grid-area: id; padding-top: 2px; }
  .shell table.leads-overview .leads-when { grid-area: when; }
  .shell table.leads-overview .leads-when strong { display: inline; font-weight: 650; }
  .shell table.leads-overview .leads-when .muted { display: inline; margin-left: 6px; }
  .shell table.leads-overview .leads-status { grid-area: status; justify-self: end; min-width: 118px; }
  .shell table.leads-overview .leads-contact { grid-area: contact; margin-top: 8px; }
  .shell table.leads-overview .leads-company { grid-area: company; }
  .shell table.leads-overview .leads-services { grid-area: services; margin-top: 4px; }
  .shell table.leads-overview td[colspan] {
    grid-column: 1 / -1;
    display: block;
    text-align: left;
    padding: 24px 0;
  }
  .shell table.leads-overview .leads-status .badge { display: none; }
  .shell table.leads-overview .leads-status form { margin-top: 0; min-width: 0; }
  .shell table.leads-overview .leads-contact a { word-break: break-all; }
}

.leads-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.leads-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
}
.leads-stat:hover { border-color: #111; }
.leads-stat.is-active {
  border-color: #111;
  background: #111;
  color: #fff;
}
.leads-stat-n { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.leads-stat-l { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.7; }
.leads-stat.is-active .leads-stat-l { opacity: 0.85; color: #fff; }
.leads-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.leads-filters input[type="search"] { flex: 1; margin: 0; }
.leads-filters .btn { width: auto; flex: 0 0 auto; }
.leads-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.leads-overview { width: 100%; }
table.leads-overview th { white-space: nowrap; }
table.leads-overview td { vertical-align: top; }
.leads-id { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 650; }
.leads-when { white-space: nowrap; }
.leads-when strong,
.leads-contact strong,
.leads-company strong { display: block; }
.leads-company .muted { display: block; }
.leads-contact a,
.leads-site {
  display: block;
  color: #2563EB;
  text-decoration: none;
  font-size: 0.82rem;
}
.leads-contact a:hover,
.leads-site:hover { text-decoration: underline; }
.leads-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.leads-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #F4F4F5;
  font-size: 0.72rem;
  font-weight: 600;
}
.leads-meta { margin-top: 4px; font-size: 0.78rem; color: var(--muted); }
.leads-status form { margin-top: 8px; min-width: 120px; }
.leads-status select { min-height: 36px; padding: 6px 8px; }

@media (max-width: 700px) {
  .leads-stats {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
  }
  .leads-stat {
    flex: 0 0 auto;
    min-width: 92px;
    padding: 10px 12px;
  }
}
