:root {
  /* Brand palette - hard-coded, not user-configurable */
  --brand-green: #22c55e;
  --brand-teal: #128c7e;
  --brand-gradient: linear-gradient(to right, var(--brand-green), var(--brand-teal));
  --brand-gradient-hover: linear-gradient(135deg, var(--brand-green), var(--brand-teal));

  --primary: #22c55e;
  --primary-dark: #4ade80;
  --primary-light: #16a34a;
  --primary-bg: #0d2818;
  --primary-bg-dark: #0a1f13;
  --accent: #22c55e;
  --accent-rgb: 34, 197, 94;
  --text-primary: #e2e8f0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --bg: #080c10;
  --bg-white: #0c1018;
  --bg-dropdown: #0d1219;
  --bg-input: #0f0f23;
  --border: rgba(255, 255, 255, .08);
  --border-light: rgba(255, 255, 255, .04);
  --danger: #f87171;
  --danger-dark: #ef4444;
  --warning: #fbbf24;
  --success: #22c55e;
  --shadow: none;
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --overlay-bg: rgba(4, 6, 8, .92);
  --code-bg: #0a0e14;
  --glow-rgb: 34, 197, 94;
  --glow-size: 400px;
  --glow: #22c55e;
  --bg-card: #0c1018;
}

[data-theme="light"] {
  --radius-md: 10px;
  /* Brand palette - same green→teal in both themes (hard-coded) */
  --brand-green: #22c55e;
  --brand-teal: #128c7e;
  --brand-gradient: linear-gradient(to right, var(--brand-green), var(--brand-teal));
  --brand-gradient-hover: linear-gradient(135deg, var(--brand-green), var(--brand-teal));
  --glow: #22c55e;
  --accent: #16a34a;
  --accent-rgb: 22, 163, 74;
  --bg-card: #ffffff;
  --primary: #22c55e;
  --primary-dark: #16a34a;
  --primary-light: #4ade80;
  --primary-bg: #dcfce7;
  --primary-bg-dark: #f0fdf4;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg: #f9fafb;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --overlay-bg: rgba(0, 0, 0, 0.5);
  --code-bg: #f3f4f6;
  --glow-rgb: 34, 197, 94;
  --glow-size: 400px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.hidden {
  display: none !important;
}

/* ===== LOGIN / AUTH PAGES (centered) ===== */
#login-page,
#admin-login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(var(--glow-rgb), .08) 0%, var(--bg) 60%);
  padding: 16px;
  box-sizing: border-box;
}

[data-theme="light"] #login-page,
[data-theme="light"] #admin-login-page {
  background: linear-gradient(135deg, var(--primary-bg-dark) 0%, var(--primary-bg) 50%, #bbf7d0 100%);
}

.login-container {
  position: relative;
  z-index: 0;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px 22px 20px;
  width: 100%;
  max-width: 360px;
  transition: background-color 0.3s ease;
  overflow: visible;
}

.login-header {
  text-align: center;
  margin-bottom: 14px;
}

.logo {
  display: flex;
  justify-content: center;
  margin-bottom: 2px;
}

.logo-img {
  height: 28px;
  width: 28px;
  vertical-align: middle;
}

.login-header h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent, var(--primary));
  margin: 0;
}

.login-header p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 17px;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg-white);
  color: var(--text-primary);
  transition: all 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-group small {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
}

.btn-primary {
  background: var(--brand-gradient);
  color: white;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

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

.btn-small {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}
.btn-icon-circle:hover { background: var(--primary-dark); }
.btn-icon-circle:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-icon-circle.btn-outline-circle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px;
  width: 32px;
  height: 32px;
}
.btn-icon-circle.btn-outline-circle:hover { background: var(--bg); }

/* Button loading spinner — applied when async operation is in progress */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  opacity: 0.7;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  top: calc(50% - 9px);
  left: calc(50% - 9px);
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.error-message {
  background: #1a0f0f;
  border: 1px solid #7f1d1d;
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-top: 16px;
}

[data-theme="light"] .error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* ===== SIDEBAR LAYOUT ===== */
#dashboard-page {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  font-size: 20px;
  font-weight: 700;
  border-bottom: none;
}

/* "RexWapi" brand text in sidebar - green→teal gradient */
.sidebar-brand > span:not(.sidebar-brand-logo) {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Logo mark uses SVG silhouette + CSS accent (tracks --primary / --accent) */
.sidebar-brand-logo,
.brand-logo-mark {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--brand-gradient);
  -webkit-mask: url('assets/logo.svg') no-repeat center / contain;
  mask: url('assets/logo.svg') no-repeat center / contain;
}

.brand-logo-mark--lg {
  width: 44px;
  height: 44px;
}

.brand-logo-mark--compact {
  width: 28px;
  height: 28px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}

.sidebar-item:hover {
  background: var(--primary-bg-dark);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(var(--glow-rgb, 34, 197, 94), 0.3);
}

.sidebar-item.active svg {
  color: #fff;
}

.sidebar-item svg {
  flex-shrink: 0;
}

.sidebar-item-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar-item-coming {
  opacity: 0.55;
}

.sidebar-item-coming:hover {
  background: transparent;
  color: var(--text-secondary);
}

.sidebar-item-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  pointer-events: none;
  white-space: nowrap;
  text-transform: none;
}

.sidebar-footer {
  padding: 12px 8px 16px;
  border-top: none;
}

/* Gradient text - used for profile "Total Paid" amounts, pricing tier prices, etc. */
.tier-price-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  display: inline-block;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  z-index: 199;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s ease, backdrop-filter 0.3s ease;
  background-color: rgba(4, 6, 8, 0.55);
  backdrop-filter: saturate(220%) blur(60px);
  -webkit-backdrop-filter: saturate(220%) blur(60px);
  border-bottom: none;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(var(--glow-rgb), 0.2) 10%, rgba(var(--glow-rgb), 0.5) 50%, rgba(var(--glow-rgb), 0.2) 90%, transparent 100%);
  pointer-events: none;
}

[data-theme="light"] .topbar {
  background-color: rgba(255, 255, 255, 0.65);
  backdrop-filter: saturate(200%) blur(60px);
  -webkit-backdrop-filter: saturate(200%) blur(60px);
}

[data-theme="light"] .topbar::after {
  background: linear-gradient(90deg, transparent 0%, rgba(34, 197, 94, 0.3) 10%, rgba(34, 197, 94, 0.6) 50%, rgba(34, 197, 94, 0.3) 90%, transparent 100%);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.section-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.hamburger-btn {
  display: none;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.topbar-user {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.icon-sun {
  display: none;
}

[data-theme="light"] .icon-sun {
  display: block;
}

[data-theme="light"] .icon-moon {
  display: none;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-area {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  width: 100%;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.section-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.section-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== CONTENT SECTIONS ===== */
.content-section {
  display: none;
  animation: sectionFadeIn 0.3s ease;
}

.content-section.active {
  display: block;
}

@keyframes sectionFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
  }
}

/* ===== USAGE CARDS ===== */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.usage-card,
.card {
  position: relative;
  z-index: 0;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.usage-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.usage-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.usage-arrow {
  font-size: 18px;
  font-weight: 700;
}

.usage-arrow.up {
  color: #22c55e;
}

.usage-arrow.down {
  color: #3b82f6;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.usage-limits {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.progress-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress.warning {
  background: var(--warning);
}

.progress.danger {
  background: var(--danger);
}

.tier-card {
  text-align: center;
  min-height: 210px;
}

.tier-days-left {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.tier-days-left.active {
  color: var(--primary);
  font-weight: 600;
}

.tier-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  text-transform: capitalize;
  margin-bottom: 8px;
}

.tier-info {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== API KEY SECTION ===== */
.api-key-section {
  margin-bottom: 24px;
  padding-top: 12px;
}

.api-key-section h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.api-key-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-key-pw {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
}

.api-key-pw input {
  font-family: monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: default;
  padding: 6px 40px 6px 0;
  background: var(--code-bg) !important;
}

.api-key-pw input:focus {
  outline: none;
}

.api-key-pw .password-toggle {
  cursor: pointer;
}

/* ===== INSTANCES GRID ===== */
.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.instance-card {
  position: relative;
  z-index: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 220px;
  contain: layout style paint;
}

.instance-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.9), rgba(var(--glow-rgb), 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
}

.instance-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.72), transparent) bottom / 100% 1px no-repeat;
}

.instance-card.edge-active::before,
.instance-card:hover::before {
  opacity: 1;
}

.create-instance-card {
  min-height: 220px;
  padding: 20px;
}

[data-theme="light"] .instance-card {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .instance-card::before {
  display: block;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(34, 197, 94, 0.7), rgba(34, 197, 94, 0) 60%);
}

[data-theme="light"] .instance-card::after {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent) bottom / 100% 1px no-repeat;
}

.instance-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.instance-name {
  font-size: 16px;
  font-weight: 600;
}

.instance-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.icon-btn-danger {
  color: var(--danger);
}
.icon-btn-danger:hover {
  background: #2d1515;
  color: var(--danger);
}

[data-theme="light"] .icon-btn-danger:hover {
  background: #fef2f2;
  color: var(--danger);
}

/* Instance ID display */
.instance-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.instance-id-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.instance-id-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--primary-dark);
  background: var(--primary-bg);
  padding: 3px 10px;
  border-radius: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-id-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.copy-id-btn:hover {
  background: var(--border-light);
  color: var(--primary);
}

.copy-id-btn.copied {
  color: var(--primary);
}

/* API Endpoints in card */
.instance-api-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.instance-api-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.api-endpoint-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
}

.api-endpoint-label {
  color: var(--text-muted);
  min-width: 68px;
  font-weight: 500;
}

.api-endpoint-url {
  flex: 1;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-secondary);
  background: var(--code-bg);
  padding: 3px 8px;
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

/* Instance status */
.instance-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.connected {
  background: var(--success);
}

.status-dot.connecting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.status-dot.disconnected {
  background: var(--danger);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.status-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.instance-phone {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.instance-connect-btn {
  margin-left: auto;
}

.instance-events {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.instance-event-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.instance-event-badge.webhook-badge {
  background: #1e293b;
  color: #60a5fa;
}

[data-theme="light"] .instance-event-badge.webhook-badge {
  background: #eff6ff;
  color: #2563eb;
}

.instance-footer {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 16px;
}

.empty-state .sub-text {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ===== SUBSCRIPTION SECTION ===== */
.subscription-plan {
  margin-bottom: 24px;
}

.sub-plan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.sub-plan-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  text-transform: capitalize;
}

.sub-plan-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.sub-plan-price span {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.sub-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sub-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
}

.sub-feature svg {
  color: var(--primary);
  flex-shrink: 0;
}

.tiers-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.tier-card-skeleton {
  border-radius: var(--radius-lg);
  height: 280px;
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .tier-card-skeleton {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.shimmer {
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .shimmer {
  background: linear-gradient(105deg, transparent 30%, rgba(0,0,0,0.04) 50%, transparent 70%);
  background-size: 200% 100%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.plan-shimmer {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 2;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  pointer-events: none;
}

[data-theme="light"] .plan-shimmer {
  background: linear-gradient(105deg, transparent 30%, rgba(0,0,0,0.04) 50%, transparent 70%);
  background-size: 200% 100%;
}

.tier-card-preview {
  position: relative;
  z-index: 0;
  border-radius: var(--radius-lg);
  padding: 1px;
  text-align: center;
  transition: all 0.2s;
  overflow: visible;
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .tier-card-preview {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .tier-card-preview::before {
  display: block !important;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(34, 197, 94, 0.7), rgba(34, 197, 94, 0) 60%);
}

[data-theme="light"] .tier-card-preview:hover {
  border-color: rgba(0, 0, 0, 0.18);
}

.tier-card-preview.featured {
  border-color: var(--primary);
  background: var(--primary-bg-dark);
}

.tier-card-inner {
  position: relative;
  z-index: 1;
  background: var(--bg-white);
  border-radius: calc(var(--radius-lg) - 1px);
  padding: 20px;
  height: 100%;
}

.tier-card-preview h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.tier-price-preview {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.tier-price-preview span {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.tier-card-preview ul {
  list-style: none;
  text-align: left;
  margin: 0;
  padding: 0;
}

.tier-card-preview li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}

/* Glow surface effect for tier cards */
.tier-card-preview::before,
.tier-card-admin::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.9), rgba(var(--glow-rgb), 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
}

.tier-card-admin::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.72), transparent) bottom / 100% 1px no-repeat;
}

.tier-card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.75), transparent) bottom / 100% 1px no-repeat;
}

.tier-card-preview:hover::before,
.tier-card-preview:focus-within::before,
.tier-card-preview.edge-active::before,
.tier-card-admin.edge-active::before,
.tier-card-admin:hover::before {
  opacity: 1;
}

.tier-card-preview:hover::after {
  border-color: rgba(var(--glow-rgb), 0.25);
}

.tier-card-preview.featured::after {
  border-color: rgba(var(--glow-rgb), 0.3);
  background:
    linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.6), transparent) bottom / 100% 1px no-repeat,
    rgba(var(--glow-rgb), 0.04);
}

/* ===== PRICING CARDS (subscription grid) - accent edge + mouse-tracked glow, no hover lift ===== */
.pricing-card {
  position: relative;
  z-index: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 32px 20px 24px;
  display: flex;
  flex-direction: column;
  min-height: 350px;
  overflow: visible;
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  isolation: isolate;
}

/* "Most Popular" pill - straddles the card's top edge (vertical center on the edge) */
.pricing-card > .badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 14px;
  border-radius: 20px;
  background: var(--brand-gradient);
  color: #fff;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(var(--glow-rgb, 34, 197, 94), 0.4);
  white-space: nowrap;
  margin: 0;
  pointer-events: none;
}

/* PROMO pill - amber, top-right corner, drape/flow off the right edge via mask.
   Sits flush against the right border so the rightmost ~20% fades to transparent. */
.pricing-card > .promo-pill {
  position: absolute;
  top: 25px;
  right: 0;
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-top-left-radius: var(--radius-md, 10px);
  border-bottom-left-radius: var(--radius-md, 10px);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
  color: #000;
  z-index: 10;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    -2px 2px 8px rgba(245, 158, 11, 0.4);
  white-space: nowrap;
  max-width: 75%;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 80%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0%, #000 80%, transparent 100%);
}
[data-theme="light"] .pricing-card > .promo-pill {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    -2px 2px 8px rgba(245, 158, 11, 0.5);
}
/* When the PROMO pill is present, push the tier name to the left so the
   "Active" / pill text doesn't collide with the title. */
.pricing-card > .promo-pill ~ .pricing-card-header .tier-name,
.pricing-card > .promo-pill + .tier-name {
  padding-right: 130px;
}

/* Undiscounted price cross-out - sits as a superscript "power" at the
   top-right of the discounted price. -webkit-text-fill-color override
   is required because .tier-price uses gradient text. */
.tier-original-power {
  position: absolute;
  top: -0.6em;
  right: -1.5em;
  font-size: 0.55em;
  font-weight: 600;
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
  text-decoration: line-through;
  white-space: nowrap;
  letter-spacing: 0.2px;
  pointer-events: none;
}
[data-theme="light"] .tier-original-power {
  color: rgba(0, 0, 0, 0.55);
  -webkit-text-fill-color: rgba(0, 0, 0, 0.55);
}

/* User-side promo topbar — sits at the top of the subscription content,
   bleeding up to the bottom of the page header (cancels the .content-area
   padding-top) and dissolving to transparent at the left/right edges
   instead of using border-radius. Mirrors the landing page's .promo-topbar
   look (gradient bg, glow, icon, label, sep, timer). */
.promo-topbar--inline {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  height: auto;
  min-height: 40px;
  /* Bleed past .content-area padding (32px) on all sides; the mask
     dissolves the left/right edges so the bleed looks intentional. */
  margin: -32px -32px 20px;
  padding: 10px 48px;
  border-radius: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 14px rgba(34, 197, 94, 0.25);
  animation: promo-topbar-glow 2.4s ease-in-out infinite;
  /* Fade the left/right edges to transparent (no rounded corners).
     Bar stays full-width; the gradient transition itself spans 20%
     of the bar on each side (0% → 20% fades out, 80% → 100% fades out). */
  -webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.6) 10%, #000 20%, #000 80%, rgba(0, 0, 0, 0.6) 90%, transparent 100%);
          mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.6) 10%, #000 20%, #000 80%, rgba(0, 0, 0, 0.6) 90%, transparent 100%);
}
.promo-topbar--inline .promo-topbar-icon {
  display: inline-flex;
  align-items: center;
  color: #fff;
}
.promo-topbar--inline .promo-topbar-label {
  font-weight: 700;
  color: #fff;
}
.promo-topbar--inline .promo-topbar-sep {
  opacity: 0.7;
  font-weight: 700;
}
.promo-topbar--inline .promo-topbar-timer {
  font-size: 1rem;
  opacity: 0.95;
}
.promo-topbar--inline .promo-topbar-timer strong {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
  color: #fff;
}
.promo-topbar--inline .promo-pct {
  color: #fff;
  font-weight: 900;
}
@keyframes promo-topbar-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 rgba(34, 197, 94, 0); }
  50%      { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 18px rgba(34, 197, 94, 0.35); }
}
@media (max-width: 600px) {
  .promo-topbar--inline {
    font-size: 0.78rem;
    gap: 6px;
    padding: 8px 14px;
    margin: -32px -16px 16px;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  .promo-topbar--inline .promo-topbar-icon { flex-shrink: 0; }
  .promo-topbar--inline .promo-topbar-label {
    font-size: 0.78rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .promo-topbar--inline .promo-topbar-timer,
  .promo-topbar--inline .promo-topbar-timer strong {
    font-size: 0.78rem;
    font-weight: 900;
    margin-left: 2px;
  }
  /* Re-enable the middle dot on mobile and give it the same weight as
     the surrounding text so it doesn't disappear. */
  .promo-topbar--inline .promo-topbar-sep {
    display: inline;
    opacity: 0.85;
    font-weight: 700;
  }
  /* Keep the discount amount bold on mobile. */
  .promo-topbar--inline .promo-pct {
    font-weight: 900;
  }
}

.pricing-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.9), rgba(var(--glow-rgb), 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
}

.pricing-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.85), transparent) bottom / 100% 1px no-repeat;
}

.pricing-card:hover::before,
.pricing-card:focus-within::before,
.pricing-card.edge-active::before {
  opacity: 1;
}

.pricing-card > * {
  position: relative;
  z-index: 1;
}

[data-theme="light"] .pricing-card::after {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent) bottom / 100% 1px no-repeat;
}

[data-theme="light"] .pricing-card::before {
  display: block;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(34, 197, 94, 0.7), rgba(34, 197, 94, 0) 60%);
}

[data-theme="light"] .pricing-card {
  background:
    linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.4), transparent) bottom / 100% 1px no-repeat,
    rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  contain: unset;
}

[data-theme="light"] .pricing-card:hover {
  border-color: rgba(0, 0, 0, 0.18);
}

.pricing-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.active-top-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
  line-height: 1.3;
  margin-top: -6px;
}

.pricing-card .tier-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.pricing-card .tier-price {
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.pricing-card .tier-price span.currency {
  font-size: 1.1rem;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.pricing-card .tier-price span.period {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
}

.tier-discount-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--primary);
  color: #000;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 4px;
  line-height: 1.4;
}

.tier-original-price {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: 4px;
}

.price-row {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.pricing-card .tier-price .total-price {
  font-size: 2rem;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  display: inline-block;
}

.pricing-card .features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
  flex-grow: 1;
}

.pricing-card .features-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.3;
}

.pricing-card .features-list li svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 1px;
}

.pricing-card .card-btn {
  width: 100%;
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  margin-top: auto;
  transition: filter 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  box-shadow: 0 4px 14px rgba(var(--glow-rgb, 34, 197, 94), 0.25);
}

.pricing-card .card-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(var(--glow-rgb, 34, 197, 94), 0.4);
  transform: scale(1.02);
}

.pricing-card .card-btn:disabled {
  background: var(--primary);
  color: #0a0f14;
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
  filter: none;
  transform: none;
}

.pricing-card .card-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[data-theme="light"] .pricing-card .card-btn {
  color: #fff;
}

[data-theme="light"] .pricing-card .card-btn:disabled {
  color: #0a0f14;
}

[data-theme="light"] .pricing-card .card-btn:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(var(--glow-rgb), 0.25);
}

/* ===== DISABLED TIER CARDS & BADGES ===== */
.pricing-card.disabled {
  opacity: 0.55;
  pointer-events: none;
}
.pricing-card.disabled .manage-btn {
  pointer-events: auto;
  opacity: 1;
}

.pricing-card .tier-status-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  padding: 4px 10px;
  border-radius: 20px;
  text-align: center;
  margin-bottom: 8px;
}
.pricing-card .badge-active {
  background: rgba(34,197,94,.15);
  color: #22c55e;
}
.pricing-card .badge-locked {
  background: rgba(148,163,184,.15);
  color: #94a3b8;
}
.pricing-card .badge-renew-soon {
  background: rgba(251,191,36,.15);
  color: #fbbf24;
}
.pricing-card .badge-switch {
  background: rgba(99,102,241,.15);
  color: #818cf8;
}
.pricing-card .manage-btn {
  background: linear-gradient(135deg, rgba(99,102,241,.18) 0%, rgba(139,92,246,.18) 100%);
  color: #a5b4fc;
  border: 1px solid rgba(139,92,246,.35);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(139,92,246,.15), 0 2px 8px rgba(99,102,241,.12);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 13px;
}
.pricing-card .manage-btn:hover {
  background: linear-gradient(135deg, rgba(99,102,241,.28) 0%, rgba(139,92,246,.28) 100%);
  border-color: rgba(139,92,246,.5);
  box-shadow: 0 0 0 1px rgba(139,92,246,.25), 0 4px 12px rgba(99,102,241,.2);
  transform: translateY(-1px);
}
.pricing-card .manage-btn:active {
  transform: translateY(0);
}
[data-theme="light"] .pricing-card .manage-btn {
  background: linear-gradient(135deg, rgba(99,102,241,.1) 0%, rgba(139,92,246,.1) 100%);
  color: #6366f1;
  border-color: rgba(99,102,241,.3);
  box-shadow: 0 0 0 1px rgba(99,102,241,.12), 0 2px 6px rgba(99,102,241,.08);
}
[data-theme="light"] .pricing-card .manage-btn:hover {
  background: linear-gradient(135deg, rgba(99,102,241,.18) 0%, rgba(139,92,246,.18) 100%);
  border-color: rgba(99,102,241,.45);
  box-shadow: 0 0 0 1px rgba(99,102,241,.22), 0 4px 10px rgba(99,102,241,.15);
}

/* ===== PROFILE SECTION ===== */
.profile-info {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.profile-field:last-of-type {
  margin-bottom: 0;
}

.profile-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.profile-field span {
  font-size: 14px;
  color: var(--text-primary);
}

.profile-api-key {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-api-key code {
  padding: 4px 10px;
  background: var(--code-bg);
  border-radius: 4px;
  font-size: 12px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Components: modal.css, toggle.css (extracted) */

/* ===== USAGE CHART ===== */
.usage-chart {
  display: flex;
  flex-direction: column;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  justify-content: center;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.chart-bars-container {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 130px;
  padding: 8px 0;
  overflow-x: auto;
}

.chart-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 20px;
  flex: 1;
}

.chart-bars {
  display: flex;
  gap: 1px;
  align-items: flex-end;
  height: 120px;
}

.chart-bar {
  width: 8px;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}

.chart-bar.sent {
  background: var(--primary);
}

.chart-bar.received {
  background: var(--warning);
}

.chart-label {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
}

/* Components: toast.css, confirm-dialog.css (extracted) */

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger-btn {
    display: flex;
  }

  .content-area {
    padding: 20px 16px;
  }

  .section-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .usage-grid {
    grid-template-columns: 1fr;
  }

  .instances-grid {
    grid-template-columns: 1fr;
  }

  .tiers-overview {
    grid-template-columns: 1fr;
    max-width: 380px;
  }

  .topbar-user {
    display: none;
  }


  .profile-api-key {
    width: 100%;
  }

  .profile-api-key code {
    max-width: 200px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 60px;
    overflow: hidden;
  }
  .sidebar.expanded {
    width: 180px;
  }
  .sidebar .sidebar-brand {
    padding: 20px 14px 16px;
    justify-content: center;
  }
  .sidebar.expanded .sidebar-brand {
    padding: 20px 20px 16px;
    justify-content: flex-start;
  }
  .sidebar .sidebar-brand span:not(.sidebar-brand-logo) {
    display: none;
  }
  .sidebar.expanded .sidebar-brand span:not(.sidebar-brand-logo) {
    display: inline;
  }
  .sidebar .sidebar-item span {
    display: none;
  }
  .sidebar.expanded .sidebar-item span {
    display: inline;
  }
  .sidebar .sidebar-item {
    justify-content: center;
    padding: 10px 0;
  }
  .sidebar.expanded .sidebar-item {
    justify-content: flex-start;
    padding: 10px 16px;
  }
  .sidebar .sidebar-footer .sidebar-item span {
    display: none;
  }
  .sidebar.expanded .sidebar-footer .sidebar-item span {
    display: inline;
  }
  .main-content {
    margin-left: 60px;
  }
  .sidebar.expanded ~ .main-content {
    margin-left: 180px;
  }
  .hamburger-btn {
    display: flex;
  }
}

@media (min-width: 769px) {
  .sidebar-overlay {
    display: none !important;
  }
}

/* ===== INSTANCE SETTINGS PAGE ===== */
.section-header-back {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.settings-tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-tab:hover {
  color: var(--text-primary);
}

.settings-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.settings-tab-content {
  display: none;
  animation: sectionFadeIn 0.3s ease;
}

.settings-tab-content.active {
  display: block;
}

.copy-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-field code {
  padding: 8px 14px;
  background: var(--code-bg);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--primary-dark);
  font-family: 'SF Mono', 'Fira Code', monospace;
  word-break: break-all;
}

.text-muted {
  color: var(--text-muted);
  font-size: 14px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row-item {
  flex: 1;
}

.pm-field {
  margin-bottom: 16px;
}

.danger-zone-card {
  border-color: var(--danger);
}

.danger-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: none;
}

.danger-action:last-child {
  border-bottom: none;
}

.danger-action strong {
  font-size: 14px;
  color: var(--text-primary);
}

/* ===== INSTANCE STATS ROW ===== */
.instance-stats-row {
  display: flex;
  gap: 16px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== AUTOMATION SECTION ===== */
.automation-intro {
  margin-bottom: 24px;
}

.automation-intro p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.automation-intro code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  color: var(--primary-dark);
}

.automation-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 20px;
}

.automation-action-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.automation-code-block {
  position: relative;
  z-index: 0;
  background: rgba(15, 18, 28, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg, 12px);
  padding: 16px;
  padding-right: 48px;
  overflow-x: auto;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  contain: layout style paint;
  transition: border-color 0.2s ease;
}

.automation-code-block::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
  border-radius: var(--radius-lg, 12px);
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.9), rgba(var(--glow-rgb), 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
}

.automation-code-block::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg, 12px);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.72), transparent) bottom / 100% 1px no-repeat;
}

.automation-code-block:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.automation-code-block.edge-active::before,
.automation-code-block:hover::before {
  opacity: 1;
}

.automation-code-block code {
  display: block;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-height: 20px;
}

.automation-code-block .icon-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* ===== EYE TOGGLE ===== */
.icon-eye-off.hidden {
  display: none;
}

.icon-eye.hidden {
  display: none;
}

/* ===== PROFILE EDIT ===== */
.profile-edit {
  padding: 24px;
}


.profile-form-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .automation-actions-grid {
    grid-template-columns: 1fr;
  }

  .danger-action {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .settings-tabs {
    overflow-x: auto;
  }
}

/* ===== ADMIN PAGE ===== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s ease;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: var(--primary-bg-dark);
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.dashboard-content {
  padding: 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.admin-section {
  animation: sectionFadeIn 0.3s ease;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

/* ── Revenue & Profit Table ── */
.stat-card.rev-table-card {
  display: block;
  padding: 16px;
  overflow-x: auto;
}
.rev-table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.rev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rev-table thead th {
  padding: 12px 8px 6px;
  text-align: right;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.rev-table thead th:first-child {
  text-align: left;
  width: 100px;
}
.rev-table thead th:last-child {
  width: 36px;
}
.rev-hdr small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
  text-transform: none;
}
.rev-table tbody td {
  padding: 10px 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border);
}
.rev-table tbody tr:last-child td {
  border-bottom: none;
}
.rev-period {
  text-align: left !important;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}
.rev-val span {
  font-weight: 700;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-muted);
}
.rev-profit span {
  color: var(--primary);
}
.rev-edit-cell {
  text-align: center !important;
  padding: 4px !important;
}
.rev-edit-cell button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.2s;
}
.rev-edit-cell button:hover {
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--glow);
}

.stat-card {
  position: relative;
  z-index: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background-color 0.3s ease;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.stat-card .stat-icon.connected {
  background: #0d2818;
}

[data-theme="light"] .stat-card .stat-icon.connected {
  background: #dcfce7;
}

.stat-card .stat-info {
  display: flex;
  flex-direction: column;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

#dash-revenue-edit-btn:hover {
  color: var(--primary) !important;
}

.table-container {
  position: relative;
  z-index: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  transition: background-color 0.3s ease;
  contain: layout style paint;
}

.table-container::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.9), rgba(var(--glow-rgb), 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
}

.table-container::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.78), transparent) bottom / 100% 1px no-repeat;
}

.table-container:hover::before,
.table-container.edge-active::before {
  opacity: 1;
}

[data-theme="light"] .table-container {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .table-container::before {
  display: block;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(34, 197, 94, 0.7), rgba(34, 197, 94, 0) 60%);
}

[data-theme="light"] .table-container::after {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent) bottom / 100% 1px no-repeat;
}

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

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--primary-bg-dark);
}

.table-actions {
  display: flex;
  gap: 6px;
}

.status-badge-table {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge-table.active {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.status-badge-table.inactive {
  background: #2d1515;
  color: #f87171;
}

[data-theme="light"] .status-badge-table.inactive {
  background: #fee2e2;
  color: #dc2626;
}

.status-badge-table.trial {
  background: rgba(20, 184, 166, 0.18);
  color: #5eead4;
}

[data-theme="light"] .status-badge-table.trial {
  background: rgba(20, 184, 166, 0.18);
  color: #0f766e;
}

.status-badge-table.pending {
  background: rgba(234, 179, 8, 0.18);
  color: #fde047;
}

[data-theme="light"] .status-badge-table.pending {
  background: rgba(234, 179, 8, 0.2);
  color: #b45309;
}

.tiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.tier-card-admin {
  position: relative;
  z-index: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.tier-card-admin.featured {
  border-color: var(--primary);
  background: rgba(15, 18, 28, 0.7);
}

[data-theme="light"] .tier-card-admin {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .tier-card-admin.featured {
  background: rgba(220, 252, 231, 0.6);
  border-color: rgba(34, 197, 94, 0.4);
}

.tier-card-admin .tier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.tier-card-admin .tier-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}

.tier-card-admin .tier-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.tier-card-admin .tier-price span {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.tier-card-admin .tier-features {
  list-style: none;
  margin-bottom: 16px;
}

.tier-card-admin .tier-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.tier-card-admin .tier-features svg {
  color: var(--primary);
  flex-shrink: 0;
}

.tier-card-admin .tier-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  justify-content: flex-end;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.health-card {
  position: relative;
  z-index: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: background-color 0.3s ease;
}

.health-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.health-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.health-status.success {
  color: var(--success);
}

.health-status.error {
  color: var(--danger);
}

.health-url {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-secondary);
}

.stats-item strong {
  color: var(--text-primary);
}

.user-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}

.detail-label {
  font-size: 13px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 13px;
  color: var(--text-primary);
}

.detail-value.code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: var(--code-bg);
  padding: 2px 8px;
  border-radius: 4px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instances-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instance-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius);
}

.instance-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.instance-item-name {
  font-size: 14px;
  font-weight: 500;
}

.instance-item-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.instance-item-status.disconnected {
  background: #2d1515;
  color: #f87171;
}

[data-theme="light"] .instance-item-status.disconnected {
  background: #fee2e2;
  color: #dc2626;
}

.back-link {
  text-align: center;
  margin-top: 16px;
}

.back-link a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}

.back-link a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 12px;
    gap: 8px;
  }

  .nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .dashboard-content {
    padding: 16px;
  }

  .user-detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .table-actions {
    flex-direction: column;
  }
}


.section-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0 16px;
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-divider-text {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ===== GLOW SYSTEM (Default Dark) ===== */

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .06);
  border-radius: 10px;
}

:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .14);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .06) transparent;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .12);
}

[data-theme="light"] :hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .2);
}

[data-theme="light"] * {
  scrollbar-color: rgba(0, 0, 0, .12) transparent;
}

.card,
.usage-card {
  position: relative;
  z-index: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  contain: layout style paint;
}

.card::before,
.usage-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.9), rgba(var(--glow-rgb), 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
}

.card::after,
.usage-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.78), transparent) bottom / 100% 1px no-repeat;
}

.card:hover::before,
.usage-card:hover::before,
.card.edge-active::before,
.usage-card.edge-active::before {
  opacity: 1;
}

[data-theme="light"] .card,
[data-theme="light"] .usage-card {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .card::before,
[data-theme="light"] .usage-card::before {
  display: block;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(34, 197, 94, 0.7), rgba(34, 197, 94, 0) 60%);
}

[data-theme="light"] .card::after,
[data-theme="light"] .usage-card::after {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent) bottom / 100% 1px no-repeat;
}

/* ===== STAT CARD (user dashboard) ===== */
.stat-card {
  position: relative;
  z-index: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  contain: layout style paint;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  transition: background-color 0.3s ease;
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.9), rgba(var(--glow-rgb), 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.78), transparent) bottom / 100% 1px no-repeat;
}

.stat-card:hover::before,
.stat-card.edge-active::before {
  opacity: 1;
}

[data-theme="light"] .stat-card {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .stat-card::before {
  display: block;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(34, 197, 94, 0.7), rgba(34, 197, 94, 0) 60%);
}

[data-theme="light"] .stat-card::after {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent) bottom / 100% 1px no-repeat;
}

.form-group input,
.form-group select {
  background: #0a0e14;
  border-color: rgba(255, 255, 255, .08);
  transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: rgba(var(--glow-rgb), .4);
  box-shadow: 0 0 0 3px rgba(var(--glow-rgb), .08);
}

[data-theme="light"] .form-group input,
[data-theme="light"] .form-group select {
  background: var(--bg-white);
  border-color: var(--border);
}

[data-theme="light"] .form-group input:focus,
[data-theme="light"] .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.btn-outline {
  border-color: rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .02);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(var(--glow-rgb), .3);
}

[data-theme="light"] .btn-outline {
  background: transparent;
  border-color: var(--border);
}

[data-theme="light"] .btn-outline:hover {
  background: var(--bg);
  border-color: var(--border);
}

.sidebar {
  background: rgba(255, 255, 255, .04);
  border-right-color: rgba(255, 255, 255, 0.1);
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, .06);
}

.sidebar-item.active {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--glow-rgb, 34, 197, 94), 0.3);
}

[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.65);
  border-right-color: rgba(0, 0, 0, 0.08);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .sidebar-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .sidebar-item.active {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--glow-rgb, 34, 197, 94), 0.35);
}

.login-container {
  background:
    linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.5), transparent) bottom / 100% 1px no-repeat,
    var(--bg-white);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .login-container {
  background:
    linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent) bottom / 100% 1px no-repeat,
    var(--bg-white);
  box-shadow: var(--shadow-lg);
}

/* SPA show/hide login: paint containment traps a stale Chrome autofill overlay */
#login-page .login-container.glow-surface,
#admin-login-page .login-container.glow-surface {
  contain: layout;
}

/* Reusable glow frame (mouse tracking via --gx / --gy from JS; matches ui.html glow-target) */
.glow-surface,
.glow-target {
  position: relative;
  z-index: 0;
  contain: layout style paint;
}

.glow-surface::before,
.glow-target::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -2;
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(var(--glow-size, 420px) circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.35), transparent 40%);
}

.glow-surface::after,
.glow-target::after {
  content: '';
  position: absolute;
  inset: 1px;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background: var(--bg-white);
}

.glow-surface:hover::before,
.glow-surface:focus-within::before,
.glow-target:hover::before,
.glow-target:focus-within::before {
  opacity: 1;
}

[data-theme="light"] .glow-surface,
[data-theme="light"] .glow-target {
  contain: unset;
}

[data-theme="light"] .glow-surface::before,
[data-theme="light"] .glow-surface::after,
[data-theme="light"] .glow-target::before,
[data-theme="light"] .glow-target::after {
  display: none;
}

.form-group.glow-surface::after {
  background: transparent;
}

.form-group.glow-surface {
  padding: 1px;
  border-radius: var(--radius);
}

.form-group.glow-surface>input,
.form-group.glow-surface>select,
.form-group.glow-surface>textarea {
  position: relative;
  z-index: 1;
}

.tier-card-preview.glow-surface>* {
  position: relative;
  z-index: 1;
}

.settings-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.data-table th {
  background: rgba(255, 255, 255, .02);
  border-bottom-color: rgba(255, 255, 255, .06);
}

.data-table td {
  border-bottom-color: rgba(255, 255, 255, .03);
}

[data-theme="light"] .data-table th {
  background: var(--bg);
  border-bottom-color: var(--border);
}

[data-theme="light"] .data-table td {
  border-bottom-color: var(--border-light);
}

.tier-card-admin {
  border-color: rgba(255, 255, 255, .08);
  background:
    linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.75), transparent) bottom / 100% 1px no-repeat,
    var(--bg-white);
}

.tier-card-admin.featured {
  border-color: rgba(var(--glow-rgb), .3);
}

[data-theme="light"] .tier-card-admin {
  background: var(--bg-white);
  border-color: var(--border);
}

[data-theme="light"] .tier-card-admin.featured {
  border-color: var(--primary);
  background: var(--primary-bg-dark);
}

.health-card {
  border-color: rgba(255, 255, 255, .06);
  background:
    linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.72), transparent) bottom / 100% 1px no-repeat,
    var(--bg-white);
}

[data-theme="light"] .health-card {
  background: var(--bg-white);
  border-color: var(--border);
}

[data-theme="light"] .automation-code-block {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .automation-code-block:hover {
  border-color: rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .automation-code-block::before {
  display: block;
  background: radial-gradient(180px circle at var(--gx, 50%) var(--gy, 50%), rgba(34, 197, 94, 0.7), rgba(34, 197, 94, 0) 60%);
}

[data-theme="light"] .automation-code-block::after {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent) bottom / 100% 1px no-repeat;
}

.danger-zone-card {
  border-color: rgba(239, 68, 68, .3);
  background:
    linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.4), transparent) bottom / 100% 1px no-repeat,
    var(--bg-white);
}

[data-theme="light"] .danger-zone-card {
  background: var(--bg-white);
}

.progress-bar {
  background: rgba(255, 255, 255, .04);
}

[data-theme="light"] .progress-bar {
  background: var(--border-light);
}

.api-key-pw input,
.profile-api-key code,
.copy-field code {
  background: #060a0e;
  border: 1px solid rgba(255, 255, 255, .06);
}

[data-theme="light"] .api-key-pw input,
[data-theme="light"] .profile-api-key code,
[data-theme="light"] .copy-field code {
  background: var(--code-bg);
  border: none;
}

/* Navbar (admin) glow â€” dark default */
.navbar {
  background: rgba(8, 12, 16, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: rgba(255, 255, 255, .06);
}

[data-theme="light"] .navbar {
  background: var(--bg-white);
  backdrop-filter: none;
  border-bottom-color: var(--border);
}

.nav-tab:hover {
  background: rgba(255, 255, 255, .04);
}

.nav-tab.active {
  background: rgba(var(--glow-rgb), .08);
  color: var(--primary);
}

[data-theme="light"] .nav-tab:hover {
  background: var(--primary-bg-dark);
  color: var(--text-primary);
}

[data-theme="light"] .nav-tab.active {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

/* Documentation tab styles */
.doc-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.doc-desc code {
  font-size: 12px;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.doc-tab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s ease;
}

.doc-tab:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.doc-tab.active {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
}


/* ===== CURRENCY TOGGLE (BDT / USD) ===== */
.currency-toggle-group {
  display: inline-flex;
  background: rgba(31, 41, 55, 0.5);
  border: none;
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}

[data-theme="light"] .currency-toggle-group {
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
}

.currency-toggle-btn {
  flex: 1;
  padding: 7px 14px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  color: var(--text-muted);
  white-space: nowrap;
}

.currency-toggle-btn:hover {
  color: var(--text-primary);
}

.currency-toggle-btn.active {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 0 12px rgba(var(--glow-rgb), 0.25);
}

[data-theme="light"] .currency-toggle-btn.active {
  color: #fff;
}

.currency-toggle-btn {
  position: relative;
}

.discount-pill {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #f59e0b;
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  line-height: 1.4;
  letter-spacing: 0.3px;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
  pointer-events: none;
}

.price-vat {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  vertical-align: super;
}

/* ===== FORM SELECT ===== */
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 36px 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--bg-white);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color .2s, box-shadow .2s;
}

.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .1);
}

/* ===== PROMO DISPLAY ===== */
.promo-display-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.promo-display-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.promo-display-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.promo-display-grid span:last-child {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

#promo-modal input::-webkit-calendar-picker-indicator {
  display: none;
}

/* ===== SUBSCRIBE MODAL (expired.html style) =====
   DEPRECATED: Migrate to .modal-content pattern
*/
#subscribe-modal .sub-review-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 45px -15px rgba(var(--glow-rgb), 0.25);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.sub-review-bottom-line {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--glow), transparent);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  z-index: 2;
}

#subscribe-modal .modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: color 0.2s;
  z-index: 10;
}

#subscribe-modal .modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}


#subscribe-modal .modal-body {
  padding: 0 24px 20px;
}

.sub-review-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--glow);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 10px 0 20px 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sub-modal-form {
  text-align: left;
}

.sub-modal-field {
  margin-bottom: 12px;
}

.sub-modal-field .field-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.sub-summary-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  margin-top: 16px;
  font-size: 12px;
}

.sub-sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.sub-sum-row span:last-child {
  color: var(--text-primary);
  font-weight: 500;
  font-family: monospace;
  font-size: 13px;
}

.sub-sum-row.sub-sum-discount span:first-child,
.sub-sum-row.sub-sum-discount span:last-child {
  color: var(--primary);
}

.sub-sum-row.sub-sum-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.sub-sum-row.sub-sum-total span:first-child {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.sub-sum-total-val {
  color: var(--glow) !important;
  font-weight: 800 !important;
  font-size: 16px !important;
}

.sub-sum-row .copy-inline-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--glow);
  margin-left: 4px;
  padding: 3px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.sub-sum-row .copy-inline-btn:hover {
  background: rgba(var(--glow-rgb), 0.1);
}

/* ===== SUBSCRIBE WIZARD ===== */
.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 16px 0 24px;
  padding: 0 8px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.wizard-step span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-light);
  color: var(--text-muted);
  border: 2px solid var(--border);
  transition: all 0.3s ease;
}

.wizard-step small {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.wizard-step.active span {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(var(--glow-rgb), 0.4);
}

.wizard-step.active small {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.wizard-step.done span {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
  font-size: 0;
}

.wizard-step.done span::after {
  content: '✓';
  font-size: 15px;
  font-weight: 700;
}

.wizard-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 6px;
  margin-bottom: 18px;
  transition: background 0.3s ease;
  min-width: 30px;
  max-width: 80px;
}

.wizard-step.done + .wizard-line,
.wizard-step.active + .wizard-line {
  background: rgba(var(--glow-rgb), 0.4);
}

.wizard-page {
  animation: wizardFadeIn 0.25s ease;
}

@keyframes wizardFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.wizard-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.wizard-methods-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-method-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.wizard-method-card:hover {
  border-color: rgba(var(--glow-rgb), 0.3);
  background: rgba(var(--glow-rgb), 0.04);
}

.wizard-method-card.selected {
  border-color: var(--primary);
  background: rgba(var(--glow-rgb), 0.08);
  box-shadow: 0 0 12px rgba(var(--glow-rgb), 0.15);
}

.wizard-method-card--paddle {
  border-color: rgba(var(--glow-rgb), 0.3);
  background: rgba(var(--glow-rgb), 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.wizard-method-card--paddle:hover {
  border-color: var(--primary);
  background: rgba(var(--glow-rgb), 0.08);
}

.wizard-method-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.wizard-method-fee {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.wizard-back-btn {
  flex-shrink: 0;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wizard-back-btn:hover {
  border-color: rgba(var(--glow-rgb), 0.3);
  color: var(--text-primary);
}

.wizard-nav .sub-confirm-btn {
  flex: 1;
  margin-top: 0;
}

.wizard-mini-summary {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(var(--glow-rgb), 0.04);
  border: 1px solid rgba(var(--glow-rgb), 0.12);
  border-radius: var(--radius-md);
}

.wizard-mini-summary .sub-sum-row {
  padding: 6px 0;
  font-size: 13px;
}

[data-theme="light"] .wizard-method-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .wizard-method-card:hover {
  border-color: rgba(var(--glow-rgb), 0.4);
  background: rgba(var(--glow-rgb), 0.06);
}

[data-theme="light"] .wizard-method-card.selected {
  background: rgba(var(--glow-rgb), 0.1);
}

[data-theme="light"] .wizard-step span {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
}

[data-theme="light"] .wizard-mini-summary {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.sub-confirm-btn {
  width: 100%;
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sub-confirm-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--glow-rgb), 0.3);
}

.sub-confirm-btn svg {
  flex-shrink: 0;
}

[data-theme="light"] .sub-confirm-btn {
  color: #fff;
}

/* ===== FORM SELECT ===== */

.plan-status-card {
  padding: 16px 20px;
  margin-bottom: 0;
}

.plan-status-card-body {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.plan-status-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.plan-status-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.plan-status-plan-line,
.plan-status-status-line,
.plan-status-date-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== SUBSCRIBE FORM ===== */
#subscribe-form {
  overflow-x: hidden;
}

/* ===== PASSWORD TOGGLE ===== */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap input {
  padding-right: 40px;
  width: 100%;
}

.password-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.password-toggle:hover {
  color: var(--text-primary);
}

.password-toggle svg {
  flex-shrink: 0;
}

.password-toggle .hidden {
  display: none;
}

/* ===== FORGOT PASSWORD LINK ===== */
.form-footer-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.forgot-link {
  color: var(--primary);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}

.forgot-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ===== FORGOT PASSWORD MODAL ===== */
#forgot-password-modal .modal-content {
  max-width: 400px;
  overflow: hidden;
}

#forgot-password-modal .modal-header h2 {
  font-size: 20px;
  margin: 0;
}

#forgot-password-modal p {
  color: var(--text-secondary);
  margin: 12px 0 1px;
  font-size: 14px;
}

#forgot-password-modal .verification-code-input {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

#forgot-password-modal .verification-code-input input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 2px;
  background: #0f0f23;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #e2e8f0;
  outline: none;
  transition: border-color 0.2s;
}

#forgot-password-modal .verification-code-input input:focus {
  border-color: var(--primary, #22c55e);
}

#verify-email-modal .verification-code-input {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

#verify-email-modal .verification-code-input input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 2px;
  background: #0f0f23;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #e2e8f0;
  outline: none;
  transition: border-color 0.2s;
}

#verify-email-modal .verification-code-input input:focus {
  border-color: var(--primary, #22c55e);
}


#forgot-password-modal .resend-link {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

#forgot-password-modal .resend-link a {
  color: var(--primary);
  cursor: pointer;
}

#forgot-password-modal .resend-link a:hover {
  text-decoration: underline;
}

#forgot-password-modal .resend-link.disabled a {
  color: var(--text-muted);
  cursor: not-allowed;
  text-decoration: none;
}

#forgot-password-modal .modal-header h2 {
  color: var(--primary);
}

#forgot-password-modal .modal-actions button {
  padding: 8px 20px;
  min-height: auto;
  font-size: 14px;
}

/* Step 2 verify button styling */
#forgot-password-modal #verify-forgot-code-btn {
  width: 100%;
  margin-bottom: 12px;
}

/* glow-input uses base component styles from input.css */

/* Google OAuth Button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  min-height: 36px;
  box-sizing: border-box;
  background: var(--bg-input, rgba(255, 255, 255, 0.04));
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-google:hover {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--glow-rgb), 0.35);
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.15);
}

.btn-google:active {
  background: rgba(var(--accent-rgb), 0.12);
}

[data-theme="light"] .btn-google {
  background: var(--bg-white);
  color: var(--text-primary);
  border-color: var(--border);
}

[data-theme="light"] .btn-google:hover {
  background: var(--primary-bg-dark);
  border-color: rgba(var(--glow-rgb), 0.25);
}

/* Divider between Google and email auth */
.divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color, var(--border));
}

.divider span {
  padding: 0 12px;
}

/* Terms and Privacy Checkbox */
.terms-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.terms-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.terms-checkbox label {
  cursor: pointer;
  line-height: 1.4;
}

.terms-checkbox a {
  color: var(--primary);
  text-decoration: none;
}

.terms-checkbox a:hover {
  text-decoration: underline;
}

/* Continue Terms Text */
.continue-terms {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  margin-bottom: 0;
  line-height: 1.45;
}

.continue-terms-intro {
  display: block;
  margin-bottom: 4px;
}

.continue-terms-links {
  display: block;
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 340px) {
  .continue-terms-links {
    white-space: normal;
  }
}

.continue-terms a {
  color: var(--accent, var(--primary));
  text-decoration: none;
  font-weight: 500;
}

.continue-terms a:hover {
  text-decoration: underline;
}

/* Auth panels: readable rhythm, still fits viewport without scroll */
.auth-form > div {
  margin-bottom: 0;
}

.auth-form .field-label {
  font-size: 11px;
  margin-bottom: 6px;
  display: block;
}

.auth-form .glow-input {
  padding: 0 12px !important;
  min-height: auto !important;
}

.auth-form .glow-input input {
  font-size: 14px;
  padding: 10px 0 !important;
  height: auto !important;
}

.auth-form .password-input-wrap {
  min-height: auto !important;
}

.auth-form .password-toggle {
  padding: 4px !important;
  flex-shrink: 0;
}

.auth-form .password-toggle svg {
  width: 18px !important;
  height: 18px !important;
}

.auth-form .btn-primary {
  padding: 10px 14px;
  font-size: 14px;
  margin-top: 4px;
  min-height: 42px;
  border-radius: var(--radius-md, 10px);
}

.auth-form .btn-google {
  margin-top: 0;
  margin-bottom: 0;
}

#login-form > div:not(:last-child),
#register-form > div:not(:last-child),
#admin-login-form > div:not(:last-child) {
  margin-bottom: 0;
}

#admin-login-form.auth-form {
  gap: 16px;
}

.divider {
  margin: 4px 0;
}

.terms-checkbox {
  margin-bottom: 0;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.45;
}

.form-footer-row {
  margin-bottom: 0;
  margin-top: -4px;
}

.forgot-link {
  font-size: 12px;
}

/* Login panels: center, avoid body scroll except very small heights */
#login-page,
#admin-login-page {
  overflow-x: hidden;
  overflow-y: auto;
}

#login-page.page,
#admin-login-page.page {
  overscroll-behavior: contain;
}

/* QR Modal */
#qr-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}

#qr-modal .modal-content {
  width: 100%;
  max-width: 380px;
  padding: 20px;
  box-sizing: border-box;
}

#qr-modal .qr-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
}

#qr-modal #qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
  width: 220px;
  height: 220px;
}

#qr-modal #qr-container.qr-expired {
  border: 2px dashed var(--border);
  border-radius: 8px;
}

#qr-modal #qr-image {
  width: 100%;
  max-width: 220px;
  height: auto;
  border-radius: 8px;
}

#qr-modal #qr-reload-icon {
  font-size: 72px;
  cursor: pointer;
  color: var(--primary);
  user-select: none;
  line-height: 1;
}

#qr-modal #qr-reload-icon:hover {
  color: var(--primary-hover, var(--primary));
}

#qr-modal #qr-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

#qr-modal #qr-loading .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: qr-spin 0.8s linear infinite;
}

@keyframes qr-spin {
  to { transform: rotate(360deg); }
}

#qr-modal .qr-instructions {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0;
  line-height: 1.4;
}

/* QR Modal status - full width green bar at bottom touching all edges */
#qr-modal .modal-status {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 14px;
  margin: 16px -20px -20px -20px;
  background: var(--primary-bg);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  box-sizing: border-box;
}

/* Status as plain text */
#qr-modal .status-badge {
  font-size: 14px;
  font-weight: 600;
  background: none;
  color: var(--primary);
  padding: 0;
}

#qr-modal .status-badge.connecting {
  color: var(--warning);
}

#qr-modal .status-badge.connected {
  color: var(--primary);
}

/* Responsive QR modal — fit narrow phone viewports (<420px) without overflow */
@media (max-width: 420px) {
  #qr-modal { padding: 8px; }
  #qr-modal .modal-content { max-width: 100%; padding: 16px; }
  #qr-modal #qr-image { max-width: 180px; }
  #qr-modal #qr-container { width: 180px; height: 180px; }
  #qr-modal #qr-reload-icon { font-size: 56px; }
  #qr-modal #qr-loading .spinner { width: 32px; height: 32px; }
  #qr-modal .qr-instructions { font-size: 12px; }
  #qr-modal .modal-status { margin: 12px -16px -16px -16px; padding: 12px; }
}


/* Remove borders/glow from create-modal inputs */
#create-modal .glow-input {
  border: none;
}

/* ── App Settings ── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.settings-form .form-group { margin-bottom: 18px; }
.settings-form .form-group:last-child { margin-bottom: 0; }
.field-hint { display: block; font-size: 12px; color: var(--text-muted, #888); margin-top: 4px; }
.color-row { display: flex; gap: 10px; align-items: center; }
.color-swatch { width: 42px; height: 42px; padding: 2px; border-radius: 8px; border: 1px solid var(--border-color, #e5e7eb); cursor: pointer; background: none; flex-shrink: 0; }

/* Settings card sub-sections (used when combining multiple settings into one card) */
.settings-subsection { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border, rgba(255,255,255,0.08)); }
.settings-subsection:first-child { padding-top: 0; margin-top: 0; border-top: none; }
.settings-subsection-title { font-size: 13px; font-weight: 600; color: var(--text-secondary, #94a3b8); text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 14px 0; display: flex; align-items: center; gap: 8px; }
.badge-sm { font-size: 10px; padding: 2px 6px; }

/* ===== PADDLE CHECKOUT OVERLAY - match RexWapi dark theme ===== */
.paddle-overlay,
[class*="paddle-overlay"],
[data-paddle-checkout-overlay] {
  background: rgba(0, 0, 0, 0.85) !important;
  backdrop-filter: blur(8px);
}

.paddle-checkout,
[class*="paddle-checkout-container"],
[data-paddle-checkout] {
  background: var(--bg-card, #111) !important;
  border: 1px solid rgba(var(--glow-rgb, 34, 197, 94), 0.2) !important;
  border-radius: var(--radius-lg, 16px) !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(var(--glow-rgb, 34, 197, 94), 0.08) !important;
}

/* Vanishing edge line at bottom of Paddle checkout */
.paddle-checkout::after,
[class*="paddle-checkout-container"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb, 34, 197, 94), 0.85), transparent);
  pointer-events: none;
  z-index: 10;
}

/* Paddle checkout overlay sizing */
.paddle-overlay .paddle-checkout {
  max-width: 540px !important;
  max-height: 720px !important;
}
.paddle-overlay {
  overscroll-behavior: contain;
}

/* ── Global glow-textarea (matches .glow-input from components.js) ── */
.glow-textarea {
  display: flex;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input, #0a0e14);
  padding: 0 12px;
  position: relative;
  z-index: 0;
  transition: border-color 0.35s, box-shadow 0.35s;
}
.glow-textarea::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -2;
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
  border-radius: 11px;
  background: radial-gradient(400px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb, 0, 230, 118), 0.3), transparent 40%);
}
.glow-textarea::after {
  content: '';
  position: absolute;
  inset: 1px;
  z-index: -1;
  pointer-events: none;
  border-radius: 9px;
  background: var(--bg-input, #0a0e14);
}
.glow-textarea:hover::before,
.glow-textarea:focus-within::before {
  opacity: 1;
}
.glow-textarea:focus-within {
  border-color: rgba(var(--glow-rgb, 34, 197, 94), 0.4);
  box-shadow: 0 0 0 3px rgba(var(--glow-rgb, 34, 197, 94), 0.08);
}
.glow-textarea textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 0;
  font-size: 13px;
  outline: none;
  width: 100%;
  min-height: 80px;
  resize: vertical;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.glow-textarea textarea::placeholder {
  color: var(--text-muted);
}

/* ===== Field Validation ===== */
.glow-input.rex-field-error,
.ri-input-wrap.rex-field-error,
.sub-modal-field.rex-field-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px #ef4444 !important;
}
[data-theme="light"] .glow-input.rex-field-error,
[data-theme="light"] .ri-input-wrap.rex-field-error,
[data-theme="light"] .sub-modal-field.rex-field-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 1px #dc2626 !important;
}
.rex-field-err-msg {
  position: absolute;
  bottom: -18px;
  left: 0;
  font-size: 11px;
  font-weight: 500;
  color: #ef4444;
  white-space: nowrap;
  pointer-events: none;
}
.glow-input,
.ri-input-wrap,
.sub-modal-field {
  position: relative;
}

/* About App Modal */
.about-app-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.about-row {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
}
.about-row:last-child {
  border-bottom: none;
}
.about-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted, #6b7280);
  min-width: 80px;
  flex-shrink: 0;
}
.about-value {
  font-size: 0.95rem;
  color: var(--text-primary, #e2e8f0);
}
.about-row-links {
  align-items: flex-start;
}
.about-contact-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent, #22c55e);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 4px 10px;
  border: 1px solid rgba(var(--accent-rgb, 34, 197, 94), 0.25);
  border-radius: 8px;
  background: rgba(var(--accent-rgb, 34, 197, 94), 0.06);
  transition: background 0.2s;
}
.about-contact-link:hover {
  background: rgba(var(--accent-rgb, 34, 197, 94), 0.12);
}
.about-contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}


/* Syntax highlight colors */
.hc-kw { color: #569cd6; }
.hc-str { color: #c97b5d; }
.hc-cm { color: #6a9955; }
.hc-num { color: #b5cea8; }

/* Code language tabs (landing-page style) */
.code-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-md, 10px);
  background: rgba(31, 41, 55, 0.5);
}
.code-tab {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  font-family: inherit;
  white-space: nowrap;
}
.code-tab:hover {
  color: #fff;
}
.code-tab.active {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--glow-rgb, 34, 197, 94), 0.2);
}
[data-theme="light"] .code-tabs {
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .code-tab {
  color: rgba(0, 0, 0, 0.5);
}
[data-theme="light"] .code-tab:hover {
  color: #000;
}
[data-theme="light"] .code-tab.active {
  color: #fff;
}
/* Legacy classes kept for backwards compat */
.code-lang-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.code-lang-tab { padding: 3px 12px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--text-muted); transition: all .2s; font-family: inherit; }
.code-lang-tab:hover { color: var(--text-primary); border-color: var(--border); }
.code-lang-tab.active { background: var(--brand-gradient); color: #fff; border-color: transparent; }
[data-theme="light"] .code-lang-tab.active { color: #fff; }
/* ===== Automation Tab ===== */
.auto-page {
  padding: 12px 0;
}

.auto-instance-bar {
  margin-bottom: 16px;
  max-width: 420px;
}

/* ── Tabs ── */
.auto-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  justify-content: center;
}

.auto-tab {
  padding: 10px 28px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.auto-tab:hover {
  color: var(--text-primary);
}

.auto-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auto-panel {
  display: none;
}

.auto-panel.active {
  display: block;
}

/* ── Toolbar ── */
.auto-canvas-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
}

.auto-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.auto-toolbar-left,
.auto-toolbar-center,
.auto-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.auto-tb-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1;
}

.auto-tb-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(var(--glow-rgb), 0.05);
}

.auto-tb-add {
  width: auto;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  gap: 4px;
}

.auto-zoom-pct {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 34px;
  text-align: center;
}

.auto-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.auto-status-dot.ok { background: #22c55e; }
.auto-status-dot.nok { background: #ef4444; }

.auto-status-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Toggle ── */
.auto-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.auto-toggle input { display: none; }

.auto-toggle-track {
  width: 32px;
  height: 18px;
  background: var(--border);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s;
}

.auto-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.auto-toggle input:checked + .auto-toggle-track {
  background: var(--primary);
}

.auto-toggle input:checked + .auto-toggle-track::after {
  transform: translateX(14px);
}

/* ── Canvas ── */
.auto-canvas {
  position: relative;
  width: 100%;
  height: 540px;
  overflow: hidden;
  cursor: grab;
  background-image:
    radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--surface);
}

.auto-canvas:active {
  cursor: grabbing;
}

.auto-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ── Nodes ── */
.auto-node {
  position: absolute;
  width: 200px;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  user-select: none;
}

.auto-node.dragging {
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 10;
}

.auto-node-trigger {
  border-color: #8b5cf6;
}

.auto-node-action {
  border-color: #22c55e;
}

.auto-node-middle {
  border-color: var(--border);
}

.auto-node-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}

.auto-node-head:active {
  cursor: grabbing;
}

.auto-node-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
}

.auto-node-trigger .auto-node-icon { color: #a78bfa; }
.auto-node-action .auto-node-icon { color: #4ade80; }

.auto-node-body {
  padding: 7px 10px;
}

.auto-node-ports {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.auto-port-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
}

.auto-port-row:hover {
  background: rgba(128,128,128,0.08);
}

.auto-port-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.12s;
}

.auto-port-row:hover .auto-port-dot {
  transform: scale(1.4);
  box-shadow: 0 0 8px currentColor;
}

.auto-port-output .auto-port-dot {
  background: #8b5cf6;
  border: 2px solid rgba(139, 92, 246, 0.3);
}

.auto-port-input .auto-port-dot {
  background: #22c55e;
  border: 2px solid rgba(34, 197, 94, 0.3);
}

.auto-port-label {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.auto-port-output .auto-port-label {
  color: #a78bfa;
}

.auto-port-input .auto-port-label {
  color: #4ade80;
}

.auto-port-right {
  justify-content: flex-end;
}

.auto-port-right .auto-port-label {
  order: -1;
}

/* ── Config panel ── */
.auto-config-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  display: none;
}
.auto-config-overlay.show {
  display: block;
}

.auto-config {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  height: 100%;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auto-config.open {
  right: 0;
}

.auto-config-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.auto-config-head h3 {
  margin: 0;
  font-size: 1rem;
}

.auto-config-x {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.auto-config-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.auto-config-body .cf {
  margin-bottom: 14px;
}

.auto-config-body .cf label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-secondary);
}

.auto-config-body .cf input,
.auto-config-body .cf select,
.auto-config-body .cf textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.auto-config-body .cf input:focus,
.auto-config-body .cf select:focus,
.auto-config-body .cf textarea:focus {
  border-color: var(--primary);
}

.auto-config-body .cf textarea {
  min-height: 70px;
  resize: vertical;
}

/* ── Credentials ── */
.auto-cred-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.auto-cred-header h3 {
  margin: 0;
  font-size: 1rem;
}

.auto-cred-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.auto-cred-card:hover {
  border-color: var(--primary);
}

.auto-cred-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auto-cred-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.auto-cred-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 2px 7px;
  background: rgba(var(--glow-rgb), 0.1);
  border-radius: 4px;
}

.auto-cred-acts {
  display: flex;
  gap: 6px;
}

.auto-cred-acts button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  transition: all 0.15s;
}

.auto-cred-acts button:hover {
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--text);
}

.auto-cred-acts .del:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ===== AUTOMATION CONTAINER ===== */
.automation-container {
  background: transparent;
  position: relative;
}

.automation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.automation-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.circuit-status {
  font-size: 0.85rem;
  font-weight: 600;
}

.automation-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.automation-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.automation-tab:hover {
  color: var(--text-primary);
}

.automation-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.automation-tab-content {
  display: none;
}

.automation-tab-content.active {
  display: block;
}

/* ===== V3 AUTOMATION WIZARD BANNER ===== */
.auto-wizard-inner {
  /* sits inside the .card; soft brand tint + slight padding */
  background: linear-gradient(135deg, rgba(34,197,94,0.06), rgba(18,140,126,0.04));
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
[data-theme="light"] .auto-wizard-inner {
  background: linear-gradient(135deg, rgba(34,197,94,0.04), rgba(18,140,126,0.03));
}
#auto-wizard.collapsed .auto-wizard-inner { display: none; }
#auto-wizard.collapsed { padding: 0; margin-bottom: 16px; min-height: 0; }
.auto-wizard-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px;
}
.auto-wizard-title { font-size: 0.95rem; font-weight: 600; }
.auto-wizard-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.auto-wizard-toggle {
  background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.78rem;
}
.auto-wizard-toggle:hover { color: var(--text-primary); }
.auto-wizard-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.auto-wizard.collapsed .auto-wizard-steps { display: none; }
@media (max-width: 720px) { .auto-wizard-steps { grid-template-columns: 1fr; } }
.auto-wizard-step { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; }
.auto-wizard-num {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--border); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600;
}
.auto-wizard-step.done .auto-wizard-num { background: var(--primary); color: #fff; }
.auto-wizard-step.active .auto-wizard-num { background: rgba(34,197,94,0.18); color: var(--primary); }
.auto-wizard-text { flex: 1; }
.auto-wizard-label { font-size: 0.85rem; font-weight: 500; }
.auto-wizard-help { font-size: 0.74rem; color: var(--text-muted); margin-top: 1px; }
.auto-wizard-help a { color: var(--primary); text-decoration: none; }
.auto-wizard-help a:hover { text-decoration: underline; }
.auto-wizard-state { font-size: 0.72rem; color: var(--text-muted); align-self: center; }
.auto-wizard-step.done .auto-wizard-state { color: var(--primary); font-weight: 600; }

/* ===== V3 SYSTEM PROMPT CARD (Flow tab) ===== */
.auto-prompt-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px; margin-bottom: 14px; background: var(--bg-card);
}
.auto-prompt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.auto-prompt-title { font-size: 0.9rem; font-weight: 600; }
.auto-prompt-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.auto-prompt-body {
  margin-top: 8px; font-size: 0.85rem; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-word;
  max-height: 120px; overflow-y: auto; padding: 8px 10px; background: rgba(0,0,0,0.03);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
[data-theme="light"] .auto-prompt-body { background: rgba(0,0,0,0.02); }

/* ===== V3 PRODUCTS / KNOWLEDGE TABLES ===== */
.auto-section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.auto-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.auto-count { font-size: 0.78rem; color: var(--text-muted); }
.auto-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.auto-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.auto-table th, .auto-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.auto-table th { background: var(--bg-card); font-weight: 600; font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.auto-table tr:last-child td { border-bottom: none; }
.auto-table tr:hover td { background: rgba(34,197,94,0.04); }
[data-theme="light"] .auto-table tr:hover td { background: rgba(34,197,94,0.06); }
.auto-empty { text-align: center !important; color: var(--text-muted); padding: 20px !important; }
.auto-row-actions { display: flex; gap: 4px; }
.auto-pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.7rem; background: rgba(34,197,94,0.14); color: var(--primary); }
.auto-pill--out { background: rgba(239,68,68,0.14); color: #ef4444; }
.auto-pill--draft { background: rgba(107,114,128,0.14); color: var(--text-muted); }
.auto-pill--in { background: rgba(34,197,94,0.14); color: var(--primary); }

.auto-input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-primary); font-size: 0.85rem; font-family: inherit; }
.auto-input:focus { outline: none; border-color: var(--primary); }
textarea.auto-input { resize: vertical; min-height: 60px; }
.auto-help { font-size: 0.75rem; color: var(--text-muted); margin: 4px 0 0; }
.auto-help code { background: rgba(0,0,0,0.05); padding: 0 4px; border-radius: 3px; font-size: 0.85em; }
[data-theme="light"] .auto-help code { background: rgba(0,0,0,0.06); }

.auto-form-row { margin-bottom: 12px; }
.auto-form-row label { display: block; font-size: 0.82rem; font-weight: 500; margin-bottom: 4px; }
.auto-form-grid { max-width: 720px; }

.auto-rag-source {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px; margin-bottom: 14px; background: var(--bg-card);
}
.auto-rag-source-label { font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; }
.auto-rag-source-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.auto-radio { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.auto-radio input { margin: 0; }
.auto-rag-source-cfg { padding: 10px; border-top: 1px solid var(--border); margin-top: 6px; }
.auto-rag-source-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.auto-rag-source-status { font-size: 0.78rem; color: var(--text-muted); }

.auto-hours-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.auto-hours-day { display: flex; align-items: center; gap: 6px; }
.auto-hours-day span { font-size: 0.78rem; font-weight: 500; width: 32px; color: var(--text-muted); }
.auto-hours-day .glow-input { flex: 1; }
.auto-hours { font-size: 0.78rem !important; padding: 4px 6px !important; }

/* ===== V3 TEST REPLY PANE ===== */
.auto-test-pane { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .auto-test-pane { grid-template-columns: 1fr; } }
.auto-test-left { padding-right: 8px; border-right: 1px solid var(--border); }
@media (max-width: 900px) { .auto-test-left { border-right: none; padding-right: 0; } }
.auto-test-actions { display: flex; gap: 8px; align-items: center; }
.auto-test-meta { font-size: 0.78rem; color: var(--text-muted); }
.auto-test-debug { margin-top: 8px; font-size: 0.72rem; color: var(--text-muted); white-space: pre-wrap; }
.auto-test-right { display: flex; flex-direction: column; }
.auto-test-label { font-size: 0.82rem; font-weight: 600; margin-bottom: 8px; }
.auto-test-bubble {
  background: #dcf8c6; color: #111;
  border-radius: 12px; padding: 12px 14px; min-height: 80px;
  font-size: 0.9rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word;
  border: 1px solid rgba(0,0,0,0.06);
}
[data-theme="light"] .auto-test-bubble { background: #dcf8c6; }
[data-theme="dark"] .auto-test-bubble { background: #005c4b; color: #e9edef; border-color: rgba(255,255,255,0.05); }
.auto-test-placeholder { color: #555; font-style: italic; }
[data-theme="dark"] .auto-test-placeholder { color: #aaa; }
.auto-test-bubble.error { background: rgba(239,68,68,0.14); color: #b91c1c; border-color: rgba(239,68,68,0.3); }
[data-theme="dark"] .auto-test-bubble.error { color: #fca5a5; }

.auto-test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .auto-test-grid { grid-template-columns: 1fr; } }

/* In-tab card stack — every .card inside an automation settings tab gets the
   standard 16px gap, no need for inline margin-bottom. */
.settings-tab-content.active { display: flex; flex-direction: column; gap: 16px; }
.settings-tab-content .card { margin-bottom: 0; }
.settings-tab-content .form-row { margin-bottom: 12px; }
.settings-tab-content .form-row:last-child { margin-bottom: 0; }
.section-intro { margin: 0 0 12px; font-size: 0.82rem; color: var(--text-muted); }
.section-intro:last-child { margin-bottom: 0; }

/* ===== PIPELINE VIEW (automation) ===== */
.pipeline-view {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 20px;
  background: transparent;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  min-height: 200px;
  overflow-x: auto;
}

.pipeline-column {
  flex: 1;
  min-width: 200px;
  background: transparent;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.pipeline-col-icon {
  font-size: 1rem;
}

.pipeline-arrow {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 0 4px;
  flex-shrink: 0;
}

.pipeline-node {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.pipeline-node:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.15);
}

.pipeline-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 0.85rem;
}

.pipeline-node-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.pipeline-node-title {
  flex: 1;
}

.pipeline-node-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.pipeline-node-edit:hover {
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--text-primary);
}

.pipeline-node-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pipeline-ports {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pipeline-port {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.pipeline-port-out {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.pipeline-port-in {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.pipeline-port-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.pipeline-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.pipeline-field-label {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 55px;
  flex-shrink: 0;
}

.pipeline-field-value {
  color: var(--text-primary);
}

.pipeline-tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pipeline-tool-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--primary-dark);
  border-radius: 4px;
  font-weight: 500;
}

.pipeline-tools-section {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.pipeline-tools-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.9rem;
}

.pipeline-tools-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.2s;
}

.pipeline-tool-card:hover {
  border-color: var(--primary);
}

.pipeline-tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
  font-weight: 500;
}

.pipeline-tool-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.pipeline-tool-name {
  flex: 1;
}

.pipeline-tool-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 1.2rem;
  line-height: 1;
  transition: color 0.15s;
}

.pipeline-tool-remove:hover {
  color: var(--danger);
}

.pipeline-tool-card-body {
  padding: 8px 12px;
}

.tool-status-ok {
  color: var(--success);
}

.pipeline-placeholder {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.pipeline-placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.pipeline-placeholder h3 {
  font-size: 1.1rem;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.pipeline-placeholder p {
  font-size: 0.85rem;
  margin: 0 0 20px;
}

.pipeline-placeholder-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ===== CONFIG PANEL ===== */
.config-panel-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 999;
}

.config-panel-overlay.hidden {
  display: none;
}

.config-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.2);
  animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.config-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.config-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.config-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.config-panel-close:hover {
  color: var(--text-primary);
}

.config-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.config-tab {
  flex: 1;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.config-tab:hover {
  color: var(--text-primary);
}

.config-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.config-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.config-section {
  margin-bottom: 20px;
}

.config-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.config-field {
  margin-bottom: 14px;
}

.config-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.config-field input,
.config-field textarea,
.config-field select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: border-color 0.2s;
}

.config-field input:focus,
.config-field textarea:focus,
.config-field select:focus {
  outline: none;
  border-color: var(--primary);
}

.config-field textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

/* ===== CREDENTIALS LIST ===== */
.credentials-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.credential-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.credential-card:hover {
  border-color: var(--primary);
}

.credential-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.credential-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.credential-type {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 2px 7px;
  background: rgba(var(--glow-rgb), 0.1);
  border-radius: 4px;
}

.credential-actions {
  display: flex;
  gap: 6px;
}

.credential-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  transition: all 0.15s;
}

.credential-actions button:hover {
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--text-primary);
}

.credential-actions .cred-btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.credential-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(var(--glow-rgb), 0.08);
  flex-shrink: 0;
}

.credential-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* ===== ADD CREDENTIAL MODAL ===== */
.auto-cred-modal-box {
  width: 460px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  background: var(--bg-elevated, #0f0f23);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  color: var(--text-primary, #e2e8f0);
}

.auto-cred-modal-box .modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auto-cred-modal-box .modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.auto-cred-modal-box .modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.auto-cred-modal-box .modal-close:hover {
  color: var(--text-primary);
  background: rgba(var(--glow-rgb), 0.08);
}

.auto-cred-modal-box .modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}

.auto-cred-modal-box .modal-actions {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.cred-type-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cred-type-select-wrap .cred-type-icon {
  position: absolute;
  left: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--brand-green);
  pointer-events: none;
  z-index: 1;
}

.cred-value-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.cred-value-hint code {
  background: rgba(var(--glow-rgb), 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.72rem;
}

/* Error state on a glow-input wrapper. Higher specificity via the
   wrapper class avoids the !important that would otherwise be needed
   to override .glow-input:focus-within. */
.glow-input.glow-input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.glow-input.glow-input-error:focus-within {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

/* Confirm dialog box (uses the same overlay pattern) */
.auto-confirm-box {
  width: 380px;
  max-width: 92vw;
  background: var(--bg-elevated, #0f0f23);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  padding: 20px;
  color: var(--text-primary, #e2e8f0);
}

.auto-confirm-box h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.auto-confirm-box p {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.auto-confirm-box .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .pipeline-view {
    flex-direction: column;
    align-items: stretch;
  }
  .pipeline-arrow {
    transform: rotate(90deg);
    justify-content: center;
    padding: 8px 0;
  }
  .pipeline-column {
    min-width: unset;
  }
}

@media (max-width: 600px) {
  .config-panel {
    width: 100vw;
  }
}

/* ===== Quick Setup (automation Flow tab) ===== */
.qs-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.qs-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.qs-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.qs-card-body {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Toggle switch */
.qs-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.qs-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.qs-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.3s;
}

.qs-toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

.qs-toggle input:checked + .qs-toggle-slider {
  background: var(--brand-gradient);
}

.qs-toggle input:checked + .qs-toggle-slider::before {
  transform: translateX(20px);
}

/* Toggle row (inline) */
.qs-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.qs-toggle-row .qs-toggle-slider {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

.qs-toggle-row .qs-toggle-slider::before {
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
}

.qs-toggle-row input:checked + .qs-toggle-slider::before {
  transform: translateX(16px);
}

.qs-toggle-label {
  font-size: 0.85rem;
  color: var(--text-primary);
}

/* Rows */
.qs-row {
  margin-bottom: 0;
}

.qs-row-cols {
  display: flex;
  gap: 12px;
}

.qs-subheading {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: block;
}

/* Fields */
.qs-field {
  flex: 1;
}

.qs-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.qs-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  width: 100%;
}

.qs-input:focus {
  border-color: var(--primary);
}

.qs-textarea {
  min-height: 80px;
  resize: vertical;
}

.qs-select {
  cursor: pointer;
  appearance: auto;
}

.qs-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.qs-inline-group {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.qs-inline-group select {
  flex: 1;
}

.qs-add-btn {
  width: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--primary);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.qs-add-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--primary);
}

/* Tool cards (inline compact) */
#qs-tool-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qs-tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--bg-secondary);
}

.qs-tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qs-tool-card-icon {
  flex-shrink: 0;
  font-size: 1rem;
}

.qs-tool-card-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

.qs-tool-card-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
}

.qs-tool-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.qs-empty-state {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 6px 0;
}

/* Tags */
.qs-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  color: var(--text-primary);
}

.qs-tag-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  font-size: 14px;
  line-height: 1;
}

.qs-tag-remove:hover {
  color: var(--danger);
}

/* Advanced collapsible */
.qs-adv-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}

.qs-adv-header:hover {
  opacity: 0.8;
}

.qs-chevron {
  transition: transform 0.25s ease;
  color: var(--text-muted);
}

.qs-adv-body {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Menu */
.qs-menu-item:hover {
  background: var(--bg) !important;
}

/* Model fetch spinner */
.qs-model-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.qs-model-loading::after {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ── Workers Table ── */
/* Reuses the Revenue & Profit table styling so the two cards stay visually
   identical. Only the last-column width needs overriding: the revenue table
   reserves 36px there for its edit button, which would squash Uptime. */
.worker-table thead th:last-child { width: auto; }
.worker-table thead th:first-child { width: 90px; }
.worker-pid {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  font-family: monospace;
}
.worker-skew span { color: #f59e0b !important; }
