/* =========================================================
   RC Logística — Design System v2
   Dark cyberpunk palette · Portal RC compatible
   Inter + JetBrains Mono · Mobile-first · iPhone-optimized
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* === Palette — Portal RC dark === */
  --primary:        #00d9ff;
  --primary-dark:   #0099cc;
  --primary-light:  #66eaff;
  --accent:         #00d9ff;
  --accent-hover:   #0099cc;
  --success:        #26a745;
  --success-bg:     rgba(38,167,69,0.15);
  --error:          #e53935;
  --error-bg:       rgba(229,57,53,0.15);
  --warning:        #ffb300;
  --warning-bg:     rgba(255,179,0,0.15);
  --info:           #00d9ff;
  --info-bg:        rgba(0,217,255,0.12);

  --bg:             #0a0e27;
  --card-bg:        #0f1430;
  --card-border:    #1f2639;
  --border:         #1f2639;
  --border-focus:   #00d9ff;
  --input-bg:       #151c32;

  --text:           #e8f0f8;
  --text-secondary: #8fa8be;
  --text-muted:     #4d6075;
  --text-on-primary:#0a0e27;

  --radius:         14px;
  --radius-sm:      8px;
  --radius-xs:      6px;

  --shadow-sm:  0 1px 4px rgba(0,0,0,0.5);
  --shadow:     0 4px 16px rgba(0,0,0,0.6);
  --shadow-md:  0 8px 28px rgba(0,0,0,0.7);
  --glow:       0 0 24px rgba(0,217,255,0.2);
  --glow-sm:    0 0 12px rgba(0,217,255,0.15);

  --header-height: 60px;
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* ---- Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,13,35,0.92);
  border-bottom: 1px solid var(--card-border);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  max-width: 800px;
  margin: 0 auto;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon   { font-size: 22px; line-height: 1; }
.header-brand h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.header-brand p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Header buttons */
.btn-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(0,217,255,0.08);
  color: var(--primary);
  border: 1px solid rgba(0,217,255,0.25);
  padding: 0 14px;
  min-height: 34px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  letter-spacing: 0.2px;
}
.btn-header:hover {
  background: rgba(0,217,255,0.15);
  border-color: rgba(0,217,255,0.5);
  box-shadow: var(--glow-sm);
}
.btn-header:active { transform: scale(0.97); }

.btn-header-admin {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.1);
}
.btn-header-admin:hover {
  background: rgba(0,217,255,0.1);
  color: var(--primary);
  border-color: rgba(0,217,255,0.3);
  box-shadow: none;
}

.btn-header-logout {
  background: rgba(229,57,53,0.1);
  color: #ff6b6b;
  border-color: rgba(229,57,53,0.3);
}
.btn-header-logout:hover {
  background: rgba(229,57,53,0.2);
  border-color: rgba(229,57,53,0.5);
  box-shadow: none;
}

/* Admin banner */
.admin-banner {
  background: linear-gradient(135deg, rgba(0,217,255,0.08) 0%, rgba(0,153,204,0.05) 100%);
  border: 1px solid rgba(0,217,255,0.2);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 20px rgba(0,217,255,0.06);
}
.admin-banner-icon { font-size: 18px; flex-shrink: 0; }
.admin-banner-text { font-size: 14px; font-weight: 600; color: var(--primary); }
.admin-banner-text span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Main ---- */
.main-content { max-width: 800px; margin: 0 auto; padding: 16px; }

/* ---- Form Sections ---- */
.form-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 14px;
}
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .icon { font-size: 14px; }

/* ---- Form Grid ---- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 480px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

/* ---- Labels ---- */
label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
label .required { color: var(--primary); margin-left: 2px; }

/* ---- Inputs ---- */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,217,255,0.12), var(--glow-sm);
  background: #1a2040;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234d6075' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}
/* Fix date picker dark bg */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6) sepia(1) hue-rotate(170deg);
  cursor: pointer;
}
textarea { resize: vertical; min-height: 80px; }

/* ---- Cubagem ---- */
.cubagem-card {
  background: rgba(0,217,255,0.06);
  border: 1px solid rgba(0,217,255,0.25);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  grid-column: 1 / -1;
  box-shadow: var(--glow-sm);
}
.cubagem-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.cubagem-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-mono);
}

/* ---- Foto Upload ---- */
.foto-upload-area {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  background: rgba(255,255,255,0.02);
}
.foto-upload-area:hover,
.foto-upload-area.drag-over {
  border-color: var(--primary);
  background: rgba(0,217,255,0.04);
}
.foto-upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.foto-upload-icon  { font-size: 32px; margin-bottom: 8px; }
.foto-upload-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.foto-upload-hint  { font-size: 12px; color: var(--text-muted); }
.foto-upload-hint span { color: var(--primary); font-weight: 600; }

.foto-preview-container { margin-top: 14px; display: none; flex-direction: column; align-items: center; gap: 10px; }
.foto-preview-container.visible { display: flex; }
.foto-preview-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--card-border); }
.foto-preview-info { font-size: 12px; color: var(--text-secondary); }
.foto-remove-btn {
  background: var(--error-bg);
  color: #ff6b6b;
  border: 1px solid rgba(229,57,53,0.3);
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Buttons ---- */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--primary);
  color: var(--text-on-primary);
  border: none;
  border-radius: var(--radius);
  padding: 15px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(0,217,255,0.3);
  letter-spacing: 0.3px;
}
.btn-primary:hover  { background: var(--primary-dark); box-shadow: 0 6px 20px rgba(0,217,255,0.4); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--text-muted); box-shadow: none; cursor: not-allowed; opacity: 0.6; }

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  text-align: center;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: rgba(0,217,255,0.05); }

.form-actions { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(10,14,39,0.4);
  border-top-color: var(--text-on-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn-primary.loading .spinner { display: block; }
.btn-primary.loading .btn-label { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s;
  white-space: nowrap;
  max-width: calc(100vw - 48px);
  text-align: center;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: rgba(38,167,69,0.9);  border-color: rgba(38,167,69,0.5);  color: #fff; }
.toast.error   { background: rgba(229,57,53,0.9);   border-color: rgba(229,57,53,0.5);  color: #fff; }
.toast.warning { background: rgba(255,179,0,0.9);   border-color: rgba(255,179,0,0.5);  color: #000; }

/* ---- Modals (bottom sheet) ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.visible {
  opacity: 1; pointer-events: all;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.modal-sheet {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34,1.2,0.64,1);
}
.modal-overlay.visible .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 18px;
}
.modal-icon    { font-size: 44px; text-align: center; margin-bottom: 8px; }
.modal-title   { font-size: 18px; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 4px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 18px; }
.modal-info-grid {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 18px;
}
.modal-info-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-info-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.modal-info-value { font-size: 13px; font-weight: 700; color: var(--text); text-align: right; }
.modal-id-value {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  color: var(--primary);
  background: var(--info-bg);
  padding: 3px 10px; border-radius: var(--radius-xs);
}
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---- Listagem ---- */
.page-title-bar {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.page-title { font-size: 16px; font-weight: 700; color: var(--text); }
.count-badge {
  background: rgba(0,217,255,0.1);
  color: var(--primary);
  border: 1px solid rgba(0,217,255,0.25);
  border-radius: 50px; padding: 3px 12px;
  font-size: 12px; font-weight: 700;
  font-family: var(--font-mono);
}

/* Search bar */
.search-bar {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.search-input-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; color: var(--text-muted); font-size: 15px; pointer-events: none; }
.search-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px 10px 36px;
  font-size: 15px;
  color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--border-focus); }
.search-input::placeholder { color: var(--text-muted); }

.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip.active {
  background: rgba(0,217,255,0.12);
  border-color: rgba(0,217,255,0.4);
  color: var(--primary);
}
.chip:hover:not(.active) { border-color: var(--text-muted); color: var(--text); }

/* Cards */
.registros-list { display: flex; flex-direction: column; gap: 10px; }
.card-registro {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card-registro:hover { border-color: rgba(0,217,255,0.2); box-shadow: var(--glow-sm); }

.card-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--card-border);
  gap: 8px; flex-wrap: wrap;
}
.card-id {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  color: var(--primary);
  background: rgba(0,217,255,0.08);
  border: 1px solid rgba(0,217,255,0.2);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.5px;
}
.card-date { font-size: 11px; color: var(--text-muted); }

.card-body { padding: 12px 14px; }
.card-descricao {
  font-size: 15px; font-weight: 700;
  color: var(--text);
  margin-bottom: 10px; line-height: 1.3;
}
.card-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
}
.card-field-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
}
.card-field-value { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-top: 1px; }

.card-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--card-border);
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Botões de ação principais dos cards */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  font-family: var(--font);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-action:active { transform: scale(0.96); }

.btn-action-photo {
  background: rgba(34,197,94,0.1);
  color: #4ade80;
  border-color: rgba(34,197,94,0.3);
}
.btn-action-photo:hover { background: rgba(34,197,94,0.18); }

.btn-action-status {
  background: rgba(0,217,255,0.1);
  color: var(--primary);
  border-color: rgba(0,217,255,0.35);
}
.btn-action-status:hover { background: rgba(0,217,255,0.18); box-shadow: var(--glow-sm); }

.btn-action-edit {
  background: rgba(99,102,241,0.1);
  color: #a5b4fc;
  border-color: rgba(99,102,241,0.35);
}
.btn-action-edit:hover { background: rgba(99,102,241,0.18); }

.btn-action-delete {
  background: rgba(239,68,68,0.1);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.35);
}
.btn-action-delete:hover { background: rgba(239,68,68,0.18); }

/* Botão foto legado (mantido para compatibilidade) */
.btn-foto {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  border: 1px solid;
  text-decoration: none;
}
.btn-foto:active { transform: scale(0.96); }

/* Badge de status — sólido, alto contraste */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
  line-height: 1;
}

/* Badge legado (mantido) */
.badge-status-custom {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  user-select: none;
}

/* Estado vazio */
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-muted); }
.empty-icon  { font-size: 44px; margin-bottom: 12px; }
.empty-text  { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-hint  { font-size: 13px; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--card-border) 25%, #1a2040 50%, var(--card-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-xs); height: 16px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ---- Workflow de status ---- */
.workflow-steps {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 12px;
  max-height: 55vh; overflow-y: auto;
}
.workflow-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, transform 0.1s;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}
.workflow-btn:hover:not(:disabled) {
  opacity: 0.88;
  transform: translateX(3px);
}
.workflow-btn:active:not(:disabled) { transform: scale(0.98); }
.workflow-btn-active {
  cursor: default;
  opacity: 1;
  position: relative;
}
.workflow-btn-active::after {
  content: "✓ atual";
  font-size: 10px;
  font-weight: 600;
  opacity: 0.7;
  letter-spacing: 0.3px;
}
.workflow-btn:disabled { opacity: 1; cursor: default; }

/* ---- Login Page ---- */
.login-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px;
}
.login-container { width: 100%; max-width: 380px; }
.login-header    { text-align: center; margin-bottom: 32px; }
.login-logo-wrap {
  width: 72px; height: 72px;
  background: rgba(0,217,255,0.08);
  border: 1px solid rgba(0,217,255,0.25);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
  box-shadow: var(--glow);
}
.login-title {
  font-size: 26px; font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px; margin-bottom: 6px;
}
.login-subtitle { font-size: 13px; color: var(--text-muted); }

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-md), 0 0 40px rgba(0,217,255,0.05);
}
.login-error {
  background: var(--error-bg);
  color: #ff6b6b;
  border: 1px solid rgba(229,57,53,0.3);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.login-label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.login-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px; color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none; appearance: none;
}
.login-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,217,255,0.12), var(--glow-sm);
  background: #1a2040;
}
.login-input::placeholder { color: var(--text-muted); }
.input-password { font-family: var(--font); letter-spacing: 3px; }
.input-password::placeholder { letter-spacing: 1px; }

.login-password-wrap { position: relative; display: flex; align-items: center; }
.login-password-wrap .login-input { flex: 1; }
.toggle-pwd {
  position: absolute; right: 12px;
  background: none; border: none; font-size: 16px;
  cursor: pointer; padding: 4px; line-height: 1;
  color: var(--text-muted);
}
.btn-login {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 50px;
  background: var(--primary);
  color: var(--text-on-primary);
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,217,255,0.3);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}
.btn-login:hover  { background: var(--primary-dark); box-shadow: 0 6px 22px rgba(0,217,255,0.4); }
.btn-login:active { transform: scale(0.98); }

.login-back {
  display: block; margin-top: 16px; text-align: center;
  font-size: 13px; color: var(--text-muted);
  transition: color 0.2s;
}
.login-back:hover { color: var(--primary); }
.login-hint {
  text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 20px;
}
.login-hint code {
  background: rgba(0,217,255,0.08);
  border: 1px solid rgba(0,217,255,0.2);
  padding: 1px 6px; border-radius: 4px;
  color: var(--primary); font-family: var(--font-mono);
}

/* ---- Log imutável ---- */
.log-trail {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0,217,255,0.04);
  border: 1px solid rgba(0,217,255,0.1);
  border-radius: var(--radius-sm);
}
.log-trail-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--primary); margin-bottom: 6px;
}
.log-entry {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.log-entry:last-child { border-bottom: none; }
.log-arrow { color: var(--primary); font-size: 10px; flex-shrink: 0; }
.log-status { font-weight: 700; color: var(--text); }
.log-meta   { font-size: 11px; color: var(--text-muted); margin-left: auto; white-space: nowrap; font-family: var(--font-mono); }

/* ---- Dashboard ---- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(2,1fr);
  gap: 10px; margin-bottom: 14px;
}
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(4,1fr); } }
.kpi-card {
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--card-border);
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-blue   { background: linear-gradient(145deg,rgba(0,217,255,0.08),rgba(0,217,255,0.02)); }
.kpi-blue::before   { background: var(--primary); }
.kpi-orange { background: linear-gradient(145deg,rgba(255,179,0,0.08),rgba(255,179,0,0.02)); }
.kpi-orange::before { background: var(--warning); }
.kpi-green  { background: linear-gradient(145deg,rgba(38,167,69,0.08),rgba(38,167,69,0.02)); }
.kpi-green::before  { background: var(--success); }
.kpi-purple { background: linear-gradient(145deg,rgba(139,92,246,0.08),rgba(139,92,246,0.02)); }
.kpi-purple::before { background: #8b5cf6; }

.kpi-icon   { font-size: 20px; }
.kpi-value  { font-size: 26px; font-weight: 800; color: var(--text); font-family: var(--font-mono); line-height: 1; }
.kpi-label  { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.dash-row {
  display: grid; grid-template-columns: 1fr;
  gap: 14px; margin-bottom: 14px;
}
@media (min-width: 768px) { .dash-row { grid-template-columns: 300px 1fr; } }
.dash-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 0;
}
.dash-card-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 14px; letter-spacing: 0.2px;
}

.status-legend-list { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-text { font-size: 12px; color: var(--text-secondary); flex: 1; }
.legend-count { font-size: 12px; font-weight: 700; color: var(--text); font-family: var(--font-mono); }

.frete-kpi-row {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 10px; margin-bottom: 14px;
}
.frete-kpi { background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.frete-kpi-value { font-size: 15px; font-weight: 800; color: var(--primary); font-family: var(--font-mono); }
.frete-kpi-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.transp-ranking { display: flex; flex-direction: column; gap: 6px; }
.transp-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.transp-rank  { font-size: 11px; font-weight: 800; color: var(--text-muted); width: 16px; font-family: var(--font-mono); }
.transp-nome  { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); }
.transp-envios{ font-size: 11px; color: var(--text-muted); }
.transp-total { font-size: 13px; font-weight: 700; color: var(--primary); font-family: var(--font-mono); }

.recente-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
}
.recente-row:last-child { border-bottom: none; }

/* ---- Logo no header ---- */
.brand-logo {
  height: 34px;
  width: auto;
  max-width: 90px;
  border-radius: 6px;
  object-fit: contain;
  display: block;
}

/* ---- Alertas de status ---- */
.alerta-box {
  background: linear-gradient(135deg, rgba(255,179,0,0.07) 0%, rgba(245,158,11,0.04) 100%);
  border: 1px solid rgba(255,179,0,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.alerta-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.alerta-icon  { font-size: 16px; }
.alerta-title { font-size: 12px; font-weight: 700; color: var(--warning); text-transform: uppercase; letter-spacing: 0.5px; }
.alerta-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.alerta-chip  {
  display: flex; align-items: center; gap: 6px;
  background: rgba(var(--chip-color), 0.08);
  border: 1px solid color-mix(in srgb, var(--chip-color) 40%, transparent);
  border-color: var(--chip-color);
  border-opacity: 0.3;
  padding: 5px 12px;
  border-radius: 50px;
  background: color-mix(in srgb, var(--chip-color) 12%, transparent);
}
.alerta-chip-count {
  font-size: 18px; font-weight: 800;
  color: var(--chip-color);
  font-family: var(--font-mono);
  line-height: 1;
}
.alerta-chip-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
}

/* ---- Leaflet popup dark ---- */
.mapa-popup .leaflet-popup-content-wrapper {
  background: rgba(15,20,48,0.97) !important;
  border: 1px solid rgba(0,217,255,0.3) !important;
  border-radius: 10px !important;
  box-shadow: 0 0 20px rgba(0,217,255,0.15) !important;
  color: #e8f0f8 !important;
}
.mapa-popup .leaflet-popup-tip {
  background: rgba(15,20,48,0.97) !important;
}
.mapa-popup .leaflet-popup-close-button {
  color: var(--text-muted) !important;
}
.leaflet-control-attribution {
  background: rgba(10,14,39,0.7) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--primary) !important; }

/* ---- Alerta chip clicável ---- */
.alerta-chip-btn {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.alerta-chip-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.alerta-chip-btn:active { transform: scale(0.97); }

.alerta-chip-arrow {
  font-size: 16px;
  font-weight: 700;
  color: var(--chip-color);
  margin-left: 4px;
  opacity: 0.7;
}

/* Linha de detalhe dentro do modal de alertas */
.alerta-detail-row {
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ---- Responsivo Desktop ---- */
@media (min-width: 640px) {
  .main-content  { padding: 20px; }
  .form-actions  { flex-direction: row; }
  .btn-primary   { flex: 1; }
  .btn-secondary { flex: 1; }
  .card-fields   { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── Dashboard: layout sidebar + filtros ─────────────────── */
.dash-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.dash-sidebar {
  width: 270px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-height) + 8px);
  max-height: calc(100vh - var(--header-height) - 32px);
  overflow-y: auto;
}
.dash-sidebar::-webkit-scrollbar { width: 4px; }
.dash-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.dash-main { flex: 1; min-width: 0; }
@media (max-width: 960px) {
  .dash-layout { flex-direction: column; }
  .dash-sidebar { width: 100%; position: static; max-height: none; }
}

.filter-bar-dash {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.filter-select-dash {
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  min-width: 152px;
  cursor: pointer;
  font-family: var(--font);
}
.filter-select-dash:focus { border-color: var(--primary); outline: none; }
.btn-filter-dash {
  background: rgba(0,217,255,0.12);
  border: 1px solid rgba(0,217,255,0.35);
  color: var(--primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.btn-filter-dash:hover { background: rgba(0,217,255,0.22); }
.btn-filter-clear {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-filter-clear:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.filter-active-label {
  font-size: 11px; color: var(--primary); font-weight: 700;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: rgba(0,217,255,0.08);
  border-radius: 50px;
  border: 1px solid rgba(0,217,255,0.2);
}

.recente-compact-row {
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.recente-compact-row:last-child { border-bottom: none; }
.recente-compact-top {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; margin-bottom: 3px;
}
.recente-compact-desc {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recente-compact-date { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.status-mini-badge {
  font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 50px; white-space: nowrap;
}
