/* ============================================================
   bygga.css - Componentes da plataforma bygga
   ============================================================ */

/* ---- APP SHELL ---- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bygga-navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 6px 16px;
  flex-shrink: 0;
}
.nav-section {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 16px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: var(--bygga-teal);
}
.nav-item i { font-size: 16px; width: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--bygga-red);
  color: #fff;
  font-size: 10px;
  border-radius: 2px;
  padding: 1px 6px;
  font-weight: 500;
}
.nav-item-only-admin,
.nav-item-only-gerente { display: none; }

.sidebar-user {
  padding: 12px 16px;
  border-top: 0.5px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bygga-teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}
.user-name  { font-size: 12px; color: rgba(255,255,255,0.8); font-weight: 500; }
.user-role  { font-size: 10px; color: rgba(255,255,255,0.35); }
.sidebar-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  font-size: 16px;
  margin-left: auto;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.sidebar-logout:hover { color: rgba(255,255,255,0.7); }

/* ---- MAIN AREA ---- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-background-tertiary);
}

.topbar {
  background: var(--color-background-primary);
  border-bottom: 0.5px solid var(--color-border-tertiary);
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.notif-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 20px;
  padding: 4px;
  display: flex;
}
.notif-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 8px; height: 8px;
  background: var(--bygga-red);
  border-radius: 50%;
  border: 2px solid var(--color-background-primary);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ---- BOTÕES ---- */
.btn-primary {
  background: var(--bygga-red);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--bygga-red-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary.btn-full { width: 100%; justify-content: center; }

.btn-outline {
  background: transparent;
  color: var(--color-text-secondary);
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--color-border-primary); color: var(--color-text-primary); }

.btn-link {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  margin-top: 8px;
  display: block;
  text-align: center;
}
.btn-link:hover { color: var(--color-text-primary); }

/* ---- CARDS ---- */
.card {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-title i { color: var(--bygga-red); }

/* ---- STATS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 16px;
}
.stat-label  { font-size: 12px; color: var(--color-text-secondary); margin-bottom: 6px; }
.stat-value  { font-size: 24px; font-weight: 500; }
.stat-value.red   { color: var(--bygga-red); }
.stat-value.teal  { color: var(--bygga-teal); }
.stat-value.amber { color: #BA7517; }

/* ---- PEDIDOS ---- */
.section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pedidos-list { display: flex; flex-direction: column; gap: 8px; }
.pedido-card {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}
.pedido-card:hover { border-color: var(--color-border-secondary); }
.pedido-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-pendente  { background: #BA7517; }
.status-analise   { background: var(--bygga-bordeaux); }
.status-concluido { background: #1D9E75; }
.status-angariado { background: #2563EB; }
.status-vendido   { background: var(--bygga-red); }
.status-cancelado { background: var(--color-text-tertiary); }
.pedido-info { flex: 1; min-width: 0; }
.pedido-codigo { font-size: 10px; font-weight: 600; color: var(--color-text-tertiary); letter-spacing: 0.05em; margin-bottom: 1px; }
.pedido-titulo { font-size: 13px; font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pedido-meta   { font-size: 11px; color: var(--color-text-secondary); }

/* ---- BADGES ---- */
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--border-radius-md);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-pendente  { background: #FAEEDA; color: #854F0B; }
.badge-analise   { background: var(--bygga-bordeaux-light); color: var(--bygga-bordeaux-dark); }
.badge-concluido { background: var(--bygga-teal-light); color: #8B0012; }
.badge-angariado { background: #DBEAFE; color: #1E40AF; }
.badge-vendido   { background: var(--bygga-red-light); color: var(--bygga-red-dark); }
.badge-cancelado { background: var(--color-background-secondary); color: var(--color-text-secondary); }
.badge-admin     { background: var(--bygga-teal-light); color: #8B0012; font-size: 10px; padding: 2px 7px; }

/* ---- FILTROS ---- */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filter-bar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 8px;
}
.filter-bar-row:last-child { margin-bottom: 0; }
.filter-label { font-size: 12px; color: var(--color-text-secondary); flex-shrink: 0; }
.filter-chip {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 2px;
  border: 0.5px solid var(--color-border-secondary);
  cursor: pointer;
  color: var(--color-text-secondary);
  background: var(--color-background-primary);
  transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--bygga-red); color: var(--bygga-red); }
.filter-chip.active { background: var(--bygga-red); color: #fff; border-color: var(--bygga-red); }
.filter-select {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 2px;
  border: 0.5px solid var(--color-border-secondary);
  color: var(--color-text-secondary);
  background: var(--color-background-primary);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236E6E73'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.filter-select:focus { outline: none; border-color: var(--bygga-red); }
.filter-search {
  margin-left: auto;
  width: 200px;
  padding: 5px 10px;
  border: 0.5px solid var(--color-border-secondary);
  border-radius: 2px;
  font-size: 12px;
  font-family: inherit;
  color: var(--color-text-primary);
  background: var(--color-background-primary);
}
.filter-search:focus { outline: none; border-color: var(--bygga-red); }

/* Prioridade badge em pedido-card */
.prio-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.prio-urgente { background: var(--bygga-red); }
.prio-alta    { background: #BA7517; }
.prio-normal  { background: var(--color-border-primary); }
.prio-baixa   { background: var(--color-border-tertiary); }

/* ---- FORMULÁRIOS ---- */
.form-group { margin-bottom: 14px; }
.form-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-label-link { font-size: 11px; color: var(--bygga-red); text-decoration: none; }
.form-label-link:hover { text-decoration: underline; }

.form-input-wrapper { position: relative; }
.form-input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  font-size: 16px;
  pointer-events: none;
}
.form-input-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: 2px;
  display: flex;
}

.form-input {
  width: 100%;
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.form-input.form-input-icon-left { padding-left: 34px; }
.form-input:focus { border-color: var(--bygga-teal); }
.form-input::placeholder { color: var(--color-text-tertiary); }

.form-textarea {
  width: 100%;
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  resize: vertical;
  min-height: 70px;
  outline: none;
  transition: border-color 0.15s;
}
.form-textarea:focus { border-color: var(--bygga-teal); }

.form-select {
  width: 100%;
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ---- DOCUMENTOS ---- */
.upload-zone {
  border: 1.5px dashed var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  padding: 20px;
  text-align: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s, color 0.15s;
}
.upload-zone:hover { border-color: var(--bygga-red); color: var(--bygga-red); }
.upload-zone i { font-size: 24px; display: block; margin-bottom: 6px; }

.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--color-background-secondary);
  border-radius: var(--border-radius-md);
  margin-bottom: 6px;
  font-size: 12px;
}
.doc-item i { color: var(--bygga-red); font-size: 16px; }
.doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-size { color: var(--color-text-secondary); flex-shrink: 0; }

/* ---- MAPA PLACEHOLDER ---- */
.map-placeholder {
  background: #e8eedb;
  border-radius: var(--border-radius-md);
  border: 0.5px solid var(--color-border-tertiary);
  height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #5F5E5A;
  position: relative;
  overflow: hidden;
}
.map-placeholder-full {
  background: #e8eedb;
  border-radius: var(--border-radius-lg);
  height: calc(100vh - var(--topbar-h) - 40px);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5F5E5A;
  position: relative;
  overflow: hidden;
  flex-direction: column;
  gap: 8px;
}
.map-grid-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.15;
  background-image:
    linear-gradient(#5F5E5A 1px, transparent 1px),
    linear-gradient(90deg, #5F5E5A 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
.map-search-bar {
  position: absolute;
  top: 12px; left: 12px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  padding: 6px 10px;
  font-size: 12px;
  width: 200px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-secondary);
  z-index: 2;
}
.map-toolbar {
  position: absolute;
  top: 12px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.map-toolbar.horizontal { flex-direction: row; }
.map-tool-btn {
  width: 30px; height: 30px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  transition: border-color 0.15s;
}
.map-tool-btn:hover { border-color: var(--bygga-red); color: var(--bygga-red); }
.map-pin {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  z-index: 2;
}
.map-pin-label {
  position: absolute;
  font-size: 10px;
  background: rgba(255,255,255,0.92);
  padding: 2px 6px;
  border-radius: 2px;
  white-space: nowrap;
  color: var(--bygga-navy);
  font-weight: 500;
  z-index: 2;
  pointer-events: none;
}
.polygon-outline {
  position: absolute;
  border: 2px dashed var(--bygga-red);
  background: rgba(192,57,43,0.08);
  border-radius: 2px;
  pointer-events: none;
}
.legend {
  position: absolute;
  bottom: 12px; right: 12px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-md);
  padding: 8px 10px;
  font-size: 11px;
  z-index: 2;
}
.legend-item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.legend-item:last-child { margin-bottom: 0; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---- MAPA POPUP ---- */
.mapa-popup {
  position: absolute;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-lg);
  padding: 12px 14px;
  width: 210px;
  z-index: 10;
  box-shadow: var(--shadow-md);
}
.popup-title { font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.popup-meta  { font-size: 11px; color: var(--color-text-secondary); margin-bottom: 8px; }
.popup-summary { font-size: 11px; line-height: 1.5; margin-bottom: 10px; }
.popup-close {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none;
  color: var(--color-text-secondary); font-size: 14px;
  display: flex; cursor: pointer;
}
.popup-actions { display: flex; gap: 6px; }
.popup-btn {
  flex: 1;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  text-align: center;
  border: none;
}
.popup-btn-primary { background: var(--bygga-red); color: #fff; }
.popup-btn-outline { background: none; border: 0.5px solid var(--color-border-secondary); color: var(--color-text-secondary); }

/* ---- ESTUDO / DETALHE ---- */
.detalhe-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.detalhe-main   { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detalhe-side   { display: flex; flex-direction: column; gap: 12px; }

/* Mini-mapa read-only */
.det-map {
  height: 220px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border-tertiary);
  overflow: hidden;
  margin-bottom: 14px;
  position: relative;
  z-index: 0;
}
.det-map-empty {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-secondary);
  border: 0.5px dashed var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  margin-bottom: 14px;
}

/* Detalhe - info grid */
.det-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.det-info-item-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-bottom: 3px;
}
.det-info-item-value {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detalhe - linha info lateral */
.det-side-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  padding-bottom: 8px;
}
.det-side-row:last-child { border-bottom: none; padding-bottom: 0; }
.det-side-row-label { color: var(--color-text-secondary); }
.det-side-row-value { font-weight: 500; text-align: right; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Notas - timeline */
.nota-timeline { display: flex; flex-direction: column; gap: 0; }
.nota-item {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}
.nota-item:last-child { padding-bottom: 0; }
.nota-item::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: var(--color-border-tertiary);
}
.nota-item:last-child::before { display: none; }
.nota-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bygga-navy);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}
.nota-avatar.sistema {
  background: var(--color-background-secondary);
  color: var(--color-text-secondary);
  font-size: 13px;
}
.nota-avatar.estado {
  background: var(--bygga-bordeaux-light);
  color: var(--bygga-bordeaux-dark);
  font-size: 13px;
}
.nota-body { flex: 1; min-width: 0; }
.nota-header {
  font-size: 12px;
  margin-bottom: 3px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.nota-autor { font-weight: 500; }
.nota-data  { color: var(--color-text-secondary); font-size: 11px; }
.nota-conteudo {
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-primary);
}
.nota-conteudo.sistema { color: var(--color-text-secondary); font-style: italic; }
.nota-conteudo.estado  { color: var(--bygga-bordeaux-dark); font-weight: 500; }

/* Documentos - item com acesso */
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  font-size: 13px;
}
.doc-item:last-child { border-bottom: none; }
.doc-item i { font-size: 18px; color: var(--bygga-red); flex-shrink: 0; }
.doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-size { font-size: 11px; color: var(--color-text-secondary); flex-shrink: 0; }
.doc-dl-btn {
  color: var(--bygga-teal);
  font-size: 18px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.doc-dl-btn:hover { color: #8B0012; }

/* Relatório - locked state melhorado */
.relatorio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
  text-decoration: none;
  color: inherit;
}
.relatorio-item:hover { border-color: var(--bygga-red); }
.relatorio-item.locked {
  cursor: not-allowed;
  background: var(--color-background-secondary);
}
.relatorio-item.locked:hover { border-color: var(--color-border-tertiary); }
.relatorio-item.locked .relatorio-icon { color: var(--color-text-tertiary); }
.relatorio-icon { font-size: 20px; color: var(--bygga-red); flex-shrink: 0; }
.relatorio-info { flex: 1; }
.relatorio-title { font-size: 12px; font-weight: 500; }
.relatorio-sub   { font-size: 11px; color: var(--color-text-secondary); }
.relatorio-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 2px;
  background: var(--color-background-tertiary);
  color: var(--color-text-secondary);
  border: 0.5px solid var(--color-border-secondary);
  margin-top: 3px;
}

.estudo-card {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}
.estudo-header {
  background: var(--bygga-navy);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.estudo-header-title { color: #fff; font-size: 13px; font-weight: 500; }
.estudo-header-sub   { color: rgba(255,255,255,0.5); font-size: 11px; }
.estudo-body { padding: 16px; }

.relatorio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.relatorio-item:hover { border-color: var(--bygga-red); }
.relatorio-item.locked { opacity: 0.5; cursor: default; }
.relatorio-item.locked:hover { border-color: var(--color-border-tertiary); }
.relatorio-icon { font-size: 20px; color: var(--bygga-red); }
.relatorio-info { flex: 1; }
.relatorio-title { font-size: 12px; font-weight: 500; }
.relatorio-sub   { font-size: 11px; color: var(--color-text-secondary); }

/* ---- ADMIN UPLOAD ---- */
.admin-upload {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 16px;
}
.admin-upload-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-upload-title i { color: var(--bygga-teal); }

/* ---- STEP INDICATOR (admin-upload) ---- */
.upload-steps {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  padding: 0 4px;
}
.upload-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-border-secondary);
  background: var(--color-background-primary);
  color: var(--color-text-tertiary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.step-label {
  font-size: 11px;
  color: var(--color-text-tertiary);
  font-weight: 400;
  white-space: nowrap;
  transition: color 0.2s;
}
.upload-step.active .step-dot {
  border-color: var(--bygga-red);
  background: var(--bygga-red-light);
  color: var(--bygga-red-dark);
}
.upload-step.active .step-label {
  color: var(--bygga-red-dark);
  font-weight: 500;
}
.upload-step.done .step-dot {
  border-color: var(--bygga-teal);
  background: var(--bygga-teal);
  color: #fff;
  font-size: 14px;
}
.upload-step.done .step-label {
  color: var(--bygga-teal);
  font-weight: 500;
}
.step-line {
  flex: 1;
  height: 2px;
  background: var(--color-border-tertiary);
  margin: 0 6px;
  margin-bottom: 22px;
  border-radius: 1px;
  transition: background 0.2s;
}
.step-line.done { background: var(--bygga-teal); }

/* ---- PROGRESS BAR UPLOAD ---- */
.upload-progress-wrap {
  margin-bottom: 14px;
}
.upload-progress-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.upload-progress-bar-track {
  height: 6px;
  background: var(--color-border-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.upload-progress-bar-fill {
  height: 100%;
  background: var(--bygga-teal);
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
}

/* ---- BANNER pedido selecionado ---- */
.pedido-banner {
  background: var(--bygga-teal-light);
  border: 0.5px solid var(--bygga-teal);
  border-radius: var(--border-radius-lg);
  padding: 14px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.pedido-banner-icon { color: var(--bygga-teal); font-size: 20px; flex-shrink: 0; }
.pedido-banner-body { flex: 1; min-width: 0; }
.pedido-banner-titulo { font-size: 13px; font-weight: 500; color: #8B0012; }
.pedido-banner-meta   { font-size: 11px; color: #CD001A; margin-top: 2px; }

/* ---- ZONA PDF com ficheiro selecionado ---- */
.pdf-zone-selected {
  border: 0.5px solid var(--bygga-teal);
  background: var(--bygga-teal-light);
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pdf-zone-selected i { color: var(--bygga-teal); font-size: 20px; }
.pdf-zone-selected .doc-name { flex: 1; font-size: 13px; font-weight: 500; color: #8B0012; }
.pdf-zone-selected .doc-size { font-size: 11px; color: #CD001A; }

/* ---- DASHBOARD - card de ação rápida ---- */
.action-card {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.action-card:hover {
  border-color: var(--color-border-secondary);
  box-shadow: var(--shadow-sm);
}
.action-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--border-radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.action-card-icon.red   { background: var(--bygga-red-light);   color: var(--bygga-red-dark); }
.action-card-icon.teal  { background: var(--bygga-teal-light);   color: #8B0012; }
.action-card-icon.amber { background: #FAEEDA; color: #854F0B; }
.action-card-body { flex: 1; }
.action-card-title { font-size: 13px; font-weight: 500; }
.action-card-sub   { font-size: 11px; color: var(--color-text-secondary); margin-top: 1px; }
.action-card-count {
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}
.action-card-count.amber { color: #854F0B; }
.action-card-count.teal  { color: #8B0012; }
.action-card-count.red   { color: var(--bygga-red-dark); }

/* ---- VISTAS (SPA) ---- */
.vista { display: none; }
.vista.active { display: block; }

/* ---- TWO COL ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- LOGIN PAGE ---- */
body.login-page {
  background: var(--color-background-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-shell {
  display: flex;
  width: 100%;
  max-width: 900px;
  min-height: 560px;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.login-brand {
  width: 380px;
  flex-shrink: 0;
  background: #ffffff !important;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand-inner { display: flex; flex-direction: column; gap: 24px; }
.login-logo-wrap {
  display: inline-block;
  margin-bottom: 4px;
}
.login-logo-img {
  height: 44px;
  display: block;
  object-fit: contain;
}
.login-brand-powered {
  font-size: 12px;
  color: var(--bygga-red);
  margin-top: 6px;
  line-height: 1.5;
}
.login-brand-powered span { color: var(--bygga-red); font-weight: 600; }
.login-brand-tagline {
  font-size: 13px;
  color: var(--bygga-red);
  line-height: 1.6;
  font-style: italic;
}
.login-brand-features { display: flex; flex-direction: column; gap: 10px; }
.login-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--bygga-red);
}
.login-feature i { color: var(--bygga-red); font-size: 16px; flex-shrink: 0; }
.login-brand-footer {
  font-size: 12px;
  font-weight: 500;
  color: var(--bygga-red);
}

.login-form-panel {
  flex: 1;
  background: var(--color-background-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}
.login-form-inner { width: 100%; max-width: 320px; }
.login-form-title { font-size: 22px; font-weight: 500; margin-bottom: 4px; }
.login-form-sub   { font-size: 13px; color: var(--color-text-secondary); margin-bottom: 28px; }

.login-error {
  background: var(--bygga-red-light);
  color: var(--bygga-red-dark);
  border: 0.5px solid var(--bygga-red-light);
  border-radius: var(--border-radius-md);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-footer {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
}
.login-footer-link { color: var(--color-text-secondary); }
.login-footer-link:hover { color: var(--color-text-primary); }

/* ---- LOADING STATE ---- */
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 10px;
  color: var(--color-text-secondary);
  font-size: 13px;
}


/* ============================================================
   APP FOOTER ("powered by bygga" discreto)
   ============================================================ */
.app-footer {
  padding: 10px 24px;
  font-size: 11px;
  color: var(--color-text-tertiary);
  border-top: 0.5px solid var(--color-border-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--color-background-primary);
}
.app-footer a {
  color: rgb(205, 0, 26);
  text-decoration: none;
}
.app-footer a:hover { text-decoration: underline; }
.app-footer-sep { color: var(--color-border-secondary); }

/* ============================================================
   TOPBAR HAMBURGER (mobile)
   ============================================================ */
.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 20px;
  padding: 4px 8px 4px 0;
  cursor: pointer;
  align-items: center;
}
.topbar-menu-btn:hover { color: var(--color-text-primary); }

/* ============================================================
   SECTION HEADER com link "Ver todos →"
   ============================================================ */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-header .section-title { margin-bottom: 0; }
.section-link {
  font-size: 12px;
  color: var(--bygga-teal);
  text-decoration: none;
  flex-shrink: 0;
}
.section-link:hover { text-decoration: underline; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-secondary);
}
.empty-state-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--color-background-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--color-text-tertiary);
  margin-bottom: 16px;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}
.empty-state-sub {
  font-size: 13px;
  line-height: 1.5;
  max-width: 320px;
  margin-bottom: 20px;
}

/* ============================================================
   ERROR STATE
   ============================================================ */
.error-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bygga-red-light);
  border: 0.5px solid var(--bygga-red);
  border-radius: var(--border-radius-md);
  font-size: 13px;
  color: var(--bygga-red-dark);
  margin-bottom: 16px;
}
.error-state i { font-size: 18px; flex-shrink: 0; }
.error-state-retry {
  margin-left: auto;
  background: none;
  border: 0.5px solid var(--bygga-red);
  color: var(--bygga-red-dark);
  border-radius: var(--border-radius-sm);
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.error-state-retry:hover { background: var(--bygga-red); color: #fff; }

/* ============================================================
   SKELETON LOADING
   ============================================================ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-background-secondary) 25%,
    var(--color-border-tertiary) 50%,
    var(--color-background-secondary) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--border-radius-sm);
}
.skeleton-card {
  border-radius: var(--border-radius-lg);
  height: 88px;
}
.skeleton-row {
  border-radius: var(--border-radius-lg);
  height: 64px;
  margin-bottom: 8px;
}
.skeleton-title {
  height: 14px;
  width: 55%;
  margin-bottom: 8px;
  border-radius: 2px;
}
.skeleton-sub {
  height: 11px;
  width: 35%;
  border-radius: 2px;
}

/* ============================================================
   RESPONSIVE - Tablet (≤ 900px) e Mobile (≤ 640px)
   ============================================================ */

/* ---- Tablet: sidebar colapsada a ícones ---- */
@media (max-width: 900px) {
  :root { --sidebar-w: 56px; }

      
  .nav-section { display: none; }
  .nav-item {
    padding: 11px 0;
    justify-content: center;
    gap: 0;
    border-left-width: 2px;
    position: relative;
  }
  .nav-item .nav-item-label { display: none; }
  .nav-item i { width: auto; }
  .nav-badge { display: none; }
  .sidebar-user { padding: 12px 8px; justify-content: center; }
  .sidebar-user .user-name,
  .sidebar-user .user-role   { display: none; }
  .sidebar-logout { margin-left: 0; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detalhe-layout { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ---- Tablet nav tooltips ---- */
@media (max-width: 900px) {
  .nav-item { position: relative; }
  .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bygga-navy);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
  }
  .nav-item:hover::after { opacity: 1; }
}

/* ---- Mobile: sidebar como drawer overlay ---- */
@media (max-width: 640px) {
  :root { --sidebar-w: 220px; }

  .topbar-menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 9000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    /* Restaura estilos colapsados */
    width: var(--sidebar-w);
  }
    .nav-section    { display: block; }
  .nav-item       { padding: 9px 16px; justify-content: flex-start; gap: 10px; }
  .nav-item .nav-item-label { display: inline; }
  .nav-badge      { display: inline-flex; }
  .sidebar-user   { padding: 12px 16px; justify-content: flex-start; }
  .sidebar-user .user-name,
  .sidebar-user .user-role  { display: block; }
  .sidebar-logout { margin-left: auto; }
  .nav-item::after { display: none; }

  /* Sidebar aberta */
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .login-brand { display: none; }
  .login-shell { max-width: 100%; border-radius: 0; min-height: 100dvh; }
  .topbar { padding: 0 16px; }
}

/* ---- Overlay escuro para sidebar mobile ---- */
.sidebar-overlay {
  display: none;
}
@media (max-width: 640px) {
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 8999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
}

/* Mapa - esconde sidebar no mapa em tablet */
@media (max-width: 900px) {
  .login-brand { display: none; }
  .login-shell { border-radius: var(--border-radius-lg); }
}
@media (max-width: 640px) {
  .login-shell { border-radius: 0; max-width: 100%; }
}

/* ---- Extras responsive ---- */
@media (max-width: 640px) {
  .filter-bar { flex-wrap: wrap; }
  .filter-search { width: 100%; margin-left: 0; }
  .detalhe-layout { grid-template-columns: 1fr; }
  .det-info-grid { grid-template-columns: 1fr 1fr; }
  .app-footer { padding: 10px 16px; }
}

/* ============================================================
   PEDIDO NOVO - Mapa interativo + Geocoder + Draw tools
   ============================================================ */

/* -- Geocoder ------------------------------------------------ */
.pn-geocoder {
  position: relative;
  margin-bottom: 10px;
}
.pn-geocoder-row {
  display: flex;
  gap: 6px;
}
.pn-geocoder-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--border-radius-md);
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-primary);
  background: #fff;
  transition: border-color 0.15s;
}
.pn-geocoder-input:focus {
  outline: none;
  border-color: var(--bygga-red);
  box-shadow: 0 0 0 2px var(--bygga-red-light);
}
.pn-geocoder-btn {
  padding: 8px 14px;
  background: var(--bygga-red);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s;
}
.pn-geocoder-btn:hover { background: var(--bygga-red-dark); }
.pn-geocoder-btn i { font-size: 15px; }
.pn-geocoder-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  display: none;
  max-height: 220px;
  overflow-y: auto;
}
.pn-geocoder-result {
  padding: 10px 14px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  line-height: 1.45;
  color: var(--color-text-primary);
}
.pn-geocoder-result:last-child { border-bottom: none; }
.pn-geocoder-result:hover { background: var(--color-background-secondary); }
.pn-geocoder-result strong {
  display: block;
  font-weight: 500;
  margin-bottom: 1px;
}
.pn-geocoder-empty {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* -- Mapa ---------------------------------------------------- */
.pn-map {
  height: 520px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border-tertiary);
  overflow: hidden;
  margin-bottom: 10px;
  position: relative;
  z-index: 0;
}

/* Fix z-index Leaflet controls */
.pn-map .leaflet-control-zoom { z-index: 400; }

/* -- Draw tools --------------------------------------------- */
.pn-draw-tools {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.pn-tool {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--border-radius-md);
  background: #fff;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}
.pn-tool i { font-size: 15px; }
.pn-tool:hover {
  border-color: var(--bygga-red);
  color: var(--bygga-red);
  background: var(--bygga-red-light);
}
.pn-tool.active {
  background: var(--bygga-red-light);
  border-color: var(--bygga-red);
  color: var(--bygga-red-dark);
  font-weight: 500;
}
.pn-tool-danger:hover {
  border-color: var(--bygga-red-dark);
  color: var(--bygga-red-dark);
  background: var(--bygga-red-light);
}

/* Wrapper dos botões à direita */
.pn-tool-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* -- Coordenadas -------------------------------------------- */
.pn-coord-info {
  font-size: 11px;
  color: var(--color-text-secondary);
  background: var(--color-background-secondary);
  border-radius: var(--border-radius-sm);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.4;
}
.pn-coord-info i { color: var(--bygga-red); font-size: 14px; flex-shrink: 0; }
.pn-coord-sep { color: var(--color-border-primary); font-size: 12px; }

/* -- Handles de edição de vértices (Leaflet-Geoman) ----------- */
.leaflet-pm-icon {
  border: 2px solid #FF6600 !important;
  background: #fff !important;
  border-radius: 2px !important;
  cursor: move !important;
}
/* Ponto médio de cada segmento */
.leaflet-pm-middle-icon {
  border-color: #FF6600 !important;
  opacity: 0.6;
}
/* Aumentar área clicável */
.leaflet-pm-icon::before {
  content: '';
  position: absolute;
  inset: -8px;
  cursor: move;
}

/* -- Pin icon personalizado ---------------------------------- */
.pn-pin-icon {
  background: none !important;
  border: none !important;
}
.pn-pin-icon .ti {
  font-size: 28px;
  color: var(--bygga-red);
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}

/* -- Cursor do mapa quando em modo de desenho --------------- */
.map-drawing { cursor: crosshair !important; }
.map-pin-mode { cursor: cell !important; }
