:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #a855f7;
  --border: #334155;
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shield-icon {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  padding: 8px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-area h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  color: var(--success);
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

.badge-action {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.75rem;
  padding-left: 4px;
}

/* Cards & Layout */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

/* Tabs */
.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

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

.tab-btn.active {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border-color: var(--border);
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background-color: rgba(15, 23, 42, 0.5);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background-color: rgba(56, 189, 248, 0.05);
}

.drop-icon {
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.drop-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.drop-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.file-label {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.file-chosen {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 500;
}

.raw-textarea {
  width: 100%;
  height: 180px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.75rem;
  resize: vertical;
}

/* Options */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.option-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.option-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.select-input {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.pii-group {
  background-color: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  align-items: center;
}

.pii-tag {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--purple);
  margin-right: 0.25rem;
}

.action-row {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent);
  color: #0f172a;
}

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

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: #475569;
}

.btn-pro {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
}

.btn-pro:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

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

.btn-export:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-block {
  width: 100%;
}

/* Results & Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background-color: var(--bg-primary);
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-purple { color: var(--purple); }
.text-blue { color: #3b82f6; }
.text-cyan { color: #06b6d4; }

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.btn-excel-accent {
  background-color: #107c41;
  color: #ffffff;
  border-color: #0c5e31;
}

.btn-excel-accent:hover {
  background-color: #159c52;
  color: #ffffff;
  border-color: #159c52;
}

/* Diff Legend & Controls */
.preview-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.diff-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.75rem;
}

.legend-title {
  color: var(--text-secondary);
  font-weight: 600;
  margin-right: 0.2rem;
}

.legend-pill {
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.pill-repaired {
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.pill-mojibake {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

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

.pill-zeros {
  background-color: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Cell Diff Highlights */
.cell-diff {
  position: relative;
  cursor: help;
}

.cell-diff-repaired {
  background-color: rgba(34, 197, 94, 0.12) !important;
  color: #86efac !important;
  border-left: 3px solid #22c55e !important;
}

.cell-diff-mojibake {
  background-color: rgba(59, 130, 246, 0.12) !important;
  color: #93c5fd !important;
  border-left: 3px solid #3b82f6 !important;
}

.cell-diff-masked {
  background-color: rgba(245, 158, 11, 0.12) !important;
  color: #fde047 !important;
  border-left: 3px solid #f59e0b !important;
}

.cell-diff-zeros {
  background-color: rgba(6, 182, 212, 0.12) !important;
  color: #67e8f9 !important;
  border-left: 3px solid #06b6d4 !important;
}

.cell-diff::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #0f172a;
  color: #f8fafc;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: var(--font-sans);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.cell-diff:hover::after {
  opacity: 1;
}

.search-input {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  width: 220px;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.table-container {
  overflow-x: auto;
  max-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background-color: var(--bg-primary);
  padding: 0.6rem 0.85rem;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.data-table td {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  max-width: 500px;
  width: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.inspector-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.inspector-metrics {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.5rem;
  background-color: var(--bg-primary);
  border-radius: var(--radius);
}

/* Pro Card */
.pro-card {
  border: 2px solid var(--warning);
}

.pro-header-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background-color: var(--warning);
  color: #0f172a;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
}

.pro-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.pro-tagline {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.pro-perks {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.pricing-box {
  background-color: var(--bg-primary);
  border: 1px dashed var(--border);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 1rem;
}

.price-amount {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.price-period {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.payout-note {
  font-size: 0.75rem;
  color: var(--success);
  margin-top: 0.25rem;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background-color: var(--bg-secondary);
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* SEO & FAQ Knowledge Section */
.seo-knowledge-section {
  margin-top: 1.5rem;
}

.seo-header {
  margin-bottom: 1.25rem;
}

.seo-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.seo-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.seo-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.seo-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.seo-card code {
  background-color: var(--bg-secondary);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.faq-accordion {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.faq-accordion h3 {
  font-size: 1.1rem;
  margin-bottom: 0.85rem;
}

.faq-item {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.faq-item summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
  outline: none;
}

.faq-item p {
  margin-top: 0.5rem;
  color: var(--text-secondary);
  line-height: 1.45;
  font-size: 0.8rem;
}

/* Network check list */
.net-list { list-style: none; margin: 0.75rem 0; padding: 0; max-height: 180px; overflow-y: auto; font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; color: var(--text-muted, #94a3b8); }
.net-list li { padding: 2px 0; overflow-wrap: anywhere; }
