:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}
header h1 { font-size: 1.35rem; display: flex; align-items: center; gap: 10px; }
header h1 span.logo {
  background: var(--primary); color: #fff; width: 38px; height: 38px;
  border-radius: 10px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 1.1rem;
}
.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.admin-badge {
  font-size: .8rem; font-weight: 700; color: #15803d; background: #dcfce7;
  padding: 6px 12px; border-radius: 999px;
}
.btn {
  border: none; cursor: pointer; font-size: .92rem; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; transition: all .15s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }

.toolbar {
  max-width: 1280px; margin: 24px auto 0; padding: 0 28px;
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.search-box { flex: 1; min-width: 220px; position: relative; }
.search-box input {
  width: 100%; padding: 11px 14px 11px 40px; border-radius: 10px;
  border: 1px solid var(--border); font-size: .95rem; background: var(--card);
  outline: none; transition: border .15s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box::before {
  content: "🔍"; position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%); font-size: .85rem; opacity: .55;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); cursor: pointer; font-size: .87rem; font-weight: 600;
  color: var(--muted); transition: all .15s;
}
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-chip .count {
  background: rgba(0,0,0,.08); border-radius: 999px; padding: 1px 8px;
  font-size: .78rem; margin-left: 4px;
}
.filter-chip.active .count { background: rgba(255,255,255,.25); }

.stats {
  max-width: 1280px; margin: 20px auto 0; padding: 0 28px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
  border-left: 4px solid var(--border);
}
.stat-card .num { font-size: 1.7rem; font-weight: 700; }
.stat-card .lbl { font-size: .82rem; color: var(--muted); font-weight: 600; }

main {
  max-width: 1280px; margin: 24px auto 60px; padding: 0 28px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px;
}
.empty {
  grid-column: 1/-1; text-align: center; padding: 80px 20px; color: var(--muted);
}
.empty .icon { font-size: 3.5rem; margin-bottom: 14px; }
.empty p { font-size: 1.05rem; }

.project-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s; cursor: pointer;
}
.project-card:hover { transform: translateY(-3px); box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.card-cover {
  height: 160px; background: linear-gradient(135deg, #e0e7ff, #f3e8ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; position: relative; overflow: hidden;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.photo-count {
  position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,.6);
  color: #fff; font-size: .78rem; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; display: flex; align-items: center; gap: 5px;
}
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-size: 1.08rem; font-weight: 700; line-height: 1.3; }
.badge {
  font-size: .74rem; font-weight: 700; padding: 5px 11px; border-radius: 999px;
  white-space: nowrap; letter-spacing: .02em;
}
.card-desc {
  font-size: .87rem; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.progress-row { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.progress-track { flex: 1; height: 7px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.progress-pct { font-size: .8rem; font-weight: 700; color: var(--muted); min-width: 34px; text-align: right; }
.card-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .78rem; color: var(--muted); padding-top: 6px;
  border-top: 1px solid var(--border); margin-top: 4px;
}

/* ===== Modais ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(15,17,26,.55); z-index: 100;
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; backdrop-filter: blur(3px);
}
.overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: 18px; width: 100%; max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  padding: 20px 26px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 1.15rem; }
.close-btn {
  background: var(--bg); border: none; width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; font-size: 1rem; color: var(--muted); transition: all .15s;
}
.close-btn:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 24px 26px; display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: .85rem; font-weight: 700; color: var(--text); }
.field input[type=text], .field input[type=date], .field textarea, .field select {
  padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  font-size: .95rem; font-family: inherit; outline: none; background: #fff;
  transition: border .15s; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 84px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input[type=range] { flex: 1; accent-color: var(--primary); }
.range-val { font-weight: 700; min-width: 46px; text-align: right; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 26px;
  text-align: center; color: var(--muted); cursor: pointer; transition: all .15s;
  font-size: .9rem;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--primary); background: #eef2ff; color: var(--primary); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.thumb { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.thumb .rm {
  position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.65); color: #fff;
  border: none; width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  font-size: .75rem; display: flex; align-items: center; justify-content: center;
}
.thumb .rm:hover { background: #dc2626; }
.modal-footer {
  padding: 18px 26px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.modal-footer .right { display: flex; gap: 10px; margin-left: auto; }

/* ===== Visualização ===== */
.view-cover { height: 220px; background: linear-gradient(135deg, #e0e7ff, #f3e8ff); overflow: hidden; border-radius: 18px 18px 0 0; }
.view-cover img { width: 100%; height: 100%; object-fit: cover; }
.view-section h3 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 8px;
}
.view-desc { font-size: .95rem; line-height: 1.6; white-space: pre-wrap; }
.view-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.view-gallery img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  cursor: pointer; transition: transform .15s;
}
.view-gallery img:hover { transform: scale(1.04); }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.meta-item { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.meta-item .k { font-size: .74rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.meta-item .v { font-size: .95rem; font-weight: 600; margin-top: 3px; }

/* Lightbox */
#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 200;
  display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 8px; object-fit: contain; }
.lb-nav { display: flex; gap: 14px; align-items: center; color: #fff; }
.lb-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 1.2rem;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer; transition: background .15s;
}
.lb-btn:hover { background: rgba(255,255,255,.3); }
#lb-close { position: absolute; top: 20px; right: 24px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1a1d23; color: #fff; padding: 13px 24px; border-radius: 12px;
  font-size: .92rem; font-weight: 600; z-index: 300; opacity: 0;
  transition: all .3s; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 640px) {
  header { padding: 14px 16px; }
  .toolbar, .stats, main { padding: 0 16px; }
  .field-row, .meta-grid { grid-template-columns: 1fr; }
}
