/* Base layout — design tokens: tokens.css */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.25s ease, transform 0.3s ease;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .main-wrapper {
  margin-left: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-warning,
body.sidebar-collapsed .sidebar-nav-heading {
  display: none !important;
}

body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 18px 10px 20px;
}

body.sidebar-collapsed .sidebar-nav {
  padding: 16px 8px;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px;
  gap: 0;
}

body.sidebar-collapsed .sidebar-footer {
  padding: 10px 8px 14px;
}

.nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content { flex: 1; width: 100%; max-width: none; min-width: 0; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 24px;
  border-bottom: 1px solid var(--border);
}

.brand-logo-sm {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent-gold), #b8860b);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #0b0f19;
}

.brand-name { display: block; font-weight: 600; font-size: 15px; }
.brand-sub { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 12px 16px; overflow-y: auto; }

.sidebar-nav-heading {
  margin: 4px 10px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.2);
  border-left-color: var(--accent-blue);
}

.nav-icon { font-size: 16px; opacity: 0.8; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

.sidebar-warning {
  font-size: 11px;
  color: var(--accent-orange);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.4;
}

.top-header {
  min-height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 16px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-leading {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.sidebar-rail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-rail-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.sidebar-rail-toggle .nav-svg {
  width: 18px;
  height: 18px;
}

.sidebar-rail-toggle .rail-icon-expand {
  display: none;
}

body.sidebar-collapsed .sidebar-rail-toggle .rail-icon-collapse {
  display: none;
}

body.sidebar-collapsed .sidebar-rail-toggle .rail-icon-expand {
  display: block;
}

.app-breadcrumb {
  min-width: 0;
  flex: 1;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 0;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.35;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.breadcrumb-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 28ch;
}

.breadcrumb-root span {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}

.breadcrumb-sep {
  color: var(--text-muted);
  padding: 0 8px;
  font-size: 12px;
  user-select: none;
}

.breadcrumb-item:not(.breadcrumb-root):not(.breadcrumb-sep) span {
  color: var(--text-primary);
  font-weight: 600;
}

.breadcrumb-tab-item span {
  color: var(--accent-cyan) !important;
  font-weight: 500 !important;
}

.menu-toggle {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
}

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

.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-live {
  background: rgba(34, 197, 94, 0.15);
  color: var(--safe);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-demo {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-SAFE { background: rgba(34,197,94,0.15); color: var(--safe); }
.status-REVIEW { background: rgba(245,158,11,0.15); color: var(--review); }
.status-DISAVOW { background: rgba(239,68,68,0.15); color: var(--disavow); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2563eb; }
.btn-secondary { background: rgba(255,255,255,0.06); color: var(--text-primary); border-color: var(--border-light); }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
.btn-gold { background: linear-gradient(135deg, var(--accent-gold), #b8860b); color: #0b0f19; }
.btn-gold:hover:not(:disabled) { background: var(--accent-gold-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.btn-safe { background: rgba(34,197,94,0.15); color: var(--safe); border-color: rgba(34,197,94,0.3); }
.btn-review { background: rgba(245,158,11,0.15); color: var(--review); border-color: rgba(245,158,11,0.3); }
.btn-disavow { background: rgba(239,68,68,0.15); color: var(--disavow); border-color: rgba(239,68,68,0.3); }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-card);
  margin-bottom: 0;
  box-shadow: var(--shadow-card);
}

.input-panel,
.settings-page .panel:not(.settings-hero) {
  padding: var(--space-card);
}

.table-panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header { margin-bottom: 20px; }
.panel-header h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.panel-header p { font-size: 13px; color: var(--text-secondary); }

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

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }

.form-group input,
.form-group select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  transition: border-color 0.15s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.input-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border-light); }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stat-safe .stat-value { color: var(--safe); }
.stat-review .stat-value { color: var(--review); }
.stat-disavow .stat-value { color: var(--disavow); }

.workspace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 16px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.08);
}

.workspace-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.workspace-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.workspace-tab.active {
  color: var(--accent-blue);
  background: var(--bg-card);
  border-color: var(--border);
  border-bottom-color: var(--bg-card);
}

.table-panel .table-toolbar {
  border-top: none;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.toolbar-left h2 { font-size: 16px; font-weight: 600; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar-right select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  min-width: 120px;
}

.search-box input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 14px;
  font-size: 13px;
  width: 220px;
}

.table-wrapper { overflow-x: auto; max-height: 600px; overflow-y: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead { position: sticky; top: 0; z-index: 10; background: #1a2238; }

.data-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.data-table th:hover { color: var(--text-primary); }
.data-table th.sorted-asc::after { content: ' \2191'; color: var(--accent-blue); }
.data-table th.sorted-desc::after { content: ' \2193'; color: var(--accent-blue); }

.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { transition: background-color 0.1s; }
.col-check { width: 40px; }

.domain-link { color: var(--accent-cyan); cursor: pointer; font-weight: 500; text-decoration: none; }
.domain-link:hover { text-decoration: underline; color: var(--accent-blue); }

.reason-cell {
  max-width: 200px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.score-bar { flex: 1; height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; min-width: 50px; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.score-low { background: var(--safe); }
.score-mid { background: var(--review); }
.score-high { background: var(--disavow); }
.score-num { font-size: 12px; font-weight: 600; min-width: 24px; }

.skeleton-table { padding: 24px; }
.skeleton-row {
  height: 48px;
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-card-hover) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

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

.empty-state { text-align: center; padding: 60px 24px; color: var(--text-secondary); }
.empty-icon { font-size: 48px; opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto; }

.disavow-panel .disavow-actions { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.code-preview {
  background: #0a0e18;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #a5f3fc;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 20px;
  min-height: 280px;
  resize: vertical;
}

.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  margin: 0 24px 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-close {
  margin-left: auto;
  background: none; border: none;
  color: inherit; font-size: 20px;
  cursor: pointer; opacity: 0.7;
}

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  max-width: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.5);
  transform: translateX(0);
  transition: transform 0.3s ease;
}

.detail-drawer.hidden { transform: translateX(100%); pointer-events: none; }

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

.drawer-header h3 { font-size: 16px; word-break: break-all; }
.drawer-close { background: none; border: none; color: var(--text-secondary); font-size: 24px; cursor: pointer; padding: 4px 8px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }

.drawer-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.drawer-detail-row span:first-child { color: var(--text-secondary); }
.drawer-detail-section { margin-top: 20px; }
.drawer-detail-section h4 { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; letter-spacing: 0.04em; }

.drawer-actions {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.drawer-actions .btn { flex: 1; min-width: 100px; font-size: 12px; padding: 8px 12px; }


@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.mobile-cards { padding: 16px; }
.mobile-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.mobile-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mobile-card-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; color: var(--text-secondary); }

.hidden { display: none !important; }

@media (max-width: 1200px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .sidebar-rail-toggle { display: none; }
  .menu-toggle { display: inline-flex; }
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .sidebar-warning,
  body.sidebar-collapsed .sidebar-nav-heading {
    display: block !important;
  }
  .input-grid { grid-template-columns: 1fr; }
  .breadcrumb-root { display: none; }
  .breadcrumb-root + .breadcrumb-sep { display: none; }
}

@media (max-width: 640px) {
  .table-wrapper { display: none !important; }
  .mobile-cards:not(.hidden) { display: block !important; }
}

@media (max-width: 600px) {
  .content { padding: 16px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .input-actions .btn { flex: 1; min-width: 140px; }
  .toolbar-right { width: 100%; }
  .toolbar-right select { flex: 1; }
}

@media (min-width: 641px) {
  .mobile-cards { display: none !important; }
}

.api-usage-panel { margin-bottom: 24px; }
.api-usage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.api-usage-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.api-usage-item span { display: block; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; }
.api-usage-item strong { font-size: 15px; margin-top: 4px; display: block; }
.badge-pending {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
@media (max-width: 900px) { .api-usage-grid { grid-template-columns: 1fr; } }


/* ─── Bulk Selection Toolbar ─── */
.table-toolbar + .bulk-toolbar { border-top: 1px solid var(--border); }
.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(59, 130, 246, 0.06);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.bulk-toolbar-left { display: flex; align-items: center; gap: 12px; }
.bulk-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
}
.bulk-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.btn-bulk {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-bulk:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); border-color: var(--accent-blue); }
.btn-bulk-disavow:hover { border-color: var(--disavow); color: var(--disavow); }
.btn-bulk-review:hover { border-color: var(--review); color: var(--review); }
.btn-bulk-sm { padding: 5px 10px; font-size: 10px; }

/* Checkbox header */
.col-check-header { min-width: 44px; max-width: 44px; width: 44px; }
.check-header-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  white-space: nowrap;
}
.check-header-label input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent-blue); }
.check-header-text { user-select: none; }

/* Table safety — column/layout rules live in table-fix.css */
.table-wrapper { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.domain-link, .truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reason-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Drawer include checkbox */
.drawer-include {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.drawer-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.drawer-check-label input { width: 18px; height: 18px; accent-color: var(--accent-blue); }
.drawer-check-label input:disabled { opacity: 0.4; cursor: not-allowed; }

/* Mobile bulk bar */
.mobile-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(59, 130, 246, 0.08);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.mobile-bulk-actions { display: flex; gap: 6px; }
.mobile-card .mobile-card-check { margin-bottom: 8px; }
.mobile-card .mobile-card-check input { width: 16px; height: 16px; accent-color: var(--accent-blue); }

/* Body scroll lock when drawer open */
body.drawer-open { overflow: hidden; }

/* Z-index stack */
.sidebar { z-index: 100; }
.top-header { z-index: 50; }
.detail-drawer, .drawer-overlay { z-index: 200; }

/* Responsive bulk toolbar */
@media (max-width: 1200px) {
  .bulk-toolbar { padding: 10px 16px; }
  .btn-bulk { font-size: 10px; padding: 5px 10px; }
}
@media (max-width: 900px) {
  .bulk-toolbar-actions { width: 100%; }
  .bulk-toolbar-actions .btn-bulk { flex: 1 1 calc(33% - 6px); min-width: 0; justify-content: center; font-size: 9px; padding: 6px 4px; }
  .check-header-text { display: none; }
  .detail-drawer { width: 100%; max-width: 100%; }
}
@media (max-width: 600px) {
  .bulk-toolbar { flex-direction: column; align-items: stretch; }
  .bulk-toolbar-actions .btn-bulk { flex: 1 1 calc(50% - 4px); }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 12px; }
  .code-preview { font-size: 11px; min-height: 200px; }
}
@media (min-width: 901px) {
  .mobile-bulk-bar { display: none !important; }
}

/* ─── Session Loader (TabiTrade / Generator style) ─── */
#session-loader-ahrefs {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 35%, rgba(59, 130, 246, 0.14), transparent 42%),
    radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.08), transparent 35%),
    rgba(8, 12, 20, 0.96);
  backdrop-filter: blur(12px);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
#session-loader-ahrefs.loader-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#session-loader-ahrefs[hidden] { display: none !important; }
.loader-scene {
  width: min(420px, 100%);
  text-align: center;
  position: relative;
}
.loader-glow {
  position: absolute;
  left: 50%;
  top: 28px;
  width: 160px;
  height: 160px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.25), transparent 68%);
  filter: blur(8px);
  pointer-events: none;
}
.loader-orbit {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
}
.loader-orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent-blue, #3b82f6);
  border-right-color: rgba(6, 182, 212, 0.45);
  animation: orbit-spin 1.1s linear infinite;
}
.loader-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 14px rgba(59, 130, 246, 0.45));
  animation: icon-float 2.4s ease-in-out infinite;
}
@keyframes icon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes orbit-spin { to { transform: rotate(360deg); } }
.loader-logo-img {
  max-width: min(220px, 78vw);
  height: auto;
  margin: 0 auto 10px;
  display: block;
  object-fit: contain;
}
.loader-brand-sub {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-cyan, #06b6d4);
}
.loader-quote {
  margin: 0 0 8px;
  font-size: 0.98rem;
  line-height: 1.6;
  font-weight: 600;
  color: var(--text-primary, #e8edf5);
}
.loader-tip {
  margin: 0 0 18px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #8b9cb8);
}
.loader-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  max-width: 280px;
  margin: 0 auto;
}
.loader-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #3b82f6, #06b6d4, #8b5cf6);
  transition: width 0.22s ease;
}
body.booting .app { opacity: 0; pointer-events: none; }
body.booting { overflow: hidden; }
body.page-loading { cursor: wait; }


/* ═══ Generator-style notifications (TabiTrade) ═══ */
.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100002;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, calc(100vw - 32px));
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  border-radius: var(--radius-sm);
  background: rgba(14, 14, 22, 0.97);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-light);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  overflow: hidden;
  animation: ahrefs-toast-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast-item.toast-out { animation: ahrefs-toast-out 0.28s ease forwards; }
@keyframes ahrefs-toast-in {
  0% { opacity: 0; transform: translateX(18px) scale(0.9); }
  55% { transform: translateX(-3px) scale(1.02); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes ahrefs-toast-out {
  to { opacity: 0; transform: translateX(14px) scale(0.95); }
}
.toast-row { display: flex; flex-direction: row; align-items: stretch; min-height: 64px; }
.toast-icon-col {
  flex-shrink: 0; width: 52px; display: flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: inset 0 -4px 12px rgba(0, 0, 0, 0.22);
}
.toast-ava-svg { width: 26px; height: 26px; display: block; }
.toast-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toast-head { display: flex; align-items: flex-start; gap: 8px; padding: 10px 10px 8px 12px; flex: 1; }
.toast-content { flex: 1; min-width: 0; }
.toast-label {
  display: block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-secondary); margin-bottom: 3px;
}
.toast-message { display: block; font-size: 0.8rem; line-height: 1.45; color: var(--text-primary); word-break: break-word; }
.toast-close {
  flex-shrink: 0; width: 24px; height: 24px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-secondary); cursor: pointer; padding: 0;
  display: grid; place-items: center; transition: background 0.15s ease, color 0.15s ease;
}
.toast-close-svg { width: 13px; height: 13px; display: block; }
.toast-close:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.toast-progress-track { height: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.toast-progress-bar { height: 100%; width: 0; animation: ahrefs-toast-progress linear forwards; }
@keyframes ahrefs-toast-progress { from { width: 0%; } to { width: 100%; } }
.toast-item.status-success { border-color: rgba(52, 211, 153, 0.35); }
.toast-item.status-success .toast-icon-col { background: linear-gradient(180deg, #2d8a62 0%, #1a5c40 100%); }
.toast-item.status-success .toast-progress-bar { background: var(--safe); }
.toast-item.status-error { border-color: rgba(248, 113, 113, 0.35); }
.toast-item.status-error .toast-icon-col { background: linear-gradient(180deg, #a84848 0%, #7a2e2e 100%); }
.toast-item.status-error .toast-progress-bar { background: var(--disavow); }
.toast-item.status-warn { border-color: rgba(251, 191, 36, 0.35); }
.toast-item.status-warn .toast-icon-col { background: linear-gradient(180deg, #c48820 0%, #8a5a12 100%); }
.toast-item.status-warn .toast-progress-bar { background: var(--review); }
.toast-item.status-info { border-color: rgba(168, 85, 247, 0.35); }
.toast-item.status-info .toast-icon-col { background: linear-gradient(180deg, #5b4db8 0%, #3d3a8c 100%); }
.toast-item.status-info .toast-progress-bar { background: var(--accent-blue); }
.section-notice {
  display: none; margin: 0 0 16px; padding: 10px 14px; border-radius: calc(var(--radius-sm) + 2px);
  font-size: 0.8rem; line-height: 1.45; overflow-wrap: anywhere; word-break: break-word; backdrop-filter: blur(8px);
}
.section-notice.show { display: block; animation: ahrefs-notice-in 0.28s cubic-bezier(0.34, 1.45, 0.64, 1); }
.section-notice.is-hiding { animation: ahrefs-notice-out 0.28s ease forwards; }
@keyframes ahrefs-notice-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ahrefs-notice-out { to { opacity: 0; transform: translateY(-4px); } }
.section-notice.status-success {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.12), rgba(16, 185, 129, 0.06));
  border: 1px solid rgba(52, 211, 153, 0.28); color: #a7f3d0;
}
.section-notice.status-error {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.12), rgba(239, 68, 68, 0.06));
  border: 1px solid rgba(248, 113, 113, 0.28); color: #fecaca;
}
.section-notice.status-warn {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(245, 158, 11, 0.06));
  border: 1px solid rgba(251, 191, 36, 0.28); color: #fde68a;
}
.section-notice.status-info {
  background: linear-gradient(135deg, rgba(192, 38, 211, 0.12), rgba(124, 58, 237, 0.06));
  border: 1px solid rgba(192, 38, 211, 0.28); color: #e9d5ff;
}
.section-notice-persist:not(.show) { display: none; }

.form-group-full{grid-column:1/-1}
.field-hint,.label-muted{font-size:.8rem;color:var(--muted,#888);margin:.25rem 0 0}
#targetDomainsBatch{min-height:5rem;font-family:inherit;resize:vertical}


/* ── Settings page ── */
.settings-page { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }
.settings-page.hidden { display: none !important; }

.settings-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  background: linear-gradient(135deg, rgba(212,175,55,0.08) 0%, rgba(255,255,255,0.02) 60%);
  border: 1px solid var(--border);
}
.settings-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold, #d4af37);
  margin-bottom: 6px;
}
.settings-hero h2 { font-size: 26px; font-weight: 700; margin: 0 0 8px; }
.settings-lead { font-size: 14px; color: var(--text-secondary); max-width: 52ch; margin: 0; line-height: 1.55; }
.settings-hero-meta { flex-shrink: 0; padding-top: 4px; }

.settings-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
}
.settings-status-pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.settings-status-ok { color: #4ade80; border-color: rgba(74,222,128,0.35); background: rgba(74,222,128,0.08); }
.settings-status-demo { color: #fbbf24; border-color: rgba(251,191,36,0.35); background: rgba(251,191,36,0.08); }
.settings-status-error { color: #f87171; border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.08); }
.settings-status-neutral { color: var(--text-secondary); }

.settings-api-card { padding: 22px 24px 24px; }
.settings-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.settings-card-head h3 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.settings-card-head p { font-size: 13px; color: var(--text-secondary); margin: 0; }
.settings-api-line {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.settings-content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.settings-card textarea {
  width: 100%;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.api-usage-highlight {
  grid-column: 1 / -1;
  background: linear-gradient(90deg, rgba(212,175,55,0.1), transparent);
  border-color: rgba(212,175,55,0.25);
}
.api-usage-bars { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.usage-bar-block { display: flex; flex-direction: column; gap: 8px; }
.usage-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.usage-bar-top strong { color: var(--text-primary, #fff); font-size: 13px; }
.usage-bar-top em { font-style: normal; color: var(--text-secondary); font-weight: 500; }
.usage-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  overflow: hidden;
}
.usage-bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.usage-bar-ok { background: linear-gradient(90deg, #22c55e, #4ade80); }
.usage-bar-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.usage-bar-danger { background: linear-gradient(90deg, #ef4444, #f87171); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

@media (max-width: 900px) {
  .settings-hero { flex-direction: column; }
  .settings-content-grid { grid-template-columns: 1fr; }
  .api-usage-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .api-usage-grid { grid-template-columns: 1fr; }
}


/* PRO UI */
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.nav-svg { width: 20px; height: 20px; display: block; stroke: currentColor; fill: none; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; color: var(--accent-cyan, #06b6d4); flex-shrink: 0; }
.nav-item.active .nav-icon { color: var(--accent-blue, #3b82f6); }
.menu-icon.nav-icon { color: var(--text-primary, #e8ecf4); }

.content { overflow-x: visible; min-width: 0; }
.top-header { flex-wrap: wrap; gap: 12px; min-height: var(--header-height); height: auto; padding: 12px 16px; }
.header-leading { flex-wrap: wrap; }
.breadcrumb-item span { max-width: 22ch; }
.header-actions { flex-wrap: wrap; }

.table-panel { overflow: hidden; }
.table-toolbar { flex-wrap: wrap; gap: 10px; }
.toolbar-left, .toolbar-right { flex-wrap: wrap; gap: 8px; }
.toolbar-right select, .search-box input { max-width: 100%; }

/* Table layout — see table-fix.css */

.bulk-toolbar {
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  row-gap: 10px;
}

.bulk-toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-bulk { white-space: nowrap; font-size: 11px; padding: 7px 10px; }

.empty-state { padding: 48px 24px; text-align: center; }
.empty-svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.45; color: var(--accent-cyan); }
.empty-state h3 { font-size: 17px; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p { max-width: 42ch; margin: 0 auto; line-height: 1.55; color: var(--text-secondary); }

.settings-page, .panel, .settings-card { min-width: 0; }
.settings-card textarea, .form-group input, .form-group select, textarea {
  max-width: 100%;
  box-sizing: border-box;
}

.toast-label:empty { display: none; }

@media (max-width: 900px) {
  .sidebar { box-shadow: 8px 0 32px rgba(0,0,0,0.45); }
}

.nav-shortcut-tag { font-size: 10px; color: var(--text-muted, #8892a8); font-weight: 500; margin-left: 2px; }
.badge-pending { background: rgba(59,130,246,0.12); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }












/* Ahrefs confirm dialog v6 */
.ahrefs-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ahrefs-confirm-modal[hidden] { display: none !important; }
.ahrefs-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ahrefs-confirm-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 24px 22px 20px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid rgba(251, 191, 36, 0.35);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  animation: ahrefs-toast-in 0.28s ease;
}
.ahrefs-confirm-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  margin-bottom: 14px;
}
.ahrefs-confirm-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text-primary);
}
.ahrefs-confirm-message {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: normal;
  overflow-wrap: anywhere;
}
.ahrefs-confirm-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
body.ahrefs-confirm-open { overflow: hidden; }

.data-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}
.data-type-badge.mode-backlink {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.12);
  color: #c4b5fd;
}

.workspace-cache-hint {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-secondary);
}
.settings-cache-card { margin-top: 16px; }
