:root {
  --primary: #1467b3;
  --primary-dark: #0d4378;
  --accent: #37c978;
  --background: #f7f9fc;
  --white: #fff;
  --danger: #ffc5c5;
  --danger-text: #c0392b;
  --border: #e5e7eb;
  --required: #e04b3c;
  --optional: #25be7c;
  --form-required: #1467b3;   /* Usa tu azul institucional */
  --form-optional: #d5dae0;   /* Gris claro para opcionales */
  --form-bg-required: #f7fbff; /* Muy leve azul para requeridos */
  --form-bg-optional: #f9f9fb; /* Muy leve gris para opcionales */
}

/* RESET & BASE */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  background: var(--background);
  color: #222;
  min-height: 100vh;
}

/* LOGO */
.fixed-logo {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 250;
  background: var(--white);
  padding: 0.3rem 1rem 0.3rem 1rem;
  height: 68px;
  width: 170px;
  display: flex;
  align-items: center;
  box-shadow: 0 3px 15px 0 rgba(20, 103, 179, 0.07);
  border-bottom-right-radius: 16px;
  border-right: 1px solid var(--border);
}
.fixed-logo img {
  height: 42px;
  max-width: 150px;
  object-fit: contain;
  display: block;
}

/* SIDEBAR */
.sidebar {
  background: var(--primary-dark);
  color: var(--white);
  width: 170px;
  min-width: 130px;
  max-width: 200px;
  padding: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 68px;        /* debajo del logo */
  left: 0;
  bottom: 0;
  height: calc(100vh - 68px);  /* Menú ocupa todo el alto debajo del logo */
  z-index: 100;
  border-right: 1px solid var(--border);
  transition: transform 0.3s;
}

/* El encabezado no hace scroll, siempre visible */
.sidebar-header {
  padding: 1.1rem 1rem 0.7rem 1.2rem;
  font-weight: bold;
  font-size: 1.09rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  background: transparent;
  border: none;
  flex-shrink: 0;
}

/* Esta zona SÍ hace scroll cuando no cabe */
.menu-nav {
  flex: 1 1 auto;        /* toma todo el espacio vertical disponible */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.2rem 1.2rem 0.2rem;
  /* Opcional: quita el borde de fondo en la zona de scroll */
  background: none;
  min-height: 0;         /* <-- IMPORTANTE para que flexbox permita el scroll */
  max-height: 100%;
}
.menuoption {
  display: block;
  background: none;
  color: var(--white) !important;
  padding: 0.48rem 1.05rem;
  border-radius: 7px;
  font-size: 1.02rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  text-align: left;
  margin: 0;
  transition: background 0.18s, color 0.14s, transform 0.07s;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.menuoption:not(.active):hover {
  background: var(--primary);
  color: var(--accent) !important;
  transform: translateX(3px) scale(1.04);
}
.menuoption.active,
.menuoption.selected {
  background: var(--accent);
  color: var(--primary-dark) !important;
  font-weight: bold;
}

/* CONTENIDO PRINCIPAL alineado */
.main-content {
  flex: 1;
  padding: 2.5rem 2rem;
  background: var(--background);
  min-width: 0;
  margin-left: 170px; /* mismo ancho que sidebar */
  transition: margin-left 0.3s;
}

/* MENU HAMBURGUESA */
.menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 15px;
  background: none;
  border: none;
  z-index: 300;
  cursor: pointer;
}
.menu-toggle span {
  display: block;
  width: 2rem;
  height: 0.22rem;
  background: var(--primary-dark);
  margin: 0.38rem 0;
  border-radius: 2px;
  transition: 0.3s;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .fixed-logo {
    height: 56px;
    width: 120px;
    padding: 0.2rem 0.6rem 0.2rem 0.7rem;
    border-bottom-right-radius: 10px;
  }
  .fixed-logo img {
    height: 32px;
    max-width: 90px;
  }
  .sidebar {
    width: 70vw;
    min-width: 120px;
    max-width: 230px;
    top: 56px;
    height: calc(100vh - 56px);
    transform: translateX(-100%);
    box-shadow: 2px 0 18px 0 rgba(20, 103, 179, 0.07);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    padding: 1.2rem 0.6rem;
  }
  .menu-toggle { display: block; }
}

/* EXTRA para facilitar el click fuera del menú en móvil */
@media (max-width: 900px) {
  .sidebar.open ~ .main-content:before {
    content: '';
    display: block;
    position: fixed;
    left: 0; top: 0; right: 0; bottom: 0;
    z-index: 90;
    background: rgba(0,0,0,0.07);
  }
}
.delete-button,
.class-buttonLink {
  display: inline-block;
  background: var(--primary);
  color: var(--white) !important;
  padding: 0.8rem 2rem;
  border-radius: 8px;
  font-size: 1.09rem;
  font-weight: 600;
  border: none;
  margin: 0.3rem 0.8rem 0.3rem 0;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 2px 8px 0 rgba(20,103,179,0.04);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.07s;
  letter-spacing: 0.02em;
  min-width: 130px;
}

/* Título principal, centrado arriba */
.headerZone {
  /* Altura igual o mayor al logo, pero puedes ajustarla */
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;   /* Centra el texto horizontalmente */
  font-size: 2.1rem;         /* Grande y notorio */
  font-weight: 700;
  color: var(--primary-dark);
  background: transparent;   /* Puedes poner un color claro si gustas */
  margin-left: 170px;        /* Lo empuja a la derecha del logo */
  margin-right: 0;           /* Llega hasta el borde derecho */
  margin-top: 0.9rem;        /* Espacio arriba */
  margin-bottom: 1.8rem;     /* Espacio con lo que sigue */
  text-align: center;
  letter-spacing: 0.04em;
}

/* Zona de trabajo, alineada a la izquierda (bajo el logo y header) */
.workingZone {
  margin-left: 200px;       /* Queda alineado con el contenido general (más allá del logo) */
  margin-top: 1.2rem;       /* Espacio bajo el título */
  max-width: 480px;         /* Ancho cómodo para formularios, ajusta a tu gusto */
  /* Puedes usar un fondo sutil si quieres: */
  /* background: #fff; */
  /* padding: 2.2rem 2.3rem 1.5rem 2.3rem; */
  /* border-radius: 14px; */
  /* box-shadow: 0 2px 18px 0 rgba(20,103,179,0.05); */
}

/* Ajusta la tabla del formulario si usas table-form */
.table-form {
  width: 100%;
}

/* Responsive: en pantallas chicas */
@media (max-width: 900px) {
  .headerZone {
    margin-left: 0;
    font-size: 1.25rem;
    min-height: 48px;
    padding: 0.6rem 0.5rem 0.6rem 0.5rem;
  }
  .workingZone {
    margin-left: 0.6rem;
    max-width: 99vw;
    margin-top: 1.0rem;
  }
}

.delete-button {
  background: var(--danger);
  color: var(--danger-text) !important;
  border: 1.5px solid #f8b0b0;
}
.delete-button:hover {
  background: #f6eeee;
  color: #b02a19 !important;
  border-color: #eabcbc;
}

.class-buttonLink {
  background: var(--primary);
  color: var(--white) !important;
}
.class-buttonLink:hover {
  background: var(--accent);
  color: var(--primary-dark) !important;
  transform: translateY(-2px) scale(1.03);
}
.clear-button,
.sendSearch-button {
  display: inline-block;
  background: #e7e7e7;
  color: var(--primary-dark) !important;
  font-size: 0.97rem;
  font-weight: 500;
  padding: 0.29rem 1.1rem;
  border-radius: 6px;
  border: 1px solid #dadada;
  box-shadow: none;
  margin: 0 0.25rem;
  text-align: center;
  vertical-align: middle;
  line-height: 1.2;
  min-width: 50px;
  min-height: 32px;
  height: 36px;
  cursor: pointer;
  transition: background 0.14s, color 0.13s;
  text-decoration: none;
}
.clear-button:hover,
.sendSearch-button:hover {
  background: #f6fafd;
  color: var(--primary);
}
/* Agrupa los controles de búsqueda */
.searchbar-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
  flex-wrap: nowrap; /* ¡IMPORTANTE! Nunca pasar a dos líneas */
}
/* El campo de búsqueda se estira y se reduce si es necesario */
.searchControl {
  flex: 1 1 220px;      /* crece y se reduce, base 220px */
  min-width: 60px;      /* permite achicar mucho si hay poco espacio */
  max-width: 350px;
  height: 38px;
  font-size: 1.04rem;
  padding: 0 1rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: #222;
  box-sizing: border-box;
  vertical-align: middle;
  appearance: none;
  outline: none;
}
/* Los selects y botones NO se encogen */
.rppControl, .clear-button, .sendSearch-button {
  width: 90px;
  height: 38px;
}

/* Botones pequeños, igual que antes */
.clear-button,
.sendSearch-button {
  min-width: 70px;
  width: auto;
  font-size: 0.97rem;
  padding: 0.28rem 1.05rem;
  height: 36px;
}

/* Responsive: en pantallas chicas, que sí bajen */
@media (max-width: 600px) {
  .searchbar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .searchControl,
  .rppControl {
    max-width: 100%;
  }
}
/* --- FORMULARIO --- */
.field-required th label:after {
  content: " *";
  color: var(--form-required);
  font-size: 1em;
  font-weight: bold;
  margin-left: 2px;
}
.field-required th, .field-required th label {
  font-weight: 600;
  color: var(--primary-dark);
}
.field-required input,
.field-required select,
.field-required textarea {
  border-left: 3px solid var(--form-required);
  background: var(--form-bg-required);
}

.field-optional th label:after { content: ""; } /* Sin letrero ni nada extra */
.field-optional th, .field-optional th label {
  color: #7e8693; /* Gris sutil, menos contraste */
  font-weight: 500;
}
.field-optional input,
.field-optional select,
.field-optional textarea {
  border-left: 3px solid var(--form-optional);
  background: var(--form-bg-optional);
}

/* Controles iguales a antes */
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 97%;
  padding: 0.52rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 1.04rem;
  background: #fcfdff;
  color: #212529;
  outline: none;
  transition: border 0.2s;
  box-sizing: border-box;
  margin-top: 0.05rem;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: #fff;
}
input[disabled], select[disabled], textarea[disabled] {
  background: #f2f2f2;
  color: #aaa;
  border-style: dashed;
}
.back-button {
  display: inline-block;
  background: #ececec;
  color: var(--primary-dark) !important;
  font-size: 1.03rem;
  font-weight: 600;
  padding: 0.56rem 1.4rem;
  border-radius: 7px;
  border: 1.5px solid #d3dbe3;
  box-shadow: none;
  margin: 0.35rem 0.2rem 0.35rem 0;
  text-align: left;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: background 0.14s, color 0.14s, border 0.15s;
}
.back-button:hover {
  background: #e3eef8;
  color: var(--primary);
  border-color: var(--primary);
}

.send-button {
  display: inline-block;
  background: var(--primary);
  color: #fff !important;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 1.15rem 3.8rem;
  border-radius: 7px;
  border: none;
  margin: 0.55rem 0.2rem 0.55rem 0.4rem;
  text-align: center;
  box-shadow: 0 2px 14px 0 rgba(20,103,179,0.10);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.13s;
}
.send-button:hover {
  background: var(--accent);
  color: var(--primary-dark) !important;
  box-shadow: 0 4px 24px 0 rgba(55,201,120,0.15);
}
/* ---------- LOGIN FORMULARIO ---------- */
.login-container {
  margin-left: 190px;        /* deja espacio fijo al logo */
  margin-top: 80px;          /* separa del logo fijo */
  display: flex;
  flex-direction: column;
  align-items: flex-start;   /* formulario alineado a la izquierda */
  min-width: 320px;
}

.login-form-table {
  background: #fff;
  padding: 2.2rem 2.3rem 1.5rem 2.3rem;
  border-radius: 12px;
  box-shadow: 0 2px 16px 0 rgba(20,103,179,0.07);
  min-width: 340px;
  max-width: 99vw;
}

.login-form-table th {
  font-size: 1.07rem;
  font-weight: 500;
  color: var(--primary-dark);
  text-align: left;
  padding-bottom: 0.33rem;
}

.login-form-table td {
  padding-bottom: 0.82rem;
}

.login-form-table input[type="text"],
.login-form-table input[type="password"] {
  width: 100%;
  font-size: 1.04rem;
  padding: 0.55rem 1.0rem;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: #fafcff;
}

.login-form-table input:focus {
  border-color: var(--primary);
  background: #fff;
}

.login-form-table .send-button {
  padding-top: 0.3rem;
  text-align: left;
}

.login-form-table button[type="submit"] {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 1.09rem;
  border: none;
  border-radius: 8px;
  padding: 0.64rem 2.1rem;
  margin-top: 0.6rem;
  margin-bottom: 0.3rem;
  cursor: pointer;
  transition: background 0.15s;
  box-shadow: 0 2px 8px 0 rgba(20,103,179,0.08);
}
.login-form-table button[type="submit"]:hover {
  background: var(--accent);
  color: var(--primary-dark);
}

.login-form-table .button-link {
  display: inline-block;
  color: var(--primary-dark);
  font-size: 1.04rem;
  margin-top: 0.5rem;
  margin-bottom: 0.3rem;
  text-decoration: underline;
  transition: color 0.15s;
  padding-left: 1px;
}
.login-form-table .button-link:hover {
  color: var(--primary);
}

@media (max-width: 600px) {
  .login-container {
    margin-left: 0;
    margin-top: 90px;
    min-width: 95vw;
    align-items: stretch;
  }
  .login-form-table {
    min-width: 0;
    padding: 1.2rem 0.8rem;
  }
}
.login-form-table .recover-button {
  display: inline-block;
  background: #e7e7e7;
  color: #656a71 !important;
  font-size: 1.04rem;
  font-weight: 500;
  border: none;
  border-radius: 7px;
  padding: 0.58rem 1.2rem;
  margin-top: 0.4rem;
  margin-bottom: 0.2rem;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 1px 3px 0 rgba(130,130,130,0.03);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
}
.login-form-table .recover-button:hover {
  background: #f4f4f6;
  color: var(--primary-dark) !important;
  text-decoration: none;
}
.menu-nav {
  scrollbar-width: thin;
  scrollbar-color: #c5daf3 #113458;
}
.menu-nav::-webkit-scrollbar {
  width: 8px;
}
.menu-nav::-webkit-scrollbar-thumb {
  background: #c5daf3;
  border-radius: 5px;
}
.menu-nav::-webkit-scrollbar-track {
  background: #113458;
  border-radius: 7px;
}
.button-link {
  display: inline-block;
  background: #e7e7e7;                 /* Gris claro, no tan llamativo */
  color: #444 !important;              /* Gris oscuro, sobrio */
  font-size: 1.04rem;
  font-weight: 500;
  border: none;
  border-radius: 7px;
  padding: 0.60rem 1.4rem;             /* Menos alto y menos ancho */
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 1px 3px 0 rgba(130,130,130,0.03);
  cursor: pointer;
  transition: background 0.13s, color 0.13s, box-shadow 0.12s;
}

.button-link:hover,
.button-link:focus {
  background: #f4f4f6;                 /* Un poco más claro al pasar el mouse */
  color: var(--primary-dark) !important;
  text-decoration: none;
  box-shadow: 0 2px 8px 0 rgba(20,103,179,0.04);
}

.error-div {
  background: #ffeaea; /* Rojo suave de fondo */
  color: #b01414;      /* Rojo oscuro para el texto */
  border: 2px solid #f27676;
  border-radius: 8px;
  font-size: 1.11rem;
  font-weight: 700;
  padding: 1rem 1.5rem;
  margin: 1.1rem 0 1.5rem 0;
  box-shadow: 0 2px 12px 0 rgba(220,0,0,0.07);
  text-align: center;
  letter-spacing: 0.04em;
}

.error-div:before {
  content: "⚠ "; /* Icono de advertencia, opcional */
  font-size: 1.22rem;
  vertical-align: middle;
}

@media (max-width: 600px) {
    .fixed-logo {
    left: auto;             /* Quita el alineado a la izquierda */
    right: 0;               /* Lo pega a la derecha */
    top: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 16px; /* Opcional: curva en la esquina izquierda */
    border-bottom-right-radius: 0;
    border-right: none;     /* Quita borde derecho */
    border-left: 1px solid var(--border); /* Borde ahora a la izquierda */
    }
    .searchControl {
    max-width: 100% !important;
    font-size: 1rem !important;
    padding: 0.5rem 0.7rem !important;
    box-sizing: border-box;
  }
  .headerZone {
    margin-left: 0;
    margin-top: 1.1rem;
    font-size: 1.20rem;
    text-align: center;
    padding: 0.5rem 0.5rem 0.8rem 0.5rem;
  }
  .workingZone {
    margin-left: 0;
    margin-right: 0;
    margin-top: 0.6rem;
    max-width: 100vw;
    min-width: 0;
    width: 100vw;
    padding: 0 2vw;
    box-sizing: border-box;
    display: block;
  }
  .table-form, form, .table-form tr, .table-form td {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    box-sizing: border-box;
    display: block;
    padding: 0;
  }
  .table-form input[type="text"],
  .table-form input[type="password"] {
    font-size: 1.15rem;
    width: 100%;
    min-width: 0;
    padding: 1rem 1rem;
    margin-bottom: 0.7rem;
    box-sizing: border-box;
  }
  .send-button {
    width: 100%;
    min-width: 0;
    font-size: 1.18rem;
    padding: 1.2rem 0;
    margin: 0.7rem 0 0.9rem 0;
    text-align: center;
    box-sizing: border-box;
  }
  .button-link {
    width: 48%;
    min-width: 100px;
    margin: 0.3rem 1% 0.3rem 1%;
    padding: 0.7rem 0;
    font-size: 1.09rem;
    text-align: center;
    box-sizing: border-box;
    display: inline-block;
  }
  .table-form tr:last-child td {
    display: flex;
    gap: 0.4rem;
    justify-content: space-between;
    padding: 0;
  }
  
}

@media (max-width: 600px) {
  /* El input de búsqueda no debe ser enorme */
  .searchControl {
    max-width: 100vw;
    font-size: 1rem;
    padding: 0.46rem 0.7rem;
    margin-right: 0.2rem;
    box-sizing: border-box;
  }

  /* Hacer la tabla horizontalmente "scrolleable" si se desborda */
  .table-responsive {
    width: 100vw;
    overflow-x: auto;
    margin-bottom: 1.1rem;
  }

  .showData, .browse, .browse-table, .main-panel {
    min-width: 500px;   /* o lo que mida tu tabla más ancha */
    width: max-content;
  }

  /* Opcional: reducir padding y fuente en las tablas en móvil */
  .showData th, .showData td {
    padding: 0.39em 0.5em;
    font-size: 0.97em;
    white-space: nowrap;
  }

  /* El formulario principal más cómodo y más ancho */
  .browseframe {
    margin: 0.5rem 0.1rem 0.1rem 0.1rem;
    padding: 0;
    width: 98vw;
  }

  /* El logo a la derecha, solo en móvil */
  .fixed-logo {
    left: auto !important;
    right: 0;
    top: 0;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 16px;
    border-right: none;
    border-left: 1px solid var(--border);
  }

  /* El menú hamburguesa no tapado por el logo */
  .menu-toggle {
    left: 10px !important;
    right: auto !important;
  }
}
@media (max-width: 600px) {
   .main-content,
   .browseframe {
    margin-top: 25px !important;  /* Ajusta según la altura de tu logo + espacio */
  }    
  .searchbar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    width: 100%;
    box-sizing: border-box;
  }
  .searchControl {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 1.1rem;
    padding: 0.7rem 0.8rem;
    margin: 0;
    box-sizing: border-box;
    flex: none !important;
  }
  .rppControl, .clear-button, .sendSearch-button {
    width: 100%;
    min-width: 0;
    margin: 0.3rem 0 0.3rem 0;
  }
  .table-responsive {
    width: 100vw;
    overflow-x: auto;
    margin-bottom: 1.1rem;
  }
  .showData, .browse, .browse-table, .main-panel {
    min-width: 700px;   /* ajusta según tu tabla */
    width: max-content;
  }
}
