:root {
  color-scheme: light;
  --bg: #eef1ef;
  --panel: #ffffff;
  --ink: #16211d;
  --muted: #65736d;
  --line: #d6ddd8;
  --accent: #006d5b;
  --accent-strong: #004f43;
  --accent-soft: #d9efe8;
  --danger: #9d2f1f;
  --warning: #956100;
  --shadow: 0 1px 2px rgb(22 33 29 / 10%);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

.app-topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  gap: 22px;
  height: 58px;
  padding: 0 24px;
}

.app-brand {
  color: var(--ink);
  font-size: 17px;
  font-weight: 850;
  text-decoration: none;
}

.app-nav-links {
  display: flex;
  gap: 4px;
}

.app-nav-links a,
.topbar-signout {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  text-decoration: none;
}

.app-nav-links a:hover,
.topbar-signout:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.app-topbar form {
  margin-left: auto;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.start-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.start-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 620px;
  padding: 20px;
  width: 100%;
}

.profile-shell {
  margin: 0 auto;
  max-width: 760px;
  padding: 28px 24px;
}

.profile-panel {
  display: grid;
  gap: 16px;
}

.security-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  padding: 20px;
}

.credential-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.credential-list li {
  align-items: center;
  background: #f7f8f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 12px;
  justify-content: space-between;
  padding: 9px 10px;
}

.message-state {
  background: var(--accent-soft);
  border: 1px solid #acd7c9;
  border-radius: 6px;
  color: var(--accent-strong);
  font-size: 13px;
  padding: 10px 12px;
}

.message-state.error,
.field-error {
  color: var(--danger);
}

.field-help {
  color: var(--muted);
  font-size: 12px;
}

.field-help ul {
  margin: 0;
  padding-left: 18px;
}

.start-map {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 340px;
  overflow: hidden;
}

.start-map.drawing-area {
  cursor: crosshair;
}

.start-header,
.lookup-header,
.section-title,
.state-panel,
.action-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
}

.lookup-form,
.field-grid {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 5px;
}

label span,
.summary-grid span,
.artifact-meta,
.source-list,
.state-text {
  color: var(--muted);
  font-size: 12px;
}

input {
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 38px;
  min-width: 0;
  padding: 7px 9px;
  width: 100%;
}

input:focus,
button:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

.primary-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 750;
  min-height: 36px;
  padding: 7px 11px;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #f7f8f7;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  background: #edf1ef;
}

.lookup-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(360px, 1fr) minmax(360px, 1fr);
  height: calc(100vh - 58px);
  min-height: 680px;
  overflow: hidden;
}

@media (max-width: 620px) {
  .app-topbar { gap: 8px; padding: 0 12px; }
  .app-brand { font-size: 15px; }
  .app-nav-links { gap: 0; }
  .app-nav-links a, .topbar-signout { font-size: 12px; padding: 7px 6px; }
}

.lookup-panel,
.detail-panel {
  background: var(--panel);
  min-width: 0;
  overflow-y: auto;
  padding: 18px;
}

.lookup-panel {
  border-right: 1px solid var(--line);
}

.detail-panel {
  border-left: 1px solid var(--line);
}

#tokenText {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.status-pill {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
  text-transform: uppercase;
}

.status-pill.failed {
  background: #f7ddd8;
  color: var(--danger);
}

.status-pill.partial {
  background: #fff1cf;
  color: var(--warning);
}

.status-pill.enriching,
.mini-pill.running,
.mini-pill.queued {
  background: #e6edf5;
  color: #285a7a;
}

.summary-grid {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 18px 0;
}

.summary-grid div {
  background: #fbfcfb;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
}

.summary-grid strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.state-panel {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 14px;
}

.artifact-list,
.source-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.catalog-list {
  display: grid;
  gap: 10px;
}

.source-progress-list {
  display: grid;
  gap: 4px;
  margin-top: 12px;
}

.source-progress-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 18px minmax(118px, 0.85fr) minmax(0, 1.35fr);
  min-width: 0;
  padding: 7px 0;
}

.source-progress-row:last-child {
  border-bottom: 0;
}

.source-progress-icon {
  font-size: 15px;
  font-weight: 850;
  text-align: center;
}

.source-progress-row.succeeded .source-progress-icon {
  color: var(--accent);
}

.source-progress-row.failed .source-progress-icon {
  color: var(--danger);
}

.source-progress-row.skipped .source-progress-icon,
.source-progress-row.queued .source-progress-icon {
  color: var(--muted);
}

.source-progress-row.running .source-progress-icon {
  animation: source-progress-spin 1.1s linear infinite;
  color: var(--accent);
}

.source-progress-name {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.source-progress-name:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.source-progress-detail {
  color: var(--muted);
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.artifact-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
  gap: 6px;
  padding: 11px;
}

.artifact-item:hover,
.artifact-item.active {
  border-color: var(--accent);
}

.artifact-title {
  font-size: 14px;
  font-weight: 800;
}

.artifact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.source-link {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.task-row,
.profile-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 10px;
}

.task-row span,
.profile-block span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.help-tip {
  align-items: center;
  background: #edf1ef;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  cursor: help;
  display: inline-flex;
  font-size: 10px;
  font-style: normal;
  font-weight: 850;
  height: 16px;
  justify-content: center;
  line-height: 1;
  margin-left: 5px;
  position: relative;
  text-transform: none;
  vertical-align: text-bottom;
  width: 16px;
  z-index: 2;
}

.help-tip::after {
  background: #16211d;
  border-radius: 6px;
  bottom: calc(100% + 7px);
  box-shadow: var(--shadow);
  color: #ffffff;
  content: attr(data-tip);
  display: none;
  font-size: 11px;
  font-weight: 600;
  left: 0;
  line-height: 1.35;
  max-width: min(280px, calc(100vw - 44px));
  min-width: 180px;
  padding: 8px 9px;
  position: absolute;
  text-transform: none;
  white-space: normal;
  width: max-content;
  z-index: 20;
}

.help-tip:hover::after,
.help-tip:focus::after {
  display: block;
}

.coverage-grid {
  display: grid;
  gap: 6px;
}

.coverage-row {
  align-items: start;
  display: grid;
  gap: 4px 8px;
  grid-template-columns: minmax(74px, 0.8fr) minmax(92px, auto);
}

.coverage-row > span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.coverage-row small {
  color: var(--muted);
  font-size: 11px;
  grid-column: 1 / -1;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.coverage-status {
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  justify-self: start;
  padding: 3px 7px;
  text-transform: uppercase;
}

.coverage-status.parsed {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.coverage-status.not_found {
  background: #edf1ef;
  color: var(--muted);
}

.coverage-status.not_attempted {
  background: #f2f3f2;
  color: #6f7c77;
}

.coverage-status.blocked_auth {
  background: #fff1cf;
  color: var(--warning);
}

.coverage-status.provider_error {
  background: #f7ddd8;
  color: var(--danger);
}

.record-list {
  display: grid;
  gap: 8px;
}

.record-card {
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 9px;
}

.record-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.record-subtitle {
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
  margin-top: 4px;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.record-row {
  display: grid;
  gap: 2px;
}

.record-row span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.record-row strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.record-row.muted strong {
  color: var(--muted);
}

.record-row strong .source-link {
  font-weight: 600;
}

.map-overlay-popup {
  display: grid;
  gap: 6px;
  min-width: 170px;
}

.map-overlay-popup > strong {
  color: var(--ink);
  font-size: 13px;
}

.map-overlay-popup div {
  display: grid;
  gap: 2px;
}

.map-overlay-popup span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.map-overlay-popup div strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.empty-inline {
  color: var(--muted);
  font-size: 12px;
}

.mini-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  justify-self: start;
  padding: 3px 7px;
  text-transform: uppercase;
}

.mini-pill.succeeded {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.mini-pill.skipped {
  background: #edf1ef;
  color: var(--muted);
}

.mini-pill.failed {
  background: #f7ddd8;
  color: var(--danger);
}

.profile-summary {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

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

.intel-grid div {
  background: #fbfcfb;
  border: 1px solid var(--line);
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px;
}

.intel-grid span {
  color: var(--muted);
  font-size: 12px;
}

.intel-grid strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.lookup-map-panel {
  min-width: 0;
}

#lookupMap {
  height: 100%;
  width: 100%;
}

.artifact-data-disclosure {
  margin-top: 12px;
}

.artifact-data-disclosure summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.artifact-data-disclosure[open] summary {
  color: var(--ink);
  margin-bottom: 8px;
}

.artifact-data {
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  min-height: 240px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state,
.error-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
}

.error-state {
  border-color: var(--warning);
  color: var(--warning);
}

@media (max-width: 1100px) {
  .lookup-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 58vh auto;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .lookup-panel,
  .detail-panel {
    border: 0;
  }

  .lookup-map-panel {
    min-height: 460px;
  }
}

@media (max-width: 640px) {
  .field-grid.two,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .start-shell,
  .lookup-panel,
  .detail-panel {
    padding: 14px;
  }
}
