:root {
  --bg: #f4f5fb;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --border: #dde0ea;
  --text: #171a27;
  --muted: #59607a;
  --accent: #8f4bff;
  --accent-glow: rgba(143, 75, 255, 0.45);
  --green: #00c46f;
  --red: #ff4d5e;
  --baby-blue: #8cc6ff;
  --purple: #a75fff;
}

body.dark {
  --bg: #060913;
  --bg-soft: #101425;
  --panel: #12172a;
  --border: #2b314a;
  --text: #eff1ff;
  --muted: #97a0c0;
  --accent: #9d68ff;
  --accent-glow: rgba(157, 104, 255, 0.5);
  --green: #00d47a;
  --red: #ff5a66;
  --baby-blue: #8cc6ff;
  --purple: #b16cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Sora", sans-serif;
  background: radial-gradient(circle at top right, rgba(143, 75, 255, 0.16), transparent 35%), var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(140deg, rgba(8, 10, 18, 0.85), rgba(8, 10, 18, 0.6));
  background-size: cover;
  background-position: center;
  filter: saturate(1.1);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(460px, 92vw);
  background: rgba(10, 14, 25, 0.84);
  border: 1px solid rgba(157, 104, 255, 0.45);
  box-shadow: 0 0 30px var(--accent-glow);
  border-radius: 18px;
  padding: 28px;
  backdrop-filter: blur(4px);
}

.login-card h1 {
  margin: 0 0 8px;
  font-family: "Rajdhani", sans-serif;
  font-size: 2rem;
}

.login-card p {
  margin: 0 0 16px;
  color: #d6d8e7;
}

label {
  display: block;
  margin: 10px 0 6px;
  font-weight: 600;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-weight: 500;
}

.modern-check,
.perm-check {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(163, 173, 210, 0.6);
  background: rgba(255, 255, 255, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: 0.18s ease;
}

.modern-check::after,
.perm-check::after {
  content: "✓";
  color: #fff;
  font-size: 12px;
  line-height: 1;
  transform: scale(0);
  transition: 0.14s ease;
}

.modern-check:hover,
.perm-check:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.modern-check:checked,
.perm-check:checked {
  background: linear-gradient(130deg, #7d42f0, #ad7aff);
  border-color: #a978ff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.modern-check:checked::after,
.perm-check:checked::after {
  transform: scale(1);
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 10px 12px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s transform, 0.2s filter, 0.2s box-shadow;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95em;
  line-height: 1;
}

.btn-label {
  line-height: 1;
}

#loginForm button[type="submit"] {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(120deg, #7f44f1, #ad7aff);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}

.error {
  color: #ff8f9a;
  margin-top: 10px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(143, 75, 255, 0.09), transparent 24%), var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #7d42f0, #ac7aff);
  box-shadow: 0 0 20px var(--accent-glow);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand h2 {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
}

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

.nav-links {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  justify-content: flex-start;
  align-items: stretch;
}

.nav-link {
  width: min(220px, 100%);
  text-align: left;
  justify-content: flex-start;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  padding: 11px 12px;
}

.nav-link.active {
  background: linear-gradient(140deg, rgba(143, 75, 255, 0.88), rgba(171, 122, 255, 0.88));
  color: #fff;
  box-shadow: 0 0 14px var(--accent-glow);
}

.nav-link-highlight {
  font-weight: 800;
  text-shadow: 0 0 10px rgba(157, 104, 255, 0.45);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 12px;
  display: grid;
  gap: 10px;
}

/* Vom Nutzer gewuenscht: unteres Sidebar-Profilfeld ausblenden */
.sidebar .sidebar-footer {
  display: none;
}

.user-mini {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-mini img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.user-mini small {
  color: var(--muted);
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.danger-btn {
  background: rgba(255, 90, 102, 0.14);
  color: var(--red);
  border: 1px solid rgba(255, 90, 102, 0.36);
}

.main {
  padding: 24px;
  position: relative;
}

.top-actions {
  position: absolute;
  top: 18px;
  right: 24px;
  display: flex;
  gap: 10px;
  z-index: 5;
}

.square-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  padding: 0;
}

.avatar-square img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.settings-popover {
  position: absolute;
  top: 70px;
  right: 24px;
  width: min(340px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  z-index: 6;
  display: grid;
  gap: 8px;
}

.settings-popover h4 {
  margin: 0;
}

.page h1 {
  margin: 0 0 4px;
  font-family: "Rajdhani", sans-serif;
  font-size: 2rem;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.card h3 {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.value {
  font-size: 2rem;
  font-weight: 700;
  margin: 8px 0 4px;
}

.green {
  color: var(--green);
}

.red {
  color: var(--red);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.bank-btn {
  flex: 1;
  min-width: 120px;
}

.bank-btn.withdraw {
  background: rgba(255, 90, 102, 0.14);
  color: var(--red);
  border: 1px solid rgba(255, 90, 102, 0.36);
}

.bank-btn.deposit {
  background: rgba(0, 212, 122, 0.12);
  color: var(--green);
  border: 1px solid rgba(0, 212, 122, 0.32);
}

.status-chip {
  border: 1px solid;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.status-red {
  color: var(--red);
  border-color: var(--red);
}

.status-green {
  color: var(--green);
  border-color: var(--green);
}

.status-blue {
  color: var(--baby-blue);
  border-color: var(--baby-blue);
}

.status-purple {
  color: var(--purple);
  border-color: var(--purple);
}

.section-head {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel {
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.panel h4 {
  margin: 0 0 8px;
  color: var(--accent);
}

.drug-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.drug-box {
  min-height: 210px;
}

.drug-page-title {
  margin-bottom: 14px !important;
}

.drug-actions {
  display: grid;
  gap: 8px;
}

.drug-btn-grow {
  background: rgba(0, 212, 122, 0.14);
  color: var(--green);
  border: 1px solid rgba(0, 212, 122, 0.45);
}

.drug-btn-water {
  background: rgba(140, 198, 255, 0.14);
  color: var(--baby-blue);
  border: 1px solid rgba(140, 198, 255, 0.45);
}

.drug-btn-harvest {
  background: rgba(255, 105, 180, 0.14);
  color: #ff78c9;
  border: 1px solid rgba(255, 105, 180, 0.45);
}

.drug-btn-clear {
  background: rgba(255, 90, 102, 0.14);
  color: var(--red);
  border: 1px solid rgba(255, 90, 102, 0.45);
}

.separated-create {
  margin-bottom: 12px;
}

.separated-table {
  margin-top: 0;
}

.panel textarea {
  min-height: 100px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 12px;
  white-space: nowrap;
}

th {
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.04em;
  color: var(--muted);
}

td img.thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

#page-items tr.item-row-draggable {
  cursor: move;
}

#page-items tr.item-row-dragging {
  opacity: 0.55;
}

#page-items tr.item-drop-before td {
  border-top: 2px solid var(--accent);
}

#page-items tr.item-drop-after td {
  border-bottom: 2px solid var(--accent);
}

.page-tools {
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-btn {
  background: linear-gradient(130deg, #7d42f0, #ad7aff);
  color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  width: min(420px, 92vw);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.48);
}

#avatarCropCanvas {
  width: 100%;
  max-width: 280px;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0e1220;
  display: block;
  margin: 0 auto 8px;
  cursor: grab;
}

#avatarCropCanvas.dragging {
  cursor: grabbing;
}

.dialog-form menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 18px 0 0;
}

#vehicleForm #vehicleCancel {
  background: rgba(255, 90, 102, 0.14);
  color: var(--red);
  border: 1px solid rgba(255, 90, 102, 0.45);
}

#vehicleForm button[type="submit"] {
  background: rgba(0, 212, 122, 0.14);
  color: var(--green);
  border: 1px solid rgba(0, 212, 122, 0.45);
}

.dialog-form h3 {
  margin: 0 0 16px;
}

.dialog-form input,
.dialog-form textarea,
.dialog-form select {
  margin-top: 10px;
}

.dialog-form input:first-of-type,
.dialog-form textarea:first-of-type,
.dialog-form select:first-of-type {
  margin-top: 0;
}

#markerForm input[type="file"] {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.9);
  color: var(--text);
  padding: 8px 10px;
}

#markerForm input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 1px solid rgba(157, 104, 255, 0.5);
  border-radius: 8px;
  background: linear-gradient(130deg, rgba(125, 66, 240, 0.2), rgba(173, 122, 255, 0.2));
  color: var(--text);
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

#markerForm input[type="file"]::file-selector-button:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 10px var(--accent-glow);
}

.dialog-form input[type="file"],
.page-tools input[type="file"],
.panel input[type="file"] {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.9);
  color: var(--text);
  padding: 8px 10px;
}

.dialog-form input[type="file"]::file-selector-button,
.page-tools input[type="file"]::file-selector-button,
.panel input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 1px solid rgba(157, 104, 255, 0.5);
  border-radius: 8px;
  background: linear-gradient(130deg, rgba(125, 66, 240, 0.24), rgba(173, 122, 255, 0.24));
  color: var(--text);
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.dialog-form input[type="file"]::file-selector-button:hover,
.page-tools input[type="file"]::file-selector-button:hover,
.panel input[type="file"]::file-selector-button:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 10px var(--accent-glow);
}

#map,
#dealerMap,
#farmingMap {
  width: 100%;
  height: min(68vh, 650px);
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #0e1325;
}

.map-only {
  height: min(84vh, 920px) !important;
}

#map .leaflet-container,
#dealerMap .leaflet-container,
#farmingMap .leaflet-container {
  background: #0e1325;
}

#dealerMap .leaflet-control-attribution,
#farmingMap .leaflet-control-attribution {
  background: rgba(16, 20, 37, 0.92);
  color: var(--muted);
  border: 1px solid var(--border);
}

#dealerMap .leaflet-control-attribution a,
#farmingMap .leaflet-control-attribution a {
  color: var(--accent);
}

#dealerMap .leaflet-popup-content-wrapper,
#farmingMap .leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 10px;
}

#dealerMap .leaflet-popup-tip,
#farmingMap .leaflet-popup-tip {
  background: var(--panel);
  border: 1px solid var(--accent);
}

.map-panel {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

#dealerMarkerSearch {
  min-width: 280px;
  flex: 1;
}

.marker-color-preview {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  background: rgba(10, 14, 28, 0.9);
}

.marker-pick-map {
  width: 100%;
  height: 340px;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #0e1325;
}

.marker-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.marker-purple {
  background: #b16cff;
}

.marker-green {
  background: #00d47a;
}

.marker-red {
  background: #ff5a66;
}

.marker-blue {
  background: #63b8ff;
}

.marker-orange {
  background: #ffaf42;
}

.marker-yellow {
  background: #ffd84d;
}

.marker-black {
  background: #1e243a;
}

.marker-white {
  background: #f4f7ff;
  border: 1px solid #94a0c7;
}

.marker-rosa {
  background: #ff8fd7;
}

.marker-brown {
  background: #9a6a4a;
}

.marker-lightblue {
  background: #7dd8ff;
}

.marker-grey {
  background: #aeb6c9;
}

.marker-darkgreen {
  background: #2b8c56;
}

.marker-darkred {
  background: #9f3347;
}

.marker-pin {
  background: #9d68ff;
  box-shadow: 0 0 0 2px rgba(157, 104, 255, 0.28);
}

.profile-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
}

.profile-quick-card {
  align-self: start;
}

.avatar-big {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.small {
  color: var(--muted);
  font-size: 0.86rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.member-grid {
  grid-template-columns: repeat(3, minmax(140px, 1fr));
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.action-cell {
  white-space: nowrap;
}

.action-cell button + button {
  margin-left: 8px;
}

.action-edit-btn {
  padding: 8px 12px;
  box-shadow: none;
}

#page-items h1,
#page-items th,
#page-items td,
#page-items button {
  font-weight: 700;
  text-shadow: 0 0 8px rgba(177, 108, 255, 0.42);
}

#page-items td img.thumb {
  display: block;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 8px;
}

#page-vehicles h1,
#page-vehicles th,
#page-vehicles td,
#page-vehicles button {
  font-weight: 700;
  text-shadow: 0 0 8px rgba(177, 108, 255, 0.42);
}

#page-vehicles td img.thumb {
  display: block;
  width: 96px;
  height: 56px;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 8px;
}

#page-leadership tbody td:nth-child(2) {
  font-weight: 700;
}

#page-members tbody td:nth-child(2),
#page-members tbody td:nth-child(3),
#page-members tbody td:nth-child(4) {
  font-weight: 700;
}

.glow {
  animation: pulse 2.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 rgba(157, 104, 255, 0);
  }
  50% {
    box-shadow: 0 0 16px rgba(157, 104, 255, 0.35);
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

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

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .drug-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 650px) {
  .cards {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 14px;
  }
}
