@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

:root {
  --bg:           #090d16;
  --bg-grid:      rgba(255, 255, 255, 0.02);
  --surface:      rgba(15, 23, 42, 0.72);
  --surface-alt:  rgba(20, 30, 52, 0.65);
  --border:       rgba(255, 255, 255, 0.08);
  --border-focus: #8b5cf6;
  --text:         #f1f5f9;
  --text-dim:     #cbd5e1;
  --muted:        #64748b;
  --accent:       #6366f1;
  --accent-glow:  rgba(99, 102, 241, 0.35);
  --purple:       #8b5cf6;
  --pink:         #ec4899;
  --red:          #f43f5e;
  --green:        #10b981;
  --yellow:       #f59e0b;
  --cyan:         #06b6d4;
  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    18px;
  --mono:         'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Custom Scrollbar ────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(9, 13, 22, 0.7);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ── Base & Ambient Background (Locket Dio Clone) ───── */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -12%, rgba(120, 119, 198, 0.25), transparent 70%),
    radial-gradient(circle at 12% 20%, rgba(236, 72, 153, 0.12), transparent 35%),
    radial-gradient(circle at 88% 75%, rgba(59, 130, 246, 0.12), transparent 35%),
    radial-gradient(circle at 50% 55%, rgba(139, 92, 246, 0.08), transparent 45%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 36px 36px, 36px 36px;
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Signature Gradient Text Animation ───────────────── */
@keyframes gradient-flow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gradient-text {
  background: linear-gradient(135deg, #ff007a 0%, #7928ca 32%, #0070f3 68%, #00dfd8 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-flow 6s ease infinite;
  font-weight: 800;
  display: inline-block;
}

.gradient-locket {
  background: linear-gradient(135deg, #f59e0b 0%, #ec4899 50%, #8b5cf6 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-flow 5s ease infinite;
  font-weight: 800;
  display: inline-block;
}

.gradient-spotify {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  display: inline-block;
}

/* ── Login View ──────────────────────────────────────── */
#login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

#login-form, .login-card {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 42px 34px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(99, 102, 241, 0.15);
  animation: fade-in-up 0.4s ease;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#login-form h1, .login-card h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
}

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

.login-header p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

/* ── Floating Modern Header ──────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.logo, .header-logo {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.stats-bar {
  display: flex;
  gap: 10px;
  margin-left: auto;
  align-items: center;
}

.stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 6px 14px;
  text-align: center;
  min-width: 86px;
  transition: all 0.2s ease;
}
.stat:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}
.stat span {
  display: block;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.accent-red    span { color: var(--red);    text-shadow: 0 0 12px rgba(244, 63, 94, 0.35); }
.accent-green  span { color: var(--green);  text-shadow: 0 0 12px rgba(16, 185, 129, 0.35); }
.accent-yellow span { color: var(--yellow); text-shadow: 0 0 12px rgba(245, 158, 11, 0.35); }

/* ── Segmented Floating Pill Tabs ────────────────────── */
.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  margin: 16px 24px 0;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}
.tab.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(168, 85, 247, 0.25));
  color: #fff;
  border: 1px solid rgba(168, 85, 247, 0.45);
  box-shadow: 0 4px 18px rgba(168, 85, 247, 0.25);
}

/* ── Content & Glass Cards ───────────────────────────── */
.tab-content {
  padding: 20px 24px 40px;
  animation: fade-in-up 0.25s ease;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card h2, .card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
  letter-spacing: -0.01em;
}

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

.card-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ── Modern Form Controls ────────────────────────────── */
input, select, textarea {
  background: rgba(11, 17, 32, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #f8fafc;
  font: inherit;
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25), 0 0 15px rgba(139, 92, 246, 0.2);
}

input::placeholder, textarea::placeholder {
  color: var(--muted);
}

select option {
  background: #0f172a;
  color: #f8fafc;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-dim);
}

.rule-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.rule-form input  { flex: 1; min-width: 180px; }
.rule-form select { width: 140px; }

/* ── Glowing Buttons ─────────────────────────────────── */
button, .btn {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  background-size: 200% 200%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

button:hover, .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
  background-position: right center;
  opacity: 1;
}

button:active, .btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  color: #e2e8f0;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
  color: #94a3b8;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}
.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
}

/* ── Modern Frosted Tables ───────────────────────────── */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th {
  background: rgba(255, 255, 255, 0.02);
  color: #94a3b8;
  font-weight: 700;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  transition: background 0.15s ease;
}

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

tr:hover td {
  background: rgba(255, 255, 255, 0.035);
}

/* ── Pill Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 9999px;
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-block {
  background: rgba(244, 63, 94, 0.15);
  color: #f87171;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-allow {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-redirect {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-full {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

/* ── Toggle Switches ─────────────────────────────────── */
.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  border: none;
  padding: 0;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on {
  background: var(--green);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.toggle.on::after {
  transform: translateX(16px);
}

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

/* ── Profiles Grid & Cards ───────────────────────────── */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.profile-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.25s ease;
}
.profile-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}
.profile-icon { font-size: 28px; margin-bottom: 10px; }
.profile-card p { color: var(--muted); font-size: 13px; margin: 6px 0 14px; line-height: 1.5; }
.profile-card strong { color: var(--text); }
.profile-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.profile-main {
  text-align: center;
  padding: 36px 24px;
}
.profile-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
  text-align: left;
}
.profile-icon-big {
  font-size: 46px;
  filter: drop-shadow(0 0 16px rgba(99, 102, 241, 0.3));
}
.profile-main h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 2px;
}
.profile-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 12px auto 18px;
  max-width: 520px;
}
.profile-contains {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}
.profile-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
}

/* ── Setup Steps ─────────────────────────────────────── */
.setup-steps ol {
  padding-left: 20px;
  line-height: 2.1;
  color: var(--text-dim);
}
.setup-steps strong {
  color: #fff;
}
.setup-steps em {
  font-style: normal;
  color: var(--purple);
}
.setup-steps code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* ── Settings Form ───────────────────────────────────── */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.settings-form label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 6px;
}
.settings-form .hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
#st-status, #pw-status { font-size: 12px; font-weight: 600; }
#st-status.ok, #pw-status.ok { color: var(--green); }
#st-status.err, #pw-status.err { color: var(--red); }

/* ── Cert Output ─────────────────────────────────────── */
pre#cert-output {
  background: rgba(11, 17, 32, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #34d399;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  margin-top: 14px;
  max-height: 360px;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Utilities ───────────────────────────────────────── */
.hidden { display: none !important; }
.muted  { color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty  { text-align: center; color: var(--muted); padding: 32px 0; }
.err    { color: var(--red); font-size: 12px; margin-top: 6px; font-weight: 500; }

code {
  font-family: var(--mono);
  font-size: 12px;
  color: #c084fc;
}

/* ── CTV User Pill ───────────────────────────────────── */
.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Modal / Popup (Locket Dio Glassmorphism) ────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-box {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  padding: 26px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.8), 0 0 50px rgba(99, 102, 241, 0.2);
  transform: translateY(16px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: #e2e8f0;
}
.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 14px;
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1;
  border-radius: 8px;
  transition: all 0.15s ease;
}
.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── Toast Notification ──────────────────────────────── */
#app-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff;
  border: 1px solid rgba(139, 92, 246, 0.35);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 25px rgba(139, 92, 246, 0.25);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px) scale(0.9);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  z-index: 10000;
  pointer-events: none;
}
#app-toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ── Responsive adjustments ──────────────────────────── */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
    gap: 12px;
  }
  .stats-bar {
    margin-left: 0;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .tabs {
    margin: 12px 16px 0;
  }
  .tab-content {
    padding: 16px;
  }
  .stat {
    min-width: 74px;
    padding: 4px 10px;
  }
  .stat span {
    font-size: 15px;
  }
}
