@import url("https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Titillium+Web:wght@400;600;700&display=swap");

/* =========================================================
   DESIGN SYSTEM
   ========================================================= */
:root {
  /* Background scale */
  --bg-0: #040b1f;
  --bg-1: #07112a;
  --bg-2: #0b1736;
  --bg-3: #10204a;

  /* Core tokens */
  --border: #23427f;
  --accent: #3d86ff;
  --accent-dark: #2d64bf;
  --green: #34d399;
  --yellow: #f4bd3f;
  --red: #f16976;
  --orange: #f2994a;
  --blue: #64a0ff;

  /* Text tokens */
  --text-primary: #d9e8ff;
  --text-secondary: #a9bfe9;
  --text-muted: #7895cb;

  /* Priority tokens */
  --prio-sofort: #f16976;
  --prio-dringend: #f4bd3f;
  --prio-normal: #64a0ff;

  /* Status tokens */
  --status-neu: #60a5fa;
  --status-uebermittelt: #3d86ff;
  --status-disponiert: #a78bfa;
  --status-anfahrt: #f4bd3f;
  --status-angekommen: #22c55e;
  --status-transport: #2ad39b;
  --status-abgeschlossen: #10b981;
  --status-storniert: #ef4444;

  /* Layout tokens */
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Compatibility tokens used across modules */
  --primary: var(--accent);
  --primary-rgb: 61, 134, 255;
  --danger: var(--red);
  --text: var(--text-primary);

  /* Layer scale */
  --z-nav: 100;
  --z-dropdown: 500;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-login: 9999;
}

/* =========================================================
   GLOBAL LAYER
   ========================================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: "Titillium Web", sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 14% -10%, rgba(var(--primary-rgb), 0.35), transparent 34%),
    radial-gradient(circle at 112% 75%, rgba(80, 126, 230, 0.24), transparent 44%),
    var(--bg-0);
}

h1,
h2,
h3,
h4,
h5 {
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.02em;
}

.hidden {
  display: none !important;
}

/* =========================================================
   LOGIN
   ========================================================= */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: var(--z-login);
}

.auth-panel {
  width: min(540px, 100%);
  background: linear-gradient(155deg, #11214a, #0a1432);
  border: 1px solid #2e56a5;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 44px rgba(3, 7, 18, 0.52);
  padding: 28px;
}

.auth-panel p {
  color: var(--text-secondary);
  margin-top: 6px;
}

.tab-row {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab {
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 10px;
  font-family: inherit;
  cursor: pointer;
}

.tab.active {
  background: #1d3770;
  border-color: #5c8ce5;
  font-weight: 700;
}

.auth-form {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg-1);
}

.topbar {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, #122554 0%, #0d1b40 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
}

.topbar-title small {
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* =========================================================
   SIDEBAR NAVIGATION
   ========================================================= */
.sidebar-nav {
  background: linear-gradient(180deg, #060f29 0%, #081636 100%);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  overflow-y: auto;
}

.brand {
  padding: 8px 10px 14px;
  border-bottom: 1px solid #24427a;
}

.brand h2 {
  font-size: 1rem;
}

.brand span {
  color: #8eaef3;
  font-size: 0.84rem;
}

.sidebar-nav nav {
  margin-top: 6px;
  display: grid;
  gap: 4px;
}

.nav-group-title {
  margin-top: 14px;
  padding: 4px 10px;
  color: #6480ba;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-link {
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: #a7bbe6;
  font: inherit;
  font-size: 0.92rem;
}

.nav-link.active {
  border-left-color: var(--accent);
  background: rgba(var(--primary-rgb), 0.18);
  color: #d8e6ff;
}

/* =========================================================
   CONTENT
   ========================================================= */
.content-area {
  padding: 14px 16px 18px;
  overflow-y: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.22s ease;
}

.kpi-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.kpi-card,
.stat-box,
.stat-card {
  background: linear-gradient(180deg, #13295e, #0d1d47);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.kpi-card span {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.kpi-card strong {
  margin-top: 6px;
  display: block;
  color: #6ea4ff;
  font-size: 1.8rem;
  line-height: 1;
}

.filters-row {
  margin-top: 12px;
}

.section-title {
  margin: 12px 0 8px;
  font-size: 1rem;
  color: #d2e1ff;
}

/* =========================================================
   FORM ELEMENTS
   ========================================================= */
label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0c1a3f;
  color: var(--text-primary);
  padding: 11px 12px;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.22);
}

.message {
  min-height: 1.4em;
  margin-top: 10px;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-icon,
.btn-sm,
.btn-link-order {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
  color: var(--text-primary);
}

.btn-primary {
  background: linear-gradient(180deg, #3d8afc, #2d6fd5);
  border-color: #4f94ff;
}

.btn-secondary {
  background: #19336b;
  border-color: #294787;
}

.btn-danger {
  background: #25162d;
  border-color: #72374f;
  color: #ffb6c2;
}

.btn-icon {
  background: #131f3f;
  border-color: #28498f;
}

.btn-sm {
  padding: 5px 8px;
  font-size: 0.82rem;
}

.btn-link-order {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  text-decoration: underline;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* =========================================================
   TABLES
   ========================================================= */
.table-wrap {
  margin-top: 14px;
  border: 1px solid #1f3461;
  border-radius: var(--radius);
  background: #0d1a3f;
  overflow: hidden;
}

.table-wrap .section-title {
  margin: 0;
  padding: 10px;
  border-bottom: 1px solid #1f3461;
}

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

.data-table th,
.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #1b2e58;
  font-size: 0.82rem;
}

.data-table thead {
  background: #13295e;
}

.data-table th {
  color: #9db7e8;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

.data-table tbody tr:hover {
  background: #152d67;
}

/* =========================================================
   STATUS BADGES
   ========================================================= */
.status-pill,
.status-badge,
.role-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  border: 1px solid transparent;
}

.status-open {
  background: rgba(66, 211, 146, 0.16);
  color: #74ebb6;
  border-color: rgba(66, 211, 146, 0.32);
}

.status-locked {
  background: rgba(243, 187, 59, 0.16);
  color: #ffd472;
  border-color: rgba(243, 187, 59, 0.32);
}

.status-taken {
  background: rgba(238, 90, 102, 0.16);
  color: #ff9ca5;
  border-color: rgba(238, 90, 102, 0.32);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
}

.badge.ok {
  background: rgba(66, 211, 146, 0.16);
  color: #81eabf;
}

.badge.warn {
  background: rgba(243, 187, 59, 0.16);
  color: #ffd478;
}

.badge.danger {
  background: rgba(238, 90, 102, 0.16);
  color: #ff9ca5;
}

/* =========================================================
   MISSION TILES
   ========================================================= */
.offer-grid {
  margin-top: 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.mission-tile,
.offer-card {
  border: 1px solid #27457e;
  background: linear-gradient(180deg, #12275a, #0d1d45);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: inset 0 0 0 1px rgba(45, 88, 160, 0.28);
  animation: fadeIn 0.22s ease;
}

.offer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.offer-id {
  color: #70a2ff;
  font-size: 0.8rem;
  font-weight: 700;
}

.meta {
  margin-top: 8px;
  display: grid;
  gap: 4px;
  font-size: 0.86rem;
  color: #c4d7ff;
}

.badges {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.offer-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.tile-on-anfahrt {
  animation: tile-pulse 1.2s ease-in-out infinite;
}

.tile-sonderrechte {
  animation: tile-doppelblitz 0.9s linear infinite;
}

/* =========================================================
   MODAL
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(17, 28, 45, 0.68);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal,
.modal-xl {
  width: min(520px, 100%);
  background: #0f1934;
  border-radius: var(--radius-lg);
  border: 1px solid #28498f;
  animation: modalIn 0.22s ease;
}

.modal-xl {
  width: min(960px, 100%);
}

.modal-header,
.modal-footer {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header {
  position: sticky;
  top: 0;
  background: #0f1934;
}

.modal-body {
  padding: 0 14px 14px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  background: #0f1934;
}

.captcha-question {
  font-weight: 700;
  color: #bcd4ff;
  background: #13244b;
  border: 1px solid #2f549d;
  border-radius: 10px;
  padding: 10px;
}

/* =========================================================
   TOAST
   ========================================================= */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--z-toast);
  background: #101d3a;
  color: #dce8ff;
  border: 1px solid #355da9;
  border-radius: 10px;
  padding: 10px 12px;
  animation: slideIn 0.2s ease;
}

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tile-pulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 1px rgba(45, 88, 160, 0.28);
  }
  50% {
    box-shadow: inset 0 0 0 1px rgba(244, 189, 63, 0.62);
  }
}

@keyframes tile-doppelblitz {
  0%,
  100% {
    border-color: #27457e;
  }
  50% {
    border-color: #6fa6ff;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1800px) {
  .offer-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 1450px) {
  .offer-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 1200px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

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

  .sidebar-nav {
    display: none;
  }
}

@media (max-width: 760px) {
  .content-area {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 680px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }
}
