/* =============================================
   DomainFilter Pro — Complete Stylesheet
   ============================================= */

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

/* ---------- CSS Variables ---------- */
:root {
  --font-base: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Colors — Light Mode */
  --bg-base: #f4f6fb;
  --bg-card: #ffffff;
  --bg-card-hover: #f9fafc;
  --bg-header: #ffffff;
  --bg-input: #f8f9fc;
  --bg-input-focus: #ffffff;
  --bg-table-head: #f0f2f8;
  --bg-table-row-even: #fafbfe;
  --bg-row-pass: #f0fdf4;
  --bg-row-fail: #fef2f2;
  --bg-row-warn: #fffbeb;
  --bg-modal: #ffffff;
  --bg-drawer: #ffffff;
  --bg-overlay: rgba(15, 20, 40, 0.45);
  --bg-progress-track: #e8eaf0;

  --text-primary: #0f1729;
  --text-secondary: #4a5578;
  --text-muted: #8693b0;
  --text-link: #2563eb;
  --text-inverse: #ffffff;

  --border-color: #e4e8f0;
  --border-focus: #2563eb;
  --border-card: rgba(0,0,0,0.06);

  --accent-primary: #2563eb;
  --accent-primary-dark: #1d4ed8;
  --accent-primary-light: #eff6ff;
  --accent-success: #16a34a;
  --accent-success-light: #dcfce7;
  --accent-danger: #dc2626;
  --accent-danger-light: #fee2e2;
  --accent-warning: #d97706;
  --accent-warning-light: #fef3c7;
  --accent-gray: #6b7280;
  --accent-gray-light: #f3f4f6;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-base: 0.22s ease;
  --transition-slow: 0.35s ease;

  --header-height: 64px;
  --drawer-width: 520px;
  --container-max: 1320px;

  /* Metric card accent colors */
  --metric-total-accent: #6366f1;
  --metric-indexed-accent: #16a34a;
  --metric-notindexed-accent: #dc2626;
  --metric-passed-accent: #0891b2;
  --metric-spam-accent: #d97706;
  --metric-errors-accent: #9ca3af;
}

[data-theme="dark"] {
  --bg-base: #0c0e18;
  --bg-card: #141726;
  --bg-card-hover: #1a1e30;
  --bg-header: #101323;
  --bg-input: #1e2235;
  --bg-input-focus: #252a40;
  --bg-table-head: #1a1e30;
  --bg-table-row-even: #141726;
  --bg-row-pass: #0d2318;
  --bg-row-fail: #230d0d;
  --bg-row-warn: #211a06;
  --bg-modal: #141726;
  --bg-drawer: #141726;
  --bg-overlay: rgba(0, 0, 0, 0.65);
  --bg-progress-track: #252a40;

  --text-primary: #e8ecf5;
  --text-secondary: #94a3c0;
  --text-muted: #5a6585;
  --text-link: #60a5fa;
  --text-inverse: #0f1729;

  --border-color: #252a40;
  --border-focus: #3b82f6;
  --border-card: rgba(255,255,255,0.06);

  --accent-primary: #3b82f6;
  --accent-primary-dark: #2563eb;
  --accent-primary-light: #1e2d4a;
  --accent-success: #22c55e;
  --accent-success-light: #0d2318;
  --accent-danger: #ef4444;
  --accent-danger-light: #2c1010;
  --accent-warning: #f59e0b;
  --accent-warning-light: #291e06;
  --accent-gray: #9ca3af;
  --accent-gray-light: #1e2235;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.45), 0 4px 12px rgba(0,0,0,0.25);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.55);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-base);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-base);
  transition: background-color var(--transition-slow), color var(--transition-slow);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- Layout ---------- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 20px;
}

.main {
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  height: var(--header-height);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-name span {
  color: var(--accent-primary);
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  margin-top: 1px;
}

.version-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--accent-primary-light);
  color: var(--accent-primary);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

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

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: var(--font-base);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-dark);
  border-color: var(--accent-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--accent-danger);
  color: white;
  border-color: var(--accent-danger);
}
.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-input);
  color: var(--text-primary);
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14.5px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
}

/* Dark mode icons */
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 800;
  background: var(--accent-warning);
  color: white;
  border-radius: var(--radius-full);
  margin-left: 2px;
}

/* ---------- Input Panel ---------- */
.input-panel .card-header {
  border-bottom: none;
  padding-bottom: 8px;
}

.domain-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.counter-limit {
  font-weight: 400;
  color: var(--text-muted);
}

.domain-textarea {
  display: block;
  width: 100%;
  min-height: 160px;
  padding: 14px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-input);
  border: none;
  border-top: 1px solid var(--border-color);
  resize: vertical;
  outline: none;
  transition: background var(--transition-fast);
}

.domain-textarea:focus {
  background: var(--bg-input-focus);
}

.domain-textarea::placeholder {
  color: var(--text-muted);
  font-family: var(--font-base);
  font-style: italic;
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 12px;
  background: var(--bg-input);
}

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

/* ---------- Filter Panel ---------- */
.filter-panel {
  animation: slideDown var(--transition-base) ease;
}

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

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
}

.filter-group {
  padding: 18px 20px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-group:last-child {
  border-right: none;
}

.filter-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  flex-shrink: 0;
}

.filter-input {
  padding: 6px 10px;
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  width: 80px;
}

.filter-search {
  width: 100% !important;
}

.filter-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
}

.filter-select {
  padding: 6px 10px;
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  width: 160px;
  transition: border-color var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--border-focus);
}

/* Custom Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
  -webkit-user-select: none;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  transition: all var(--transition-fast);
  position: relative;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ---------- Progress ---------- */
.progress-section {
  padding: 20px;
}

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

.progress-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.progress-percent {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-progress-track);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary) 0%, #7c3aed 100%);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
  to { left: 100%; }
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.progress-details, .progress-eta {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.current-domain-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 12px;
  background: var(--accent-primary-light);
  border-radius: var(--radius-full);
  font-size: 12.5px;
  color: var(--accent-primary);
  font-weight: 500;
}

.chip-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ---------- Metrics Grid ---------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  animation: fadeIn var(--transition-base) ease;
}

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

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
}

.metric-total::before    { background: var(--metric-total-accent); }
.metric-indexed::before  { background: var(--metric-indexed-accent); }
.metric-notindexed::before { background: var(--metric-notindexed-accent); }
.metric-passed::before   { background: var(--metric-passed-accent); }
.metric-spam::before     { background: var(--metric-spam-accent); }
.metric-errors::before   { background: var(--metric-errors-accent); }

.metric-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-total    .metric-icon { background: rgba(99,102,241,0.12); color: var(--metric-total-accent); }
.metric-indexed  .metric-icon { background: rgba(22,163,74,0.12);  color: var(--metric-indexed-accent); }
.metric-notindexed .metric-icon { background: rgba(220,38,38,0.12); color: var(--metric-notindexed-accent); }
.metric-passed   .metric-icon { background: rgba(8,145,178,0.12);  color: var(--metric-passed-accent); }
.metric-spam     .metric-icon { background: rgba(217,119,6,0.12);  color: var(--metric-spam-accent); }
.metric-errors   .metric-icon { background: rgba(156,163,175,0.15); color: var(--metric-errors-accent); }

.metric-body {
  flex: 1;
  min-width: 0;
}

.metric-value {
  display: block;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-pct {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ---------- Results Table ---------- */
.results-section .card-header {
  align-items: center;
}

.results-count-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
}

.results-count-label { color: var(--text-muted); }
.results-count-val   { font-weight: 700; color: var(--text-primary); }

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

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.results-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.results-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  background: var(--bg-table-head);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.results-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.results-table thead th.sortable:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.results-table thead th.sorted-asc::after  { content: ' \2191'; color: var(--accent-primary); }
.results-table thead th.sorted-desc::after { content: ' \2193'; color: var(--accent-primary); }

.results-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

.results-table tbody tr:last-child { border-bottom: none; }
.results-table tbody tr:nth-child(even) { background: var(--bg-table-row-even); }
.results-table tbody tr:hover { background: var(--bg-card-hover) !important; }

.results-table tbody tr.row-pass  { background: var(--bg-row-pass) !important; }
.results-table tbody tr.row-fail  { background: var(--bg-row-fail) !important; }
.results-table tbody tr.row-warn  { background: var(--bg-row-warn) !important; }
.results-table tbody tr.row-error { background: var(--bg-table-row-even); opacity: 0.7; }

.results-table tbody td {
  padding: 9px 12px;
  color: var(--text-primary);
  vertical-align: middle;
}

.col-no      { width: 40px; color: var(--text-muted) !important; font-size: 12px !important; }
.col-domain  { min-width: 180px; max-width: 240px; }
.col-status  { width: 100px; }
.col-indexed { width: 80px; text-align: center !important; }
.col-dr      { width: 60px; text-align: center !important; }
.col-pa      { width: 60px; text-align: center !important; }
.col-da      { width: 60px; text-align: center !important; }
.col-ss      { width: 60px; text-align: center !important; }
.col-traffic { width: 90px; text-align: right !important; }
.col-http    { width: 70px; text-align: center !important; }
.col-actions { width: 80px; text-align: center !important; }

.domain-cell {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
}

.domain-cell a {
  color: inherit;
  text-decoration: none;
}

.domain-cell a:hover { color: var(--accent-primary); text-decoration: underline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-success {
  background: var(--accent-success-light);
  color: var(--accent-success);
}

.badge-danger {
  background: var(--accent-danger-light);
  color: var(--accent-danger);
}

.badge-warning {
  background: var(--accent-warning-light);
  color: var(--accent-warning);
}

.badge-gray {
  background: var(--accent-gray-light);
  color: var(--accent-gray);
}

.badge-primary {
  background: var(--accent-primary-light);
  color: var(--accent-primary);
}

/* Metric value chips */
.val-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: center;
}

.val-high    { background: rgba(22,163,74,0.12);  color: var(--accent-success); }
.val-mid     { background: rgba(245,158,11,0.12); color: var(--accent-warning); }
.val-low     { background: rgba(220,38,38,0.1);   color: var(--accent-danger); }
.val-neutral { background: var(--bg-input); color: var(--text-secondary); }
.val-na      { background: transparent; color: var(--text-muted); font-weight: 400; }

/* ---------- Summary ---------- */
.summary-section .card-header {
  border-bottom: 1px solid var(--border-color);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0;
}

.summary-item {
  padding: 16px 20px;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child {
  border-right: none;
}

.summary-item-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.summary-item-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.summary-item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Detail Drawer ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  animation: fadeInOverlay var(--transition-base) ease;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.detail-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: var(--drawer-width);
  max-width: calc(100vw - 20px);
  background: var(--bg-drawer);
  z-index: 201;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-slow) cubic-bezier(0.22, 1, 0.36, 1);
}

.detail-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.drawer-domain {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  word-break: break-all;
}

.drawer-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.drawer-metric-item {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.drawer-metric-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.drawer-metric-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.drawer-section {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.drawer-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-url-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.drawer-url-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.drawer-url-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition-fast);
  word-break: break-all;
}

.drawer-url-item:hover {
  background: var(--bg-card-hover);
  color: var(--accent-primary);
}

.drawer-url-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.drawer-tech-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 12.5px;
}

.drawer-tech-key {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.drawer-tech-val {
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-all;
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInOverlay var(--transition-base) ease;
}

.modal {
  background: var(--bg-modal);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn var(--transition-base) ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.api-modal       { max-width: 600px; }
.add-key-modal   { max-width: 460px; }

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

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ---------- API Settings ---------- */
.api-section {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.api-section-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-section-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.api-section-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-free { background: var(--accent-success-light); color: var(--accent-success); }
.badge-paid { background: var(--accent-warning-light); color: var(--accent-warning); }

.api-section-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.link-muted {
  font-size: 12px;
  color: var(--text-link);
  text-decoration: none;
}
.link-muted:hover { text-decoration: underline; }

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

.api-key-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.api-key-info {
  flex: 1;
  min-width: 0;
}

.api-key-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.api-key-id {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-key-toggle {
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.api-key-toggle:hover { background: var(--bg-input); }

/* Quota */
.quota-section { background: var(--bg-input); }
.quota-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quota-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.quota-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.quota-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ---------- Form ---------- */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input-wrap {
  position: relative;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-base);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.form-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
}

.form-input-wrap .form-input {
  padding-right: 38px;
}

.btn-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
}

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

.required { color: var(--accent-danger); }

.test-key-result {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
}

.test-key-result.success {
  background: var(--accent-success-light);
  color: var(--accent-success);
}

.test-key-result.error {
  background: var(--accent-danger-light);
  color: var(--accent-danger);
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  max-width: 340px;
  pointer-events: all;
  animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.toast-out {
  animation: toastOut 0.2s ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px); }
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-success .toast-icon { color: var(--accent-success); }
.toast-error   .toast-icon { color: var(--accent-danger); }
.toast-warning .toast-icon { color: var(--accent-warning); }
.toast-info    .toast-icon { color: var(--accent-primary); }

.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  animation: toastProgress 3.5s linear forwards;
}

.toast-success::after { background: var(--accent-success); }
.toast-error::after   { background: var(--accent-danger); }
.toast-warning::after { background: var(--accent-warning); }
.toast-info::after    { background: var(--accent-primary); }

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ---------- Footer ---------- */
.footer {
  padding: 16px 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-header);
  margin-top: auto;
}

.footer .container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.footer-sep {
  color: var(--border-color);
}

/* ---------- Empty State ---------- */
.empty-state {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* ---------- Spinning loader ---------- */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner-dark {
  border-color: rgba(0,0,0,0.1);
  border-top-color: var(--accent-primary);
}

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

/* ---------- Scanning row indicator ---------- */
.scanning-row td {
  opacity: 0.6;
}

.scanning-row .domain-cell::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--accent-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- API key single ---------- */
.api-single-key {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  :root {
    --drawer-width: 100vw;
    --header-height: 56px;
  }

  .header-inner {
    padding: 0 12px;
  }

  .brand-tagline {
    display: none;
  }

  .main {
    padding: 16px 12px 40px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left, .toolbar-right {
    justify-content: center;
  }

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

  .filter-group {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .filter-group:last-child { border-bottom: none; }

  .col-traffic, .col-http { display: none; }

  .brand-name { font-size: 16px; }
  .version-badge { display: none; }

  .drawer-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  .metric-value { font-size: 20px; }
  .metric-icon { width: 32px; height: 32px; }

  .toast-container {
    left: 12px;
    right: 12px;
  }

  .toast { max-width: 100%; }
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

.text-mono { font-family: var(--font-mono); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
