/* ==========================================================================
   TonTon SEOPilot 2.0 (tontonseo.com) — Master Cybernetic Design System
   Optimized for: Desktop (4K/1080p), Tablet (iPad/Surfaces), Mobile (iOS/Android)
   ========================================================================== */

/* Fonts are loaded via <link rel="preconnect"> + <link rel="stylesheet"> in index.html.
   A CSS @import here would serialise the request and delay first paint. */

:root {
  /* Dark Cyber Surfaces */
  --bg-0: #030712;
  --bg-sidebar: #060d1a;
  --bg-topbar: rgba(6, 13, 26, 0.92);
  --bg-1: rgba(134, 239, 172, 0.035);
  --bg-2: rgba(134, 239, 172, 0.065);
  --bg-card: rgba(11, 20, 38, 0.88);
  --bg-card-hover: rgba(15, 27, 51, 0.95);
  --bg-input: rgba(4, 9, 18, 0.95);
  --bg-glass: rgba(11, 20, 38, 0.82);

  /* Precise Glowing Lines */
  --line: rgba(134, 239, 172, 0.12);
  --line-strong: rgba(134, 239, 172, 0.24);
  --line-bright: rgba(134, 239, 172, 0.42);
  --line-glow: rgba(0, 255, 65, 0.45);
  --border-subtle: rgba(255, 255, 255, 0.08);

  /* Neon Brand Accents */
  --accent: #00ff41;
  --accent-soft: #4ade80;
  --accent-deep: #15803d;
  --accent-dim: rgba(0, 255, 65, 0.15);
  --cyan: #00f2fe;
  --cyan-soft: rgba(0, 242, 254, 0.15);
  --blue: #38bdf8;
  --indigo: #818cf8;
  --purple: #c084fc;
  --purple-soft: rgba(192, 132, 252, 0.15);
  --green: #4ade80;
  --amber: #fbbf24;
  --rose: #f87171;
  --pink: #f472b6;
  --teal: #14b8a6;

  /* Typography */
  --text: #f8fafc;
  --text-primary: #f8fafc;
  --text-secondary: rgba(248, 250, 252, 0.82);
  --text-muted: rgba(248, 250, 252, 0.52);
  --text-muted-soft: rgba(248, 250, 252, 0.32);

  --font-display: 'Outfit', 'Uncut Sans', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  /* Geometry & Physics */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 9999px;
  --ease-default: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-hover: 0.22s;
  --z-nav: 1000;
  --z-modal: 9999;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-sans);
}

html, body {
  background-color: var(--bg-0);
  color: var(--text);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Visibility Control */
.hidden {
  display: none !important;
}

.tab-view {
  display: block;
  width: 100%;
  animation: tabFadeIn 0.18s var(--ease-default);
}

.tab-view.hidden {
  display: none !important;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dot Grid Background Overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: screen;
  background-image: radial-gradient(circle, rgba(74, 222, 128, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #030712; }
::-webkit-scrollbar-thumb { background: rgba(134, 239, 172, 0.2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

::selection {
  background: rgba(0, 255, 65, 0.35);
  color: #fff;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
  width: 270px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 50;
  position: relative;
  transition: transform 0.3s var(--ease-default), width 0.3s var(--ease-default);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(0, 255, 65, 0.25) 0%, rgba(0, 242, 254, 0.15) 100%);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--accent);
  box-shadow: 0 0 16px rgba(0, 255, 65, 0.25);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
  display: inline-block;
  margin-top: 2px;
  font-weight: 600;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--duration-hover) var(--ease-default);
  position: relative;
  user-select: none;
}

.nav-item:hover {
  color: #fff;
  background: var(--bg-1);
  border-color: var(--line);
  transform: translateX(3px);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(0, 255, 65, 0.09);
  border-color: var(--line-bright);
  box-shadow: inset 0 0 14px rgba(0, 255, 65, 0.12);
  font-weight: 700;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 14px 8px 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 45;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   Main Content Shell & Top Header
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  position: relative;
  min-width: 0;
}

/* Responsive Top Navbar */
.top-header {
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: var(--bg-topbar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 30;
  gap: 14px;
  flex-wrap: nowrap;
}

.top-left-section {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Mobile Hamburger Toggle */
.btn-mobile-toggle {
  display: none;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mobile-toggle:hover {
  background: var(--bg-2);
  border-color: var(--accent);
  color: var(--accent);
}

/* Breadcrumb Navigation */
.header-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-breadcrumbs .brand-tag {
  color: var(--accent);
  font-weight: 700;
}

.header-breadcrumbs .separator {
  color: var(--text-muted-soft);
}

.header-breadcrumbs .active-crumb {
  color: #fff;
  font-weight: 600;
}

/* Header Actions Toolbar */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Admin Profile Button & Dropdown */
.admin-profile-wrap {
  position: relative;
}

.admin-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 27, 51, 0.8);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 5px 14px 5px 6px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-hover) var(--ease-default);
}

.admin-profile-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 242, 254, 0.2);
  background: rgba(15, 27, 51, 1);
}

.admin-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #030712;
  font-weight: 800;
}

.admin-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Admin Dropdown Menu */
.admin-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: rgba(11, 20, 38, 0.96);
  border: 1px solid var(--cyan);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(0, 242, 254, 0.15);
  backdrop-filter: blur(20px);
  padding: 12px;
  z-index: 100;
  display: none;
}

.admin-dropdown-menu.show {
  display: block;
  animation: dropdownFadeIn 0.2s var(--ease-default);
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.admin-dropdown-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.admin-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.admin-dropdown-item:hover {
  background: rgba(0, 242, 254, 0.08);
  color: var(--cyan);
}

/* ==========================================================================
   Content Body & Universal Page Hero Banner
   ========================================================================== */
.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-width: 0;
}

/* Universal Dedicated Page Hero Banner */
.page-hero-banner {
  background: linear-gradient(135deg, rgba(11, 20, 38, 0.95) 0%, rgba(15, 27, 51, 0.88) 100%);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.page-hero-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent) 0%, var(--cyan) 100%);
}

.page-hero-title-group h1 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-hero-title-group p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  max-width: 720px;
}

.page-hero-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.84rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--duration-hover) var(--ease-default);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: #ffffff;
  color: #030712;
  border-color: #ffffff;
}

.btn-primary:hover {
  background: #f1f5f9;
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(134, 239, 172, 0.05);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: rgba(134, 239, 172, 0.12);
  border-color: var(--line-bright);
  color: var(--accent-soft);
  transform: translateY(-1px);
}

.btn-success {
  background: rgba(0, 255, 65, 0.14);
  color: var(--accent);
  border-color: rgba(0, 255, 65, 0.4);
}

.btn-success:hover {
  background: var(--accent);
  color: #030712;
  box-shadow: 0 0 22px rgba(0, 255, 65, 0.45);
  transform: translateY(-1px);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(0, 255, 65, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 255, 65, 0.3);
}

.badge-running {
  background: rgba(0, 242, 254, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 242, 254, 0.3);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 600;
  border: 1px solid transparent;
}

/* ==========================================================================
   Cards, Surfaces & Grid Systems
   ========================================================================== */
.table-card, .stat-card, .terminal-card, .card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 22px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--duration-hover) var(--ease-default);
}

.table-card:hover, .stat-card:hover, .card:hover {
  border-color: var(--line-bright);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 255, 65, 0.08);
}

/* Stats Grid (4 cols -> 2 cols -> 1 col) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px 22px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* Real-Time Terminal */
.terminal-card {
  padding: 0;
  background: #040812;
  border: 1px solid var(--line-strong);
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #081022;
  border-bottom: 1px solid var(--line);
}

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; }
}

.terminal-body {
  height: 380px;
  overflow-y: auto;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: #94a3b8;
}

.terminal-line {
  margin-bottom: 4px;
}

.terminal-timestamp {
  color: var(--cyan);
  font-weight: 600;
  margin-right: 6px;
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.data-table th {
  background: rgba(15, 27, 51, 0.6);
  padding: 12px 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: rgba(134, 239, 172, 0.03);
  color: #fff;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.25);
  background: #060e20;
}

/* Canvas Visualizer */
.canvas-container {
  width: 100%;
  height: 580px;
  background: #040711;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.canvas-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.canvas-tool-btn {
  width: 34px;
  height: 34px;
  background: rgba(11, 20, 38, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--accent-soft);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-hover) var(--ease-default);
}

.canvas-tool-btn:hover {
  background: var(--bg-1);
  border-color: var(--accent);
  color: #fff;
}

.inspector-drawer {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 280px;
  background: rgba(6, 10, 16, 0.94);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-md);
  padding: 16px;
  backdrop-filter: blur(12px);
  z-index: 10;
}

/* Telemetry Equalizer Bars */
.telemetry-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.telemetry-eq span {
  width: 2px;
  height: 3px;
  background: var(--accent);
  animation: eq-bounce 0.8s ease-in-out infinite;
}

.telemetry-eq span:nth-child(2) { animation-delay: 0.2s; }
.telemetry-eq span:nth-child(3) { animation-delay: 0.4s; }
.telemetry-eq span:nth-child(4) { animation-delay: 0.1s; }

@keyframes eq-bounce {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 20px;
}

.modal-card {
  background: #091224;
  border: 1px solid var(--cyan);
  border-radius: var(--radius-md);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 45px rgba(0, 242, 254, 0.18);
  padding: 26px;
  max-width: 100%;
  animation: modalPop 0.22s var(--ease-default);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==========================================================================
   Comprehensive Responsive Media Queries (Mobile, Tablet, Desktop)
   ========================================================================== */

/* 1. Tablet View (768px to 1024px) */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.9);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .btn-mobile-toggle {
    display: inline-flex;
  }

  .content-body {
    padding: 18px;
  }

  .page-hero-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .top-header {
    padding: 10px 16px;
  }
}

/* 2. Mobile View (< 768px) */
@media (max-width: 768px) {
  .top-header {
    min-height: 56px;
    padding: 8px 12px;
  }

  .header-breadcrumbs {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .page-hero-banner {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .page-hero-title-group h1 {
    font-size: 1.3rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 14px 16px;
  }

  .stat-value {
    font-size: 1.7rem;
  }

  .terminal-body {
    height: 280px;
    font-size: 0.74rem;
  }

  .content-body {
    padding: 14px 10px;
  }

  .table-card {
    padding: 16px 12px;
  }

  /* Table Horizontal Scrolling */
  .table-responsive-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
  }
}

/* 3. Small Mobile Devices (< 480px) */
@media (max-width: 480px) {
  .sidebar {
    width: 250px;
  }

  .admin-profile-btn span.admin-email-text {
    display: none;
  }

  .modal-card {
    padding: 18px 14px;
  }
}

/* ==========================================================================
   2.1 — Feedback, table states, accessibility and responsive corrections
   ========================================================================== */

/* --- Screen-reader-only utility (labels for unlabelled inputs) ------------ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Visible focus. Outlines were suppressed everywhere, which made the
       dashboard impossible to operate by keyboard. ------------------------- */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Toasts (replacing the blocking alert() dialogs) ---------------------- */
.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
  border: 1px solid var(--line-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.5;
  animation: toast-in 0.22s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
}
.toast-msg { flex: 1; word-break: break-word; }
.toast-close {
  background: none; border: 0; cursor: pointer;
  color: var(--text-muted); font-size: 1.15rem; line-height: 1;
  padding: 0 2px;
}
.toast-close:hover { color: var(--text); }
.toast-success { border-color: rgba(74, 222, 128, 0.5); }
.toast-success .toast-icon { background: rgba(74, 222, 128, 0.18); color: var(--green); }
.toast-error   { border-color: rgba(248, 113, 113, 0.5); }
.toast-error .toast-icon { background: rgba(248, 113, 113, 0.18); color: var(--rose); }
.toast-warn    { border-color: rgba(251, 191, 36, 0.5); }
.toast-warn .toast-icon { background: rgba(251, 191, 36, 0.18); color: var(--amber); }
.toast-info .toast-icon { background: rgba(0, 242, 254, 0.18); color: var(--cyan); }

/* --- Button loading state ------------------------------------------------- */
.btn[aria-busy="true"] { opacity: 0.75; cursor: progress; }
.btn-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -1px;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-spinner, .toast { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.btn-xs { font-size: 0.74rem; padding: 4px 9px; }
.btn-danger-ghost { color: var(--rose); }
.btn-danger-ghost:hover { border-color: rgba(248, 113, 113, 0.5); }

.link-button {
  background: none;
  border: 0;
  color: var(--cyan);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

/* --- Table empty / error / meta states ------------------------------------ */
.table-empty, .table-error {
  text-align: center;
  padding: 26px 18px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.table-empty { color: var(--text-muted); }
.table-error { color: var(--rose); }

.table-meta { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 10px; }
.table-pager { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.table-pager .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Cell helpers --------------------------------------------------------- */
.cell-mono { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }
.cell-muted { color: var(--text-muted); font-size: 0.8rem; }
.cell-link { color: var(--cyan); text-decoration: none; }
.cell-link:hover { text-decoration: underline; }
.cell-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Campaign progress bar ------------------------------------------------ */
.progress-cell { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.progress-track {
  height: 6px;
  width: 100%;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), var(--accent-soft));
  transition: width 0.35s ease;
}
.progress-label { font-size: 0.76rem; color: var(--text-muted); }

/* --- Badges added in 2.1 -------------------------------------------------- */
.badge-error { background: rgba(248, 113, 113, 0.15); color: var(--rose); }
.badge-tier  { background: rgba(0, 242, 254, 0.12); color: var(--cyan); }

/* --- Form helpers --------------------------------------------------------- */
.form-hint { font-size: 0.75rem; color: var(--text-muted); line-height: 1.5; margin: 6px 0 0; }
.form-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.82rem;
  margin-bottom: 14px;
}
.form-link { font-size: 0.72rem; font-family: var(--font-mono); color: var(--cyan); text-decoration: none; }
.input-with-status { display: flex; align-items: center; gap: 8px; }
.input-with-status .form-input { flex: 1; min-width: 0; }
.input-with-status .badge { flex-shrink: 0; }

/* --- Plan cards get a real selected state (previously inline styles only) - */
.plan-card { outline-offset: 2px; }
.plan-card.selected {
  border-color: var(--cyan) !important;
  background: rgba(0, 242, 254, 0.07) !important;
  box-shadow: 0 0 0 1px rgba(0, 242, 254, 0.35);
}

/* --- Guide callouts ------------------------------------------------------- */
.guide-callout {
  border-left: 3px solid var(--cyan);
  background: rgba(0, 242, 254, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  margin: 14px 0;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.guide-callout.warn { border-left-color: var(--amber); background: rgba(251, 191, 36, 0.06); }
.guide-callout strong { color: #fff; }

.guide-steps { margin: 12px 0 0; padding-left: 20px; line-height: 1.85; font-size: 0.87rem; color: var(--text-secondary); }
.guide-steps li { margin-bottom: 6px; }
.guide-steps strong { color: #fff; }

/* --- Tables scroll inside their card; the page itself never scrolls sideways */
.table-card { overflow: hidden; }
.table-responsive-wrap,
.table-card > div[style*="overflow-y"] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-card .data-table { min-width: 720px; }
html, body { max-width: 100%; overflow-x: hidden; }

/* --- Responsive corrections ---------------------------------------------- */
@media (max-width: 1024px) {
  #view-settings > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #modal-paywall .modal-card > div[style*="1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  .canvas-container { height: 460px; }
}

@media (max-width: 768px) {
  .toast-host { right: 10px; left: 10px; bottom: 10px; max-width: none; }
  .cell-truncate { max-width: 150px; }
  #modal-paywall .modal-card > div[style*="1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #view-guide div[style*="grid-template-columns:1fr 1fr"],
  .table-card div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  .modal-card { width: 96vw !important; max-width: 96vw; max-height: 90vh; overflow-y: auto; }
  .page-hero-badges { width: 100%; flex-wrap: wrap; }
  .page-hero-badges .btn, .page-hero-badges .form-select { flex: 1 1 auto; }
  .canvas-container { height: 380px; }
  .table-pager { justify-content: stretch; }
  .table-pager .btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
  .content-body { padding: 12px 8px; }
  .canvas-container { height: 320px; }
}

/* Comfortable touch targets on coarse pointers. */
@media (pointer: coarse) {
  .btn, .nav-item, .canvas-tool-btn { min-height: 40px; }
  .btn-xs { min-height: 34px; }
}

/* --- In-app section guides ------------------------------------------------ */
.section-guide {
  background: rgba(0, 242, 254, 0.035);
  border: 1px solid rgba(0, 242, 254, 0.18);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  overflow: hidden;
}
.section-guide > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.section-guide > summary::-webkit-details-marker { display: none; }
.section-guide > summary::after {
  content: "\25BE";
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}
.section-guide[open] > summary::after { transform: rotate(180deg); }
.section-guide > summary:hover { background: rgba(0, 242, 254, 0.05); }

.section-guide-icon {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0, 242, 254, 0.16);
  color: var(--cyan);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}
.section-guide-heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.section-guide-heading strong { color: #fff; font-size: 0.92rem; font-weight: 700; }
.section-guide-heading span { color: var(--text-muted); font-size: 0.8rem; }

.section-guide-body {
  padding: 4px 18px 16px 52px;
  border-top: 1px solid rgba(0, 242, 254, 0.12);
}
.section-guide-body code {
  background: rgba(0, 0, 0, 0.4);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--cyan);
}
.section-guide-body kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.8em;
}

@media (max-width: 768px) {
  .section-guide-body { padding: 4px 14px 14px 16px; }
  .section-guide-heading span { display: none; }
}

/* --- Niche grouping chips (target directory) ------------------------------ */
.niche-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.niche-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.niche-chip:hover { border-color: var(--cyan); color: #fff; }
.niche-chip span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan);
  background: rgba(0, 242, 254, 0.12);
  border-radius: 999px;
  padding: 1px 7px;
}

/* ==========================================================================
   LINK ENGINE
   --------------------------------------------------------------------------
   Built on the existing tokens rather than new colours, so this section reads
   as part of the same product. The one deliberate signal: a nofollow link is
   shown in muted grey and a dofollow one in green, because the difference is
   the whole point and a dashboard that renders them alike is lying by design.
   ========================================================================== */

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.method-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color .16s ease, background .16s ease;
}

.method-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--line-strong);
}

.method-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.method-name {
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: .01em;
}

.method-about {
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 0 0 10px;
}

.method-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

/* Platform picker ------------------------------------------------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-1);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.chip:hover {
  border-color: var(--line-bright);
  color: var(--text-primary);
}

.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-primary);
}

.chip input { accent-color: var(--accent); margin: 0; }

.chip-note {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent-soft);
}

/* The distinction that matters ------------------------------------------ */

.badge-muted {
  background: rgba(248, 250, 252, 0.07);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.badge-warn {
  background: rgba(251, 191, 36, 0.13);
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.32);
}

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

/* Form rows in the Link Engine ------------------------------------------- */
/* .form-group exists but has no row container, so two fields on one line
   collapsed into a single inline run. */

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}

.form-row .form-group { min-width: 240px; }

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

.form-group input[type="url"],
.form-group input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color .16s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

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