:root {
  --cid-bg: #101c2b;
  --cid-bg-pattern: #111f30;
  --cid-header: #0a192f;
  --cid-panel: #12263f;
  --cid-panel-soft: #0d1a2b;
  --cid-control: #182b45;
  --cid-tab: #14304e;
  --cid-tab-active: #0b223a;
  --cid-tab-text: var(--cid-accent-soft);
  --cid-tab-active-text: var(--cid-text);
  --cid-text: #e0eaf5;
  --cid-text-soft: #b5d9ff;
  --cid-muted: #8ea8bf;
  --cid-accent: #4db8ff;
  --cid-accent-soft: #7dc1ff;
  --cid-border: #334d6e;
  --cid-shadow: rgba(51, 153, 255, 0.22);
  --qr-dark: #0a192f;
  --qr-light: #ffffff;
}

body[data-theme="corporate"] {
  --cid-bg: #f2f4f7; --cid-bg-pattern: #e5e9ef; --cid-header: #202a36;
  --cid-panel: #ffffff; --cid-panel-soft: #f6f7f9; --cid-control: #edf0f3;
  --cid-tab: #d9dfe6; --cid-tab-active: #202a36; --cid-text: #263442;
  --cid-text-soft: #42586a; --cid-muted: #667786; --cid-accent: #c0923f;
  --cid-accent-soft: #d0a751; --cid-border: #aeb8c2; --cid-shadow: rgba(31, 42, 54, 0.15);
  --cid-tab-text: #62480a; --cid-tab-active-text: #f7f9fb;
}

body[data-theme="rebel"] {
  --cid-bg: #111111; --cid-bg-pattern: #181818; --cid-header: #080808;
  --cid-panel: #202020; --cid-panel-soft: #171717; --cid-control: #292929;
  --cid-tab: #363636; --cid-tab-active: #0f0f0f; --cid-text: #f2f2f2;
  --cid-text-soft: #d1d1d1; --cid-muted: #a0a0a0; --cid-accent: #8dff70;
  --cid-accent-soft: #baffaa; --cid-border: #555555; --cid-shadow: rgba(141, 255, 112, 0.16);
  --qr-dark: #111111; --qr-light: #f2f2f2;
}

body[data-theme="ustf"] {
  --cid-bg: #0f1b2b; --cid-bg-pattern: #111f30; --cid-header: #0a121f;
  --cid-panel: #162536; --cid-panel-soft: #101d2b; --cid-control: #1e2e44;
  --cid-tab: #203650; --cid-tab-active: #b12c2c; --cid-text: #e0e8f0;
  --cid-text-soft: #c2d0dd; --cid-muted: #7a8ba0; --cid-accent: #ff5555;
  --cid-accent-soft: #ff8181; --cid-border: #446688; --cid-shadow: rgba(255, 68, 68, 0.18);
}

body[data-theme="solarized"] {
  color-scheme: light;
  --cid-bg: #fdf6e3; --cid-bg-pattern: #eee8d5; --cid-header: #073642;
  --cid-panel: #fefcea; --cid-panel-soft: #eee8d5; --cid-control: #f5efd9;
  --cid-tab: #e3dcc5; --cid-tab-active: #586e75; --cid-text: #586e75;
  --cid-text-soft: #657b83; --cid-muted: #7b8e92; --cid-accent: #b58900;
  --cid-accent-soft: #cb4b16; --cid-border: #c8bea3; --cid-shadow: rgba(88, 110, 117, 0.16);
  --cid-tab-text: #80380f; --cid-tab-active-text: #fff8e6;
}

body[data-theme="foxified"] {
  color-scheme: light;
  --cid-bg: #fff8f2; --cid-bg-pattern: #fff0e6; --cid-header: #5a2e0c;
  --cid-panel: #fff0e6; --cid-panel-soft: #ffe5d0; --cid-control: #fff8f2;
  --cid-tab: #ffd6b3; --cid-tab-active: #ff8330; --cid-text: #5a2e0c;
  --cid-text-soft: #70401e; --cid-muted: #aa6033; --cid-accent: #f96400;
  --cid-accent-soft: #ff8330; --cid-border: #cc7744; --cid-shadow: rgba(255, 102, 0, 0.2);
  --cid-tab-text: #8a3100; --cid-tab-active-text: #351707;
  --qr-dark: #5a2e0c; --qr-light: #fff8f2;
}

html, body {
  /* height: 95vh; */
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background-color: var(--cid-bg);
  background-image: repeating-linear-gradient(
    135deg,
    var(--cid-bg),
    var(--cid-bg-pattern) 50%,
    var(--cid-bg) 100%
  );
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--cid-text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
  background-color: var(--cid-header);
  padding: 1rem 2rem;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--cid-accent-soft);
  text-align: left;
  border-bottom: 2px solid var(--cid-border);
}

header h1 { margin: 0; }
header p { margin: 0.25rem 0 0; color: var(--cid-muted); font-size: 0.9rem; font-weight: normal; }
.header-kicker { color: var(--cid-accent); font-family: "Consolas", monospace; font-size: 0.68rem; letter-spacing: 0.1em; }
.access-badge { padding: 0.5rem 0.7rem; border: 1px solid var(--cid-border); color: var(--cid-accent); font-family: "Consolas", monospace; font-size: 0.7rem; white-space: nowrap; }
.access-badge.is-restricted { border-color: #c34040; color: #ff8d8d; }

/* Main content hidden initially */
main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: none;
  overflow-y: auto;
  height: 100%;
}

/* Login screen overlay */
#loginScreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--cid-panel), var(--cid-header));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  user-select: none;
}
#loginScreen h2 {
  margin-bottom: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  font-size: 1.8rem;
  color: var(--cid-accent);
  text-transform: uppercase;
}
#progressBarContainer {
  width: 320px;
  height: 20px;
  display: none;
  background: var(--cid-control);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: 0 0 8px var(--cid-shadow);
}
#progressBarContainer.is-running { display: block; }
#progressBarContainer:not(.is-running) + #progressText { display: none; }
#progressBar {
  height: 100%;
  width: 0%;
  background: var(--cid-accent);
  transition: width 0.2s ease-out;
}
#progressText {
  font-size: 1rem;
  font-style: italic;
  min-height: 1.2em;
  color: var(--cid-text-soft);
  font-family: "Consolas", monospace;
}
.login-classification { color: var(--cid-accent); font: 0.7rem "Consolas", monospace; letter-spacing: 0.12em; }
.login-profile { display: grid; width: min(320px, calc(100% - 2rem)); gap: 0.45rem; color: var(--cid-text-soft); font-size: 0.78rem; text-transform: uppercase; }
.login-profile select, #login-submit { padding: 0.75rem; border: 1px solid var(--cid-border); color: var(--cid-text); background: var(--cid-control); font: inherit; }
#login-submit { margin: 0.5rem 0 1.2rem; color: var(--cid-header); background: var(--cid-accent); cursor: pointer; font-weight: bold; text-transform: uppercase; }
#login-submit:disabled { cursor: wait; opacity: 0.5; }

.session-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0 0 1rem; padding: 1rem; border: 1px solid var(--cid-border); background: var(--cid-panel); box-shadow: 0 6px 20px var(--cid-shadow); }
.control-group { display: grid; grid-template-columns: auto minmax(150px, 1fr); gap: 0.35rem 0.8rem; align-items: center; }
.control-group label { color: var(--cid-accent-soft); font-size: 0.78rem; font-weight: bold; text-transform: uppercase; }
.control-group span { grid-column: 1 / -1; color: var(--cid-muted); font-size: 0.72rem; }
.control-group select { padding: 0.55rem; border: 1px solid var(--cid-border); color: var(--cid-text); background: var(--cid-control); }
.search-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.search-bar input,
.search-bar select {
  padding: 0.5rem 1rem;
  background-color: var(--cid-control);
  border: 1px solid var(--cid-border);
  color: var(--cid-text);
  border-radius: 4px;
}

.search-bar input:focus,
.search-bar select:focus {
  outline: none;
  border-color: var(--cid-accent-soft);
  box-shadow: 0 0 5px var(--cid-shadow);
}

#clear-search { padding: 0.5rem 1rem; border: 1px solid var(--cid-border); border-radius: 4px; color: var(--cid-text); background: var(--cid-tab); cursor: pointer; }
#clear-search:hover { border-color: var(--cid-accent); color: var(--cid-accent); }
#result-summary { margin: -1rem 0 1rem; color: var(--cid-muted); font: 0.75rem "Consolas", monospace; text-transform: uppercase; }

/* Card Styles */
.person-card {
  background: var(--cid-panel);
  border: 1px solid var(--cid-border);
  border-radius: 8px;
  margin-bottom: 2rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 0 12px var(--cid-shadow);
}

.person-card:hover {
  transform: scale(1.01);
  box-shadow: 0 0 20px var(--cid-shadow);
}

.person-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.person-header img.visuel {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  object-position: top; /* <-- aligne le haut de l’image */
  border: 2px solid var(--cid-border);
}

.person-content div,
.extra-info div {
  margin: 0.25rem 0;
}

.toggle-extra {
  margin-top: 1rem;
  background: none;
  color: #7dc1ff;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  text-align: left;
}

.extra-info {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #334d6e;
}

.hidden {
  display: none;
}

/* Modal overlay */
#image-modal {
  display: none; /* cachée par défaut */
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
}

/* Modal content (the image) */
#image-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 0 20px #00aaffcc;
  cursor: zoom-out;
}

.aff-tessier-ashpol {
  border-left: 4px solid #bba246; /* Jaune vieilli */
  box-shadow: 0 0 8px #bba24633;
}

.aff-green-pastures {
  border-left: 4px solid #5e7d64; /* Vert terne naturel */
  box-shadow: 0 0 8px #5e7d6433;
}

.aff-free-air {
  border-left: 4px solid #7a8a99; /* Gris acier naturel */
  box-shadow: 0 0 8px #7a8a9944;
}

.aff-weyland-cat {
  border-left: 4px solid #507d89; /* Bleu pétrole */
  box-shadow: 0 0 8px #507d8944;
}

.aff-bluetech {
  border-left: 4px solid #5a6c8f; /* Bleu désaturé tech */
  box-shadow: 0 0 8px #5a6c8f44;
}

.aff-default {
  border-left: 4px solid #666; /* Gris standard */
  box-shadow: 0 0 6px #44444422;
}

.aff-independent {
  border-left: 4px solid #7a8a99; /* Gris acier */
  box-shadow: 0 0 6px #7a8a9933;
}

.aff-banard {
  border-left: 4px solid #6a5a7d; /* Violet industriel */
  box-shadow: 0 0 8px #6a5a7d33;
}

.aff-sirius {
  border-left: 4px solid #507d89; /* Bleu pétrole technocratique */
  box-shadow: 0 0 8px #507d8933;
}

.aff-dalai-noir {
  border-left: 4px solid #444; /* Noir technique */
  box-shadow: 0 0 8px #44444455;
}

.aff-europa {
  border-left: 4px solid #7a8a99; /* Acier glacial */
  box-shadow: 0 0 8px #7a8a9944;
}

.aff-cic {
  border-left: 4px solid #888; /* Gris administratif */
  box-shadow: 0 0 8px #88888833;
}

.aff-mankind-united,
.aff-sol-united {
  border-left: 4px solid #bba246; /* Jaune terne solaire */
  box-shadow: 0 0 8px #bba24633;
}

.aff-centauri {
  border-left: 4px solid #6a5a7d; /* Violet spatial maîtrisé */
  box-shadow: 0 0 8px #6a5a7d33;
}

.aff-seven-spades {
  border-left: 4px solid #444; /* Noir discret, espionnage */
  box-shadow: 0 0 8px #44444444;
}

.aff-eridani {
  border-left: 4px solid #5e7d64; /* Vert militaire pâle */
  box-shadow: 0 0 8px #5e7d6444;
}

.aff-tusk {
  border-left: 4px solid #705a48; /* Brun désaturé, robuste */
  box-shadow: 0 0 8px #705a4833;
}

.aff-habea-corpus-inc {
  border-left: 4px solid #9a5a5a; /* Rouge désaturé, légaliste */
  box-shadow: 0 0 8px #9a5a5a33;
}

.aff-dupont-monsanto {
  border-left: 4px solid #5e7d64; /* Vert terne industriel */
  box-shadow: 0 0 8px #5e7d6433;
}

.aff-ustf {
  border-left: 4px solid #445a66; /* Bleu acier militaire */
  box-shadow: 0 0 8px #445a6644;
}

.modifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: bold;
  background: #333;
  color: #fff;
  letter-spacing: 0.04em;
}

/* Styles spécifiques */
.badge.renegade {
  background: #661111;
  color: #fdd;
}
.badge.deceased {
  background: #222;
  color: #aaa;
  font-style: italic;
}
.badge.classified {
  background: #111;
  color: #fff;
  border: 1px solid #888;
}
.badge.red-notice {
  background: #550000;
  color: #ffaaaa;
}
.badge.black-notice {
  background: #000;
  color: #ccc;
}
.badge.do-not-engage {
  background: #bba246;
  color: #111;
}
.badge.shoot-to-kill {
  background: #220000;
  color: #ff4444;
}

.person-card.deceased {
  filter: grayscale(0.9) brightness(0.8);
  opacity: 0.75;
  position: relative;
}

.person-card.classified .person-content,
.person-card.classified .extra-info {
  filter: blur(1px);
  pointer-events: none;
  user-select: none;
}

.person-card.renegade::before {
  content: "RENEGADE";
  position: absolute;
  top: -8px;
  right: -8px;
  background: #661111;
  color: #fdd;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: bold;
  text-transform: uppercase;
  transform: rotate(5deg);
  box-shadow: 0 0 4px #000;
  z-index: 2;
}

.person-card.shoot-to-kill::after {
  content: "⚠ SHOOT TO KILL";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #220000;
  color: #ff4444;
  text-align: center;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 4px 0;
  box-shadow: 0 0 6px #000;
  z-index: 1;
}

.person-card {
  position: relative;
  padding-bottom: 2.5rem; /* so shoot-to-kill banner doesn't cover content */
  transition: all 0.3s ease;
}


.tab-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin: 0.75em 0;
  background: linear-gradient(to right, var(--cid-header), var(--cid-panel-soft));
  padding: 0.4em 0.6em;
  border-radius: 6px;
  box-shadow: inset 0 0 4px var(--cid-shadow);
}

/*.tab-header {
  position: relative;
  z-index: 1;
}*/

.tab-button {
  padding: 0.4em 0.8em;
  border: none;
  background: var(--cid-tab);
  color: var(--cid-tab-text);
  cursor: pointer;
  font-size: 0.9em;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.tab-button:hover {
  border-color: var(--cid-accent);
  color: var(--cid-text);
}

.tab-button.tab-active {
  background: var(--cid-tab-active);
  color: var(--cid-tab-active-text);
  font-weight: bold;
  box-shadow: 0 0 6px var(--cid-shadow);
}

/*.tab-button.tab-active {
  border-bottom: 2px solid transparent;
  position: relative;
  z-index: 2;
}*/


.tab-content {
  margin-bottom: 1.2em;
  background: var(--cid-panel-soft);
  border: 1px solid var(--cid-border);
  padding: 1em;
  border-radius: 6px;
  box-shadow: inset 0 0 8px var(--cid-shadow);
  color: var(--cid-text);
}

.tab-content.hidden {
  display: none;
}

.field {
  margin-bottom: 0.75em;
}

.field ul {
  margin: 0.3em 0 0 1.2em;
  padding-left: 1em;
  color: var(--cid-text-soft);
}

.qrcode-wrapper {
  display: grid;
  min-width: 252px;
  min-height: 252px;
  padding: 1em;
  place-items: center;
  background: var(--qr-light);
  border-radius: 8px;
  box-shadow: 0 0 10px var(--cid-shadow);
  border: 1px solid var(--cid-border);
}

.share-panel { max-width: 760px; }
.share-heading { margin: 0; color: var(--cid-accent); font-size: 1.05rem; font-weight: bold; text-transform: uppercase; }
.share-explanation { color: var(--cid-muted); }
.share-url-label { display: grid; gap: 0.4rem; color: var(--cid-accent-soft); font-size: 0.76rem; font-weight: bold; text-transform: uppercase; }
.share-url { width: 100%; padding: 0.7rem; border: 1px solid var(--cid-border); color: var(--cid-text); background: var(--cid-control); font: 0.78rem "Consolas", monospace; }
.share-option { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.8rem; color: var(--cid-text-soft); font-size: 0.8rem; }
.share-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 1rem; }
.share-actions button { padding: 0.55rem 0.8rem; border: 1px solid var(--cid-border); border-radius: 4px; color: var(--cid-text); background: var(--cid-tab); cursor: pointer; }
.share-actions button:hover:not(:disabled) { border-color: var(--cid-accent); color: var(--cid-accent); }
.share-actions button:disabled { cursor: not-allowed; opacity: 0.4; }
.share-status { min-height: 1.2em; color: var(--cid-accent-soft); font: 0.75rem "Consolas", monospace; }
.qr-panel { display: grid; grid-template-columns: auto 1fr; gap: 1.2rem; align-items: center; margin-top: 1rem; padding: 1rem; border: 1px solid var(--cid-border); background: var(--cid-panel); }
.qr-panel.hidden { display: none; }
.qr-panel p { overflow-wrap: anywhere; color: var(--cid-text-soft); font: 0.75rem "Consolas", monospace; }
.qr-panel small { color: var(--cid-muted); }

@media (max-width: 700px) {
  main { margin-top: 1rem; }
  header { align-items: flex-start; padding: 1rem; flex-direction: column; }
  header h1 { font-size: 1.65rem; }
  .session-toolbar { grid-template-columns: 1fr; }
  .search-bar { align-items: stretch; flex-direction: column; gap: 0.55rem; }
  .search-bar input, .search-bar select, #clear-search { width: 100%; }
  .person-card { padding: 1rem 0.8rem 2.5rem; }
  .person-header { align-items: flex-start; }
  .person-header h2 { font-size: 1.2rem; }
  .tab-header { overflow-x: auto; flex-wrap: nowrap; }
  .tab-button { flex: 0 0 auto; }
  .qr-panel { grid-template-columns: 1fr; }
  .qrcode-wrapper { min-width: 0; }
  #loginScreen h2 { padding: 0 1rem; font-size: 1.25rem; text-align: center; }
  #progressBarContainer { width: min(320px, calc(100% - 2rem)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
