@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Marcellus&display=swap");

:root {
  --ink: #0b2a4a;
  --muted: #4d667a;
  --paper: #f4f8fb;
  --fog: #dbe8f2;
  --navy: #0a2f5d;
  --blue: #1c73c9;
  --sky: #8dc5f6;
  --green: #1f8c2d;
  --green-soft: #44b353;
  --edge: rgba(10, 47, 93, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, #f4fbff, #ecf3fb 45%, #e2eef8 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-orbit {
  position: fixed;
  inset: -18% -12% auto auto;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: conic-gradient(from 120deg, rgba(28, 115, 201, 0.35), rgba(31, 140, 45, 0.35), rgba(141, 197, 246, 0.45));
  filter: blur(10px);
  opacity: 0.75;
  z-index: 0;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' 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.35;
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid var(--edge);
  box-shadow: 0 12px 30px rgba(15, 35, 51, 0.08);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 36px);
}

.brandline {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-text {
  display: grid;
  gap: 2px;
}

.brand-name {
  font-family: "Marcellus", serif;
  font-size: 1.2rem;
}

.brand-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.logo {
  display: grid;
  place-items: center;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 20px rgba(15, 35, 51, 0.08);
  border: 1px solid rgba(15, 35, 51, 0.08);
}

.logo img {
  width: clamp(56px, 6vw, 84px);
  height: auto;
  object-fit: contain;
}

.quick-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 520px;
}

.quick-search input {
  flex: 1;
  min-width: 180px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(12, 27, 42, 0.04);
  border: 1px solid rgba(12, 27, 42, 0.08);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
  background: linear-gradient(130deg, var(--blue), var(--green-soft));
}

.user-name {
  font-weight: 600;
}

.user-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-only {
  display: none;
}

.nav-button.admin-only.visible {
  display: inline-flex;
}

.view.admin-only.visible.active {
  display: block;
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 240px;
  padding: 24px 18px;
  border-right: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
}

.sidebar-title {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.nav-button {
  width: 100%;
  text-align: left;
  border-radius: 14px;
  padding: 12px 14px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  border: 1px solid transparent;
}

.nav-button + .nav-button {
  margin-top: 10px;
}

.nav-button.active {
  background: rgba(28, 115, 201, 0.12);
  border-color: rgba(28, 115, 201, 0.25);
  color: var(--blue);
}

.workspace {
  flex: 1;
  padding: 28px clamp(18px, 3vw, 42px) 48px;
  overflow-y: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.4s ease-out both;
}

.panel,
.results {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--edge);
  box-shadow: 0 22px 60px rgba(15, 35, 51, 0.1);
  border-radius: 24px;
  padding: 28px;
  backdrop-filter: blur(12px);
}

.panel {
  margin-bottom: 28px;
  animation: riseUp 0.8s ease-out 0.1s both;
}


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

.panel h2,
.results h2 {
  font-family: "Marcellus", serif;
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.panel p,
.results p {
  margin: 0;
  color: var(--muted);
}

.panel-actions,
.results-actions,
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.results-actions {
  margin-left: auto;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.form {
  display: grid;
  gap: 18px;
}

.form.tight {
  gap: 14px;
}

.form.tight input[type="text"] {
  padding: 12px 14px;
}

.form.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form.two-column .form-actions {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--ink);
}

label.inline-field {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

label.inline-field input {
  width: 100px;
}

input[type="text"] {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(12, 27, 42, 0.2);
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  background: white;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"] {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(12, 27, 42, 0.2);
  font-family: "DM Sans", sans-serif;
  font-size: 0.95rem;
}

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

.records-table {
  overflow-x: auto;
}

.records-table th,
.records-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(12, 27, 42, 0.08);
  text-align: left;
  vertical-align: top;
}

.records-table th {
  font-family: "DM Sans", sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(12, 27, 42, 0.2);
  background: rgba(12, 27, 42, 0.08);
}

.status-icon.status-success {
  background: #2f9b4a;
  border-color: #2f9b4a;
}

.status-icon.status-warning {
  background: #f1b400;
  border-color: #f1b400;
}

.status-icon.status-error {
  background: #d84848;
  border-color: #d84848;
}

.status-icon.status-muted {
  background: #c8d3de;
  border-color: #c8d3de;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(12, 27, 42, 0.08);
  color: var(--muted);
  margin-bottom: 8px;
}

.status-badge.status-success {
  background: rgba(31, 140, 45, 0.15);
  color: var(--green);
}

.status-badge.status-warning {
  background: rgba(241, 180, 0, 0.18);
  color: #8a6400;
}

.status-badge.status-not_found {
  background: rgba(28, 115, 201, 0.12);
  color: var(--blue);
}

.status-badge.status-skipped_company,
.status-badge.status-invalid {
  background: rgba(12, 27, 42, 0.08);
  color: var(--muted);
}

.status-badge.status-error {
  background: rgba(186, 29, 29, 0.12);
  color: #b32020;
}

.records-table th.sortable {
  cursor: pointer;
  position: relative;
  padding-right: 18px;
}

.records-table th.sortable::after {
  content: "↕";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  opacity: 0.4;
}

.records-table th.sortable[data-sort-direction="asc"]::after {
  content: "↑";
  opacity: 0.85;
}

.records-table th.sortable[data-sort-direction="desc"]::after {
  content: "↓";
  opacity: 0.85;
}

.records-table tr:hover {
  background: rgba(12, 27, 42, 0.03);
}

.records-table tr.active {
  background: rgba(28, 115, 201, 0.08);
}

.action-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.action-group {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.action-cell .icon-button {
  width: 34px;
  height: 34px;
}

.icon-button {
  background: rgba(28, 115, 201, 0.12);
  color: var(--blue);
  padding: 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.danger {
  background: rgba(186, 29, 29, 0.12);
  color: #b32020;
}

.link-button {
  background: rgba(28, 115, 201, 0.14);
  color: var(--blue);
  padding: 8px 12px;
  font-size: 0.85rem;
}

.danger-button {
  background: rgba(186, 29, 29, 0.12);
  color: #b32020;
  padding: 8px 12px;
  font-size: 0.85rem;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(28, 115, 201, 0.15);
}

.checkbox {
  align-items: center;
  grid-auto-flow: column;
  justify-content: start;
}

.checkbox input {
  width: 18px;
  height: 18px;
}

button {
  border: none;
  cursor: pointer;
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 999px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:active {
  transform: scale(0.98);
}

.primary {
  background: linear-gradient(120deg, var(--blue), var(--green-soft));
  color: white;
  box-shadow: 0 12px 30px rgba(28, 115, 201, 0.25);
}

.primary.small {
  padding: 10px 16px;
  font-size: 0.9rem;
}

.ghost {
  background: rgba(12, 27, 42, 0.06);
  color: var(--ink);
}

.ghost.small {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.record-grid {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.card {
  border: 1px solid rgba(12, 27, 42, 0.08);
  border-radius: 18px;
  padding: 18px;
  background: white;
  animation: fadeIn 0.5s ease-out both;
}

.section-title {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  margin: 0 0 14px;
}

.section-title-info {
  background: rgba(28, 115, 201, 0.14);
  color: var(--navy);
}

.list-table th,
.grid-table th {
  background: rgba(12, 27, 42, 0.08);
  color: var(--ink);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.list-table tr:nth-child(2n + 2) td,
.grid-table tr:nth-child(2n + 2) td {
  background: rgba(12, 27, 42, 0.03);
}

.grid-table-currency td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.card h3 {
  font-family: "Marcellus", serif;
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.card-compact {
  padding: 16px;
}

.card-compact .kv-table td {
  padding: 6px 6px;
}

.kv-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kv-columns .kv-table td:first-child {
  width: auto;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 520px;
}

.card-pair {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 960px) {
  .card-pair {
    grid-template-columns: 1fr;
  }
}

.kv-table,
.grid-table,
.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.kv-table td,
.grid-table td,
.grid-table th,
.list-table td,
.list-table th {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(12, 27, 42, 0.08);
  text-align: left;
  vertical-align: top;
}

.kv-table td:first-child {
  font-weight: 600;
  color: var(--muted);
  width: 32%;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(31, 140, 45, 0.15);
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 600;
}

.raw {
  background: #0b2a4a;
  color: #f8f5ee;
  padding: 20px;
  border-radius: 18px;
  overflow-x: auto;
  margin-top: 20px;
  font-size: 0.85rem;
}

.hidden {
  display: none;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 38, 0.45);
  display: grid;
  place-items: center;
  z-index: 20;
}

.login-overlay.hidden {
  display: none;
}

.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 38, 0.45);
  display: grid;
  place-items: center;
  z-index: 20;
}

.progress-overlay.hidden {
  display: none;
}

.progress-card {
  background: white;
  border-radius: 24px;
  padding: 32px;
  width: min(420px, 92vw);
  box-shadow: 0 30px 60px rgba(15, 35, 51, 0.25);
  border: 1px solid rgba(12, 27, 42, 0.12);
  display: grid;
  gap: 12px;
  text-align: left;
}

.progress-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(12, 27, 42, 0.15);
  border-top-color: var(--blue);
  animation: spin 0.9s linear infinite;
}

.progress-title {
  font-family: "Marcellus", serif;
  font-size: 1.4rem;
}

.progress-subtitle {
  color: var(--muted);
  margin: 0;
}

.progress-steps {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-step.active {
  color: var(--ink);
  font-weight: 600;
}

.progress-step.complete {
  color: var(--green);
  font-weight: 600;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(12, 27, 42, 0.2);
}

.progress-step.active .step-dot {
  background: var(--blue);
}

.progress-step.complete .step-dot {
  background: var(--green);
}

.login-card {
  background: white;
  border-radius: 24px;
  padding: 32px;
  width: min(420px, 92vw);
  box-shadow: 0 30px 60px rgba(15, 35, 51, 0.25);
  border: 1px solid rgba(12, 27, 42, 0.12);
}

.login-title {
  font-family: "Marcellus", serif;
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.login-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: #b32020;
  font-size: 0.85rem;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(11, 42, 74, 0.92);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform-origin: bottom center;
  box-shadow: 0 10px 20px rgba(15, 35, 51, 0.2);
  z-index: 10;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

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

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

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

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

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

@media (max-width: 720px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .results-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .results-actions button {
    flex: 1 1 auto;
  }

  .card {
    padding: 14px;
  }

  .section-title {
    padding: 8px 10px;
    font-size: 0.95rem;
  }

  .kv-table,
  .grid-table,
  .list-table {
    font-size: 0.85rem;
  }

  .table-scroll table {
    min-width: 420px;
  }

  .brandline {
    justify-content: space-between;
  }

  .user-card {
    width: 100%;
    justify-content: flex-start;
  }

  .app-body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    display: flex;
    gap: 10px;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar-title {
    display: none;
  }

  .nav-button {
    width: auto;
    white-space: nowrap;
  }

  .form.two-column {
    grid-template-columns: 1fr;
  }

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

  .kv-table td:first-child {
    width: auto;
  }

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