:root {
  --line: #e4e4e4;
  --text: #141414;
  --muted: #555;
  --green: #08b56c;
  --green-dark: #0aa16d;
  --green-soft: #f6fff9;
  --max: 1200px;
  --radius: 10px;
  --font-heading: 'Outfit', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
  --danger: #c0392b;
  --danger-bg: #fff5f5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: #fff;
  min-height: 100vh;
}

a {
  color: var(--green-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* —— Auth shell —— */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(8, 181, 108, 0.12), transparent 60%),
    linear-gradient(180deg, var(--green-soft) 0%, #fff 42%);
}

.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--green-dark);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 18px;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.auth-top-meta {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 500;
}

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1rem;
}

.auth-card {
  width: min(100%, 400px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.35rem 1.2rem;
}

.auth-card h1 {
  font-size: 22px;
  margin-bottom: 0.2rem;
}

.auth-card .sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 1.1rem;
}

.auth-foot {
  padding: 0.9rem 1.25rem 1.15rem;
  text-align: center;
}

.auth-foot .rails {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.85rem 1.1rem;
  margin-bottom: 0.75rem;
  opacity: 0.55;
  filter: grayscale(1);
}

.auth-foot .rails img {
  height: 22px;
  width: auto;
}

.auth-foot .copy {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}

/* —— Forms —— */
.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.form-group input,
.form-group select {
  width: 100%;
  height: 40px;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #fff;
  outline: none;
  resize: vertical;
  line-height: 1.45;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 181, 108, 0.18);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.15rem 0 0.95rem;
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 40px;
  padding: 0 1.15rem;
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: var(--green-dark);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  height: auto;
  padding: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 500;
}

.btn-ghost:hover {
  color: var(--green-dark);
}

.alert {
  font-size: 12px;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  margin-bottom: 0.85rem;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f5c6c6;
}

.alert-ok {
  background: rgba(8, 181, 108, 0.1);
  color: var(--green-dark);
  border: 1px solid rgba(8, 181, 108, 0.25);
}

.otp-input {
  letter-spacing: 0.35em;
  text-align: center;
  font-size: 18px !important;
  font-weight: 600;
  font-family: var(--font-heading);
}

.hint {
  font-size: 11px;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

/* —— App shell (dashboard) —— */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  background: #f7f8f9;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--green-dark);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 16px;
  text-decoration: none;
}

.sidebar-brand:hover {
  text-decoration: none;
}

.sidebar-brand img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.sidebar-nav {
  padding: 0.65rem 0.55rem;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  font-weight: 600;
  padding: 0.55rem 0.55rem 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-link:hover {
  background: var(--green-soft);
  color: var(--green-dark);
  text-decoration: none;
}

.nav-link.active {
  background: rgba(8, 181, 108, 0.12);
  color: var(--green-dark);
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 0.75rem 0.9rem;
  font-size: 11px;
  color: var(--muted);
}

.sidebar-foot strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
}

.icon-btn:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.content {
  padding: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.stats-status {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
}

.stat-ok {
  border-color: rgba(8, 181, 108, 0.28);
  background: linear-gradient(180deg, #f6fff9 0%, #fff 70%);
}

.stat-pending {
  border-color: #f0e0b8;
  background: linear-gradient(180deg, #fffaf0 0%, #fff 70%);
}

.stat-fail {
  border-color: #f5c6c6;
  background: linear-gradient(180deg, #fff5f5 0%, #fff 70%);
}

.dash-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.dash-filter {
  position: sticky;
  top: 3.6rem;
}

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border: 1px solid transparent;
}

.filter-option:hover {
  background: var(--green-soft);
}

.filter-option:has(input:checked) {
  background: rgba(8, 181, 108, 0.1);
  border-color: rgba(8, 181, 108, 0.25);
  color: var(--green-dark);
}

.filter-option input {
  accent-color: var(--green);
  margin: 0;
}

.filter-custom {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.filter-custom .form-group {
  margin-bottom: 0.5rem;
}

.filter-custom .form-group:last-child {
  margin-bottom: 0;
}

.filter-custom input[type="date"] {
  height: 36px;
  font-size: 12px;
}

.stat .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.stat .value {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  margin-top: 0.2rem;
  letter-spacing: -0.02em;
}

.stat .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 0.15rem;
}

.stat .meta.up {
  color: var(--green-dark);
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 13px;
  font-weight: 600;
}

.panel-body {
  padding: 0.75rem 0.9rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.65rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.data th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  background: #f8f8f8;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

table.data td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chip-ok {
  background: rgba(8, 181, 108, 0.12);
  color: var(--green-dark);
}

.chip-pending {
  background: #fff8e8;
  color: #a67c00;
}

.chip-fail {
  background: var(--danger-bg);
  color: var(--danger);
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.channel-badge--text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.channel-logo {
  width: auto;
  display: block;
  object-fit: contain;
  object-position: left center;
}

.channel-logo--md {
  height: 22px;
  max-width: 96px;
}

.channel-logo--sm {
  height: 18px;
  max-width: 80px;
}

.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
}

.channel-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.channel-row:first-child {
  padding-top: 0;
}

.channel-row strong {
  font-family: var(--font-heading);
  font-weight: 600;
  white-space: nowrap;
}

/* —— Integration guide —— */
.integ-mode,
.integ-platform {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.integ-mode-btn,
.integ-plat-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
}

.integ-mode-btn.active,
.integ-plat-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.integ-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 0.65rem;
}

.integ-banner strong {
  display: block;
  font-size: 13px;
  margin-bottom: 0.15rem;
}

.integ-banner p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.integ-banner--sandbox {
  background: #fffaf0;
  border-color: #f0e0b8;
}

.integ-banner--live {
  background: var(--green-soft);
  border-color: rgba(8, 181, 108, 0.3);
}

.integ-lead {
  margin: 0 0 0.65rem;
  font-size: 12.5px;
  color: var(--muted);
}

.integ-steps {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 12.5px;
  color: var(--text);
}

.integ-steps li {
  margin-bottom: 0.35rem;
}

.integ-check {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 12.5px;
}

.integ-check li {
  margin-bottom: 0.4rem;
}

.integ-guide h3 {
  font-size: 12.5px;
  margin: 1rem 0 0.4rem;
}

.integ-guide h3:first-child {
  margin-top: 0;
}

.integ-guide p {
  margin: 0 0 0.5rem;
  font-size: 12.5px;
  color: var(--muted);
}

.integ-guide .hint {
  margin-bottom: 0.5rem;
}

.integ-guide textarea,
.integ-creds textarea {
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
}

.code-block {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.85rem;
  background: #0f1419;
  color: #e8eef4;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.55;
}

.code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.panel-body code,
.integ-lead code,
.integ-steps code,
.integ-check code,
.hint code {
  background: #f3f3f3;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

.code-block code {
  background: transparent;
  padding: 0;
}

/* —— Modal —— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.45);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-lg {
  width: min(560px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 14px;
}

.modal-body {
  padding: 0.85rem 0.9rem 1rem;
  max-height: min(78vh, 640px);
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.access-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
}

.access-item:hover {
  border-color: rgba(8, 181, 108, 0.35);
  background: var(--green-soft);
}

.access-item:has(input:checked) {
  border-color: rgba(8, 181, 108, 0.4);
  background: rgba(8, 181, 108, 0.08);
  color: var(--green-dark);
}

.access-item input {
  accent-color: var(--green);
  margin: 0;
}

.perm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.perm-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: #f3f3f3;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}

/* —— Toggle switch —— */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: #d8d8d8;
  border-radius: 999px;
  transition: background 0.15s;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.switch input:checked + .switch-slider {
  background: var(--green);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

/* —— API key field —— */
.key-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.key-field input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.mobile-nav-toggle {
  display: none;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 960px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-status {
    grid-template-columns: 1fr;
  }
  .dash-layout {
    grid-template-columns: 1fr;
  }
  .dash-filter {
    position: static;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .access-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(82vw, 260px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  .auth-card {
    padding: 1.15rem;
  }

  .auth-card h1 {
    font-size: 20px;
  }

  .content {
    padding: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
