:root {
  --navy: #12314f;
  --navy-2: #0b2238;
  --orange: #ef7d22;
  --paper: #f4f6f8;
  --white: #fff;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe2ea;
  --danger: #b42318;
  --success: #137333;
  --warning: #a15c00;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(15, 35, 55, .08);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--paper); }
a { color: #155f9a; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: linear-gradient(180deg, var(--navy-2), var(--navy)); color: white; padding: 24px 18px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--orange); font-weight: 800; }
.brand strong { display: block; font-size: 1rem; }
.brand span { color: #cbd5e1; font-size: .78rem; }
.nav-group { margin: 24px 0; }
.nav-label { color: #93a8bc; text-transform: uppercase; font-size: .68rem; letter-spacing: .12em; margin: 0 10px 8px; }
.nav-link { display: flex; align-items: center; gap: 10px; color: #edf5fb; padding: 10px 12px; border-radius: 9px; margin: 3px 0; }
.nav-link:hover { background: rgba(255,255,255,.09); text-decoration: none; }
.sidebar-footer { margin-top: 30px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.15); color: #cbd5e1; font-size: .82rem; }
.main { min-width: 0; }
.topbar { height: 70px; background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.menu-button { display: none; border: 0; background: transparent; font-size: 1.4rem; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #e8eef4; color: var(--navy); font-weight: 700; }
.content { padding: 28px; max-width: 1500px; margin: 0 auto; }
.page-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 22px; }
.page-header h1 { margin: 0; font-size: 1.7rem; }
.page-header p { margin: 6px 0 0; color: var(--muted); }
.card { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 20px; border-left: 4px solid var(--orange); }
.stat .value { font-size: 2rem; font-weight: 750; }
.stat .label { color: var(--muted); font-size: .88rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #475569; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
tr:hover td { background: #fbfdff; }
.form-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 650; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; background: white; padding: 10px 12px; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #3182bd; box-shadow: 0 0 0 3px rgba(49,130,189,.14); }
textarea { min-height: 110px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.help { color: var(--muted); font-size: .8rem; }
.error-text { color: var(--danger); font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { appearance: none; border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--navy); color: white; }
.btn-accent { background: var(--orange); color: white; }
.btn-light { background: #edf2f7; color: var(--ink); }
.btn-danger { background: #fee4e2; color: var(--danger); }
.btn-sm { padding: 7px 10px; font-size: .82rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: .75rem; font-weight: 750; white-space: nowrap; }
.badge-primary { color: #0c4a6e; background: #e0f2fe; }
.badge-info { color: #1e40af; background: #dbeafe; }
.badge-success { color: #166534; background: #dcfce7; }
.badge-warning { color: #92400e; background: #fef3c7; }
.badge-danger { color: #991b1b; background: #fee2e2; }
.badge-neutral, .badge-muted { color: #475569; background: #e2e8f0; }
.alert { border-radius: 10px; padding: 13px 15px; margin-bottom: 18px; border: 1px solid; }
.alert-success { background: #ecfdf3; border-color: #a6f4c5; color: #05603a; }
.alert-error { background: #fff1f0; border-color: #fecdca; color: #912018; }
.alert-warning { background: #fffaeb; border-color: #fedf89; color: #7a2e0e; }
.filters { display: grid; gap: 12px; grid-template-columns: 2fr repeat(4, 1fr); align-items: end; }
.definition { display: grid; grid-template-columns: 190px 1fr; gap: 0; }
.definition dt, .definition dd { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--line); }
.definition dt { color: var(--muted); font-weight: 650; }
.resource-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.resource-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.resource-item input { margin-top: 7px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid #cbd5e1; padding: 0 0 18px 16px; }
.timeline li:last-child { padding-bottom: 0; }
.empty { text-align: center; padding: 38px; color: var(--muted); }
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: white; }
.login-hero { background: linear-gradient(145deg, var(--navy-2), var(--navy)); color: white; padding: 70px; display: flex; flex-direction: column; justify-content: center; }
.login-hero h1 { font-size: clamp(2.2rem, 5vw, 4.5rem); line-height: 1; margin: 0 0 20px; max-width: 700px; }
.login-hero p { color: #d7e5f2; max-width: 600px; font-size: 1.08rem; }
.login-panel { display: grid; place-items: center; padding: 30px; }
.login-box { width: min(430px,100%); }
.login-box h2 { margin-bottom: 6px; }
.login-box .field { margin-bottom: 16px; }
.login-box .btn { width: 100%; margin-top: 8px; }
#calendar { min-height: 720px; }
code { background: #eef2f6; padding: 2px 5px; border-radius: 5px; }
@media (max-width: 1050px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .filters { grid-template-columns: repeat(2,1fr); }
  .filters .search { grid-column: 1 / -1; }
  .resource-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 270px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: block; }
  .content { padding: 18px; }
  .topbar { padding: 0 18px; }
  .grid-2,.grid-3,.grid-4,.form-grid,.resource-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .page-header { flex-direction: column; }
  .filters { grid-template-columns: 1fr; }
  .filters .search { grid-column: auto; }
  .definition { grid-template-columns: 1fr; }
  .definition dt { padding-bottom: 2px; border-bottom: 0; }
  .definition dd { padding-top: 2px; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

.login-hero .brand {
  display: flex;
  align-items: center;
  margin-bottom: 35px;
}

.login-logo {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: left center;
}




/* ==========================================================
   MENÚ LATERAL EN DISPOSITIVOS MÓVILES
   ========================================================== */

.sidebar-backdrop {
  display: none;
}

@media (max-width: 800px) {

  /*
   * Evita que el contenido de fondo se desplace mientras
   * el menú lateral está abierto.
   */
  body.sidebar-open {
    overflow: hidden;
    touch-action: none;
  }

  /*
   * El menú queda por encima de la capa oscura.
   */
  .sidebar {
    top: 0;
    left: 0;
    z-index: 1001;
    height: 100vh;
    height: 100dvh;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.22);
  }

  /*
   * Capa que cubre el resto de la pantalla.
   */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;

    background: rgba(4, 18, 31, 0.58);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
      opacity 0.2s ease,
      visibility 0.2s ease;
  }

  /*
   * La capa se activa al abrir el menú.
   */
  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}
