*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════
   FOCO VISIBLE — accessibilitat
══════════════════════════════ */

:focus { outline: none; }

:focus-visible {
  outline: 3px solid #1a6edb;
  outline-offset: 3px;
  border-radius: 6px;
  box-shadow: 0 0 0 6px rgba(26, 110, 219, 0.3);
}

.nav-btn:focus-visible {
  outline: 3px solid #1a6edb;
  outline-offset: 2px;
  background: var(--btn-hover);
  box-shadow: 0 0 0 6px rgba(26, 110, 219, 0.35), 0 3px 10px var(--btn-shadow);
}

.sub-card:focus-visible {
  outline: 3px solid #1a6edb;
  outline-offset: 4px;
  border-radius: 8px;
  box-shadow: 0 0 0 6px rgba(26, 110, 219, 0.2);
  color: var(--btn);
}
.sub-card:focus-visible .card-arrow {
  transform: translateX(4px);
  color: var(--btn);
}

/* Skip-link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: #1a6edb;
  color: #ffffff;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .85rem;
  font-weight: 700;
  padding: .6rem 1.2rem;
  border-radius: 0 0 8px 8px;
  z-index: 9999;
  text-decoration: none;
  transition: top .2s;
}
.skip-link:focus { top: 0; outline: 3px solid #1a6edb; outline-offset: 2px; }

/* ══════════════════════════════
   VARIABLES I BASE
══════════════════════════════ */
:root {
  --bg:         #ffffff;
  --ink:        #111111;
  --muted:      #888888;
  --surface:    #f7f7f7;
  --border:     #e8e8e8;
  --btn:        #830051;
  --btn-border: #640040;
  --btn-hover:  #9a0060;
  --btn-active: #4f0031;
  --btn-shadow: rgba(131, 0, 81, .22);
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible', sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ══════════════════════════════
   CAPÇALERA CORPORATIVA
══════════════════════════════ */
.site-header {
  width: 100%;
  height: 90px;
  background: var(--btn);          /* mateix color que els botons */
  display: flex;
  align-items: center;
  padding: 0 2rem;
  flex-shrink: 0;
  display:flex;
  padding:0 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}


.site-header-right {
  margin-left: auto; /* empuja el bloque al extremo derecho */
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-logo {
  height: 58px;       /* ajusta l'alçada segons el teu logo */
  width: auto;
  object-fit: contain;
  /* si el logo és fosc, posa-lo en blanc amb filter */
  filter: brightness(0) invert(1);
  opacity: .92;
}

.site-user {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Atkinson Hyperlegible', sans-serif;
  letter-spacing: 0.03em;
}

.site-header-divider {
  color: rgba(255, 255, 255, 0.35); 
  opacity: 0.35;
  font-size: 0.875rem;
}


.site-tancar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Atkinson Hyperlegible', sans-serif;
  letter-spacing: 0.03em;  
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.site-tancar:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.12);
  text-decoration: underline;
}

.site-tancar:focus-visible {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.12);
}



/* ══════════════════════════════
   CONTENIDOR PRINCIPAL
══════════════════════════════ */
.body-wrap {
  display: flex;
  flex: 1;
}

/* ══════════════════════════════
   SIDEBAR
══════════════════════════════ */
.sidebar {
  width: 260px;
  min-height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.25rem;
  gap: 1rem;
  flex-shrink: 0;
  animation: slideIn .4s ease both;
}

@keyframes slideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* H1 títol sidebar */
.nav-title {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--ink);
  padding: .4rem .5rem .6rem;
  border-bottom: 2px solid var(--btn);
}

/* Nav: flex column amb gap per separar els botons */
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.nav-label {
  font-size: .65rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: .6rem .5rem .2rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem 1rem;
  background: var(--btn);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: #ffffff;
  text-decoration: none;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .12s;
  box-shadow: 0 1px 4px var(--btn-shadow);
  width: 100%;
  text-align: left;
  animation: fadeUp .4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-btn:hover  { background: var(--btn-hover); box-shadow: 0 3px 10px var(--btn-shadow); transform: translateX(2px); }
.nav-btn.active { background: var(--btn-active); border-color: var(--btn-active); }

.nav-text   { flex: 1; }
.nav-arrow  { color: rgba(255,255,255,.5); font-size: .7rem; transition: transform .2s; }
.nav-btn:hover .nav-arrow { transform: translateX(2px); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .65rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: .06em;
}

/* ══════════════════════════════
   ÀREA CENTRAL
══════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2.5rem 2.5rem 3rem;
  animation: fadeUp .5s .15s ease both;
}


.main h1 {  
  margin-bottom: 2.5rem;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;  
  background: #F7EEF4;
  color: var(--btn);
  align-items: center;
  border-radius: 8px;
  padding: .75rem 1.25rem;
  display: flex; 
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  justify-content: center
}


@keyframes panelIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

 

/* ══════════════════════════════
   PANEL
══════════════════════════════ */
 
 .panel {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: 100%;          
  max-width: 420px;    
  animation: panelIn .3s ease both;
}
 

.panel-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: var(--ink); 
  
}

.panel.visible { display: flex; }

.panel-title span { font-size: 1.6rem; }





/* ══════════════════════════════
   CARD LINKS
══════════════════════════════ */
/* links de texto del panel central */
    .sub-card {
      display: flex;
      align-items: center;
      gap: .75rem;
      padding: .4rem 0;
      color: var(--ink);
      text-decoration: none;
      font-family: 'DM Mono', monospace;
      font-size: 1rem;
      transition: color .15s;
    }

    .sub-card:hover { color: var(--btn); }

    .sub-card .card-icon { font-size: 1.1rem; flex-shrink: 0; }
    .sub-card .card-body { flex: 1; }
    .sub-card .card-name { font-weight: 500; font-size: 1rem;  margin: 0;  }
  
    .sub-card .card-desc { display: none; }

    .sub-card .card-arrow { color: var(--muted); font-size: .8rem; transition: transform .2s; }
    .sub-card:hover .card-arrow { transform: translateX(4px); color: var(--btn); }






/* ══════════════════════════════
   PANELL FORMULARI
══════════════════════════════ */
.form-panel {
  display: none;
  flex-direction: column;
  gap: 1.4rem;
  width: 100%;
  max-width: 420px;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  animation: panelIn .3s ease both;
}
.form-panel.visible { display: flex; }




.form-group {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.form-group label {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink);
}

.form-group input[type="text"],
.form-group input[type="password"] {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .95rem;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid ;
  border-radius: 8px;
  padding: .65rem 1rem;
  width: 50%;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input[type="text"]:hover,
.form-group input[type="password"]:hover { border-color: #bbb; }

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
  outline: 3px solid #1a6edb;
  outline-offset: 2px;
  border-color: #1a6edb;
  box-shadow: 0 0 0 5px rgba(26, 110, 219, 0.25);
}

.form-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}


.btn-action {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  padding: .65rem 1.6rem;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .12s;
}
.btn-action:focus-visible {
  outline: 3px solid #1a6edb;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(26, 110, 219, 0.3);
}

.btn-primary {
  background: var(--btn);
  color: #fff;
  border-color: var(--btn-border);
  box-shadow: 0 1px 4px var(--btn-shadow);
}
.btn-primary:hover  { background: var(--btn-hover); transform: translateY(-1px); box-shadow: 0 3px 10px var(--btn-shadow); }
.btn-primary:active { background: var(--btn-active); transform: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--btn);
  border-color: var(--btn);
}
.btn-secondary:hover  { background: #f0e0eb; transform: translateY(-1px); }
.btn-secondary:active { transform: none; }


/* ══════════════════════════════
   SELECT
══════════════════════════════ */

.form-group select {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .95rem;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .65rem 1rem;
  width: 50%;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

.form-group select:hover { border-color: #bbb; }

.form-group select:focus {
  outline: 3px solid #1a6edb;
  outline-offset: 2px;
  border-color: #1a6edb;
  box-shadow: 0 0 0 5px rgba(26, 110, 219, 0.25);
}

.form-group select option {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .95rem;
  color: var(--ink);
  background: var(--bg);
}


/* ══════════════════════════════
   MODAL BOX
══════════════════════════════ */


#modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#modal-box {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

/* ══════════════════════════════
   MISSATGE ERROR
══════════════════════════════ */

.missatge-error {
  display: block;
  color: #c0392b;
  font-size: 0.85rem;
  margin-top: 0.3rem;
  min-height: 1.1em;
}

.form-group input.input-error {
  border-color: #c0392b;
  background-color: #fdecea;
}



/* ══════════════════════════════
   CAPÇALERA CENS
══════════════════════════════ */
.cens-header {
  background: var(--btn);
  border-radius: 8px;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: left;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;          /* ocupa todo el ancho disponible */
  max-width: 100%;
}

.cens-header-label {
  color: #fff;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cens-header-value {
  color: #fff;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

/* ══════════════════════════════
   DADES CENS
══════════════════════════════ */
.cens-data {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .75rem;
}

.cens-data-row {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.cens-data dt {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: .85rem;
  font-weight: 700;
  color: var(--btn);      /* color institucional */
  white-space: nowrap;
}

.cens-data dd {
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 1rem;
  color: var(--ink);      /* negro */
  margin: 0;
}

.panel--cens {
  max-width: 70%;
}
/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 640px) {
  .form-group select { width: 100%; }

  .site-header { height: 64px; padding: 0 1rem; }
  .site-logo   { height: 40px; }
  .body-wrap { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; flex-direction: row; flex-wrap: wrap; padding: 1rem; gap: .4rem; }
  .nav-label { display: none; }
  .sidebar-footer { display: none; }
  .main { padding: 2rem 1.25rem; }
  .form-actions { flex-direction: column; }
}