/* Style général pour l’éditeur de baronnies */
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Le conteneur principal occupe tout l’espace libre sous l’en-tête */
main {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 0;
}

.gestion-main {
  padding-left: 20px;
  padding-right: 20px;
}

/* En-tête avec contrôles et outils */
.app-header {
  background-color: #D13521;
  color: white;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 1100;
}
.app-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

/* Lignes de boutons */
.controls-row,
.tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.auth-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.seigneur-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: 0;
}

.seigneur-search input {
  width: 200px;
  max-width: 45vw;
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px solid #ddd;
  font-size: 0.9rem;
}

.seigneur-search input:focus {
  outline: none;
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

.organigramme-search-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1200;
}

.seigneur-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 8px;
  min-width: 220px;
  max-width: 320px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: none;
  z-index: 1200;
}

.seigneur-search-results button {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

.seigneur-search-results button:hover,
.seigneur-search-results button:focus {
  background: #f2f4f8;
}

.seigneur-search-empty {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: #666;
}

.loading-indicator {
  color: #555;
  font-style: italic;
}

.user-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: white;
  text-decoration: none;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: white;
}

.bell-btn {
  position: relative;
}

.bell-btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e53935;
  color: white;
  border-radius: 50%;
  padding: 2px 5px;
  font-size: 10px;
}

.notif-panel {
  position: fixed;
  top: 0;
  right: 0;
  background: white;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  width: 300px;
  min-height: 100px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.notification {
  padding: 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.notification.unread {
  background: #eef3ff;
  font-weight: bold;
}

.notification:hover {
  background: #f5f5f5;
}

.notification time {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #666;
}

#authDialog form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#authDialog input {
  padding: 6px;
}

.profile-main {
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.profile-form {
  display: flex;
  flex-direction: column;
  max-width: 400px;
  width: 100%;
  margin: 20px auto;
  gap: 20px;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.profile-form input {
  padding: 8px;
}

.tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background-color: #e6ebf3;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}

.tab-btn.active {
  background-color: #fff;
  border-bottom: 2px solid white;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.tab-content.active {
  display: flex;
}

/* Boutons généraux */
.control-btn {
  background-color: #1d56a4;
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}
.control-btn:hover {
  background-color: #3d6db2;
}
.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Fichier input stylé */
.file-label {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.file-label input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Outils de dessin */
.tools-row .tool-btn {
  background-color: #e6ebf3;
  border: 1px solid #c4d0e3;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #0b3d91;
  transition: background-color 0.2s, border-color 0.2s;
}
.tools-row .tool-btn:hover {
  background-color: #d2dcec;
  border-color: #b2c1d6;
}
.tools-row .tool-btn.active {
  background-color: #0b3d91;
  color: white;
  border-color: #0b3d91;
}

/* Taille du pinceau */
.brush-size-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: white;
  font-size: 0.9rem;
}
#brushSize {
  width: 80px;
}

/* Conteneur de la carte */
.map-container {
  position: relative;
  flex: 1;
  overflow: hidden;
  border-top: 1px solid #ccc;
}

.panzoom-group {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}

.base-map {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
  pointer-events: none;
}

.pixel-canvas {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
  /* Autoriser les événements souris pour dessiner */
  pointer-events: auto;
}

.id-overlay-map {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 3;
}

/* Panneau d’informations */
.info-panel {
  position: absolute;
  top: 100px;
  right: 10px;
  background-color: white;
  border: 1px solid #ccc;
  padding: 10px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  max-width: 300px;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: manual;
  z-index: 10;
}
.info-panel h2 {
  margin-top: 0;
  font-size: 1rem;
}
.info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.info-group {
  margin-bottom: 15px;
}
.info-group:last-child {
  margin-bottom: 0;
}
.info-group h3 {
  margin: 4px 0;
  font-size: 0.9rem;
}
.info-row {
  margin: 2px 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}
.info-row.seigneur-line {
  align-items: center;
}
.info-label {
  font-weight: 600;
  min-width: 90px;
}
.info-panel ul {
  margin: 2px 0 0 16px;
  padding: 0;
}
.info-panel label {
  display: block;
  margin-top: 6px;
  font-weight: bold;
}
.info-panel label.checkbox-label {
  display: flex;
  align-items: center;
  font-weight: normal;
}
.info-panel label.checkbox-label input {
  margin-right: 4px;
}
.info-panel input {
  width: 100%;
  padding: 4px;
  margin-top: 2px;
  box-sizing: border-box;
}
.info-panel button {
  margin-top: 4px;
  margin-bottom: 4px;
  background-color: #1d56a4;
  color: white;
  border: none;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.info-panel button:hover {
  background-color: #3d6db2;
}
.connection-list {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.connection-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  font-size: 0.9rem;
  background: #f6f8ff;
  border: 1px solid #d6def7;
  padding: 4px;
  border-radius: 4px;
}
.connection-row input {
  width: 70px;
  margin: 0;
}
.connection-actions {
  margin-top: 6px;
  display: grid;
  gap: 4px;
}
.seigneur-link,
.barony-link {
  margin: 0;
  background-color: #eef3ff;
  color: #1d56a4;
  border: 1px solid #c7d6f5;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.seigneur-link:hover,
.barony-link:hover {
  background-color: #dfe9ff;
}
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.info-table th,
.info-table td {
  text-align: left;
  padding: 4px 6px;
  border: 1px solid #ccc;
}

.info-table.hide-dejure-column th:nth-child(2),
.info-table.hide-dejure-column td:nth-child(2) {
  display: none;
}

/* Table d'administration */
.admin-table {
  border-collapse: collapse;
  margin-bottom: 20px;
}
.trade-table {
  width: max-content;
  min-width: 100%;
  font-size: 0.85rem;
  margin-bottom: 8px;
  white-space: nowrap;
}
.trade-table th,
.trade-table td {
  padding: 2px 4px;
  vertical-align: middle;
}
.trade-table th:first-child,
.trade-table td:first-child {
  padding: 0;
  text-align: center;
}
.trade-table .control-btn {
  padding: 2px 6px;
  margin: 0;
}
.trade-table .trade-route-path,
.trade-table .trade-line-path {
  text-align: center;
  cursor: help;
}
#tradeRoutesList,
#tradeLinesList {
  max-height: 240px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 4px;
  background-color: #fafafa;
}
#tradeRoutesList .admin-table,
#tradeLinesList .admin-table {
  margin-bottom: 0;
}
.admin-table th,
.admin-table td {
  border: 1px solid #ccc;
  padding: 4px 6px;
}
.admin-table th {
  position: sticky;
  top: 0;
  background-color: #f0f0f0;
  z-index: 2;
}
.admin-table input,
.admin-table select {
  width: 100%;
  box-sizing: border-box;
}
.admin-table button {
  padding: 4px 8px;
  background-color: #1d56a4;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.admin-table button:hover {
  background-color: #3d6db2;
}
.empty-state {
  padding: 10px 12px;
  border: 1px solid #e0b4b4;
  background-color: #fff1f1;
  color: #7a1a1a;
  border-radius: 4px;
  font-weight: 600;
}
.log-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin: 8px 0;
}
.log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  width: 100%;
}
.log-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}
.log-filter-buttons {
  display: flex;
  gap: 8px;
}
.log-filter-summary {
  margin-bottom: 8px;
  font-size: 0.95em;
  color: #333;
}
.log-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.log-page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.log-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
}
.log-pagination button {
  padding: 4px 8px;
  background-color: #1d56a4;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.log-pagination button:disabled {
  opacity: 0.6;
  cursor: default;
}
.log-table .log-desc {
  width: 60%;
}
.log-table .log-user {
  width: 20%;
}
.log-table .log-time {
  width: 20%;
}

#logAdvancedDialog form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 360px;
}

#logAdvancedDialog h3 {
  margin: 0;
}

.advanced-filter-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(200px, 1.5fr);
  gap: 10px 12px;
}

.advanced-filter-grid input,
.log-filter select,
.log-controls-row select,
#logAdvancedDialog select {
  padding: 6px;
}

.multi-col {
  padding-left: 10px;
  vertical-align: top;
  border: none !important;
}

th.multi-col {
  display: none;
}

.instant-prod-table {
  margin-bottom: 0;
}

.var-workers-table {
  margin-bottom: 0;
}

.qty-control {
  display: flex;
  align-items: center;
}
.qty-control .qty-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  margin: 0 2px;
}
.qty-control input {
  width: 50px;
  text-align: center;
}

.cost-row,
.restriction-row,
.effect-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.cost-row select,
.restriction-row select,
.effect-row select {
  flex: 1;
}
.effect-row span {
  flex: 1;
}
.cost-row input,
.restriction-row input,
.effect-row input {
  width: 60px;
}
.cost-row button,
.restriction-row button,
.effect-row button {
  padding: 0 6px;
}
.sanctuary-status {
  min-width: 70px;
  font-size: 0.85rem;
  text-transform: capitalize;
  color: #555;
}

/* Onglets de la page d'administration */
.tab-buttons {
  display: flex;
  gap: 4px;
  padding-left: 15px;
  margin-bottom: 10px;
}
.tab-buttons .push-right {
  margin-left: auto;
}
.tab-btn {
  background-color: #e6ebf3;
  border: 1px solid #c4d0e3;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 6px 10px;
  cursor: pointer;
}
.tab-btn.active {
  background-color: white;
  border-bottom: 1px solid white;
}
.tab-panel {
  display: none;
  padding: 10px 15px;
}
.tab-panel.active {
  display: block;
}
.tab-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.tab-panels {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.admin-table th.sortable {
  cursor: pointer;
  background-color: #f0f0f0;
}

/* Légende pour les filtres de couleur */
.legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background-color: white;
  border: 1px solid #ccc;
  padding: 6px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  font-size: 0.9rem;
  max-height: 40vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}
.legend-color {
  width: 14px;
  height: 14px;
  border: 1px solid #000;
}


.legend--tall {
  top: 10px;
  bottom: auto;
  max-height: calc(100vh - var(--legend-header-offset, 120px));
  overflow-y: auto;
}
.legend-item--interactive {
  cursor: pointer;
}
.legend-item--interactive:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Classement des cultures */
.culture-ranking {
  position: absolute;
  top: 10px;
  left: 10px;
  background-color: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 0.9rem;
  max-height: 40vh;
  overflow-y: auto;
  overflow-x: visible;
  min-width: 220px;
  z-index: 3;
}
.culture-ranking-table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.culture-ranking-table th,
.culture-ranking-table td {
  padding: 4px 6px;
  text-align: left;
  border: 1px solid #ddd;
}
.culture-ranking-table th {
  font-weight: 600;
  background-color: #f7f7f7;
}
.culture-ranking-table thead th {
  text-align: center;
}
.culture-ranking-table tbody td {
  font-weight: 700;
}
.culture-ranking-title-row th {
  text-align: center;
}
.culture-ranking-table td:last-child,
.culture-ranking-table th:last-child {
  text-align: right;
}

/* Indicateur de sauvegarde */
.save-indicator {
  position: fixed;
  background-color: #4caf50;
  color: white;
  padding: 6px 8px;
  border-radius: 50%;
  font-size: 1.2rem;
  display: none;
  z-index: 1000;
}

.destroy-btn,
.danger {
  background-color: #c00;
  color: #fff;
}
.destroy-btn:hover,
.danger:hover {
  background-color: #a00;
}

.confirm-dialog::backdrop {
  background: rgba(0,0,0,0.5);
}

.confirm-dialog {
  border: 2px solid #444;
  padding: 20px;
  border-radius: 6px;
}

.confirm-dialog .dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.trade-route-dialog {
  min-width: 320px;
}

.trade-route-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trade-route-fields {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  align-items: center;
}

.trade-route-path {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f8f8f8;
}

.admin-table .trade-route-path {
  display: table-cell;
  padding: 2px 4px;
  border: 1px solid #ccc;
  border-radius: 0;
  background: transparent;
  text-align: center;
}

.trade-route-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trade-route-endpoint {
  font-weight: bold;
  text-align: center;
}

.trade-route-hint {
  font-size: 0.9rem;
  color: #b04a00;
}

/* Organigramme féodal */
.organigramme-main {
  display: flex;
  flex: 1;
  gap: 0;
  padding: 0;
}

.organigramme-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.organigramme-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
}

.organigramme-hint {
  font-size: 0.9rem;
  color: #607d8b;
}

.organigramme-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #f8f9fb;
  user-select: none;
}

.organigramme-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}

.organigramme-svg:active {
  cursor: grabbing;
}

.organigramme-node-label {
  font-size: 14px;
  font-weight: 600;
  color: #2b2b2b;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  width: 100%;
  padding: 6px 12px;
  box-sizing: border-box;
  white-space: normal;
  line-height: 18px;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: manual;
}

.organigramme-node {
  cursor: pointer;
}

.organigramme-legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: auto;
  max-width: 220px;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.organigramme-legend h2 {
  margin-top: 0;
  font-size: 0.9rem;
}

.organigramme-legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.organigramme-legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.organigramme-info-panel {
  max-height: calc(100% - 140px);
  overflow-y: auto;
}

.organigramme-seigneur-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.organigramme-seigneur-btn {
  padding: 4px 8px;
  font-size: 0.85rem;
}

.info-panel .organigramme-seigneur-btn {
  margin: 0;
}

.organigramme-empty {
  font-size: 0.9rem;
  color: #6b7280;
}

@media (max-width: 1100px) {
  .organigramme-main {
    flex-direction: column;
  }

  .organigramme-legend {
    width: auto;
  }
}

.trade-route-info-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.trade-route-info-header {
  font-weight: bold;
  text-align: center;
}

.trade-route-info-path {
  margin: 0;
  padding-left: 18px;
}

.trade-route-empty {
  font-style: italic;
  color: #555;
}

.column-preferences-dialog {
  min-width: 320px;
}

.column-preferences-content {
  display: grid;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
  margin-top: 10px;
}

.column-preferences-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-toggle-btn {
  padding: 2px 8px;
  font-weight: bold;
  line-height: 1;
}

/* Indicateurs de production */
.prod-positive {
  color: #2e8b57;
}
.prod-negative {
  color: #c0392b;
}

/* Tooltip styling */
.tooltip {
  font-weight: bold;
  cursor: help;
  position: relative;
  display: inline-block;
}

.tooltip-table {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: white;
  border-collapse: collapse;
  border: 1px solid #ccc;
  color: inherit;
  font-weight: normal;
  margin-top: 4px;
  z-index: 10;
}

.tooltip-table td {
  padding: 2px 6px;
  white-space: nowrap;
  text-align: left;
}

.tooltip:hover .tooltip-table {
  display: table;
}

.tooltip-floating {
  position: fixed;
  top: 0;
  left: 0;
  transform: none;
  margin-top: 0;
  z-index: 2000;
  pointer-events: none;
}

/* Tables des ressources */
.resource-tables {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.resource-table-container {
  flex: 1;
  min-width: 250px;
}

/* Bouton de construction désactivé */
.build-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup {
  background: #fff;
  padding: 10px;
  border-radius: 4px;
  max-height: 80vh;
  overflow: auto;
}

.popup.spell-success {
  border: 2px solid #28a745;
  color: #155724;
}

.popup.spell-failure {
  border: 2px solid #dc3545;
  color: #721c24;
}

/* Commerce tab */
.trade-section {
  display: flex;
  gap: 10px;
  padding: 10px;
  box-sizing: border-box;
}

.trade-map {
  flex: 2;
  position: relative;
  aspect-ratio: 4 / 3;
}

.trade-map img,
.trade-map canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.trade-routes {
  flex: 1;
  overflow: auto;
}

.trade-legend {
  margin-top: 5px;
  display: flex;
  gap: 10px;
  font-size: 0.9em;
}

.legend-box {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
}

.legend-box.land {
  background: rgba(128, 0, 128, 0.5);
}

.legend-box.sea {
  background: rgba(0, 128, 255, 0.5);
}

/* Responsive mobile (sans impact desktop) */
@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden;
  }

  .map-container,
  .pixel-canvas,
  .organigramme-canvas,
  .organigramme-svg {
    touch-action: none;
    overscroll-behavior: contain;
  }

  .mobile-zoom-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-zoom-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
  }

  .gestion-main,
  .profile-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .tab-buttons {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }

  .tab-buttons .push-right {
    margin-left: 0;
  }

  .tab-panels,
  .tab-panel,
  .admin-table,
  .trade-table,
  .info-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-panel {
    padding: 8px 10px;
  }

  .tab-btn {
    padding: 6px 8px;
    font-size: 0.9rem;
  }

  .organigramme-search-overlay {
    top: 8px;
    right: 8px;
    max-width: calc(100% - 16px);
  }

  .organigramme-legend {
    bottom: 8px;
    left: 8px;
    max-width: min(72vw, 260px);
    max-height: 34vh;
  }

  .organigramme-info-panel {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    max-width: none;
    max-height: 42vh;
    overflow-y: auto;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 8px;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }

  .controls-row,
  .tools-row {
    gap: 4px;
  }

  .control-btn,
  .tab-btn {
    font-size: 0.85rem;
  }

  .info-panel {
    min-width: 0;
  }
}
