* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #f5f7fb;
}

.app-header {
  padding: 1rem 1.25rem;
  background: #111827;
  color: white;
}

.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.app-header p {
  margin: 0.25rem 0 0;
  opacity: 0.85;
}

.layout {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 1rem;
  padding: 1rem;
  min-height: calc(100vh - 150px);
}

.panel {
  background: white;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.panel h2 {
  margin-top: 0;
}

label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-weight: 700;
}

input {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
}

button {
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.75rem;
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(0.96);
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

button.secondary {
  background: #374151;
}

button.secondary.active {
  background: #059669;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

.map-section {
  min-height: 700px;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 700px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.result-box {
  background: #111827;
  color: #d1fae5;
  border-radius: 10px;
  padding: 0.75rem;
  min-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}

.app-footer {
  padding: 1rem;
  text-align: center;
  background: #111827;
}

.app-footer a {
  color: white;
  text-decoration: none;
}

.mode-box {
  padding: 0.75rem;
  background: #f3f4f6;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.mode-title {
  margin: 0;
  font-weight: 800;
}

.help {
  margin: 0.75rem 0 0;
  color: #4b5563;
  font-size: 0.9rem;
}

.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  color: #374151;
  font-size: 0.9rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
}

.origin-dot {
  background: #2563eb;
}

.destination-dot {
  background: #dc2626;
}

/* Marcadores Leaflet personalizados */
.map-pin {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.35);
  border: 3px solid #ffffff;
}

.map-pin span {
  position: absolute;
  inset: 0;
  transform: rotate(45deg);
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 900;
  font-size: 0.8rem;
  line-height: 1;
}

.map-pin-origin {
  background: #2563eb;
}

.map-pin-destination {
  background: #dc2626;
}

.sector-label {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #334155;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.18rem 0.35rem;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.18);
  text-align: center;
  white-space: nowrap;
}


.notice {
  margin-bottom: 0.85rem;
  padding: 0.75rem;
  border-radius: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.notice.warning {
  color: #78350f;
  background: #fef3c7;
  border: 1px solid #fbbf24;
}

.notice.success {
  color: #064e3b;
  background: #d1fae5;
  border: 1px solid #34d399;
}

.mode-box + .mode-box {
  margin-top: 0.85rem;
}

.suggestion-dot {
  background: #f59e0b;
}

.map-pin-suggestion {
  background: #f59e0b;
}

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

  .map-section,
  #map {
    min-height: 500px;
  }
}

button.external {
  background: #16a34a;
}

button.external:disabled {
  background: #9ca3af;
}


.operational-limits-card {
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
}

.limits-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.eyebrow {
  margin: 0;
  color: #4338ca;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.operational-limits-card h3,
.how-it-works h3 {
  margin: 0.1rem 0 0;
}

.limits-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.limit-item {
  padding: 0.6rem;
  background: #ffffff;
  border: 1px solid #dbe4ff;
  border-radius: 10px;
}

.limit-item span {
  display: block;
  color: #4b5563;
  font-size: 0.75rem;
  font-weight: 700;
}

.limit-item strong {
  display: block;
  margin-top: 0.2rem;
  color: #111827;
  font-size: 1rem;
}

.text-button {
  width: auto;
  min-width: 120px;
  margin-top: 0;
  padding: 0.55rem 0.75rem;
  background: #4f46e5;
  white-space: nowrap;
}

.small-action {
  width: auto;
  margin-top: 0;
  padding: 0.45rem 0.7rem;
  background: #374151;
  white-space: nowrap;
}

.how-it-works {
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-left: 5px solid #2563eb;
  border-radius: 12px;
}

.how-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.how-it-works ol {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.45;
}

.how-it-works li + li {
  margin-top: 0.35rem;
}

@media (max-width: 520px) {
  .limits-header,
  .how-header {
    display: block;
  }

  .text-button,
  .small-action {
    width: 100%;
    margin-top: 0.65rem;
  }

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


.usage-card {
  margin: 0.85rem 0;
  padding: 0.85rem;
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 12px;
}

.usage-summary {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  min-height: 160px;
  max-height: 280px;
  overflow: auto;
  background: #0f172a;
  color: #e0f2fe;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.backend-status {
  margin: -0.35rem 0 0.85rem;
  color: #374151;
  font-size: 0.86rem;
  font-weight: 700;
}

.admin-access-card {
  margin-top: 0.85rem;
  padding: 0.85rem;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
}

.warning-text {
  color: #92400e;
  font-weight: 700;
}

.success-text {
  color: #065f46;
  font-weight: 700;
}


select,
textarea {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font: inherit;
  background: white;
}

textarea {
  resize: vertical;
}

.operations-card {
  margin: 0.85rem 0;
  padding: 0.85rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
}

.orders-list {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.65rem;
}

.order-card {
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid #d1fae5;
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
}

.order-card p {
  margin: 0.35rem 0 0;
  color: #374151;
  font-size: 0.82rem;
  line-height: 1.35;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 0.4rem;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  background: #e5e7eb;
  color: #111827;
  font-size: 0.7rem;
  font-weight: 900;
  vertical-align: middle;
}

.status-accepted,
.status-created {
  background: #dbeafe;
  color: #1e3a8a;
}

.status-assigned {
  background: #fef3c7;
  color: #92400e;
}

.status-in_route {
  background: #ede9fe;
  color: #5b21b6;
}

.status-delivered {
  background: #dcfce7;
  color: #166534;
}

.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}


/* v0.3.1 - Panel operativo separado */
.app-header-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.top-nav a,
.button-link {
  display: inline-block;
  margin-top: 0.8rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.top-nav a {
  margin-top: 0;
  background: #374151;
}

.navigation-card {
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  background: #ecfeff;
  border: 1px solid #67e8f9;
  border-radius: 12px;
}

.orders-page-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  min-height: calc(100vh - 150px);
}

.orders-control-panel,
.orders-review-panel {
  align-self: start;
}

.orders-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.toolbar-actions {
  min-width: 220px;
}

select,
textarea {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font: inherit;
  background: #ffffff;
}

.compact-result {
  min-height: 150px;
}

.orders-list-large {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
}

.order-card-large {
  min-height: 220px;
}

.order-card.selected,
.order-card-large.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18), 0 4px 18px rgba(15, 23, 42, 0.12);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
}

.order-meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  margin: 0.75rem 0;
  color: #374151;
}

@media (max-width: 900px) {
  .app-header-split {
    align-items: stretch;
    flex-direction: column;
  }

  .top-nav a {
    width: 100%;
    text-align: center;
  }

  .orders-page-layout {
    grid-template-columns: 1fr;
  }

  .orders-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    min-width: 0;
  }
}

.orders-toolbar .text-button {
  margin-top: 0.65rem;
}

.orders-review-panel .how-it-works {
  margin-top: 0.75rem;
}
