/* ============================================================
   MKT Telecom — Sistema de Gestão de Ordens de Serviço
   Tema Escuro · Mobile-First · Responsivo
   ============================================================ */

/* ──────────────────────────────────────────────────────────
   VARIÁVEIS GLOBAIS
   ────────────────────────────────────────────────────────── */
:root {
  --bg: #090e1b;
  --surface: #0f1729;
  --card: #141e33;
  --card2: #1a2640;
  --border: #1e3356;
  --border2: #2a4a7f;
  --cyan: #00d4ff;
  --cyan2: #0ea5e9;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --text: #dde8f5;
  --muted: #5a7a9a;
  --mono: 'Share Tech Mono', 'Courier New', monospace;
  --ui: 'Exo 2', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bnav-h: 62px;
  --topbar-h: 52px;
  --sidebar-w: 220px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ──────────────────────────────────────────────────────────
   RESET E BASE
   ────────────────────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ──────────────────────────────────────────────────────────
   LAYOUT PRINCIPAL
   ────────────────────────────────────────────────────────── */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ──────────────────────────────────────────────────────────
   SIDEBAR (DESKTOP)
   ────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--cyan);
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.logo-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}

.nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 2px;
  padding: 14px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: var(--transition);
  border-left: 2px solid transparent;
  user-select: none;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(0, 212, 255, 0.04);
}

.nav-item.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: rgba(0, 212, 255, 0.07);
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
}

.sidebar-bottom {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

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

.user-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
}

.user-role {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}

.drawer-overlay {
  display: none;
}

/* ──────────────────────────────────────────────────────────
   TOPBAR
   ────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.page-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.btn-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 10px;
  font-size: 18px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────
   BOTÕES
   ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--cyan);
  color: #050e1a;
}

.btn-primary:hover,
.btn-primary:active {
  background: #22dcff;
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.35);
  color: #050e1a;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--border2);
  color: var(--text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-xs {
  padding: 3px 7px;
  font-size: 10px;
}

/* ──────────────────────────────────────────────────────────
   CONTEÚDO
   ────────────────────────────────────────────────────────── */
.content {
  padding: 20px 22px;
  flex: 1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

/* ──────────────────────────────────────────────────────────
   CARDS DE ESTATÍSTICAS
   ────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border2);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), transparent);
  pointer-events: none;
}

.stat-accent {
  width: 3px;
  height: 36px;
  border-radius: 2px;
  position: absolute;
  top: 16px;
  right: 14px;
}

.stat-label {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 1.5px;
  margin-bottom: 7px;
}

.stat-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}

.stat-sub b {
  color: var(--green);
  font-weight: 600;
}

/* ──────────────────────────────────────────────────────────
   TABELAS
   ────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 460px;
}

thead tr {
  background: var(--card2);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 1.5px;
  font-weight: 400;
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid rgba(30, 51, 86, 0.5);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.clickable:hover {
  background: rgba(0, 212, 255, 0.03);
  cursor: pointer;
}

.mono {
  font-family: var(--mono);
  font-size: 11px;
}

.td-nome b {
  display: block;
  font-size: 13px;
}

.td-nome small {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 28px;
}

/* ──────────────────────────────────────────────────────────
   LISTA EM CARDS (MOBILE)
   ────────────────────────────────────────────────────────── */
.card-list {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.cli-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border 0.15s;
}

.cli-card:active {
  border-color: var(--border2);
}

.cli-card-body {
  padding: 14px 16px;
}

.cli-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.cli-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.cli-card-doc {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 2px;
}

.cli-card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cli-card-meta span {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.cli-card-actions {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
}

.cli-card-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 4px;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--muted);
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.cli-card-btn:last-child {
  border-right: none;
}

.cli-card-btn:active {
  background: rgba(0, 212, 255, 0.08);
  color: var(--cyan);
}

.cli-card-btn .ico {
  font-size: 14px;
}

/* OS card list */
.os-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border 0.15s;
  margin-bottom: 8px;
}

.os-card:active {
  border-color: var(--border2);
}

.os-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.os-card-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
}

.os-card-tipo {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.os-card-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* ──────────────────────────────────────────────────────────
   BADGES
   ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.badge-green {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.badge-cyan {
  background: rgba(0, 212, 255, 0.12);
  color: var(--cyan);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber);
}

.badge-red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.12);
  color: var(--purple);
}

.badge-muted {
  background: rgba(90, 122, 154, 0.12);
  color: var(--muted);
}

/* ──────────────────────────────────────────────────────────
   FILTROS E BUSCA
   ────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.search-wrap input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px 8px 34px;
  font-family: var(--ui);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border 0.15s;
}

.search-wrap input:focus {
  border-color: var(--border2);
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--muted);
}

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 12px;
  outline: none;
  -webkit-appearance: none;
}

.filter-select option {
  background: var(--card);
}

/* ──────────────────────────────────────────────────────────
   ABAS
   ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--card);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.tab.active {
  background: var(--card2);
  color: var(--cyan);
}

/* ══════════════════════════════════════════════════════════
   MODAL GLOBAL (DEFINIÇÃO ÚNICA - SEM CONFLITOS)
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.82);
  -webkit-tap-highlight-color: transparent;
}

.modal-overlay.open {
  display: flex;
}

.modal-overlay .modal {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  position: relative;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-overlay .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.modal-overlay .modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.modal-overlay .modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.modal-overlay .modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.modal-overlay .modal-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.modal-overlay .modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ──────────────────────────────────────────────────────────
   FORMULÁRIOS
   ────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid.cols3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-grid.cols4 {
  grid-template-columns: repeat(4, 1fr);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 1.2px;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 11px 12px;
  font-family: var(--ui);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border 0.15s;
  width: 100%;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--cyan2);
}

.form-input:read-only {
  color: var(--muted);
  background: var(--surface);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%235a7a9a' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.form-select option {
  background: var(--card);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  font-size: 14px;
}

.form-section-title {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--cyan);
  letter-spacing: 2px;
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.15);
}

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.form-error {
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
}

.form-hint {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  font-family: var(--mono);
}

/* ──────────────────────────────────────────────────────────
   DETALHES (FICHA RÁPIDA)
   ────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  transition: var(--transition);
}

.detail-item:hover {
  border-color: var(--border2);
  background: rgba(0, 212, 255, 0.02);
}

.detail-label {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 1.5px;
  margin-bottom: 5px;
}

.detail-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.detail-val.mono {
  font-family: var(--mono);
  font-size: 12px;
}

#conteudo-ficha .detail-item {
  background: rgba(20, 30, 51, 0.5);
}

#conteudo-ficha .detail-item:hover {
  background: rgba(0, 212, 255, 0.03);
  border-color: var(--border2);
}

#conteudo-ficha .chip {
  display: inline-block;
  background: rgba(0, 212, 255, 0.1);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--cyan);
  margin-left: 8px;
}

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

#conteudo-ficha > div {
  animation: fadeIn 0.3s ease-out;
}

/* ──────────────────────────────────────────────────────────
   LINHA DE OS
   ────────────────────────────────────────────────────────── */
.os-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border 0.15s;
}

.os-row:hover {
  border-color: var(--border2);
}

.os-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.os-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
}

.os-tipo {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 3px;
}

.os-desc {
  font-size: 12px;
  color: var(--muted);
}

.os-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 8px;
}

/* ──────────────────────────────────────────────────────────
   GEOLOCALIZAÇÃO
   ────────────────────────────────────────────────────────── */
.geo-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--mono);
  margin-top: 10px;
}

.geo-status.loading {
  background: rgba(245, 158, 11, 0.1);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.geo-status.ok {
  background: rgba(16, 185, 129, 0.1);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.geo-status.err {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.mini-map {
  height: 180px;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 12px;
}

#main-map {
  height: calc(100vh - 180px);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.leaflet-container {
  background: #0a1220 !important;
}

.map-legend {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-square {
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────
   ALERTAS E NOTIFICAÇÕES
   ────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--green);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--red);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--amber);
}

.alert-info {
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: var(--cyan);
}

.notif {
  position: fixed;
  bottom: 80px;
  right: 16px;
  background: var(--card2);
  border: 1px solid var(--green);
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 13px;
  color: var(--green);
  z-index: 3000;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.3s;
  min-width: 220px;
  max-width: 90vw;
}

.notif.show {
  opacity: 1;
  transform: translateY(0);
}

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

/* ──────────────────────────────────────────────────────────
   UTILITÁRIOS
   ────────────────────────────────────────────────────────── */
.pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseA 1.4s ease-in-out infinite;
}

@keyframes pulseA {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

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

.text-cyan {
  color: var(--cyan);
}

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

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

.text-amber {
  color: var(--amber);
}

.text-purple {
  color: var(--purple);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.chip {
  display: inline-block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
}

/* ──────────────────────────────────────────────────────────
   TELA DE LOGIN
   ────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 36px 32px;
  width: 400px;
  max-width: 100%;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 3px;
}

.login-logo .logo-name {
  font-size: 36px;
  font-weight: 800;
  margin: 4px 0;
}

.login-logo .logo-sub {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

/* ──────────────────────────────────────────────────────────
   BOTTOM NAVIGATION (MOBILE)
   ────────────────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 300;
  height: var(--bnav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: stretch;
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--muted);
  text-decoration: none;
  font-size: 9px;
  font-family: var(--mono);
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 4px 2px;
  border-top: 2px solid transparent;
  transition: color 0.15s;
  min-width: 0;
  overflow: hidden;
}

.bn-item.active {
  color: var(--cyan);
  border-top-color: var(--cyan);
}

.bn-item:active {
  background: rgba(0, 212, 255, 0.06);
}

.bn-icon {
  font-size: 20px;
  line-height: 1;
}

.bn-label {
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ──────────────────────────────────────────────────────────
   RESPONSIVIDADE
   ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid.cols4 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 767px) {
  .shell {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    min-width: unset;
    transform: translateX(-100%);
    box-shadow: 6px 0 40px rgba(0, 0, 0, 0.7);
    z-index: 500;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    z-index: 499;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  
  .drawer-overlay.open {
    opacity: 1;
    pointer-events: all;
  }
  
  .btn-hamburger {
    display: inline-flex;
  }
  
  .main {
    width: 100%;
  }
  
  .topbar {
    padding: 10px 14px;
  }
  
  .page-title {
    font-size: 14px;
  }
  
  .page-sub {
    display: none;
  }
  
  .topbar-actions .btn-ghost {
    display: none;
  }
  
  .topbar-actions .btn-primary {
    padding: 8px 12px;
    font-size: 11px;
  }
  
  .content {
    padding: 14px 14px calc(var(--bnav-h) + 14px);
  }
  
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  
  .stat-val {
    font-size: 24px;
  }
  
  .table-wrap {
    display: none;
  }
  
  .card-list {
    display: flex;
  }
  
  .form-grid,
  .form-grid.cols3,
  .form-grid.cols4 {
    grid-template-columns: 1fr;
  }
  
  .form-group.full {
    grid-column: 1;
  }
  
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  
  .detail-grid {
    grid-template-columns: 1fr;
  }
  
  /* Modal bottom-sheet mobile */
  .modal-overlay {
    align-items: flex-end;
  }
  
  .modal-overlay .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
  }
  
  .bottom-nav {
    display: block;
  }
  
  .notif {
    bottom: calc(var(--bnav-h) + 12px);
    right: 12px;
    left: 12px;
    min-width: unset;
  }
  
  #main-map {
    height: calc(100vh - 200px);
  }
  
  .search-wrap {
    max-width: 100%;
  }
  
  .filter-bar .filter-select {
    flex: 1;
    min-width: 0;
  }
  
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
  
  .section-head .btn {
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .stat-val {
    font-size: 22px;
  }
}

/* ──────────────────────────────────────────────────────────
   IMPRESSÃO
   ────────────────────────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar-actions,
  .bottom-nav,
  .btn,
  .filter-bar,
  .modal-close,
  .cli-card-actions,
  .topbar .btn-hamburger {
    display: none !important;
  }
  
  .main {
    margin: 0;
    padding: 0;
  }
  
  .content {
    padding: 0;
  }
  
  .stat-card,
  .detail-item,
  .form-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  table {
    break-inside: avoid;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .badge {
    border: 1px solid #ccc;
    background: none !important;
  }
}