:root {
  --bg: #070a10;
  --bg-elevated: #0d121c;
  --bg-card: #121826;
  --border: rgba(148, 163, 184, 0.14);
  --text: #e8eef8;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #eab308;
  --radius: 14px;
  --font: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: #070a10;
}

.auth-card {
  width: min(440px, 100%);
  background: #121826;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: none;
}

.auth-card.wide { width: min(560px, 100%); }

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 0.85rem;
  display: block;
  object-fit: contain;
  border-radius: 50%;
}

.auth-seal {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1e3a8a;
  border: 2px solid #3b82f6;
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.auth-brand p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: none;
  font-family: var(--font);
}

.auth-title {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.auth-footer {
  margin-top: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .span-2 {
  grid-column: span 2;
}

@media (max-width: 560px) {
  .form-grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: span 2; }
}

@media (max-width: 640px) {
  .form-grid.three { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  background: #0a0f18;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  transition: filter 0.15s, transform 0.1s;
}

.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); }
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  width: auto;
}

.auth-forgot {
  margin-top: 1.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

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

.modal-panel {
  width: min(560px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: #121826;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.35rem 1.35rem 1.2rem;
  box-shadow: none;
}

.modal-panel-wide {
  width: min(980px, 100%);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.04);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.alert {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}
.alert-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}
.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #bfdbfe;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  background: #0a101b;
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 5;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.65rem;
  padding: 0.5rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: #111827;
}

.sidebar-brand-text {
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.sidebar-brand-text strong {
  display: block;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-text span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.nav-section-label {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0.85rem 0.7rem 0.4rem;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.62rem 0.85rem;
  margin: 0 0.35rem;
  border-radius: 10px;
  color: #94a3b8;
  text-decoration: none !important;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  min-width: 0;
  overflow: hidden;
}
.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.045);
  color: #e2e8f0;
}
.nav-link.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: #f8fafc;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.nav-link.active::before {
  content: none;
}
.nav-ico {
  display: inline-flex;
  color: #64748b;
  flex-shrink: 0;
}
.nav-link.active .nav-ico,
.nav-link:hover .nav-ico {
  color: var(--accent);
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 16, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: min(420px, 48vw);
  background: #0a0f18;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  color: var(--muted);
}
.topbar-search input {
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  color: var(--text);
}
.topbar-search input:focus { box-shadow: none; }
.topbar-search kbd {
  margin-left: auto;
  font-size: 0.68rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  color: #64748b;
  font-family: var(--mono);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-menu { position: relative; }

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.35rem 0.45rem;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.profile-trigger:hover,
.profile-menu.is-open .profile-trigger {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.profile-avatar.lg {
  width: 52px;
  height: 52px;
  font-size: 1.15rem;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.profile-meta strong {
  font-size: 0.9rem;
  white-space: nowrap;
}
.profile-meta span {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.profile-caret { color: var(--muted); transition: transform 0.15s; }
.profile-menu.is-open .profile-caret { transform: rotate(180deg); }

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  min-width: 200px;
  background: #121826;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.4rem;
  z-index: 30;
  display: grid;
  gap: 0.15rem;
}
.profile-dropdown[hidden] { display: none !important; }
.profile-dropdown a,
.profile-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  text-decoration: none !important;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.profile-dropdown a:hover,
.profile-dropdown button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.content {
  padding: 1.6rem 1.75rem 2rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  margin: 0;
  color: var(--accent);
  font-size: 1.65rem;
  font-weight: 700;
}
.page-header p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.3rem;
}

.dash-welcome {
  display: none;
}

.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}
.status-banner strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}
.status-banner span,
.status-banner em {
  color: #bbf7d0;
  font-size: 0.85rem;
  font-style: normal;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.15rem;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat .label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat .value {
  font-size: 1.9rem;
  font-weight: 700;
  margin-top: 0.55rem;
  line-height: 1;
}
.stat .value.accent { color: var(--accent); }
.stat .value.warn { color: #eab308; }
.stat .value.danger { color: #ef4444; }

.dash-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
  align-items: start;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.panel-head {
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}
.panel-body {
  padding: 1.1rem;
}
.empty-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.9rem;
  min-height: 160px;
}
.empty-panel p {
  margin: 0;
  color: var(--muted);
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}
.quick-tile {
  display: block;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: inherit !important;
  text-decoration: none !important;
  transition: border-color 0.15s, background 0.15s;
}
.quick-tile strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}
.quick-tile span {
  color: var(--muted);
  font-size: 0.82rem;
}
.quick-tile:hover {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
}

.quick-links {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 0.65rem !important;
}
.quick-links a {
  display: block !important;
  padding: 0.85rem 1rem !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #e2e8f0 !important;
  text-decoration: none !important;
}

.main {
  min-width: 0;
  overflow-x: hidden;
}

.badge-danger { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

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

.citizens-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.citizens-search {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-top: 0;
}
.citizens-search input { margin: 0; }

.citizen-name-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.profile-avatar.sm {
  width: 32px;
  height: 32px;
  font-size: 0.78rem;
}
.profile-avatar.xl {
  width: 72px;
  height: 72px;
  font-size: 1.4rem;
}

.row-link { cursor: pointer; }
.row-link:hover td { background: rgba(59, 130, 246, 0.06) !important; }

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none !important;
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
}
.back-link:hover { color: var(--accent); }

.citizen-fiche { display: grid; gap: 1rem; }

.citizen-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}
.citizen-hero-left {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.citizen-hero-right textarea {
  min-height: 140px;
  resize: vertical;
}

.marker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.marker-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0a0f18;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.marker-toggle input { accent-color: currentColor; }
.marker-toggle.danger.is-on,
.marker-toggle.danger:has(input:checked) {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}
.marker-toggle.warn.is-on,
.marker-toggle.warn:has(input:checked) {
  background: rgba(234, 179, 8, 0.16);
  border-color: rgba(234, 179, 8, 0.4);
  color: #fde68a;
}
.marker-toggle.info.is-on,
.marker-toggle.info:has(input:checked) {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.4);
  color: #bfdbfe;
}

.citizen-mini-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 0;
}
.citizen-mini-stats .stat { min-height: 88px; }

.citizen-save-bar {
  justify-content: flex-end;
  margin: 0;
}

.citizen-sections {
  display: grid;
  gap: 1rem;
  margin-top: 1.15rem;
}
.citizen-sections h3 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
}
.tag-pill button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.inline-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.inline-add input,
.inline-add select {
  width: auto;
  min-width: 140px;
  flex: 1;
}

.simple-list {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}
.simple-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

@media (max-width: 980px) {
  .citizen-hero { grid-template-columns: 1fr; }
  .citizen-mini-stats { grid-template-columns: repeat(3, 1fr); }
  .citizens-stats { grid-template-columns: 1fr; }
}

.settings-stack {
  display: grid;
  gap: 1.15rem;
  max-width: 760px;
}
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem;
}
.settings-card-head {
  margin-bottom: 1.15rem;
}
.settings-card-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.settings-identity {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.settings-identity strong {
  display: inline-block;
  margin-right: 0.45rem;
  font-size: 1.05rem;
}

.field-hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.35rem;
}
.btn-auto { width: auto; min-width: 160px; }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.3rem;
  background: #0a0f18;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.segmented.wrap { display: flex; }
.segment {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment.is-active,
.segment:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--swatch, #3b82f6);
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
}
.swatch input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.swatch.is-active,
.swatch:has(input:checked) {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}
.swatch.custom {
  width: auto;
  min-width: 70px;
  height: 34px;
  border-radius: 999px;
  background: #0a0f18;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  gap: 0.35rem;
  padding: 0 0.55rem;
}
.swatch.custom input[type="color"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
}

html[data-theme="light"] {
  --bg: #eef2f7;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #64748b;
}
html[data-theme="light"] .sidebar {
  background: #0f172a;
}
html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.92);
}
html[data-theme="light"] .topbar-search,
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="light"] .segmented,
html[data-theme="light"] .profile-dropdown {
  background: #f8fafc;
}
html[data-theme="light"] .nav-link { color: #cbd5e1; }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; overflow: auto; }
  .sidebar { width: 100%; max-width: none; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); }
  .topbar-search { min-width: 0; flex: 1; }
  .profile-meta { display: none; }
}

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
table.data tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge-muted { background: rgba(148,163,184,0.15); color: #cbd5e1; }
.badge-ok { background: rgba(34,197,94,0.15); color: #86efac; }
.badge-warn { background: rgba(234,179,8,0.15); color: #fde047; }
.badge-owner { background: rgba(59,130,246,0.18); color: #93c5fd; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.inline-form input, .inline-form select {
  width: auto;
  min-width: 120px;
  padding: 0.4rem 0.55rem;
}

.stack { display: grid; gap: 1rem; }
.muted { color: var(--muted); }
.actions-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* —— Base de données —— */
.db-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.db-hub {
  padding: 1.15rem 1.25rem 1.35rem;
}

.db-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.db-search-ico {
  position: absolute;
  left: 0.9rem;
  color: #64748b;
  pointer-events: none;
}

.db-search-wrap input {
  padding-left: 2.55rem;
  margin: 0;
  font-size: 1rem;
}

.db-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
  min-height: 0.5rem;
}

.db-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0a0f18;
  color: var(--text);
  text-decoration: none !important;
  font-size: 0.92rem;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.db-pill:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, #0a0f18);
  transform: translateY(-1px);
}

.db-pill.is-wanted {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.db-empty,
.db-hint {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.recensement-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.95fr;
  gap: 1.15rem;
}

.recensement-col {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.recensement-col legend {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding: 0;
}

.recensement-col label { margin-top: 0.65rem; }
.recensement-col label:first-of-type { margin-top: 0; }

.photo-drop {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 220px;
  max-height: 320px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  background: #0a0f18;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  margin: 0 !important;
  text-transform: none;
  letter-spacing: 0;
  font-size: inherit;
  color: inherit;
}

.photo-drop:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.photo-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 3;
  padding: 0;
  border: 0;
  margin: 0;
}

.photo-drop img[data-photo-preview] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  border-radius: 13px;
  z-index: 1;
}

.photo-drop-hint,
.photo-drop [data-photo-placeholder] {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 0.35rem;
  color: var(--muted);
  text-align: center;
  padding: 0.75rem;
  pointer-events: none;
}

.photo-drop.has-photo .photo-drop-hint,
.photo-drop.has-photo [data-photo-placeholder] {
  display: none;
}

.photo-drop [data-photo-placeholder] strong,
.photo-drop-hint strong {
  color: var(--text);
  font-size: 0.95rem;
}

.photo-drop [data-photo-placeholder] small,
.photo-drop-hint small {
  font-size: 0.78rem;
}

.license-picker {
  margin-top: 1.15rem;
  padding: 1rem 1.1rem 0.85rem;
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 12px;
  background: rgba(8, 12, 20, 0.55);
}

.license-picker-main {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.license-picker-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f1f5f9;
}

.license-sub {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: #e2e8f0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.license-toggles {
  display: flex;
  gap: 0.55rem;
}

.license-toggle {
  position: relative;
  margin: 0 !important;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: inherit;
  color: inherit;
}

.license-toggle input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.license-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.55);
  background: #0a0f18;
  color: #f8fafc;
  font-weight: 700;
  font-size: 1.05rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.license-toggle:hover span {
  border-color: rgba(212, 175, 55, 0.85);
}

.license-toggle:has(input:checked) span,
.license-toggle.is-on span {
  background: #1f6b3a;
  border-color: rgba(212, 175, 55, 0.7);
  color: #fff;
}

.license-status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.license-status-item {
  text-align: center;
}

.license-status-letter {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f8fafc;
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-bottom: 0.35rem;
}

.license-status-value {
  font-size: 0.95rem;
  font-weight: 700;
}

.license-status-value.is-na {
  color: #ef4444;
}

.license-status-value.is-valid {
  color: #4ade80;
}

.license-legend {
  margin: 0.9rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.82rem;
  color: #e2e8f0;
}

@media (max-width: 720px) {
  .license-picker-main {
    grid-template-columns: 1fr;
  }
}

/* —— Fiche personne —— */
.fiche-shell {
  display: grid;
  gap: 1rem;
}

.fiche-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.fiche-kicker {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fiche-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
}

.fiche-dob {
  color: var(--muted);
  font-weight: 500;
}

.fiche-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none !important;
  font-size: 1.5rem;
  line-height: 1;
  background: #0a0f18;
  flex-shrink: 0;
}

.fiche-close:hover {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.fiche-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.fiche-id-col,
.fiche-main-col {
  display: grid;
  gap: 1rem;
}

.id-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(160deg, #141b2a 0%, #0c121c 55%, #101826 100%);
}

.id-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #94a3b8;
}

.wanted-badge {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  text-transform: uppercase;
}

.id-card-body {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.id-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 260px;
  border-radius: 12px;
  overflow: hidden;
  background: #070b12;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.id-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.id-photo-fallback {
  font-size: 3rem;
  font-weight: 700;
  color: #64748b;
}

.id-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.85rem;
  margin: 0;
}

.id-meta .full { grid-column: 1 / -1; }

.id-meta dt {
  margin: 0;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.id-meta dd {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
  color: var(--text);
}

.licenses-card h3,
.fiche-edit h3,
.fiche-panel h3 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
}

.licenses-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.lic-field {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0a0f18;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  color: var(--text);
}

.lic-field.lic-ok { border-color: rgba(34, 197, 94, 0.35); }
.lic-field.lic-bad { border-color: rgba(239, 68, 68, 0.35); }
.lic-field.lic-warn { border-color: rgba(234, 179, 8, 0.35); }

.fiche-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.fiche-edit-head h3 { margin: 0; }

.fiche-edit .marker-toggle {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.fiche-panels {
  display: grid;
  gap: 1rem;
}

.fiche-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.fiche-panel-head h3 { margin: 0; }

.panel-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.35rem 0 0.15rem;
}

.panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.panel-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a0f18;
}

.panel-list span {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 980px) {
  .fiche-layout { grid-template-columns: 1fr; }
  .recensement-grid { grid-template-columns: 1fr 1fr; }
  .db-stats { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .recensement-grid { grid-template-columns: 1fr; }
  .licenses-grid { grid-template-columns: 1fr; }
  .id-meta { grid-template-columns: 1fr; }
}
