:root {
  color-scheme: light;
  --ink: #1b1b1f;
  --muted: #5f5f6b;
  --accent: #ee6c4d;
  --accent-dark: #c94b2e;
  --card: #f6f3f0;
  --panel: rgba(255, 255, 255, 0.86);
  --stroke: rgba(24, 24, 28, 0.14);
  --shadow: 0 20px 60px rgba(28, 26, 32, 0.12);
  --glow: 0 0 80px rgba(238, 108, 77, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f2efe9;
  min-height: 100vh;
  overflow-x: hidden;
}

h1,
h2 {
  font-family: "Fraunces", "Georgia", serif;
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.5rem, 4vw, 3.5rem);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

p {
  margin: 0;
  color: var(--muted);
}

ul {
  margin: 0;
  padding-left: 1.1rem;
}

.bg-orbit {
  position: fixed;
  inset: -20% -10% auto auto;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle at top, #f6b89c, #f2efe9 60%);
  border-radius: 50%;
  filter: blur(0.5px);
  opacity: 0.8;
  animation: drift 18s ease-in-out infinite;
  will-change: transform;
  z-index: -2;
}

@media (max-width: 720px), (prefers-reduced-motion: reduce) {
  .bg-orbit {
    filter: none;
  }
}

.bg-grain {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
  z-index: -1;
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-30px, 20px, 0);
  }
}

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  animation: fadeIn 0.8s ease-out;
}

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

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

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

.skeleton {
  background: #f6f7f8;
  background-image: linear-gradient(
    to right,
    #f6f7f8 0%,
    #edeef1 20%,
    #f6f7f8 40%,
    #f6f7f8 100%
  );
  background-repeat: no-repeat;
  background-size: 800px 100%;
  animation-duration: 1s;
  animation-fill-mode: forwards;
  animation-iteration-count: infinite;
  animation-name: shimmer;
  border-radius: 8px;
  min-height: 120px;
}

.hero {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: center;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  font-weight: 600;
  color: var(--accent-dark);
}

.lead {
  font-size: 1.05rem;
  margin-top: 12px;
  max-width: 34ch;
}

.hero-card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.hero-card .label {
  color: var(--accent-dark);
  font-weight: 600;
  margin-bottom: 10px;
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(6px);
  position: relative;
  z-index: 1;
}

.panel.results {
  z-index: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

#status {
  font-size: 0.95rem;
  color: var(--muted);
}

#status.ok {
  color: #2d6a4f;
}

#status.error {
  color: #b42318;
}

#status.pending {
  color: #8c4a32;
  position: relative;
  padding-right: 22px;
}

#status.pending::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(238, 108, 77, 0.4);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.toggle {
  display: inline-flex;
  gap: 12px;
  background: #fff;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
}

#lang-toggle {
  margin-left: auto;
}

.toggle-item {
  position: relative;
  font-weight: 500;
  color: var(--muted);
}

.toggle-item input {
  position: absolute;
  opacity: 0;
}

.toggle-item span {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.toggle-item input:checked + span {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--glow);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
  position: relative;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--muted);
}

.field-label svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.field-wide {
  grid-column: 1 / -1;
}

.advanced {
  grid-column: 1 / -1;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 12px 16px 16px;
  background: rgba(255, 255, 255, 0.8);
}

.advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced summary::after {
  content: "▾";
  font-size: 0.9rem;
  color: var(--accent-dark);
  transition: transform 0.2s ease;
}

.advanced[open] summary::after {
  transform: rotate(180deg);
}

.advanced-content {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 16px;
}

.field-hint {
  font-size: 0.85rem;
  color: #7c7c88;
}

.autofill-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.field input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(238, 108, 77, 0.2);
}

.field input:disabled {
  background: #f1eeea;
  color: #9a9aa5;
  cursor: not-allowed;
}

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

button.chip {
  border: 1px solid rgba(238, 108, 77, 0.4);
  background: transparent;
  color: var(--accent-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button.chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(238, 108, 77, 0.18);
}

button.chip.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--glow);
  border-color: transparent;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  color: var(--ink);
}

.toggle-line input {
  position: absolute;
  opacity: 0;
}

.toggle-pill {
  width: 46px;
  height: 24px;
  border-radius: 999px;
  background: rgba(238, 108, 77, 0.2);
  border: 1px solid rgba(238, 108, 77, 0.4);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.toggle-pill::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  box-shadow: 0 4px 10px rgba(27, 27, 31, 0.2);
  transition: transform 0.2s ease;
}

.toggle-line input:checked + .toggle-pill {
  background: var(--accent);
  border-color: transparent;
}

.toggle-line input:checked + .toggle-pill::after {
  transform: translateX(22px);
}

.toggle-line input:disabled + .toggle-pill {
  opacity: 0.6;
}

.toggle-line input:disabled ~ span {
  color: var(--muted);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 180px;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  box-shadow: 0 16px 36px rgba(27, 27, 31, 0.16);
  padding: 6px;
  z-index: 100;
  display: none;
}

.dropdown-menu.is-up {
  top: auto;
  bottom: calc(100% + 6px);
}

.dropdown-menu.is-open {
  display: block;
}

.dropdown-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.dropdown-item:hover,
.dropdown-item:focus {
  outline: none;
  background: rgba(238, 108, 77, 0.12);
}

.dropdown-code {
  font-weight: 600;
  color: var(--accent-dark);
  white-space: nowrap;
  font-size: 0.95rem;
}

.dropdown-label {
  color: #3e3e4a;
  line-height: 1.25;
  font-size: 0.95rem;
  display: block;
  overflow-wrap: anywhere;
}

.dropdown-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

button {
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font: inherit;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(238, 108, 77, 0.25);
}

button:disabled,
button:disabled:hover {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid rgba(238, 108, 77, 0.5);
  box-shadow: none;
}

.results #results {
  display: grid;
  gap: 16px;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.results-meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.results-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.results-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px solid var(--stroke);
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
}

.results-option input {
  accent-color: var(--accent);
}

.results-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.results-filter input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
  font: inherit;
  color: var(--ink);
  min-width: min(320px, 100%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.results-filter input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(238, 108, 77, 0.2);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.page-info {
  font-size: 0.9rem;
  color: var(--muted);
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.page-jump input {
  width: 90px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.page-jump input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(238, 108, 77, 0.2);
}

.page-jump input:disabled {
  background: #f1eeea;
  color: #9a9aa5;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.preset-row input,
.preset-select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
  font: inherit;
  color: var(--ink);
  min-width: min(220px, 100%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.preset-row input:focus,
.preset-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(238, 108, 77, 0.2);
}

.preset-select:disabled {
  background: #f1eeea;
  color: #9a9aa5;
}

.notice-card,
.stats-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--stroke);
  box-shadow: 0 8px 16px rgba(27, 27, 31, 0.08);
  animation: rise 0.4s ease-out;
}

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

.notice-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.notice-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button.notice-expand {
  padding: 6px 12px;
  font-size: 0.85rem;
}

button.bookmark-btn {
  background: transparent;
  box-shadow: none;
  border: 1px solid transparent;
  color: #ccc;
  padding: 6px;
  font-size: 1.2rem;
  line-height: 1;
}

button.bookmark-btn:hover {
  transform: scale(1.1);
  color: #ebc040;
}

button.bookmark-btn.active {
  color: #fca311;
  text-shadow: 0 0 10px rgba(252, 163, 17, 0.4);
}

.bookmark-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}

.notice-action {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.notice-meta {
  display: grid;
  gap: 12px 32px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  font-size: 0.9rem;
  color: var(--muted);
}

.notice-meta span {
  display: block;
}

.notice-meta span strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 2px;
}

.notice-meta a {
  word-break: break-all;
}

.notice-html {
  margin-top: 12px;
  width: 100%;
  min-height: 260px;
  max-height: 420px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
  box-shadow: inset 0 1px 4px rgba(27, 27, 31, 0.06);
}

.notice-html-placeholder {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed var(--stroke);
  background: #faf8f5;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.notice-html-placeholder:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f6b89c, #ee6c4d);
  margin-top: 8px;
}

.empty {
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px dashed var(--stroke);
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 24, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}

.modal.is-open {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 18px;
  width: min(1200px, 96vw);
  height: min(92vh, 880px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(27, 27, 31, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--stroke);
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.modal-frame {
  flex: 1;
  border: none;
  border-radius: 0 0 18px 18px;
  background: #fff;
}

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

@media (max-width: 720px) {
  .panel {
    padding: 20px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .notice-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal {
    padding: 16px;
  }
}
.panel {
  overflow: visible;
}
/* Comparator Styles */
.compare-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--accent);
  color: white;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(238, 108, 77, 0.4);
  z-index: 100;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border: none;
  cursor: pointer;
}

.compare-fab[hidden] {
  display: none !important;
}

.compare-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(238, 108, 77, 0.5);
}

.modal-card.wide {
  width: 90vw;
  max-width: 1200px;
}

.compare-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  overflow-y: auto;
  max-height: 70vh;
  padding: 1rem;
  background: #f9fafb;
}

.compare-column {
  background: white;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.compare-row {
  display: flex;
  border-bottom: 1px solid #eee;
  padding: 0.5rem 0;
}

.compare-row strong {
  flex: 0 0 140px;
  color: #666;
  font-size: 0.9em;
}

.compare-row span {
  flex: 1;
  word-break: break-word;
}

/* Checkbox styling in card */
.notice-select {
  /* position: absolute; removed for flex layout */
  /* top: 1rem; */
  /* left: 1rem; */
  /* z-index: 2; */
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.notice-card {
  position: relative; /* Ensure checkbox positioning context */
}

/* Adjust card content padding if needed or rely on existing */

/* CPV Tag Styles */
.cpv-tag {
  display: inline-block;
  background: #f1f5f9;
  color: #475569;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  font-size: 0.85em;
  margin: 2px;
  font-family: monospace;
}

/* Stats Chart Styles */
.stats-chart-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 32px;
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

.chart-wrapper {
  flex: 0 0 240px;
  width: 240px;
  height: 240px;
  position: relative;
}

.pie-chart {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.chart-legend {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); /* Widened from 200px */
  gap: 16px;
  align-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.legend-color {
  flex: 0 0 16px; /* Do not shrink */
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.legend-count {
  margin-left: auto;
  font-weight: 600;
  color: var(--ink);
}

.legend-label {
  color: var(--muted);
  word-break: break-word; /* Handle long words */
  line-height: 1.3;
}

/* Analytics Dashboard Styles */
.stats-dashboard {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.stat-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  font-family: "Fraunces", serif;
}

.stat-label {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.stats-table-container {
  overflow-x: auto;
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  padding: 8px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.stats-table th,
.stats-table td {
  padding: 16px 24px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.stats-table th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

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

.stats-table td.text-right,
.stats-table th.text-right {
  text-align: right;
}
