/* ================================================================
   LP Admin — Dark Luxury Theme
   Paleta: Evolution Residences (fundo #080808, gold #C9A864, cream #EDE6D8)
================================================================ */

/* Fontes (Cormorant Garamond + Montserrat): carregadas no <head> do index.html, em paralelo com este CSS */

/* ── Dark theme (default) ── */
:root {
  --bg: #080808;
  --surface: #111111;
  --surface2: #171717;
  --surface3: #222222;
  --gold: #D4A85A;
  --gold2: #B08840;
  --gold-faint: rgba(212,168,90,.08);
  --gold-border: rgba(212,168,90,.18);
  --text: #F0EAD8;
  --text-muted: #8A8480;
  --border: rgba(240,234,216,.12);
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #ef4444;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Montserrat', sans-serif;
  --nav-h: 56px;
  --ease: cubic-bezier(.25,.46,.45,.94);
  --shadow: 0 2px 12px rgba(0,0,0,.5);
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg: #F5F2EC;
  --surface: #FFFFFF;
  --surface2: #F0EDE6;
  --surface3: #E8E4DB;
  --gold: #A07830;
  --gold2: #8A6520;
  --gold-faint: rgba(160,120,48,.07);
  --gold-border: rgba(160,120,48,.22);
  --text: #1A1612;
  --text-muted: #7A7268;
  --border: rgba(26,22,18,.12);
  --green: #15803d;
  --yellow: #b45309;
  --red: #dc2626;
  --shadow: 0 2px 12px rgba(0,0,0,.10);
}

/* Light mode: disable animated orbs (too light-on-light) */
[data-theme="light"] body::before,
[data-theme="light"] body::after { opacity: 0; }

/* Light mode: noise layer less visible */
[data-theme="light"] .noise-layer { opacity: .012; }

/* Light mode: login box */
[data-theme="light"] .login-box { background: rgba(255,255,255,.9); }

/* Light mode: scrollbar */
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--surface3); }

/* ── Reset ── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--sans); }
img { display: block; max-width: 100%; }

/* ── Fundo animado — orbs douradas com drift lento ── */
body::before,
body::after {
  content: '';
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
}

/* Orb principal — canto superior esquerdo, deriva para baixo-direita */
body::before {
  width: 600px;
  height: 600px;
  top: -200px;
  left: -200px;
  background: radial-gradient(circle, rgba(201,168,100,.055) 0%, transparent 70%);
  animation: orbDrift1 40s ease-in-out infinite alternate;
}

/* Orb secundária — canto inferior direito, deriva para cima-esquerda */
body::after {
  width: 500px;
  height: 500px;
  bottom: -150px;
  right: -150px;
  background: radial-gradient(circle, rgba(201,168,100,.04) 0%, transparent 70%);
  animation: orbDrift2 50s ease-in-out infinite alternate;
}

@keyframes orbDrift1 {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(120px, 80px) scale(1.1); }
  66%  { transform: translate(60px, 160px) scale(.95); }
  100% { transform: translate(180px, 120px) scale(1.05); }
}

@keyframes orbDrift2 {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(-100px, -60px) scale(1.08); }
  66%  { transform: translate(-40px, -140px) scale(.92); }
  100% { transform: translate(-150px, -80px) scale(1.06); }
}

/* Noise texture subtil sobre tudo */
body .noise-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .022;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* Todo o conteúdo acima das orbs */
#login-page, #app { position: relative; z-index: 2; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

/* ================================================================
   LOGIN PAGE
================================================================ */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: rgba(13,13,13,.7);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  padding: 48px 40px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.login-logo {
  text-align: center;
  margin-bottom: 40px;
}
.login-logo .diamond {
  font-size: 1.8rem;
  color: var(--gold);
  display: block;
  margin-bottom: 12px;
}
.login-logo h1 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 500;
  letter-spacing: .04em;
}
.login-logo p {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: .75rem;
  display: none;
}
.login-error.show { display: block; }

/* ================================================================
   FORM ELEMENTS
================================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  background: var(--surface3);
  border: 1px solid var(--gold-border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 3px;
  font-size: .85rem;
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--gold); }
.field textarea { resize: vertical; min-height: 80px; }
.field select { cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity .2s, background .2s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--gold); color: #0a0800; }
.btn-primary:hover:not(:disabled) { background: var(--gold2); }
.btn-secondary { background: var(--surface3); color: var(--text); border: 1px solid var(--gold-border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--gold); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.25); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: .65rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 7px; border-radius: 3px; }
/* Variáveis de template — clicáveis para inserir no cursor */
.tpl-var-btn {
  display: inline-block;
  background: var(--surface1);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: .7rem;
  cursor: pointer;
  margin: 2px 2px;
  transition: background .15s, color .15s;
}
.tpl-var-btn:hover {
  background: var(--gold, #c9a864);
  color: #fff;
  border-color: var(--gold, #c9a864);
}

/* ================================================================
   NAV
================================================================ */
#app { display: none; min-height: 100vh; }
nav#main-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  z-index: 100;
  gap: 0;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 40px;
  flex-shrink: 0;
}
.nav-brand .diamond { color: var(--gold); font-size: 1rem; }
.nav-brand span {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: .04em;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 3px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .2s, background .2s;
  border: none;
  background: none;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--gold); background: var(--gold-faint); }
.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-user-name {
  font-size: .68rem;
  color: var(--text-muted);
}

/* ================================================================
   MAIN CONTENT
================================================================ */
main#content {
  padding: 32px 28px;
  max-width: 1300px;
  margin-left: auto;
  margin-right: auto;
  padding-top: calc(var(--nav-h) + 32px);
}

.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.section-title {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: .04em;
}
.section-subtitle {
  font-size: .68rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ================================================================
   STATS BAR
================================================================ */
.stats-bar {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
}
.stat-pill.green { background: rgba(74,222,128,.1); color: var(--green); }
.stat-pill.yellow { background: rgba(251,191,36,.1); color: var(--yellow); }
.stat-pill.red { background: rgba(239,68,68,.1); color: var(--red); }
.stat-pill.muted { background: var(--surface3); color: var(--text-muted); }

/* Linha não lida na tabela de contactos */
.unread-row td:first-child { border-left: 2px solid var(--gold); }

/* ================================================================
   FILTERS BAR
================================================================ */
.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-select {
  background: var(--surface3);
  border: 1px solid var(--gold-border);
  color: var(--text);
  padding: 7px 32px 7px 12px;
  border-radius: 3px;
  font-size: .72rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  appearance: none;
  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='%236B6460'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color .2s;
}
.filter-select:focus { border-color: var(--gold); }

/* ================================================================
   TABLE
================================================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gold-border);
  border-radius: 4px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--gold-border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 8px 12px;
  font-size: .8rem;
  vertical-align: middle;
}
/* tighter for number/flag cells */
tbody td[data-col="fase"],
tbody td[data-col="piso"],
tbody td[data-col="tipo"],
tbody td[data-col="exposicao"],
tbody td[data-col="areaApt"],
tbody td[data-col="areaTerr"],
tbody td[data-col="areaGar"],
tbody td[data-col="areaTotal"] { padding: 8px 10px; }
thead th[data-col="fase"],
thead th[data-col="piso"],
thead th[data-col="areaApt"],
thead th[data-col="areaTerr"],
thead th[data-col="areaGar"],
thead th[data-col="areaTotal"] { padding: 9px 10px; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* Estado select na tabela */
.estado-select {
  background: transparent;
  border: 1px solid var(--gold-border);
  color: var(--text);
  padding: 4px 28px 4px 10px;
  border-radius: 3px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236B6460'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-color: var(--surface3);
  transition: border-color .2s;
  outline: none;
}
.estado-select:focus { border-color: var(--gold); }
.estado-select.livre { color: var(--green); border-color: rgba(74,222,128,.3); }
.estado-select.reservado { color: var(--yellow); border-color: rgba(251,191,36,.3); }
.estado-select.vendido { color: var(--red); border-color: rgba(239,68,68,.3); text-decoration: line-through; }

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 2px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.badge-green { background: rgba(74,222,128,.1); color: var(--green); }
.badge-yellow { background: rgba(251,191,36,.1); color: var(--yellow); }
.badge-red { background: rgba(239,68,68,.1); color: var(--red); }
.badge-muted { background: var(--surface3); color: var(--text-muted); }

/* ================================================================
   TABS
================================================================ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--gold-border);
  padding-bottom: 0;
}
.tab-btn {
  padding: 8px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .2s, border-color .2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ================================================================
   CARD / PANEL
================================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--gold);
  letter-spacing: .04em;
}
.card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }

/* ================================================================
   MEDIA GRID
================================================================ */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.media-card {
  background: var(--surface2);
  border: 1px solid var(--gold-border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.media-card.inactive { opacity: .45; }
.media-thumb {
  aspect-ratio: 16/9;
  background: var(--surface3);
  overflow: hidden;
}
.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-thumb .video-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
}
.media-info {
  padding: 10px 12px;
}
.media-legenda {
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.media-ordem {
  margin-left: auto;
  font-size: .65rem;
  color: var(--text-muted);
}

/* ================================================================
   UPLOAD ZONE
================================================================ */
.upload-zone {
  border: 2px dashed var(--gold-border);
  border-radius: 4px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 24px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--gold);
  background: var(--gold-faint);
}
.upload-zone .upload-icon { font-size: 2.5rem; color: var(--gold); margin-bottom: 12px; }
.upload-zone p { font-size: .78rem; color: var(--text-muted); }
.upload-zone strong { color: var(--text); }
.upload-progress {
  display: none;
  margin-top: 12px;
}
.progress-bar {
  height: 3px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gold);
  transition: width .3s;
  width: 0;
}

/* ================================================================
   TOGGLE
================================================================ */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border-radius: 11px;
  cursor: pointer;
  border: 1px solid var(--gold-border);
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle input:checked + .toggle-slider { background: rgba(201,168,100,.2); border-color: var(--gold); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--gold); }
.toggle-label { font-size: .78rem; }

/* ================================================================
   MODAL
================================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.show,
.modal-overlay.open { display: flex; }

/* Modal box (frações edit, etc.) */
.modal-box {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--gold-border);
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: .04em;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--gold); }
.modal-form {
  padding: 20px 24px;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.form-group input,
.form-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: .85rem;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--gold);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gold-border);
}
.modal-header h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
}
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ================================================================
   TOAST
================================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid;
  animation: toastIn .25s var(--ease);
  pointer-events: auto;
}
.toast.success {
  background: rgba(74,222,128,.12);
  border-color: rgba(74,222,128,.3);
  color: var(--green);
}
.toast.error {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.3);
  color: #fca5a5;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   EMPTY STATE
================================================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: .8rem; }

/* ================================================================
   LOADING SPINNER
================================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: .75rem;
  gap: 10px;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--surface3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 768px) {
  nav#main-nav { padding: 0 16px; gap: 0; }
  .nav-links { gap: 0; }
  .nav-link { padding: 6px 8px; font-size: .6rem; }
  .nav-brand span { display: none; }
  main#content { padding: 16px; padding-top: calc(var(--nav-h) + 16px); }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ================================================================
   FRAÇÕES — Tabs, Bulk bar, Table extras
================================================================ */
.fracoes-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.fracoes-tab {
  padding: 6px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s;
}
.fracoes-tab.active,
.fracoes-tab:hover {
  background: var(--gold-faint);
  border-color: var(--gold-border);
  color: var(--gold);
}

/* Bulk action bar */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  padding: 8px 16px;
  margin-bottom: 10px;
  animation: slideDown .15s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.bulk-count {
  font-size: .78rem;
  color: var(--gold);
  font-weight: 600;
  flex: 1;
}

/* Table extras */
.th-check, .td-check { width: 30px; text-align: center; padding: 0 !important; }
.row-check,
#check-all {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  background: var(--surface3);
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  transition: border-color .12s, background .12s;
}
.row-check:hover, #check-all:hover { border-color: var(--gold-border); }
.row-check:checked, #check-all:checked {
  background: var(--gold);
  border-color: var(--gold);
}
.row-check:checked::after, #check-all:checked::after {
  content: '';
  position: absolute;
  left: 2px; top: 0px;
  width: 5px; height: 8px;
  border: 1.5px solid var(--bg);
  border-top: none; border-left: none;
  transform: rotate(40deg);
}
.text-muted-sm { color: var(--text-muted); font-size: .78rem; }
.btn-edit { font-size: 1.05rem; padding: 3px 8px; }
.btn-danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: .85rem;
  cursor: pointer;
  padding: 3px 6px;
  transition: color .15s;
}
.btn-danger-ghost:hover { color: var(--red); }

/* Stat pills — clickable */
.stat-pill { cursor: pointer; transition: opacity .15s, transform .1s; }
.stat-pill:hover { opacity: .8; transform: translateY(-1px); }

/* ================================================================
   MEDIA — Category tabs, Section slots
================================================================ */
.media-tabs {
  margin-bottom: 16px;
}
.media-tab-btn {
  padding: 6px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: .75rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s;
}
.media-tab-btn.active,
.media-tab-btn:hover {
  background: var(--gold-faint);
  border-color: var(--gold-border);
  color: var(--gold);
}
.media-cat-badge {
  display: inline-block;
  font-size: .6rem;
  background: var(--gold-faint);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  border-radius: 3px;
  padding: 0 5px;
  vertical-align: middle;
  margin-left: 4px;
}

/* Section slots grid */
.seccoes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  padding: 4px 0;
}
.seccao-slot {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.seccao-label {
  padding: 8px 12px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  background: var(--gold-faint);
}
.seccao-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}
.seccao-empty {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: var(--text-muted);
}
.seccao-actions {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
}
/* Wrapper para thumb com badge de estado */
.seccao-thumb-wrap {
  position: relative;
}
.seccao-fallback {
  opacity: .55;
  filter: grayscale(.3);
}
.seccao-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  pointer-events: none;
}
.seccao-badge.custom {
  background: rgba(201,168,100,.9);
  color: #1a1408;
}
.seccao-badge.fallback {
  background: rgba(0,0,0,.55);
  color: rgba(255,255,255,.65);
}
/* Thumb para slots de vídeo */
.seccao-video-thumb {
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface3);
}
.seccao-video-icon {
  font-size: 2rem;
  color: var(--gold);
}
.seccao-video-name {
  font-size: .62rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0 8px;
  word-break: break-all;
}
.seccao-video-empty {
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 1.5rem;
}
.seccao-video-empty small {
  font-size: .62rem;
  letter-spacing: .04em;
}

/* ================================================================
   MEDIA PICKER MODAL
================================================================ */
.picker-modal-box {
  max-width: 700px;
  width: 95vw;
}
.picker-new-wrap {
  padding: 16px 0 4px;
  text-align: center;
}
.picker-divider {
  text-align: center;
  font-size: .65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 14px 0 10px;
  position: relative;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 2px 8px;
}
.picker-item {
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s;
  background: var(--surface2);
}
.picker-item:hover {
  border-color: var(--gold);
}
.picker-item.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
}
.picker-item-thumb img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
}
.picker-vid-thumb {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--gold);
  background: var(--surface3);
}
.picker-item-label {
  padding: 4px 6px;
  font-size: .58rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem;
  font-size: .8rem;
  grid-column: 1/-1;
}

/* ================================================================
   TRADUÇÕES — Card header row, field translate
================================================================ */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-header-row .card-title { margin-bottom: 0; }
.field-with-translate .field-input-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.field-with-translate .field-input-row input,
.field-with-translate .field-input-row textarea {
  flex: 1;
}
.trad-field-btn {
  padding: 4px 7px;
  font-size: .85rem;
  color: var(--gold);
  opacity: .65;
  flex-shrink: 0;
  margin-top: 1px;
}
.trad-field-btn:hover { opacity: 1; }

/* ================================================================
   NAV — Empreendimento selector
================================================================ */
.emp-selector {
  background: var(--surface3);
  border: 1px solid var(--gold-border);
  color: var(--text);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: .75rem;
  cursor: pointer;
  margin-left: 12px;
}

/* ================================================================
   SVG ICON BUTTONS — edit, delete, restore
================================================================ */
.ico-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  color: rgba(240,234,216,.3);
  vertical-align: middle;
  flex-shrink: 0;
}
.ico-btn svg { display: block; width: 14px; height: 14px; }
.ico-btn:hover { background: var(--surface3); border-color: var(--border); color: var(--text-muted); }

.ico-edit:hover  { color: var(--gold); border-color: var(--gold-border); background: var(--gold-faint); }
.ico-delete:hover { color: #e05c5c; border-color: rgba(224,92,92,.3); background: rgba(224,92,92,.07); }
.ico-restore:hover { color: #5cba87; border-color: rgba(92,186,135,.3); background: rgba(92,186,135,.07); }

/* ================================================================
   COLUMN HEADER FILTERS
================================================================ */
.col-filters-row th {
  padding: 4px 6px;
  background: var(--surface2);
}
.col-filter-input {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: .7rem;
  padding: 3px 7px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.col-filter-input:focus { border-color: var(--gold-border); }
.col-filter-input::placeholder { color: var(--text-muted); opacity: .6; }
select.col-filter-input { cursor: pointer; }

/* ================================================================
   TRANSLATE ICON (SVG globe)
================================================================ */
.trad-icon {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
}
.trad-section-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: .75rem;
  color: var(--gold);
  background: var(--gold-faint);
  border: 1px solid var(--gold-border);
  border-radius: 4px;
  cursor: pointer;
  opacity: .8;
  transition: opacity .15s;
}
.trad-section-btn:hover { opacity: 1; }
.trad-field-btn svg { width: 15px; height: 15px; display: block; stroke: currentColor; }

/* Batch translate progress bar */
#trad-batch-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--gold-faint);
  overflow: hidden;
  margin-top: 8px;
}
#trad-batch-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width .3s ease;
}

/* ================================================================
   COLUMN VISIBILITY PANEL
================================================================ */
.col-vis-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  padding: 10px 12px;
  z-index: 200;
  min-width: 160px;
  box-shadow: var(--shadow);
  flex-direction: column;
  gap: 6px;
}
.col-vis-panel.open { display: flex; }
.col-vis-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  color: var(--text);
  cursor: pointer;
  padding: 2px 0;
  white-space: nowrap;
}
.col-vis-item:hover { color: var(--gold); }
.col-vis-item input { margin: 0; }

/* Map icon for plant link */
.ico-map { color: rgba(240,234,216,.35); }
.ico-map:hover { color: var(--gold); border-color: var(--gold-border); background: var(--gold-faint); }

/* Better content spacing */
.stats-bar { margin-bottom: 18px; gap: 10px; }
.table-wrap table { border-spacing: 0; }
main#content { max-width: 1400px; }

/* Logo upload slot */
.logo-upload-slot {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
}
.logo-preview-wrap { flex: 1; }

/* ================================================================
   REVISÃO 2026-12 — selector de empreendimento, barra no telemóvel,
   estados vazios, foco visível
================================================================ */
[hidden] { display: none !important; }

.emp-switch { display: flex; align-items: center; gap: 8px; margin-right: 24px; min-width: 0; }
.emp-switch .emp-selector { margin-left: 0; max-width: 240px; text-overflow: ellipsis; padding: 6px 10px; }
.emp-novo-btn { white-space: nowrap; color: var(--gold); border-color: var(--gold-border); }

.emp-linguas { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px 18px; }
.emp-linguas legend {
  font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px; width: 100%;
}
.emp-linguas label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: .82rem; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text);
}
.emp-linguas input { width: auto; accent-color: var(--gold); }
.field-hint { font-size: .72rem; color: var(--text-muted); line-height: 1.5; }
#emp-url-preview { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.form-erro { color: var(--red, #ef4444); font-size: .78rem; min-height: 1em; }
.form-erro:empty { display: none; }

.tabela-vazia thead { display: none; }
.vazio-msg { text-align: left; color: var(--text-muted); padding: 32px 24px !important; font-size: .85rem; line-height: 1.6; white-space: normal; }

.nav-link:focus-visible, .btn:focus-visible, .emp-selector:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

@media (max-width: 768px) {
  :root { --nav-h: 100px; }
  nav#main-nav { flex-wrap: wrap; align-content: flex-start; padding: 0 12px; height: var(--nav-h); }
  .nav-brand { height: 54px; margin-right: 10px; }
  .nav-brand img { max-width: 110px !important; height: 26px !important; }
  .emp-switch { height: 54px; margin-right: 0; flex: 1 1 auto; }
  .emp-switch .emp-selector { max-width: 46vw; font-size: .8rem; }
  .nav-user { height: 54px; gap: 4px; }
  .nav-user-name { display: none; }
  .nav-links {
    order: 4; flex: 0 0 calc(100% + 24px); margin: 0 -12px; padding: 0 8px;
    height: 46px; border-top: 1px solid var(--border);
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-link { flex: 0 0 auto; padding: 8px 12px; font-size: .64rem; }
  .modal-overlay { padding: 12px; align-items: flex-end; }
}
.media-grid > .empty-state { grid-column: 1 / -1; }
@media (max-width: 768px) {
  .nav-links { -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); mask-image: linear-gradient(to right, #000 88%, transparent); }
}
.field input[type="radio"], .field input[type="checkbox"] { width: auto; padding: 0; accent-color: var(--gold); }
