:root {
  color-scheme: light dark;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Theme tokens using modern light-dark() */
  --bg: light-dark(#f8fafc, #0b1120);
  --card-bg: light-dark(#ffffff, #1e293b);
  --text: light-dark(#0f172a, #f8fafc);
  --text-muted: light-dark(#64748b, #94a3b8);
  --border: light-dark(#e2e8f0, #334155);
  --border-focus: light-dark(#3b82f6, #60a5fa);
  --primary: light-dark(#2563eb, #3b82f6);
  --primary-hover: light-dark(#1d4ed8, #2563eb);
  --primary-subtle: light-dark(#eff6ff, rgba(59, 130, 246, 0.12));

  /* Status and badge palette */
  --badge-green-bg: light-dark(#dcfce7, #14532d);
  --badge-green-txt: light-dark(#166534, #86efac);
  --badge-blue-bg: light-dark(#dbeafe, #1e3a8a);
  --badge-blue-txt: light-dark(#1e40af, #93c5fd);
  --badge-purple-bg: light-dark(#f3e8ff, #581c87);
  --badge-purple-txt: light-dark(#6b21a8, #d8b4fe);
  --badge-amber-bg: light-dark(#fef3c7, #78350f);
  --badge-amber-txt: light-dark(#92400e, #fde68a);
  --badge-red-bg: light-dark(#fee2e2, #7f1d1d);
  --badge-red-txt: light-dark(#991b1b, #fca5a5);
  --badge-gray-bg: light-dark(#f1f5f9, #334155);
  --badge-gray-txt: light-dark(#475569, #cbd5e1);

  /* Layout tokens */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 3rem;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
}

.page-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Grid for stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stats-grid > * {
  min-width: 0;
}

/* Data Table container */
.table-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

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

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Column Width Controls & Overflow handling to prevent over-wide tables */
.col-key {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.col-domain {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-target {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  background: var(--card-bg);
  position: sticky;
  top: 0;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 10;
}

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

tr:hover td {
  background-color: light-dark(rgba(0, 0, 0, 0.015), rgba(255, 255, 255, 0.02));
}

code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.06));
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

/* Action button and filters */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search-input {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  width: 100%;
  max-width: 320px;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--border-focus);
}

.filter-group {
  display: inline-flex;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.2rem;
  gap: 0.2rem;
}

.btn-filter {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-filter.active {
  background: var(--primary);
  color: #ffffff;
}

.btn-action {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  line-height: 1.2;
  box-sizing: border-box;
}

.btn-action:hover {
  background: var(--border);
  color: var(--text);
}

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

.btn-action.btn-jump {
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.3);
  font-weight: 500;
}

.btn-action.btn-jump:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--primary);
}

.domain-link {
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

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

.source-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.source-link:hover {
  transform: translateY(-1px);
  opacity: 0.85;
}

.detail-view {
  margin-top: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 280px;
  overflow-y: auto;
}
