/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --green:     #1a4a2e;
  --green-mid: #2d6a4f;
  --green-lt:  #52b788;
  --green-bg:  #d8f3dc;
  --cream:     #faf8f3;
  --cream-dk:  #f0ece0;
  --text:      #1e3a2a;
  --text-mid:  #4a5568;
  --text-lt:   #718096;
  --border:    #d4c9a8;
  --white:     #ffffff;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(26,74,46,.1);
  --shadow-lg: 0 8px 30px rgba(26,74,46,.15);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-mid); }

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--green);
  color: var(--white);
  padding: .75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--white);
  text-decoration: none;
}

.nav-flag { font-size: 1.4rem; }

.nav-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-link {
  color: rgba(255,255,255,.85);
  font-size: .875rem;
  transition: color .2s;
}
.nav-link:hover, .nav-admin { color: var(--white); }

.nav-user {
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout {
  background: rgba(255,255,255,.15);
  color: var(--white);
  padding: .3rem .8rem;
  border-radius: 6px;
  font-size: .85rem;
  transition: background .2s;
}
.nav-logout:hover { background: rgba(255,255,255,.25); color: var(--white); }

/* ── Main content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--green);
  color: rgba(255,255,255,.6);
  text-align: center;
  padding: 1rem;
  font-size: .8rem;
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warn    { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--green);
  color: var(--white);
  border: none;
  padding: .65rem 1.4rem;
  border-radius: 8px;
  font-size: .95rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, transform .1s;
  display: inline-block;
}
.btn-primary:hover { background: var(--green-mid); color: var(--white); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
  background: var(--cream-dk);
  color: var(--text);
  border: 1px solid var(--border);
  padding: .6rem 1.2rem;
  border-radius: 8px;
  font-size: .9rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background .2s;
  display: inline-block;
}
.btn-secondary:hover { background: var(--border); }

.btn-full { width: 100%; text-align: center; display: block; }

.btn-sm {
  padding: .3rem .7rem;
  font-size: .8rem;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-family: 'Inter', sans-serif;
  transition: opacity .2s;
  display: inline-block;
}
.btn-sm:hover { opacity: .85; }
.btn-view   { background: var(--green-bg); color: var(--green); }
.btn-edit   { background: #dbeafe; color: #1e40af; }
.btn-delete { background: #fee2e2; color: #991b1b; }
.btn-warn   { background: #fef9c3; color: #92400e; }
.btn-ok     { background: #d1fae5; color: #065f46; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}
.form-group label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-mid);
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: 'Inter', sans-serif;
  background: var(--white);
  color: var(--text);
  transition: border-color .2s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,74,46,.1);
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 180px; }
.form-grow { flex: 2; }

.form-hint { font-size: .82rem; color: var(--text-lt); margin-bottom: .75rem; }

.form-inline {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-inline input, .form-inline select { flex: 1; min-width: 150px; }

.filter-form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}
.filter-form select, .filter-form input { padding: .4rem .7rem; font-size: .875rem; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-body {
  background: linear-gradient(135deg, #1a4a2e 0%, #2d6a4f 60%, #52b788 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}
.login-flag { font-size: 3rem; display: block; margin-bottom: .5rem; }
.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--green);
  font-weight: 700;
}
.login-subtitle { color: var(--text-lt); font-size: .9rem; margin-top: .3rem; }

.step-info { font-size: .9rem; color: var(--text-mid); margin-bottom: .75rem; }
.step-hint { font-size: .85rem; color: var(--text-lt); margin-bottom: 1rem; }

.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: .75rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.link-btn {
  background: none;
  border: none;
  color: var(--green);
  cursor: pointer;
  font-size: .85rem;
  font-family: 'Inter', sans-serif;
  padding: 0;
  text-decoration: underline;
}
.link-btn:hover { color: var(--green-mid); }

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: .85rem;
}

/* ── Hub ─────────────────────────────────────────────────────────────────── */
.hub-header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.hub-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  color: var(--green);
  font-weight: 700;
}
.hub-subtitle { color: var(--text-lt); font-size: 1rem; margin-top: .4rem; }

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.section-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  text-decoration: none;
  color: var(--text);
  transition: all .25s;
  position: relative;
  overflow: hidden;
}
.section-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--green-lt));
  opacity: 0;
  transition: opacity .25s;
}
.section-card:hover {
  border-color: var(--green-lt);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  color: var(--text);
}
.section-card:hover::before { opacity: 1; }

.section-icon { font-size: 2.2rem; }
.section-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--green);
}
.section-desc { font-size: .875rem; color: var(--text-mid); flex: 1; }
.section-arrow {
  font-size: 1.2rem;
  color: var(--green-lt);
  align-self: flex-end;
  margin-top: .5rem;
}

/* ── Section page ───────────────────────────────────────────────────────── */
.section-header { margin-bottom: 2rem; }
.back-link {
  display: inline-block;
  color: var(--text-mid);
  font-size: .875rem;
  margin-bottom: 1rem;
  transition: color .2s;
}
.back-link:hover { color: var(--green); }

.section-hero {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.section-icon-big { font-size: 3rem; }
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--green);
  font-weight: 700;
}
.section-desc-full { color: var(--text-mid); font-size: .95rem; margin-top: .3rem; }

.subsecciones-container { display: flex; flex-direction: column; gap: 1rem; }

.subseccion-block {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.subseccion-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--green);
  background: var(--cream);
  list-style: none;
  user-select: none;
  transition: background .2s;
}
.subseccion-title::-webkit-details-marker { display: none; }
.subseccion-title::before { content: '▸'; font-size: .75rem; margin-right: .5rem; transition: transform .2s; }
details[open] .subseccion-title::before { transform: rotate(90deg); }
.subseccion-title:hover { background: var(--cream-dk); }

.sub-count {
  font-family: 'Inter', sans-serif;
  font-size: .78rem;
  font-weight: 400;
  color: var(--text-lt);
  background: var(--cream-dk);
  padding: .2rem .6rem;
  border-radius: 20px;
}

.files-list { padding: .75rem 1rem; }
.no-files { color: var(--text-lt); font-size: .875rem; padding: .5rem 0; font-style: italic; }

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem .5rem;
  border-bottom: 1px solid var(--cream-dk);
  gap: 1rem;
  flex-wrap: wrap;
}
.file-row:last-child { border-bottom: none; }

.file-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  flex: 1;
}
.tipo-badge {
  color: white;
  font-size: .72rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 20px;
  white-space: nowrap;
}
.file-year {
  background: var(--cream-dk);
  color: var(--text-mid);
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 20px;
}
.file-name { font-size: .9rem; color: var(--text); font-weight: 500; }
.file-desc { font-size: .8rem; color: var(--text-lt); }
.file-actions { flex-shrink: 0; }

.file-link {
  background: var(--green);
  color: var(--white);
  padding: .3rem .8rem;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  transition: background .2s;
  white-space: nowrap;
}
.file-link:hover { background: var(--green-mid); color: var(--white); }
.file-link-ext { background: #7c3aed; }
.file-link-ext:hover { background: #6d28d9; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h3 {
  font-family: 'Playfair Display', serif;
  color: var(--green);
  margin-bottom: 1.25rem;
}
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-ok   { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fef9c3; color: #92400e; }
.badge-off  { background: #fee2e2; color: #991b1b; }

.tipo-badge-sm {
  display: inline-block;
  color: white;
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 20px;
}

/* ── Reset link box ──────────────────────────────────────────────────────── */
.reset-link-box {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .8rem;
  word-break: break-all;
}
.small-link { font-size: .78rem; color: #1d4ed8; text-decoration: underline; }

/* ── Bulk upload preview ─────────────────────────────────────────────────── */
.bulk-preview {
  background: #f8f5ee;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  max-height: 200px;
  overflow-y: auto;
}
.bulk-item {
  font-size: .85rem;
  padding: .2rem 0;
  color: var(--text);
}
.file-size { color: var(--text-lt); font-size: .78rem; font-weight: 400; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { padding: .75rem 1rem; }
  .nav-title { font-size: 1.1rem; }
  .nav-user { display: none; }
  .main-content { padding: 1.25rem 1rem; }
  .hub-title { font-size: 1.8rem; }
  .sections-grid { grid-template-columns: 1fr; }
  .section-hero { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .file-row { gap: .5rem; }
  .form-row { flex-direction: column; }
  .login-box { padding: 2rem 1.5rem; }
}
