*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:   #2563eb;
  --blue-h: #1d4ed8;
  --green:  #16a34a;
  --green-h:#15803d;
  --amber:  #d97706;
  --amber-h:#b45309;
  --red:    #dc2626;
  --red-h:  #b91c1c;
  --bg:     #f1f5f9;
  --surface:#ffffff;
  --border: #e2e8f0;
  --text:   #0f172a;
  --muted:  #64748b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo { height: 34px; width: auto; }

.header-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  border-left: 1px solid var(--border);
  padding-left: 14px;
}

.btn-header-action {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .12s;
}
.btn-header-action svg { width: 17px; height: 17px; }
.btn-header-action:active { transform: scale(.97); }

.btn-add-action { background: var(--green); color: #fff; }
.btn-add-action:hover { background: var(--green-h); }

/* ── Search ─────────────────────────────────────── */
.search-wrap {
  padding: 28px 24px 12px;
  display: flex;
  justify-content: center;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 460px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  background: var(--surface);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
#search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── Grid ───────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
  padding: 16px 24px 80px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Card ───────────────────────────────────────── */
.dl-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}
.dl-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0,0,0,.1);
}

.card-img-wrap {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  position: relative;
}

.card-img-wrap img {
  max-height: 76px;
  max-width: 100%;
  object-fit: contain;
}

.card-icon-fallback {
  width: 52px;
  height: 52px;
  color: var(--blue);
  opacity: .55;
  display: none;
}

/* Botões editar/excluir sobre a imagem */
.card-actions {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  transition: opacity .18s;
}
.dl-card:hover .card-actions { opacity: 1; }

.card-act-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s;
}
.card-act-btn svg { width: 17px; height: 17px; }
.card-act-btn:hover { transform: scale(1.1); }
.card-act-btn.edit   { background: #f59e0b; color: #fff; }
.card-act-btn.delete { background: var(--red); color: #fff; }

/* Badges de ação abaixo da imagem (visíveis o tempo todo) */
.card-admin-badges {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.card-badge-btn {
  flex: 1;
  padding: 7px 0;
  border: none;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background .15s;
}
.card-badge-btn svg { width: 13px; height: 13px; }
.card-badge-btn.edit   { color: #92400e; background: #fef3c7; }
.card-badge-btn.edit:hover   { background: #fde68a; }
.card-badge-btn.delete { color: #991b1b; background: #fee2e2; }
.card-badge-btn.delete:hover { background: #fecaca; }
.card-badge-btn + .card-badge-btn { border-left: 1px solid var(--border); }

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
}

.card-desc {
  font-size: .8rem;
  color: var(--muted);
  flex: 1;
  line-height: 1.5;
  margin-bottom: 14px;
}

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-family: 'Inter', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .12s;
}
.btn-download svg { width: 16px; height: 16px; }
.btn-download:hover { background: var(--blue-h); }
.btn-download:active { transform: scale(.97); }

/* ── Empty / Error ──────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: .95rem; font-weight: 500; }

/* ── Skeletons ──────────────────────────────────── */
.skeleton {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.sk-img {
  height: 108px;
  background: linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 50%,#f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.sk-body { padding: 16px; }
.sk-line {
  height: 11px;
  border-radius: 6px;
  margin-bottom: 9px;
  background: linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 50%,#f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.sk-line.w60 { width: 60%; }
.sk-btn {
  height: 36px;
  border-radius: 8px;
  margin-top: 14px;
  background: linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 50%,#f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Modal overlay ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn  { from { opacity: 0; }             to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

.modal-card-wide { max-width: 500px; max-height: 88vh; overflow-y: auto; }

.modal-x {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-x svg { width: 16px; height: 16px; }
.modal-x:hover { background: var(--border); }

.modal-icon-wrap {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.modal-icon-wrap svg { width: 28px; height: 28px; }
.modal-icon-wrap.blue   { background: #dbeafe; color: var(--blue); }
.modal-icon-wrap.green  { background: #dcfce7; color: var(--green); }
.modal-icon-wrap.amber  { background: #fef3c7; color: var(--amber); }
.modal-icon-wrap.red    { background: #fee2e2; color: var(--red); }

.modal-title {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-sub {
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ── Forms inside modals ────────────────────────── */
.pw-field {
  position: relative;
  margin-bottom: 10px;
}
.pw-field input {
  width: 100%;
  padding: 11px 44px 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.pw-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.pw-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: flex;
}
.pw-eye svg { width: 17px; height: 17px; }
.pw-eye:hover { color: var(--text); }

.field-error {
  font-size: .8rem;
  color: var(--red);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-error[hidden] { display: none; }

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 9px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  transition: background .18s, transform .12s;
}
.btn-primary svg { width: 17px; height: 17px; }
.btn-primary:active { transform: scale(.98); }
.btn-primary.blue  { background: var(--blue);  }
.btn-primary.blue:hover  { background: var(--blue-h); }
.btn-primary.green { background: var(--green); }
.btn-primary.green:hover { background: var(--green-h); }
.btn-primary.amber { background: var(--amber); }
.btn-primary.amber:hover { background: var(--amber-h); }
.btn-primary.red   { background: var(--red);  }
.btn-primary.red:hover   { background: var(--red-h); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  flex: 1;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: var(--bg); }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

/* Edit form rows */
.form-row { margin-bottom: 15px; }
.form-row label {
  display: block;
  font-size: .76rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.form-row input[type=text],
.form-row input[type=password] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.form-row input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.1);
}

/* Drop zone */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: .82rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color .18s, background .18s;
}
.drop-zone svg { width: 28px; height: 28px; opacity: .45; }
.drop-zone:hover, .drop-zone.over { border-color: var(--green); background: #f0fdf4; color: var(--green); }
.drop-zone.over svg { opacity: 1; }
.hidden-file { display: none; }

/* Progress */
.prog-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.prog-wrap[hidden] { display: none; }
.prog-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.prog-fill  { height: 100%; background: var(--green); border-radius: 3px; width: 0; transition: width .2s; }
.prog-wrap span { font-size: .75rem; font-weight: 700; color: var(--green); min-width: 34px; }

/* ── Toast ──────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 12px 22px;
  border-radius: 50px;
  font-size: .87rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  z-index: 999;
  white-space: nowrap;
  animation: fadeIn .2s ease;
}
.toast[hidden] { display: none; }
.toast.success { background: #15803d; }
.toast.error   { background: var(--red); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 520px) {
  .card-grid { padding: 12px 12px 60px; gap: 12px; }
  .modal-card { padding: 28px 18px 22px; }
  .site-header { padding: 0 14px; }
  .header-title { display: none; }
  .search-wrap { padding: 16px 12px 8px; }
}
