/* PEP/Sanction Scanner — shared design system (light / dark) */

:root,
[data-theme="light"] {
  --bg: #e8eef2;
  --bg-accent: #d5e0e8;
  --surface: #ffffff;
  --surface-2: #f4f7f9;
  --ink: #14212b;
  --ink-muted: #5a6b78;
  --border: #c5d0d8;
  --accent: #0d7a6f;
  --accent-hover: #0a5f56;
  --accent-soft: #d8f0ed;
  --danger: #b42318;
  --danger-soft: #fce8e6;
  --success: #0d7a6f;
  --success-soft: #d8f0ed;
  --table-head: #0d7a6f;
  --table-stripe: #eef6f5;
  --shadow: 0 1px 2px rgba(20, 33, 43, 0.06), 0 8px 24px rgba(20, 33, 43, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --font-label: "IBM Plex Sans", "Source Sans 3", sans-serif;
  --focus: 0 0 0 3px rgba(13, 122, 111, 0.35);
  --pill-track: #e0e7ec;
  --pill-thumb: #14212b;
  --pill-text: #5a6b78;
  --pill-text-active: #ffffff;
  --pill-shadow: 0 2px 6px rgba(20, 33, 43, 0.18);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f161c;
  --bg-accent: #1a242e;
  --surface: #18222b;
  --surface-2: #1f2b36;
  --ink: #e8eef2;
  --ink-muted: #9aadb8;
  --border: #2f3f4c;
  --accent: #3dbdb0;
  --accent-hover: #5dccc1;
  --accent-soft: #163832;
  --danger: #f97066;
  --danger-soft: #3b1c1a;
  --success: #3dbdb0;
  --success-soft: #163832;
  --table-head: #1e4a45;
  --table-stripe: #1a2e32;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 3px rgba(61, 189, 176, 0.4);
  --pill-track: #243340;
  --pill-thumb: #3dbdb0;
  --pill-text: #9aadb8;
  --pill-text-active: #0f161c;
  --pill-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, var(--bg-accent) 0%, transparent 42%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 31px,
      rgba(20, 33, 43, 0.03) 31px,
      rgba(20, 33, 43, 0.03) 32px
    );
}

[data-theme="dark"] body {
  background-image:
    linear-gradient(180deg, var(--bg-accent) 0%, transparent 42%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 31px,
      rgba(232, 238, 242, 0.03) 31px,
      rgba(232, 238, 242, 0.03) 32px
    );
}

h1, h2, h3, h4 {
  font-family: var(--font-label);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; color: var(--accent); }
h4 { font-size: 0.95rem; margin: 1rem 0 0.5rem; color: var(--ink-muted); }

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

/* —— Layout shells —— */

.page-center {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

.page-wide {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.25rem 1.25rem;
  width: 100%;
  max-width: 420px;
}

.panel--wide {
  max-width: none;
}

.panel-title {
  text-align: center;
  margin-bottom: 1.25rem;
}

.panel-title--login {
  margin-bottom: 1.5rem;
}

/* —— Chrome pill (theme + logout) —— */

.chrome-bar {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 30;
}

.page-wide > .chrome-bar {
  top: 0.75rem;
  right: 0.75rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.chrome-pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.chrome-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1;
}

.chrome-btn:hover,
.chrome-btn[aria-expanded="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.chrome-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.chrome-btn__tip {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  padding: 0.2rem 0.4rem;
  background: var(--ink);
  color: var(--surface);
  border-radius: 4px;
  font-family: var(--font-label);
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 40;
}

.chrome-btn:hover .chrome-btn__tip,
.chrome-btn:focus-visible .chrome-btn__tip {
  opacity: 1;
  visibility: visible;
}

.theme-menu {
  position: relative;
}

.theme-menu__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: none;
  flex-direction: row;
  gap: 0.1rem;
  padding: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 40;
}

.theme-menu__dropdown.is-open {
  display: flex;
}

.theme-menu__item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 0.72rem;
}

.theme-menu__item:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.theme-menu__item[aria-pressed="true"] {
  color: #fff;
  background: var(--accent);
}

.theme-menu__item:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.theme-menu__tip {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.4rem;
  background: var(--ink);
  color: var(--surface);
  border-radius: 4px;
  font-family: var(--font-label);
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 50;
}

.theme-menu__item:hover .theme-menu__tip,
.theme-menu__item:focus-visible .theme-menu__tip {
  opacity: 1;
  visibility: visible;
}

.header-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.header-container h1 {
  margin: 0;
}

.header-meta {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin: 0 0 1rem;
}

.header-meta strong {
  color: var(--ink);
}

/* —— Forms —— */

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-label);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
}

.required {
  color: var(--danger);
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.bulk-help {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.bulk-steps {
  margin: 0 0 0.65rem;
  padding-left: 1.2rem;
  color: var(--ink);
  font-size: 0.92rem;
}

.bulk-steps li {
  margin-bottom: 0.4rem;
}

.bulk-steps li:last-child {
  margin-bottom: 0;
}

.bulk-steps code {
  font-size: 0.85em;
  padding: 0.1rem 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.bulk-help .field-hint {
  margin-top: 0;
}

input[type="text"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  margin-top: 0.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--accent);
}

.pill-selector {
  --position: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  margin-top: 0.35rem;
  background: var(--pill-track);
  border-radius: 999px;
}

.pill-selector__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  background: var(--pill-thumb);
  border-radius: 999px;
  transform: translateX(calc(var(--position) * 100%));
  transition: transform 200ms ease;
  box-shadow: var(--pill-shadow);
  pointer-events: none;
}

.pill-selector__btn {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 0.65rem 0.5rem;
  font-family: var(--font-label);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--pill-text);
  cursor: pointer;
  border-radius: 999px;
}

.pill-selector__btn.active {
  color: var(--pill-text-active);
}

.pill-selector__btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-label);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
}

.btn-primary:disabled {
  background: var(--ink-muted);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: var(--accent);
}

.btn-inline {
  width: auto;
  padding: 0.55rem 1rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0.25rem;
}

.btn-icon:hover {
  color: var(--accent-hover);
}

.login-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.login-theme {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Google material button — light (default) / dark via data-theme */
#gisAnchor {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.gsi-material-button {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-appearance: none;
  appearance: none;
  background-color: #f2f2f2;
  background-image: none;
  border: none;
  -webkit-border-radius: 20px;
  border-radius: 20px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  color: #1f1f1f;
  cursor: pointer;
  font-family: 'Roboto', arial, sans-serif;
  font-size: 14px;
  height: 40px;
  letter-spacing: 0.25px;
  outline: none;
  overflow: hidden;
  padding: 0 12px;
  position: relative;
  text-align: center;
  -webkit-transition: background-color .218s, border-color .218s, box-shadow .218s;
  transition: background-color .218s, border-color .218s, box-shadow .218s;
  vertical-align: middle;
  white-space: nowrap;
  width: auto;
  max-width: 400px;
  min-width: min-content;
}

.gsi-material-button .gsi-material-button-icon {
  height: 20px;
  margin-right: 10px;
  min-width: 20px;
  width: 20px;
}

.gsi-material-button .gsi-material-button-content-wrapper {
  -webkit-align-items: center;
  align-items: center;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: nowrap;
  flex-wrap: nowrap;
  height: 100%;
  justify-content: space-between;
  position: relative;
  width: 100%;
}

.gsi-material-button .gsi-material-button-contents {
  -webkit-flex-grow: 1;
  flex-grow: 1;
  font-family: 'Roboto', arial, sans-serif;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.gsi-material-button .gsi-material-button-state {
  -webkit-transition: opacity .218s;
  transition: opacity .218s;
  bottom: 0;
  left: 0;
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.gsi-material-button:disabled {
  cursor: default;
  background-color: #ffffff61;
}

.gsi-material-button:disabled .gsi-material-button-state {
  background-color: #1f1f1f1f;
}

.gsi-material-button:disabled .gsi-material-button-contents {
  opacity: 38%;
}

.gsi-material-button:disabled .gsi-material-button-icon {
  opacity: 38%;
}

.gsi-material-button:not(:disabled):active .gsi-material-button-state,
.gsi-material-button:not(:disabled):focus .gsi-material-button-state {
  background-color: #001d35;
  opacity: 12%;
}

.gsi-material-button:not(:disabled):hover {
  -webkit-box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
}

.gsi-material-button:not(:disabled):hover .gsi-material-button-state {
  background-color: #001d35;
  opacity: 8%;
}

[data-theme="dark"] .gsi-material-button {
  background-color: #131314;
  border: 1px solid #8e918f;
  color: #e3e3e3;
}

[data-theme="dark"] .gsi-material-button:disabled {
  background-color: #13131461;
  border-color: #8e918f1f;
}

[data-theme="dark"] .gsi-material-button:disabled .gsi-material-button-state {
  background-color: #e3e3e31f;
}

[data-theme="dark"] .gsi-material-button:not(:disabled):active .gsi-material-button-state,
[data-theme="dark"] .gsi-material-button:not(:disabled):focus .gsi-material-button-state {
  background-color: white;
  opacity: 12%;
}

[data-theme="dark"] .gsi-material-button:not(:disabled):hover .gsi-material-button-state {
  background-color: white;
  opacity: 8%;
}

.alert {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  text-align: center;
}

.alert.visible {
  display: block;
}

.flash-message {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.flash-message li {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  border: 1px solid;
}

.flash-message li.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.flash-message li.success {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success);
}

.flash-message .icon {
  margin-right: 0.5rem;
}

/* —— Results —— */

.result-container {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.result-item {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.result-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.result-item h2 {
  margin: 0 0 0.75rem;
}

.result-item p {
  margin: 0.35rem 0;
  color: var(--ink-muted);
}

.result-item strong {
  color: var(--ink);
  font-weight: 600;
}

.match-summary-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 640px) {
  .match-summary-grid {
    grid-template-columns: 1fr;
  }
}

.profile-photo {
  max-width: 160px;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.no-match {
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-muted);
}

.summary-card {
  margin-bottom: 1.25rem;
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.summary-card p {
  margin: 0.35rem 0;
  font-weight: 600;
  color: var(--ink);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0;
}

.tab-button {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-label);
  font-size: 0.9rem;
  font-weight: 500;
}

.tab-button:hover {
  color: var(--ink);
  background: var(--surface);
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
}

.tab-content {
  display: none;
  padding: 0;
  border: none;
}

.tab-content.active {
  display: block;
  margin-top: 1rem;
}

.tab-content-container {
  margin-bottom: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

th {
  background: var(--table-head);
  color: #fff;
  padding: 0.55rem 0.65rem;
  text-align: left;
  font-family: var(--font-label);
  font-weight: 500;
  font-size: 0.85rem;
}

td {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  color: var(--ink);
  vertical-align: top;
}

tr:nth-child(odd) {
  background: var(--surface);
}

tr:nth-child(even) {
  background: var(--table-stripe);
}

.content-type-table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  margin: 0.75rem 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.content-type-table th,
.content-type-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.content-type-table th {
  background: var(--table-head);
  color: #fff;
}

.content-type-table td ul {
  margin: 0;
  padding-left: 1rem;
}

.content-type-table ul {
  list-style-type: disc;
}

.content-type-table td {
  max-width: 320px;
  word-wrap: break-word;
}

.hint {
  position: relative;
  cursor: help;
  color: var(--accent);
  font-weight: 600;
}

.hint .tooltip {
  visibility: hidden;
  position: absolute;
  background: var(--ink);
  color: var(--surface);
  text-align: center;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
  z-index: 5;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  width: max-content;
  max-width: 240px;
  white-space: normal;
}

.hint .tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--ink) transparent transparent transparent;
}

.hint:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

.collapsible {
  cursor: pointer;
  background: var(--surface-2);
  color: var(--ink);
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--border);
  outline: none;
  width: 100%;
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
  font-family: var(--font-label);
  font-weight: 500;
}

.collapsible:hover,
.collapsible.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.json-panel {
  display: none;
  overflow: hidden;
  margin-bottom: 1rem;
}

.json-panel.is-open {
  display: block;
}

#jsoneditor {
  height: 480px;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.image-link {
  position: relative;
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
}

.image-link:hover .image-tooltip {
  visibility: visible;
  opacity: 1;
}

.image-tooltip {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s;
  position: absolute;
  top: -5px;
  left: 110%;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.image-tooltip img {
  max-width: 200px;
  max-height: 150px;
  display: block;
}

ul {
  padding-left: 1.1rem;
}

.small-text {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.back-link,
.download-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: var(--accent);
  color: #fff !important;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 0.9rem;
}

.back-link:hover,
.download-link:hover {
  background: var(--accent-hover);
  color: #fff !important;
}

.download-link {
  background: var(--ink);
}

.download-link:hover {
  background: var(--ink-muted);
  color: #fff !important;
}

[data-theme="dark"] .download-link {
  background: var(--accent-soft);
  color: var(--accent) !important;
  border: 1px solid var(--accent);
}

[data-theme="dark"] .download-link:hover {
  background: var(--accent);
  color: #fff !important;
}
